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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE; | 166 virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE; |
167 | 167 |
168 virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config, | 168 virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config, |
169 int width, int height, | 169 int width, int height, |
170 bool isOpaque, | 170 bool isOpaque, |
171 Usage usage) SK_OVERRIDE; | 171 Usage usage) SK_OVERRIDE; |
172 | 172 |
173 virtual void writePixels(const SkBitmap& bitmap, int x, int y, | 173 virtual void writePixels(const SkBitmap& bitmap, int x, int y, |
174 SkCanvas::Config8888 config8888) SK_OVERRIDE; | 174 SkCanvas::Config8888 config8888) SK_OVERRIDE; |
175 | 175 |
| 176 virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE; |
| 177 |
176 protected: | 178 protected: |
177 virtual const SkBitmap& onAccessBitmap() SK_OVERRIDE; | 179 virtual const SkBitmap& onAccessBitmap() SK_OVERRIDE; |
178 virtual bool onReadPixels(const SkBitmap& bitmap, | 180 virtual bool onReadPixels(const SkBitmap& bitmap, |
179 int x, int y, | 181 int x, int y, |
180 SkCanvas::Config8888 config8888) SK_OVERRIDE; | 182 SkCanvas::Config8888 config8888) SK_OVERRIDE; |
181 | 183 |
182 // The following methods are no-ops on a deferred device | 184 // The following methods are no-ops on a deferred device |
183 virtual bool filterTextFlags(const SkPaint& paint, TextFlags*) SK_OVERRIDE { | 185 virtual bool filterTextFlags(const SkPaint& paint, TextFlags*) SK_OVERRIDE { |
184 return false; | 186 return false; |
185 } | 187 } |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 // Save layer usage not supported, and not required by SkDeferredCanvas. | 490 // Save layer usage not supported, and not required by SkDeferredCanvas. |
489 SkASSERT(usage != kSaveLayer_Usage); | 491 SkASSERT(usage != kSaveLayer_Usage); |
490 // Create a compatible non-deferred device. | 492 // Create a compatible non-deferred device. |
491 // We do not create a deferred device because we know the new device | 493 // We do not create a deferred device because we know the new device |
492 // will not be used with a deferred canvas (there is no API for that). | 494 // will not be used with a deferred canvas (there is no API for that). |
493 // And connecting a DeferredDevice to non-deferred canvas can result | 495 // And connecting a DeferredDevice to non-deferred canvas can result |
494 // in unpredictable behavior. | 496 // in unpredictable behavior. |
495 return immediateDevice()->createCompatibleDevice(config, width, height, isOp
aque); | 497 return immediateDevice()->createCompatibleDevice(config, width, height, isOp
aque); |
496 } | 498 } |
497 | 499 |
| 500 SkSurface* DeferredDevice::newSurface(const SkImageInfo& info) { |
| 501 return this->immediateDevice()->newSurface(info); |
| 502 } |
| 503 |
498 bool DeferredDevice::onReadPixels( | 504 bool DeferredDevice::onReadPixels( |
499 const SkBitmap& bitmap, int x, int y, SkCanvas::Config8888 config8888) { | 505 const SkBitmap& bitmap, int x, int y, SkCanvas::Config8888 config8888) { |
500 this->flushPendingCommands(kNormal_PlaybackMode); | 506 this->flushPendingCommands(kNormal_PlaybackMode); |
501 return fImmediateCanvas->readPixels(const_cast<SkBitmap*>(&bitmap), | 507 return fImmediateCanvas->readPixels(const_cast<SkBitmap*>(&bitmap), |
502 x, y, config8888); | 508 x, y, config8888); |
503 } | 509 } |
504 | 510 |
505 class AutoImmediateDrawIfNeeded { | 511 class AutoImmediateDrawIfNeeded { |
506 public: | 512 public: |
507 AutoImmediateDrawIfNeeded(SkDeferredCanvas& canvas, const SkBitmap* bitmap, | 513 AutoImmediateDrawIfNeeded(SkDeferredCanvas& canvas, const SkBitmap* bitmap, |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { | 988 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { |
983 this->drawingCanvas()->setDrawFilter(filter); | 989 this->drawingCanvas()->setDrawFilter(filter); |
984 this->INHERITED::setDrawFilter(filter); | 990 this->INHERITED::setDrawFilter(filter); |
985 this->recordedDrawCommand(); | 991 this->recordedDrawCommand(); |
986 return filter; | 992 return filter; |
987 } | 993 } |
988 | 994 |
989 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { | 995 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { |
990 return this->drawingCanvas(); | 996 return this->drawingCanvas(); |
991 } | 997 } |
OLD | NEW |