OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkSurface_Gpu_DEFINED | 8 #ifndef SkSurface_Gpu_DEFINED |
9 #define SkSurface_Gpu_DEFINED | 9 #define SkSurface_Gpu_DEFINED |
10 | 10 |
11 #include "SkSurface_Base.h" | 11 #include "SkSurface_Base.h" |
| 12 #include "SkDevice.h" |
12 | 13 |
13 #if SK_SUPPORT_GPU | 14 #if SK_SUPPORT_GPU |
14 | 15 |
15 class SkGpuDevice; | 16 class SkGpuDevice; |
16 | 17 |
17 class SkSurface_Gpu : public SkSurface_Base { | 18 class SkSurface_Gpu : public SkSurface_Base { |
18 public: | 19 public: |
19 SK_DECLARE_INST_COUNT(SkSurface_Gpu) | 20 SK_DECLARE_INST_COUNT(SkSurface_Gpu) |
20 | 21 |
21 SkSurface_Gpu(SkGpuDevice*); | 22 SkSurface_Gpu(SkGpuDevice*); |
22 virtual ~SkSurface_Gpu(); | 23 virtual ~SkSurface_Gpu(); |
23 | 24 |
24 SkCanvas* onNewCanvas() SK_OVERRIDE; | 25 SkCanvas* onNewCanvas() SK_OVERRIDE; |
25 SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE; | 26 SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE; |
26 SkImage* onNewImageSnapshot(Budgeted) SK_OVERRIDE; | 27 SkImage* onNewImageSnapshot(Budgeted) SK_OVERRIDE; |
27 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, | 28 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, |
28 const SkPaint*) SK_OVERRIDE; | 29 const SkPaint*) SK_OVERRIDE; |
29 void onCopyOnWrite(ContentChangeMode) SK_OVERRIDE; | 30 void onCopyOnWrite(ContentChangeMode) SK_OVERRIDE; |
30 void onDiscard() SK_OVERRIDE; | 31 void onDiscard() SK_OVERRIDE; |
31 | 32 |
32 SkGpuDevice* getDevice() { return fDevice; } | 33 SkGpuDevice* getDevice() { return fDevice; } |
33 | 34 |
34 /** Creates a backing store for a surface. | 35 /** Creates a backing store for a surface. |
35 * The target can be used as the render target of a gpu device. | 36 * The target can be used as the render target of a gpu device. |
36 */ | 37 */ |
37 static GrRenderTarget* CreateRenderTarget(GrContext*, SkSurface::Budgeted, c
onst SkImageInfo&, | 38 static GrRenderTarget* CreateRenderTarget(GrContext*, SkSurface::Budgeted, c
onst SkImageInfo&, |
38 int sampleCount); | 39 int sampleCount); |
| 40 |
| 41 /** Creates a surface that is attached to a device. |
| 42 * The device will own the reference to the surface, and the surface will go
out of scope when |
| 43 * the device goes out of scope. Note: This function is deprecated, it will
be renamed to |
| 44 * SkSurface_Gpu* createCompatibleSurface(const SkBaseDevice::CreateInfo& ci
nfo) |
| 45 */ |
| 46 SkGpuDevice* createCompatibleDeviceDeprecated(const SkBaseDevice::CreateInfo
& cinfo); |
| 47 |
39 private: | 48 private: |
| 49 enum ReverseOwnershipDeprecated { kReverseOwnershipDeprecated }; |
| 50 SkSurface_Gpu(SkGpuDevice*, ReverseOwnershipDeprecated); |
| 51 |
40 SkGpuDevice* fDevice; | 52 SkGpuDevice* fDevice; |
| 53 bool fOwnsDevice; |
41 | 54 |
42 typedef SkSurface_Base INHERITED; | 55 typedef SkSurface_Base INHERITED; |
43 }; | 56 }; |
44 | 57 |
45 #endif // SK_SUPPORT_GPU | 58 #endif // SK_SUPPORT_GPU |
46 | 59 |
47 #endif // SkSurface_Gpu_DEFINED | 60 #endif // SkSurface_Gpu_DEFINED |
OLD | NEW |