• 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 "SkSurface_Base.h"
12 
13 #if SK_SUPPORT_GPU
14 
15 class SkGpuDevice;
16 
17 class SkSurface_Gpu : public SkSurface_Base {
18 public:
19     SkSurface_Gpu(sk_sp<SkGpuDevice>);
20     ~SkSurface_Gpu() override;
21 
22     // This is an internal-only factory
23     static sk_sp<SkSurface> MakeWrappedRenderTarget(GrContext*, sk_sp<GrRenderTargetContext>);
24 
25     GrBackendObject onGetTextureHandle(BackendHandleAccess) override;
26     bool onGetRenderTargetHandle(GrBackendObject*, BackendHandleAccess) override;
27     SkCanvas* onNewCanvas() override;
28     sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override;
29     sk_sp<SkImage> onNewImageSnapshot() override;
30     void onWritePixels(const SkPixmap&, int x, int y) override;
31     void onCopyOnWrite(ContentChangeMode) override;
32     void onDiscard() override;
33     GrSemaphoresSubmitted onFlush(int numSemaphores,
34                                   GrBackendSemaphore signalSemaphores[]) override;
35     bool onWait(int numSemaphores, const GrBackendSemaphore* waitSemaphores) override;
36     bool onCharacterize(SkSurfaceCharacterization*) const override;
37     bool isCompatible(const SkSurfaceCharacterization&) const;
38     bool onDraw(const SkDeferredDisplayList*) override;
39 
getDevice()40     SkGpuDevice* getDevice() { return fDevice.get(); }
41 
42     static bool Valid(const SkImageInfo&);
43     static bool Valid(GrContext*, GrPixelConfig, SkColorSpace*);
44 
45 private:
46     sk_sp<SkGpuDevice> fDevice;
47 
48     typedef SkSurface_Base INHERITED;
49 };
50 
51 #endif // SK_SUPPORT_GPU
52 
53 #endif // SkSurface_Gpu_DEFINED
54