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     GrBackendObject onGetTextureHandle(BackendHandleAccess) override;
23     bool onGetRenderTargetHandle(GrBackendObject*, BackendHandleAccess) override;
24     SkCanvas* onNewCanvas() override;
25     sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override;
26     sk_sp<SkImage> onNewImageSnapshot() override;
27     void onCopyOnWrite(ContentChangeMode) override;
28     void onDiscard() override;
29     void onPrepareForExternalIO() override;
30 
getDevice()31     SkGpuDevice* getDevice() { return fDevice.get(); }
32 
33     static bool Valid(const SkImageInfo&);
34     static bool Valid(GrContext*, GrPixelConfig, SkColorSpace*);
35 
36 private:
37     sk_sp<SkGpuDevice> fDevice;
38 
39     typedef SkSurface_Base INHERITED;
40 };
41 
42 #endif // SK_SUPPORT_GPU
43 
44 #endif // SkSurface_Gpu_DEFINED
45