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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 SK_OVERRIDE; |
162 | 162 |
163 GrRenderTarget* accessRenderTarget() SK_OVERRIDE; | 163 GrRenderTarget* accessRenderTarget() SK_OVERRIDE; |
164 | 164 |
165 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) SK_OVERRIDE; | 165 SkBaseDevice* onCreateCompatibleDevice(const CreateInfo&) SK_OVERRIDE; |
166 | 166 |
167 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE
; | 167 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE
; |
168 | 168 |
169 protected: | 169 protected: |
170 const SkBitmap& onAccessBitmap() SK_OVERRIDE; | 170 const SkBitmap& onAccessBitmap() SK_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) SK_OVERRI
DE; |
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) SK
_OVERRIDE; |
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 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 const SkPoint texCoords[4], SkXfermode* xmode, | 224 const SkPoint texCoords[4], SkXfermode* xmode, |
225 const SkPaint& paint) SK_OVERRIDE | 225 const SkPaint& paint) SK_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&) SK_OVERRIDE |
229 {SkASSERT(0);} | 229 {SkASSERT(0);} |
230 | 230 |
231 void lockPixels() SK_OVERRIDE {} | 231 void lockPixels() SK_OVERRIDE {} |
232 void unlockPixels() SK_OVERRIDE {} | 232 void unlockPixels() SK_OVERRIDE {} |
233 | 233 |
| 234 bool allowImageFilter(const SkImageFilter*) SK_OVERRIDE { |
| 235 return false; |
| 236 } |
234 bool canHandleImageFilter(const SkImageFilter*) SK_OVERRIDE { | 237 bool canHandleImageFilter(const SkImageFilter*) SK_OVERRIDE { |
235 return false; | 238 return false; |
236 } | 239 } |
237 virtual bool filterImage(const SkImageFilter*, const SkBitmap&, | 240 virtual bool filterImage(const SkImageFilter*, const SkBitmap&, |
238 const SkImageFilter::Context&, SkBitmap*, SkIPoint*
) SK_OVERRIDE { | 241 const SkImageFilter::Context&, SkBitmap*, SkIPoint*
) SK_OVERRIDE { |
239 return false; | 242 return false; |
240 } | 243 } |
241 | 244 |
242 private: | 245 private: |
243 void flush() SK_OVERRIDE; | 246 void flush() SK_OVERRIDE; |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 454 |
452 this->prepareForImmediatePixelWrite(); | 455 this->prepareForImmediatePixelWrite(); |
453 return immediateDevice()->onWritePixels(info, pixels, rowBytes, x, y); | 456 return immediateDevice()->onWritePixels(info, pixels, rowBytes, x, y); |
454 } | 457 } |
455 | 458 |
456 const SkBitmap& SkDeferredDevice::onAccessBitmap() { | 459 const SkBitmap& SkDeferredDevice::onAccessBitmap() { |
457 this->flushPendingCommands(kNormal_PlaybackMode); | 460 this->flushPendingCommands(kNormal_PlaybackMode); |
458 return immediateDevice()->accessBitmap(false); | 461 return immediateDevice()->accessBitmap(false); |
459 } | 462 } |
460 | 463 |
461 SkBaseDevice* SkDeferredDevice::onCreateDevice(const CreateInfo& cinfo, const Sk
Paint* layerPaint) { | 464 SkBaseDevice* SkDeferredDevice::onCreateCompatibleDevice(const CreateInfo& cinfo
) { |
| 465 // Save layer usage not supported, and not required by SkDeferredCanvas. |
| 466 SkASSERT(cinfo.fUsage != kSaveLayer_Usage); |
| 467 |
462 // Create a compatible non-deferred device. | 468 // Create a compatible non-deferred device. |
463 // We do not create a deferred device because we know the new device | 469 // We do not create a deferred device because we know the new device |
464 // will not be used with a deferred canvas (there is no API for that). | 470 // will not be used with a deferred canvas (there is no API for that). |
465 // And connecting a SkDeferredDevice to non-deferred canvas can result | 471 // And connecting a SkDeferredDevice to non-deferred canvas can result |
466 // in unpredictable behavior. | 472 // in unpredictable behavior. |
467 return immediateDevice()->onCreateDevice(cinfo, layerPaint); | 473 return immediateDevice()->onCreateCompatibleDevice(cinfo); |
468 } | 474 } |
469 | 475 |
470 SkSurface* SkDeferredDevice::newSurface(const SkImageInfo& info, const SkSurface
Props& props) { | 476 SkSurface* SkDeferredDevice::newSurface(const SkImageInfo& info, const SkSurface
Props& props) { |
471 return this->immediateDevice()->newSurface(info, props); | 477 return this->immediateDevice()->newSurface(info, props); |
472 } | 478 } |
473 | 479 |
474 bool SkDeferredDevice::onReadPixels(const SkImageInfo& info, void* pixels, size_
t rowBytes, | 480 bool SkDeferredDevice::onReadPixels(const SkImageInfo& info, void* pixels, size_
t rowBytes, |
475 int x, int y) { | 481 int x, int y) { |
476 this->flushPendingCommands(kNormal_PlaybackMode); | 482 this->flushPendingCommands(kNormal_PlaybackMode); |
477 return fImmediateCanvas->readPixels(info, pixels, rowBytes, x, y); | 483 return fImmediateCanvas->readPixels(info, pixels, rowBytes, x, y); |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { | 934 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { |
929 this->drawingCanvas()->setDrawFilter(filter); | 935 this->drawingCanvas()->setDrawFilter(filter); |
930 this->INHERITED::setDrawFilter(filter); | 936 this->INHERITED::setDrawFilter(filter); |
931 this->recordedDrawCommand(); | 937 this->recordedDrawCommand(); |
932 return filter; | 938 return filter; |
933 } | 939 } |
934 | 940 |
935 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { | 941 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { |
936 return this->drawingCanvas(); | 942 return this->drawingCanvas(); |
937 } | 943 } |
OLD | NEW |