• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2014 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkSurface_Gpu_DEFINED
9 #define SkSurface_Gpu_DEFINED
10 
11 #include "include/private/GrTypesPriv.h"
12 #include "src/image/SkSurface_Base.h"
13 
14 #if SK_SUPPORT_GPU
15 
16 class GrBackendFormat;
17 class SkGpuDevice;
18 
19 class SkSurface_Gpu : public SkSurface_Base {
20 public:
21     SkSurface_Gpu(sk_sp<SkGpuDevice>);
22     ~SkSurface_Gpu() override;
23 
24     // This is an internal-only factory
25     static sk_sp<SkSurface> MakeWrappedRenderTarget(GrContext*, sk_sp<GrRenderTargetContext>);
26 
27     GrBackendTexture onGetBackendTexture(BackendHandleAccess) override;
28     GrBackendRenderTarget onGetBackendRenderTarget(BackendHandleAccess) override;
29     bool onReplaceBackendTexture(const GrBackendTexture&, GrSurfaceOrigin, TextureReleaseProc,
30                                  ReleaseContext) override;
31 
32     SkCanvas* onNewCanvas() override;
33     sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override;
34     sk_sp<SkImage> onNewImageSnapshot(const SkIRect* subset) override;
35     void onWritePixels(const SkPixmap&, int x, int y) override;
36     void onAsyncRescaleAndReadPixels(const SkImageInfo& info, const SkIRect& srcRect,
37                                      RescaleGamma rescaleGamma, SkFilterQuality rescaleQuality,
38                                      ReadPixelsCallback callback,
39                                      ReadPixelsContext context) override;
40     void onAsyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace,
41                                            sk_sp<SkColorSpace> dstColorSpace,
42                                            const SkIRect& srcRect, int dstW, int dstH,
43                                            RescaleGamma rescaleGamma,
44                                            SkFilterQuality rescaleQuality,
45                                            ReadPixelsCallbackYUV420 callback,
46                                            ReadPixelsContext context) override;
47 
48     void onCopyOnWrite(ContentChangeMode) override;
49     void onDiscard() override;
50     GrSemaphoresSubmitted onFlush(BackendSurfaceAccess access, const GrFlushInfo& info) override;
51     bool onWait(int numSemaphores, const GrBackendSemaphore* waitSemaphores) override;
52     bool onCharacterize(SkSurfaceCharacterization*) const override;
53     bool onIsCompatible(const SkSurfaceCharacterization&) const override;
54     void onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) override;
55     bool onDraw(const SkDeferredDisplayList*) override;
56 
getDevice()57     SkGpuDevice* getDevice() { return fDevice.get(); }
58 
59     static bool Valid(const GrCaps*, const GrBackendFormat&);
60 
61 private:
62     sk_sp<SkGpuDevice> fDevice;
63 
64     typedef SkSurface_Base INHERITED;
65 };
66 
67 #endif // SK_SUPPORT_GPU
68 
69 #endif // SkSurface_Gpu_DEFINED
70