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 |
(...skipping 23 matching lines...) Expand all Loading... |
34 enum Flags { | 34 enum Flags { |
35 kNeedClear_Flag = 1 << 0, //!< Surface requires an initial clear | 35 kNeedClear_Flag = 1 << 0, //!< Surface requires an initial clear |
36 }; | 36 }; |
37 | 37 |
38 /** | 38 /** |
39 * Creates an SkGpuDevice from a GrRenderTarget. | 39 * Creates an SkGpuDevice from a GrRenderTarget. |
40 */ | 40 */ |
41 static SkGpuDevice* Create(GrRenderTarget* target, const SkSurfaceProps*, un
signed flags = 0); | 41 static SkGpuDevice* Create(GrRenderTarget* target, const SkSurfaceProps*, un
signed flags = 0); |
42 | 42 |
43 /** | 43 /** |
| 44 * Creates an SkGpuDevice from a GrRenderTarget whose texture width/height i
s |
| 45 * different than its actual width/height (e.g., approx-match scratch textur
e). |
| 46 */ |
| 47 static SkGpuDevice* Create(GrRenderTarget* target, int width, int height, |
| 48 const SkSurfaceProps*, unsigned flags = 0); |
| 49 |
| 50 /** |
44 * New device that will create an offscreen renderTarget based on the ImageI
nfo and | 51 * 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 | 52 * sampleCount. The Budgeted param controls whether the device's backing sto
re counts against |
46 * the resource cache budget. On failure, returns NULL. | 53 * the resource cache budget. On failure, returns NULL. |
47 */ | 54 */ |
48 static SkGpuDevice* Create(GrContext*, SkSurface::Budgeted, const SkImageInf
o&, | 55 static SkGpuDevice* Create(GrContext*, SkSurface::Budgeted, const SkImageInf
o&, |
49 int sampleCount, const SkSurfaceProps*, unsigned
flags = 0); | 56 int sampleCount, const SkSurfaceProps*, unsigned
flags = 0); |
50 | 57 |
51 virtual ~SkGpuDevice(); | 58 virtual ~SkGpuDevice(); |
52 | 59 |
53 SkGpuDevice* cloneDevice(const SkSurfaceProps& props) { | 60 SkGpuDevice* cloneDevice(const SkSurfaceProps& props) { |
54 SkBaseDevice* dev = this->onCreateDevice(CreateInfo(this->imageInfo(), k
Possible_TileUsage, | 61 SkBaseDevice* dev = this->onCreateDevice(CreateInfo(this->imageInfo(), k
Possible_TileUsage, |
55 props.pixelGeometry(
)), | 62 props.pixelGeometry(
)), |
56 NULL); | 63 NULL); |
57 return static_cast<SkGpuDevice*>(dev); | 64 return static_cast<SkGpuDevice*>(dev); |
58 } | 65 } |
59 | 66 |
60 GrContext* context() const { return fContext; } | 67 GrContext* context() const { return fContext; } |
61 | 68 |
62 // set all pixels to 0 | 69 // set all pixels to 0 |
63 void clearAll(); | 70 void clearAll(); |
64 | 71 |
65 void replaceRenderTarget(bool shouldRetainContent); | 72 void replaceRenderTarget(bool shouldRetainContent); |
66 | 73 |
67 GrRenderTarget* accessRenderTarget() override; | 74 GrRenderTarget* accessRenderTarget() override; |
68 | 75 |
69 SkImageInfo imageInfo() const override { | 76 SkImageInfo imageInfo() const override { |
70 return fRenderTarget ? fRenderTarget->surfacePriv().info() : SkImageInfo
::MakeUnknown(); | 77 return fLegacyBitmap.info(); |
71 } | 78 } |
72 | 79 |
73 const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; } | 80 const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; } |
74 | 81 |
75 void drawPaint(const SkDraw&, const SkPaint& paint) override; | 82 void drawPaint(const SkDraw&, const SkPaint& paint) override; |
76 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, |
77 const SkPoint[], const SkPaint& paint) override; | 84 const SkPoint[], const SkPaint& paint) override; |
78 virtual void drawRect(const SkDraw&, const SkRect& r, | 85 virtual void drawRect(const SkDraw&, const SkRect& r, |
79 const SkPaint& paint) override; | 86 const SkPaint& paint) override; |
80 virtual void drawRRect(const SkDraw&, const SkRRect& r, | 87 virtual void drawRRect(const SkDraw&, const SkRRect& r, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 void onAttachToCanvas(SkCanvas* canvas) override; | 121 void onAttachToCanvas(SkCanvas* canvas) override; |
115 void onDetachFromCanvas() override; | 122 void onDetachFromCanvas() override; |
116 | 123 |
117 const SkBitmap& onAccessBitmap() override; | 124 const SkBitmap& onAccessBitmap() override; |
118 | 125 |
119 bool canHandleImageFilter(const SkImageFilter*) override; | 126 bool canHandleImageFilter(const SkImageFilter*) override; |
120 virtual bool filterImage(const SkImageFilter*, const SkBitmap&, | 127 virtual bool filterImage(const SkImageFilter*, const SkBitmap&, |
121 const SkImageFilter::Context&, | 128 const SkImageFilter::Context&, |
122 SkBitmap*, SkIPoint*) override; | 129 SkBitmap*, SkIPoint*) override; |
123 | 130 |
124 bool filterTexture(GrContext*, GrTexture*, const SkImageFilter*, | 131 bool filterTexture(GrContext*, GrTexture*, int width, int height, const SkIm
ageFilter*, |
125 const SkImageFilter::Context&, | 132 const SkImageFilter::Context&, |
126 SkBitmap* result, SkIPoint* offset); | 133 SkBitmap* result, SkIPoint* offset); |
127 | 134 |
128 protected: | 135 protected: |
129 bool onReadPixels(const SkImageInfo&, void*, size_t, int, int) override; | 136 bool onReadPixels(const SkImageInfo&, void*, size_t, int, int) override; |
130 bool onWritePixels(const SkImageInfo&, const void*, size_t, int, int) overri
de; | 137 bool onWritePixels(const SkImageInfo&, const void*, size_t, int, int) overri
de; |
131 bool onShouldDisableLCD(const SkPaint&) const override; | 138 bool onShouldDisableLCD(const SkPaint&) const override; |
132 | 139 |
133 /** PRIVATE / EXPERIMENTAL -- do not call */ | 140 /** PRIVATE / EXPERIMENTAL -- do not call */ |
134 virtual bool EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pic
ture, | 141 virtual bool EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pic
ture, |
135 const SkMatrix*, const SkPaint*) overr
ide; | 142 const SkMatrix*, const SkPaint*) overr
ide; |
136 | 143 |
137 private: | 144 private: |
138 GrContext* fContext; | 145 GrContext* fContext; |
139 GrSkDrawProcs* fDrawProcs; | 146 GrSkDrawProcs* fDrawProcs; |
140 SkAutoTUnref<const SkClipStack> fClipStack; | 147 SkAutoTUnref<const SkClipStack> fClipStack; |
141 SkIPoint fClipOrigin; | 148 SkIPoint fClipOrigin; |
142 GrClip fClip; | 149 GrClip fClip; |
143 GrTextContext* fTextContext; | 150 GrTextContext* fTextContext; |
144 SkSurfaceProps fSurfaceProps; | 151 SkSurfaceProps fSurfaceProps; |
145 GrRenderTarget* fRenderTarget; | 152 GrRenderTarget* fRenderTarget; |
146 // remove when our clients don't rely on accessBitmap() | 153 // remove when our clients don't rely on accessBitmap() |
147 SkBitmap fLegacyBitmap; | 154 SkBitmap fLegacyBitmap; |
148 bool fNeedClear; | 155 bool fNeedClear; |
149 | 156 |
150 SkGpuDevice(GrRenderTarget*, const SkSurfaceProps*, unsigned flags); | 157 SkGpuDevice(GrRenderTarget*, int width, int height, const SkSurfaceProps*, u
nsigned flags); |
151 | 158 |
152 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; | 159 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; |
153 | 160 |
154 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) override; | 161 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) override; |
155 | 162 |
156 SkImageFilter::Cache* getImageFilterCache() override; | 163 SkImageFilter::Cache* getImageFilterCache() override; |
157 | 164 |
158 bool forceConservativeRasterClip() const override { return true; } | 165 bool forceConservativeRasterClip() const override { return true; } |
159 | 166 |
160 // sets the render target and clip on context | 167 // sets the render target and clip on context |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 static SkPicture::AccelData::Key ComputeAccelDataKey(); | 217 static SkPicture::AccelData::Key ComputeAccelDataKey(); |
211 | 218 |
212 static GrRenderTarget* CreateRenderTarget(GrContext*, SkSurface::Budgeted, c
onst SkImageInfo&, | 219 static GrRenderTarget* CreateRenderTarget(GrContext*, SkSurface::Budgeted, c
onst SkImageInfo&, |
213 int sampleCount); | 220 int sampleCount); |
214 | 221 |
215 friend class GrTextContext; | 222 friend class GrTextContext; |
216 typedef SkBaseDevice INHERITED; | 223 typedef SkBaseDevice INHERITED; |
217 }; | 224 }; |
218 | 225 |
219 #endif | 226 #endif |
OLD | NEW |