OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #ifndef SkGpuDevice_DEFINED | 9 #ifndef SkGpuDevice_DEFINED |
10 #define SkGpuDevice_DEFINED | 10 #define SkGpuDevice_DEFINED |
11 | 11 |
12 #include "SkGr.h" | 12 #include "SkGr.h" |
13 #include "SkBitmap.h" | 13 #include "SkBitmap.h" |
14 #include "SkDevice.h" | 14 #include "SkDevice.h" |
15 #include "SkPicture.h" | 15 #include "SkPicture.h" |
16 #include "SkRegion.h" | 16 #include "SkRegion.h" |
17 #include "SkSurface.h" | 17 #include "SkSurface.h" |
18 #include "GrContext.h" | 18 #include "GrContext.h" |
19 #include "GrSurfacePriv.h" | 19 #include "GrSurfacePriv.h" |
20 | 20 |
21 struct SkDrawProcs; | 21 struct SkDrawProcs; |
22 struct GrSkDrawProcs; | 22 struct GrSkDrawProcs; |
23 | 23 |
24 class GrAccelData; | 24 class GrAccelData; |
25 struct GrCachedLayer; | 25 struct GrCachedLayer; |
26 class GrTextContext; | 26 class GrTextContext; |
| 27 class SkSurface_Gpu; |
27 | 28 |
28 /** | 29 /** |
29 * Subclass of SkBaseDevice, which directs all drawing to the GrGpu owned by th
e | 30 * Subclass of SkBaseDevice, which directs all drawing to the GrGpu owned by th
e |
30 * canvas. | 31 * canvas. |
31 */ | 32 */ |
32 class SK_API SkGpuDevice : public SkBaseDevice { | 33 class SK_API SkGpuDevice : public SkBaseDevice { |
33 public: | 34 public: |
34 enum Flags { | 35 enum Flags { |
35 kNeedClear_Flag = 1 << 0, //!< Surface requires an initial clear | 36 kNeedClear_Flag = 1 << 0, //!< Surface requires an initial clear |
36 }; | 37 }; |
37 | 38 |
38 /** | 39 /** |
39 * Creates an SkGpuDevice from a GrRenderTarget. | 40 * Creates an SkGpuDevice from a GrRenderTarget. |
40 */ | 41 */ |
41 static SkGpuDevice* Create(GrRenderTarget* target, const SkSurfaceProps*, un
signed flags = 0); | 42 static SkGpuDevice* Create(GrRenderTarget* target, const SkSurfaceProps*, un
signed flags = 0); |
42 | 43 |
43 /** | 44 /** |
44 * New device that will create an offscreen renderTarget based on the ImageI
nfo and | 45 * New device that will create an offscreen renderTarget based on the ImageI
nfo and |
45 * sampleCount. The Budgeted param controls whether the device's backing sto
re counts against | 46 * sampleCount. The Budgeted param controls whether the device's backing sto
re counts against |
46 * the resource cache budget. On failure, returns NULL. | 47 * the resource cache budget. On failure, returns NULL. |
47 */ | 48 */ |
48 static SkGpuDevice* Create(GrContext*, SkSurface::Budgeted, const SkImageInf
o&, | 49 static SkGpuDevice* Create(GrContext*, SkSurface::Budgeted, const SkImageInf
o&, |
49 int sampleCount, const SkSurfaceProps*, unsigned
flags = 0); | 50 int sampleCount, const SkSurfaceProps*, unsigned
flags = 0); |
50 | 51 |
| 52 static SkGpuDevice* CreateWithReverseOwnershipDeprecated(GrRenderTarget* tar
get, const SkSurfaceProps*, unsigned flags = 0); |
| 53 |
51 virtual ~SkGpuDevice(); | 54 virtual ~SkGpuDevice(); |
52 | 55 |
| 56 void setSurface(SkSurface_Gpu* surface); |
| 57 |
53 SkGpuDevice* cloneDevice(const SkSurfaceProps& props) { | 58 SkGpuDevice* cloneDevice(const SkSurfaceProps& props) { |
54 SkBaseDevice* dev = this->onCreateCompatibleDevice(CreateInfo(this->imag
eInfo(), | 59 SkBaseDevice* dev = this->onCreateCompatibleDevice(CreateInfo(this->imag
eInfo(), |
55 kGeneral_U
sage, | 60 kGeneral_U
sage, |
56 props.pixe
lGeometry())); | 61 props.pixe
lGeometry())); |
57 return static_cast<SkGpuDevice*>(dev); | 62 return static_cast<SkGpuDevice*>(dev); |
58 } | 63 } |
59 | 64 |
60 GrContext* context() const { return fRenderTarget->getContext(); } | 65 GrContext* context() const { return fRenderTarget->getContext(); } |
61 | 66 |
62 // set all pixels to 0 | 67 // set all pixels to 0 |
63 void clearAll(); | 68 void clearAll(); |
64 | 69 |
65 void swapRenderTarget(GrRenderTarget* newTarget); | 70 void swapRenderTarget(GrRenderTarget* newTarget); |
66 | 71 |
67 | |
68 GrRenderTarget* accessRenderTarget() SK_OVERRIDE; | 72 GrRenderTarget* accessRenderTarget() SK_OVERRIDE; |
69 | 73 |
70 SkImageInfo imageInfo() const SK_OVERRIDE { | 74 SkImageInfo imageInfo() const SK_OVERRIDE { |
71 return fRenderTarget ? fRenderTarget->surfacePriv().info() : SkImageInfo
::MakeUnknown(); | 75 return fRenderTarget ? fRenderTarget->surfacePriv().info() : SkImageInfo
::MakeUnknown(); |
72 } | 76 } |
73 | 77 |
74 const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; } | 78 const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; } |
75 | 79 |
| 80 void discard() SK_OVERRIDE; |
| 81 |
76 void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE; | 82 void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE; |
77 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t coun
t, | 83 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t coun
t, |
78 const SkPoint[], const SkPaint& paint) SK_OVERRIDE; | 84 const SkPoint[], const SkPaint& paint) SK_OVERRIDE; |
79 virtual void drawRect(const SkDraw&, const SkRect& r, | 85 virtual void drawRect(const SkDraw&, const SkRect& r, |
80 const SkPaint& paint) SK_OVERRIDE; | 86 const SkPaint& paint) SK_OVERRIDE; |
81 virtual void drawRRect(const SkDraw&, const SkRRect& r, | 87 virtual void drawRRect(const SkDraw&, const SkRRect& r, |
82 const SkPaint& paint) SK_OVERRIDE; | 88 const SkPaint& paint) SK_OVERRIDE; |
83 virtual void drawDRRect(const SkDraw& draw, const SkRRect& outer, | 89 virtual void drawDRRect(const SkDraw& draw, const SkRRect& outer, |
84 const SkRRect& inner, const SkPaint& paint) SK_OVERR
IDE; | 90 const SkRRect& inner, const SkPaint& paint) SK_OVERR
IDE; |
85 virtual void drawOval(const SkDraw&, const SkRect& oval, | 91 virtual void drawOval(const SkDraw&, const SkRect& oval, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 private: | 145 private: |
140 GrContext* fContext; | 146 GrContext* fContext; |
141 GrSkDrawProcs* fDrawProcs; | 147 GrSkDrawProcs* fDrawProcs; |
142 GrClipData fClipData; | 148 GrClipData fClipData; |
143 GrTextContext* fTextContext; | 149 GrTextContext* fTextContext; |
144 SkSurfaceProps fSurfaceProps; | 150 SkSurfaceProps fSurfaceProps; |
145 GrRenderTarget* fRenderTarget; | 151 GrRenderTarget* fRenderTarget; |
146 // remove when our clients don't rely on accessBitmap() | 152 // remove when our clients don't rely on accessBitmap() |
147 SkBitmap fLegacyBitmap; | 153 SkBitmap fLegacyBitmap; |
148 bool fNeedClear; | 154 bool fNeedClear; |
149 | 155 SkSurface_Gpu* fSurface; |
| 156 bool fDeviceOwnsSurface; |
150 SkGpuDevice(GrRenderTarget*, const SkSurfaceProps*, unsigned flags); | 157 SkGpuDevice(GrRenderTarget*, const SkSurfaceProps*, unsigned flags); |
151 | 158 |
152 SkBaseDevice* onCreateCompatibleDevice(const CreateInfo&) SK_OVERRIDE; | 159 SkBaseDevice* onCreateCompatibleDevice(const CreateInfo&) SK_OVERRIDE; |
153 | 160 |
154 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE
; | 161 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE
; |
155 | 162 |
156 SkImageFilter::Cache* getImageFilterCache() SK_OVERRIDE; | 163 SkImageFilter::Cache* getImageFilterCache() SK_OVERRIDE; |
157 | 164 |
158 bool forceConservativeRasterClip() const SK_OVERRIDE { return true; } | 165 bool forceConservativeRasterClip() const SK_OVERRIDE { return true; } |
159 | 166 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 bool bicubic); | 209 bool bicubic); |
203 | 210 |
204 bool drawDashLine(const SkPoint pts[2], const SkPaint& paint); | 211 bool drawDashLine(const SkPoint pts[2], const SkPaint& paint); |
205 | 212 |
206 static SkPicture::AccelData::Key ComputeAccelDataKey(); | 213 static SkPicture::AccelData::Key ComputeAccelDataKey(); |
207 | 214 |
208 typedef SkBaseDevice INHERITED; | 215 typedef SkBaseDevice INHERITED; |
209 }; | 216 }; |
210 | 217 |
211 #endif | 218 #endif |
OLD | NEW |