OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 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 #include "SkDeferredCanvas.h" | 9 #include "SkDeferredCanvas.h" |
10 | 10 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 //----------------------------------------------------------------------------- | 59 //----------------------------------------------------------------------------- |
60 // DeferredPipeController | 60 // DeferredPipeController |
61 //----------------------------------------------------------------------------- | 61 //----------------------------------------------------------------------------- |
62 | 62 |
63 class DeferredPipeController : public SkGPipeController { | 63 class DeferredPipeController : public SkGPipeController { |
64 public: | 64 public: |
65 DeferredPipeController(); | 65 DeferredPipeController(); |
66 void setPlaybackCanvas(SkCanvas*); | 66 void setPlaybackCanvas(SkCanvas*); |
67 virtual ~DeferredPipeController(); | 67 virtual ~DeferredPipeController(); |
68 void* requestBlock(size_t minRequest, size_t* actual) SK_OVERRIDE; | 68 void* requestBlock(size_t minRequest, size_t* actual) override; |
69 void notifyWritten(size_t bytes) SK_OVERRIDE; | 69 void notifyWritten(size_t bytes) override; |
70 void playback(bool silent); | 70 void playback(bool silent); |
71 bool hasPendingCommands() const { return fAllocator.totalUsed() != 0; } | 71 bool hasPendingCommands() const { return fAllocator.totalUsed() != 0; } |
72 size_t storageAllocatedForRecording() const { return fAllocator.totalCapacit
y(); } | 72 size_t storageAllocatedForRecording() const { return fAllocator.totalCapacit
y(); } |
73 private: | 73 private: |
74 enum { | 74 enum { |
75 kMinBlockSize = 4096 | 75 kMinBlockSize = 4096 |
76 }; | 76 }; |
77 struct PipeBlock { | 77 struct PipeBlock { |
78 PipeBlock(void* block, size_t size) { fBlock = block, fSize = size; } | 78 PipeBlock(void* block, size_t size) { fBlock = block, fSize = size; } |
79 void* fBlock; | 79 void* fBlock; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 bool isFreshFrame(); | 151 bool isFreshFrame(); |
152 bool hasPendingCommands(); | 152 bool hasPendingCommands(); |
153 size_t storageAllocatedForRecording() const; | 153 size_t storageAllocatedForRecording() const; |
154 size_t freeMemoryIfPossible(size_t bytesToFree); | 154 size_t freeMemoryIfPossible(size_t bytesToFree); |
155 void flushPendingCommands(PlaybackMode); | 155 void flushPendingCommands(PlaybackMode); |
156 void skipPendingCommands(); | 156 void skipPendingCommands(); |
157 void setMaxRecordingStorage(size_t); | 157 void setMaxRecordingStorage(size_t); |
158 void recordedDrawCommand(); | 158 void recordedDrawCommand(); |
159 void setIsDrawingToLayer(bool value) {fIsDrawingToLayer = value;} | 159 void setIsDrawingToLayer(bool value) {fIsDrawingToLayer = value;} |
160 | 160 |
161 SkImageInfo imageInfo() const SK_OVERRIDE; | 161 SkImageInfo imageInfo() const override; |
162 | 162 |
163 GrRenderTarget* accessRenderTarget() SK_OVERRIDE; | 163 GrRenderTarget* accessRenderTarget() override; |
164 | 164 |
165 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) SK_OVERRIDE; | 165 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; |
166 | 166 |
167 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE
; | 167 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) override; |
168 | 168 |
169 protected: | 169 protected: |
170 const SkBitmap& onAccessBitmap() SK_OVERRIDE; | 170 const SkBitmap& onAccessBitmap() override; |
171 bool onReadPixels(const SkImageInfo&, void*, size_t, int x, int y) SK_OVERRI
DE; | 171 bool onReadPixels(const SkImageInfo&, void*, size_t, int x, int y) override; |
172 bool onWritePixels(const SkImageInfo&, const void*, size_t, int x, int y) SK
_OVERRIDE; | 172 bool onWritePixels(const SkImageInfo&, const void*, size_t, int x, int y) ov
erride; |
173 | 173 |
174 // None of the following drawing methods should ever get called on the | 174 // None of the following drawing methods should ever get called on the |
175 // deferred device | 175 // deferred device |
176 void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE | 176 void drawPaint(const SkDraw&, const SkPaint& paint) override |
177 {SkASSERT(0);} | 177 {SkASSERT(0);} |
178 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, | 178 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, |
179 size_t count, const SkPoint[], | 179 size_t count, const SkPoint[], |
180 const SkPaint& paint) SK_OVERRIDE | 180 const SkPaint& paint) override |
181 {SkASSERT(0);} | 181 {SkASSERT(0);} |
182 virtual void drawRect(const SkDraw&, const SkRect& r, | 182 virtual void drawRect(const SkDraw&, const SkRect& r, |
183 const SkPaint& paint) SK_OVERRIDE | 183 const SkPaint& paint) override |
184 {SkASSERT(0);} | 184 {SkASSERT(0);} |
185 void drawOval(const SkDraw&, const SkRect&, const SkPaint&) SK_OVERRIDE | 185 void drawOval(const SkDraw&, const SkRect&, const SkPaint&) override |
186 {SkASSERT(0);} | 186 {SkASSERT(0);} |
187 virtual void drawRRect(const SkDraw&, const SkRRect& rr, | 187 virtual void drawRRect(const SkDraw&, const SkRRect& rr, |
188 const SkPaint& paint) SK_OVERRIDE | 188 const SkPaint& paint) override |
189 {SkASSERT(0);} | 189 {SkASSERT(0);} |
190 virtual void drawPath(const SkDraw&, const SkPath& path, | 190 virtual void drawPath(const SkDraw&, const SkPath& path, |
191 const SkPaint& paint, | 191 const SkPaint& paint, |
192 const SkMatrix* prePathMatrix = NULL, | 192 const SkMatrix* prePathMatrix = NULL, |
193 bool pathIsMutable = false) SK_OVERRIDE | 193 bool pathIsMutable = false) override |
194 {SkASSERT(0);} | 194 {SkASSERT(0);} |
195 virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap, | 195 virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap, |
196 const SkMatrix& matrix, const SkPaint& paint) SK_OVE
RRIDE | 196 const SkMatrix& matrix, const SkPaint& paint) overri
de |
197 {SkASSERT(0);} | 197 {SkASSERT(0);} |
198 virtual void drawBitmapRect(const SkDraw&, const SkBitmap&, const SkRect*, | 198 virtual void drawBitmapRect(const SkDraw&, const SkBitmap&, const SkRect*, |
199 const SkRect&, const SkPaint&, | 199 const SkRect&, const SkPaint&, |
200 SkCanvas::DrawBitmapRectFlags) SK_OVERRIDE | 200 SkCanvas::DrawBitmapRectFlags) override |
201 {SkASSERT(0);} | 201 {SkASSERT(0);} |
202 virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap, | 202 virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap, |
203 int x, int y, const SkPaint& paint) SK_OVERRIDE | 203 int x, int y, const SkPaint& paint) override |
204 {SkASSERT(0);} | 204 {SkASSERT(0);} |
205 virtual void drawText(const SkDraw&, const void* text, size_t len, | 205 virtual void drawText(const SkDraw&, const void* text, size_t len, |
206 SkScalar x, SkScalar y, const SkPaint& paint) SK_OVE
RRIDE | 206 SkScalar x, SkScalar y, const SkPaint& paint) overri
de |
207 {SkASSERT(0);} | 207 {SkASSERT(0);} |
208 virtual void drawPosText(const SkDraw&, const void* text, size_t len, | 208 virtual void drawPosText(const SkDraw&, const void* text, size_t len, |
209 const SkScalar pos[], int scalarsPerPos, | 209 const SkScalar pos[], int scalarsPerPos, |
210 const SkPoint& offset, const SkPaint& paint) SK_OVE
RRIDE | 210 const SkPoint& offset, const SkPaint& paint) overri
de |
211 {SkASSERT(0);} | 211 {SkASSERT(0);} |
212 virtual void drawTextOnPath(const SkDraw&, const void* text, | 212 virtual void drawTextOnPath(const SkDraw&, const void* text, |
213 size_t len, const SkPath& path, | 213 size_t len, const SkPath& path, |
214 const SkMatrix* matrix, | 214 const SkMatrix* matrix, |
215 const SkPaint& paint) SK_OVERRIDE | 215 const SkPaint& paint) override |
216 {SkASSERT(0);} | 216 {SkASSERT(0);} |
217 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, | 217 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, |
218 int vertexCount, const SkPoint verts[], | 218 int vertexCount, const SkPoint verts[], |
219 const SkPoint texs[], const SkColor colors[], | 219 const SkPoint texs[], const SkColor colors[], |
220 SkXfermode* xmode, const uint16_t indices[], | 220 SkXfermode* xmode, const uint16_t indices[], |
221 int indexCount, const SkPaint& paint) SK_OVERRID
E | 221 int indexCount, const SkPaint& paint) override |
222 {SkASSERT(0);} | 222 {SkASSERT(0);} |
223 virtual void drawPatch(const SkDraw&, const SkPoint cubics[12], const SkColo
r colors[4], | 223 virtual void drawPatch(const SkDraw&, const SkPoint cubics[12], const SkColo
r colors[4], |
224 const SkPoint texCoords[4], SkXfermode* xmode, | 224 const SkPoint texCoords[4], SkXfermode* xmode, |
225 const SkPaint& paint) SK_OVERRIDE | 225 const SkPaint& paint) override |
226 {SkASSERT(0);} | 226 {SkASSERT(0);} |
227 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, | 227 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, |
228 const SkPaint&) SK_OVERRIDE | 228 const SkPaint&) override |
229 {SkASSERT(0);} | 229 {SkASSERT(0);} |
230 | 230 |
231 void lockPixels() SK_OVERRIDE {} | 231 void lockPixels() override {} |
232 void unlockPixels() SK_OVERRIDE {} | 232 void unlockPixels() override {} |
233 | 233 |
234 bool canHandleImageFilter(const SkImageFilter*) SK_OVERRIDE { | 234 bool canHandleImageFilter(const SkImageFilter*) override { |
235 return false; | 235 return false; |
236 } | 236 } |
237 virtual bool filterImage(const SkImageFilter*, const SkBitmap&, | 237 virtual bool filterImage(const SkImageFilter*, const SkBitmap&, |
238 const SkImageFilter::Context&, SkBitmap*, SkIPoint*
) SK_OVERRIDE { | 238 const SkImageFilter::Context&, SkBitmap*, SkIPoint*
) override { |
239 return false; | 239 return false; |
240 } | 240 } |
241 | 241 |
242 private: | 242 private: |
243 void flush() SK_OVERRIDE; | 243 void flush() override; |
244 void replaceBitmapBackendForRasterSurface(const SkBitmap&) SK_OVERRIDE {} | 244 void replaceBitmapBackendForRasterSurface(const SkBitmap&) override {} |
245 | 245 |
246 void beginRecording(); | 246 void beginRecording(); |
247 void init(); | 247 void init(); |
248 void aboutToDraw(); | 248 void aboutToDraw(); |
249 void prepareForImmediatePixelWrite(); | 249 void prepareForImmediatePixelWrite(); |
250 | 250 |
251 DeferredPipeController fPipeController; | 251 DeferredPipeController fPipeController; |
252 SkGPipeWriter fPipeWriter; | 252 SkGPipeWriter fPipeWriter; |
253 SkCanvas* fImmediateCanvas; | 253 SkCanvas* fImmediateCanvas; |
254 SkCanvas* fRecordingCanvas; | 254 SkCanvas* fRecordingCanvas; |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { | 928 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { |
929 this->drawingCanvas()->setDrawFilter(filter); | 929 this->drawingCanvas()->setDrawFilter(filter); |
930 this->INHERITED::setDrawFilter(filter); | 930 this->INHERITED::setDrawFilter(filter); |
931 this->recordedDrawCommand(); | 931 this->recordedDrawCommand(); |
932 return filter; | 932 return filter; |
933 } | 933 } |
934 | 934 |
935 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { | 935 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { |
936 return this->drawingCanvas(); | 936 return this->drawingCanvas(); |
937 } | 937 } |
OLD | NEW |