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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 virtual SkImageInfo imageInfo() const SK_OVERRIDE; | 164 virtual SkImageInfo imageInfo() const SK_OVERRIDE; |
165 | 165 |
166 virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE; | 166 virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE; |
167 | 167 |
168 virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE; | 168 virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE; |
169 | 169 |
170 virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE; | 170 virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE; |
171 | 171 |
172 protected: | 172 protected: |
173 virtual const SkBitmap& onAccessBitmap() SK_OVERRIDE; | 173 virtual const SkBitmap& onAccessBitmap() SK_OVERRIDE; |
| 174 #ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG |
174 virtual bool onReadPixels(const SkBitmap& bitmap, | 175 virtual bool onReadPixels(const SkBitmap& bitmap, |
175 int x, int y, | 176 int x, int y, |
176 SkCanvas::Config8888 config8888) SK_OVERRIDE; | 177 SkCanvas::Config8888 config8888) SK_OVERRIDE; |
| 178 #endif |
| 179 virtual bool onReadPixels(const SkImageInfo&, void*, size_t, int x, int y) S
K_OVERRIDE; |
177 virtual bool onWritePixels(const SkImageInfo&, const void*, size_t, int x, i
nt y) SK_OVERRIDE; | 180 virtual bool onWritePixels(const SkImageInfo&, const void*, size_t, int x, i
nt y) SK_OVERRIDE; |
178 | 181 |
179 // The following methods are no-ops on a deferred device | 182 // The following methods are no-ops on a deferred device |
180 virtual bool filterTextFlags(const SkPaint& paint, TextFlags*) SK_OVERRIDE { | 183 virtual bool filterTextFlags(const SkPaint& paint, TextFlags*) SK_OVERRIDE { |
181 return false; | 184 return false; |
182 } | 185 } |
183 | 186 |
184 // None of the following drawing methods should ever get called on the | 187 // None of the following drawing methods should ever get called on the |
185 // deferred device | 188 // deferred device |
186 virtual void clear(SkColor color) SK_OVERRIDE | 189 virtual void clear(SkColor color) SK_OVERRIDE |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 // will not be used with a deferred canvas (there is no API for that). | 502 // will not be used with a deferred canvas (there is no API for that). |
500 // And connecting a SkDeferredDevice to non-deferred canvas can result | 503 // And connecting a SkDeferredDevice to non-deferred canvas can result |
501 // in unpredictable behavior. | 504 // in unpredictable behavior. |
502 return immediateDevice()->createCompatibleDevice(info); | 505 return immediateDevice()->createCompatibleDevice(info); |
503 } | 506 } |
504 | 507 |
505 SkSurface* SkDeferredDevice::newSurface(const SkImageInfo& info) { | 508 SkSurface* SkDeferredDevice::newSurface(const SkImageInfo& info) { |
506 return this->immediateDevice()->newSurface(info); | 509 return this->immediateDevice()->newSurface(info); |
507 } | 510 } |
508 | 511 |
| 512 #ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG |
509 bool SkDeferredDevice::onReadPixels( | 513 bool SkDeferredDevice::onReadPixels( |
510 const SkBitmap& bitmap, int x, int y, SkCanvas::Config8888 config8888) { | 514 const SkBitmap& bitmap, int x, int y, SkCanvas::Config8888 config8888) { |
511 this->flushPendingCommands(kNormal_PlaybackMode); | 515 this->flushPendingCommands(kNormal_PlaybackMode); |
512 return fImmediateCanvas->readPixels(const_cast<SkBitmap*>(&bitmap), | 516 return fImmediateCanvas->readPixels(const_cast<SkBitmap*>(&bitmap), |
513 x, y, config8888); | 517 x, y, config8888); |
514 } | 518 } |
| 519 #endif |
| 520 |
| 521 bool SkDeferredDevice::onReadPixels(const SkImageInfo& info, void* pixels, size_
t rowBytes, |
| 522 int x, int y) { |
| 523 this->flushPendingCommands(kNormal_PlaybackMode); |
| 524 return fImmediateCanvas->readPixels(info, pixels, rowBytes, x, y); |
| 525 } |
515 | 526 |
516 class AutoImmediateDrawIfNeeded { | 527 class AutoImmediateDrawIfNeeded { |
517 public: | 528 public: |
518 AutoImmediateDrawIfNeeded(SkDeferredCanvas& canvas, const SkBitmap* bitmap, | 529 AutoImmediateDrawIfNeeded(SkDeferredCanvas& canvas, const SkBitmap* bitmap, |
519 const SkPaint* paint) { | 530 const SkPaint* paint) { |
520 this->init(canvas, bitmap, paint); | 531 this->init(canvas, bitmap, paint); |
521 } | 532 } |
522 | 533 |
523 AutoImmediateDrawIfNeeded(SkDeferredCanvas& canvas, const SkPaint* paint) { | 534 AutoImmediateDrawIfNeeded(SkDeferredCanvas& canvas, const SkPaint* paint) { |
524 this->init(canvas, NULL, paint); | 535 this->init(canvas, NULL, paint); |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { | 998 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { |
988 this->drawingCanvas()->setDrawFilter(filter); | 999 this->drawingCanvas()->setDrawFilter(filter); |
989 this->INHERITED::setDrawFilter(filter); | 1000 this->INHERITED::setDrawFilter(filter); |
990 this->recordedDrawCommand(); | 1001 this->recordedDrawCommand(); |
991 return filter; | 1002 return filter; |
992 } | 1003 } |
993 | 1004 |
994 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { | 1005 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { |
995 return this->drawingCanvas(); | 1006 return this->drawingCanvas(); |
996 } | 1007 } |
OLD | NEW |