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