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 |
51 virtual ~SkGpuDevice(); | 52 virtual ~SkGpuDevice(); |
52 | 53 |
| 54 void setSurface(SkSurface_Gpu* surface) { |
| 55 fSurface = surface; |
| 56 } |
| 57 |
53 /** Creates a render targetthat can be used as the render target of the devi
ce. */ | 58 /** Creates a render targetthat can be used as the render target of the devi
ce. */ |
54 static GrRenderTarget* CreateRenderTarget(GrContext* context, SkSurface::Bud
geted budgeted, | 59 static GrRenderTarget* CreateRenderTarget(GrContext* context, SkSurface::Bud
geted budgeted, |
55 const SkImageInfo& info, int sampl
eCount); | 60 const SkImageInfo& info, int sampl
eCount); |
56 | 61 |
57 SkGpuDevice* cloneDevice(const SkSurfaceProps& props) { | 62 SkGpuDevice* cloneDevice(const SkSurfaceProps& props) { |
58 SkBaseDevice* dev = this->onCreateCompatibleDevice(CreateInfo(this->imag
eInfo(), | 63 SkBaseDevice* dev = this->onCreateCompatibleDevice(CreateInfo(this->imag
eInfo(), |
59 kGeneral_U
sage, | 64 kGeneral_U
sage, |
60 props.pixe
lGeometry())); | 65 props.pixe
lGeometry())); |
61 return static_cast<SkGpuDevice*>(dev); | 66 return static_cast<SkGpuDevice*>(dev); |
62 } | 67 } |
63 | 68 |
64 GrContext* context() const { return fRenderTarget->getContext(); } | 69 GrContext* context() const { return fRenderTarget->getContext(); } |
65 | 70 |
66 // set all pixels to 0 | 71 // set all pixels to 0 |
67 void clearAll(); | 72 void clearAll(); |
68 | 73 |
69 void swapRenderTarget(GrRenderTarget* newTarget); | 74 void detachBackendRenderTarget(bool retainContent); |
70 | 75 |
71 GrRenderTarget* accessRenderTarget() SK_OVERRIDE; | 76 GrRenderTarget* accessRenderTarget() SK_OVERRIDE; |
72 | 77 |
73 SkImageInfo imageInfo() const SK_OVERRIDE { | 78 SkImageInfo imageInfo() const SK_OVERRIDE { |
74 return fRenderTarget ? fRenderTarget->surfacePriv().info() : SkImageInfo
::MakeUnknown(); | 79 return fRenderTarget ? fRenderTarget->surfacePriv().info() : SkImageInfo
::MakeUnknown(); |
75 } | 80 } |
76 | 81 |
77 const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; } | 82 const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; } |
78 | 83 |
| 84 void discard() SK_OVERRIDE; |
| 85 |
79 void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE; | 86 void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE; |
80 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t coun
t, | 87 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t coun
t, |
81 const SkPoint[], const SkPaint& paint) SK_OVERRIDE; | 88 const SkPoint[], const SkPaint& paint) SK_OVERRIDE; |
82 virtual void drawRect(const SkDraw&, const SkRect& r, | 89 virtual void drawRect(const SkDraw&, const SkRect& r, |
83 const SkPaint& paint) SK_OVERRIDE; | 90 const SkPaint& paint) SK_OVERRIDE; |
84 virtual void drawRRect(const SkDraw&, const SkRRect& r, | 91 virtual void drawRRect(const SkDraw&, const SkRRect& r, |
85 const SkPaint& paint) SK_OVERRIDE; | 92 const SkPaint& paint) SK_OVERRIDE; |
86 virtual void drawDRRect(const SkDraw& draw, const SkRRect& outer, | 93 virtual void drawDRRect(const SkDraw& draw, const SkRRect& outer, |
87 const SkRRect& inner, const SkPaint& paint) SK_OVERR
IDE; | 94 const SkRRect& inner, const SkPaint& paint) SK_OVERR
IDE; |
88 virtual void drawOval(const SkDraw&, const SkRect& oval, | 95 virtual void drawOval(const SkDraw&, const SkRect& oval, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 private: | 149 private: |
143 GrContext* fContext; | 150 GrContext* fContext; |
144 GrSkDrawProcs* fDrawProcs; | 151 GrSkDrawProcs* fDrawProcs; |
145 GrClipData fClipData; | 152 GrClipData fClipData; |
146 GrTextContext* fTextContext; | 153 GrTextContext* fTextContext; |
147 SkSurfaceProps fSurfaceProps; | 154 SkSurfaceProps fSurfaceProps; |
148 GrRenderTarget* fRenderTarget; | 155 GrRenderTarget* fRenderTarget; |
149 // remove when our clients don't rely on accessBitmap() | 156 // remove when our clients don't rely on accessBitmap() |
150 SkBitmap fLegacyBitmap; | 157 SkBitmap fLegacyBitmap; |
151 bool fNeedClear; | 158 bool fNeedClear; |
| 159 SkSurface_Gpu* fSurface; |
152 | 160 |
153 SkGpuDevice(GrRenderTarget*, const SkSurfaceProps*, unsigned flags); | 161 SkGpuDevice(GrRenderTarget*, const SkSurfaceProps*, unsigned flags); |
154 | 162 |
155 SkBaseDevice* onCreateCompatibleDevice(const CreateInfo&) SK_OVERRIDE; | 163 SkBaseDevice* onCreateCompatibleDevice(const CreateInfo&) SK_OVERRIDE; |
156 | 164 |
157 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE
; | 165 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE
; |
158 | 166 |
159 SkImageFilter::Cache* getImageFilterCache() SK_OVERRIDE; | 167 SkImageFilter::Cache* getImageFilterCache() SK_OVERRIDE; |
160 | 168 |
161 bool forceConservativeRasterClip() const SK_OVERRIDE { return true; } | 169 bool forceConservativeRasterClip() const SK_OVERRIDE { return true; } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 bool bicubic); | 213 bool bicubic); |
206 | 214 |
207 bool drawDashLine(const SkPoint pts[2], const SkPaint& paint); | 215 bool drawDashLine(const SkPoint pts[2], const SkPaint& paint); |
208 | 216 |
209 static SkPicture::AccelData::Key ComputeAccelDataKey(); | 217 static SkPicture::AccelData::Key ComputeAccelDataKey(); |
210 | 218 |
211 typedef SkBaseDevice INHERITED; | 219 typedef SkBaseDevice INHERITED; |
212 }; | 220 }; |
213 | 221 |
214 #endif | 222 #endif |
OLD | NEW |