• 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(GrRecordingContext*,
26                                                     std::unique_ptr<GrSurfaceDrawContext>);
27 
28     GrRecordingContext* onGetRecordingContext() override;
29 
30     GrBackendTexture onGetBackendTexture(BackendHandleAccess) override;
31     GrBackendRenderTarget onGetBackendRenderTarget(BackendHandleAccess) override;
32     bool onReplaceBackendTexture(const GrBackendTexture&, GrSurfaceOrigin, ContentChangeMode, TextureReleaseProc,
33                                  ReleaseContext) override;
34 
35     SkCanvas* onNewCanvas() override;
36     sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override;
37     sk_sp<SkImage> onNewImageSnapshot(const SkIRect* subset) override;
38     void onWritePixels(const SkPixmap&, int x, int y) override;
39     void onAsyncRescaleAndReadPixels(const SkImageInfo& info, const SkIRect& srcRect,
40                                      RescaleGamma rescaleGamma, RescaleMode,
41                                      ReadPixelsCallback callback,
42                                      ReadPixelsContext context) override;
43     void onAsyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace,
44                                            sk_sp<SkColorSpace> dstColorSpace,
45                                            const SkIRect& srcRect,
46                                            const SkISize& dstSize,
47                                            RescaleGamma rescaleGamma,
48                                            RescaleMode,
49                                            ReadPixelsCallback callback,
50                                            ReadPixelsContext context) override;
51 
52     void onCopyOnWrite(ContentChangeMode) override;
53     void onDiscard() override;
54     GrSemaphoresSubmitted onFlush(BackendSurfaceAccess access, const GrFlushInfo& info,
55                                   const GrBackendSurfaceMutableState*) override;
56     bool onWait(int numSemaphores, const GrBackendSemaphore* waitSemaphores,
57                  bool deleteSemaphoresAfterWait) override;
58     bool onCharacterize(SkSurfaceCharacterization*) const override;
59     bool onIsCompatible(const SkSurfaceCharacterization&) const override;
60     void onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkSamplingOptions&,
61                 const SkPaint* paint) override;
62     bool onDraw(sk_sp<const SkDeferredDisplayList>, SkIPoint offset) override;
63 
getDevice()64     SkGpuDevice* getDevice() { return fDevice.get(); }
65 
66 private:
67     sk_sp<SkGpuDevice> fDevice;
68 
69     using INHERITED = SkSurface_Base;
70 };
71 
72 #endif // SK_SUPPORT_GPU
73 
74 #endif // SkSurface_Gpu_DEFINED
75