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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 161 |
162 virtual uint32_t getDeviceCapabilities() SK_OVERRIDE; | 162 virtual uint32_t getDeviceCapabilities() SK_OVERRIDE; |
163 virtual int width() const SK_OVERRIDE; | 163 virtual int width() const SK_OVERRIDE; |
164 virtual int height() const SK_OVERRIDE; | 164 virtual int height() const SK_OVERRIDE; |
165 virtual SkBitmap::Config config() const SK_OVERRIDE; | 165 virtual SkBitmap::Config config() const SK_OVERRIDE; |
166 virtual bool isOpaque() const SK_OVERRIDE; | 166 virtual bool isOpaque() const SK_OVERRIDE; |
167 virtual SkImageInfo imageInfo() const SK_OVERRIDE; | 167 virtual SkImageInfo imageInfo() const SK_OVERRIDE; |
168 | 168 |
169 virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE; | 169 virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE; |
170 | 170 |
171 virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config, | 171 virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE; |
172 int width, int height, | |
173 bool isOpaque, | |
174 Usage usage) SK_OVERRIDE; | |
175 | 172 |
176 virtual void writePixels(const SkBitmap& bitmap, int x, int y, | 173 virtual void writePixels(const SkBitmap& bitmap, int x, int y, |
177 SkCanvas::Config8888 config8888) SK_OVERRIDE; | 174 SkCanvas::Config8888 config8888) SK_OVERRIDE; |
178 | 175 |
179 virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE; | 176 virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE; |
180 | 177 |
181 protected: | 178 protected: |
182 virtual const SkBitmap& onAccessBitmap() SK_OVERRIDE; | 179 virtual const SkBitmap& onAccessBitmap() SK_OVERRIDE; |
183 virtual bool onReadPixels(const SkBitmap& bitmap, | 180 virtual bool onReadPixels(const SkBitmap& bitmap, |
184 int x, int y, | 181 int x, int y, |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 this->recordedDrawCommand(); | 505 this->recordedDrawCommand(); |
509 | 506 |
510 } | 507 } |
511 } | 508 } |
512 | 509 |
513 const SkBitmap& DeferredDevice::onAccessBitmap() { | 510 const SkBitmap& DeferredDevice::onAccessBitmap() { |
514 this->flushPendingCommands(kNormal_PlaybackMode); | 511 this->flushPendingCommands(kNormal_PlaybackMode); |
515 return immediateDevice()->accessBitmap(false); | 512 return immediateDevice()->accessBitmap(false); |
516 } | 513 } |
517 | 514 |
518 SkBaseDevice* DeferredDevice::onCreateCompatibleDevice( | 515 SkBaseDevice* DeferredDevice::onCreateDevice(const SkImageInfo& info, Usage usag
e) { |
519 SkBitmap::Config config, int width, int height, bool isOpaque, | |
520 Usage usage) { | |
521 | |
522 // Save layer usage not supported, and not required by SkDeferredCanvas. | 516 // Save layer usage not supported, and not required by SkDeferredCanvas. |
523 SkASSERT(usage != kSaveLayer_Usage); | 517 SkASSERT(usage != kSaveLayer_Usage); |
524 // Create a compatible non-deferred device. | 518 // Create a compatible non-deferred device. |
525 // We do not create a deferred device because we know the new device | 519 // We do not create a deferred device because we know the new device |
526 // will not be used with a deferred canvas (there is no API for that). | 520 // will not be used with a deferred canvas (there is no API for that). |
527 // And connecting a DeferredDevice to non-deferred canvas can result | 521 // And connecting a DeferredDevice to non-deferred canvas can result |
528 // in unpredictable behavior. | 522 // in unpredictable behavior. |
529 return immediateDevice()->createCompatibleDevice(config, width, height, isOp
aque); | 523 return immediateDevice()->createCompatibleDevice(info); |
530 } | 524 } |
531 | 525 |
532 SkSurface* DeferredDevice::newSurface(const SkImageInfo& info) { | 526 SkSurface* DeferredDevice::newSurface(const SkImageInfo& info) { |
533 return this->immediateDevice()->newSurface(info); | 527 return this->immediateDevice()->newSurface(info); |
534 } | 528 } |
535 | 529 |
536 bool DeferredDevice::onReadPixels( | 530 bool DeferredDevice::onReadPixels( |
537 const SkBitmap& bitmap, int x, int y, SkCanvas::Config8888 config8888) { | 531 const SkBitmap& bitmap, int x, int y, SkCanvas::Config8888 config8888) { |
538 this->flushPendingCommands(kNormal_PlaybackMode); | 532 this->flushPendingCommands(kNormal_PlaybackMode); |
539 return fImmediateCanvas->readPixels(const_cast<SkBitmap*>(&bitmap), | 533 return fImmediateCanvas->readPixels(const_cast<SkBitmap*>(&bitmap), |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { | 1014 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { |
1021 this->drawingCanvas()->setDrawFilter(filter); | 1015 this->drawingCanvas()->setDrawFilter(filter); |
1022 this->INHERITED::setDrawFilter(filter); | 1016 this->INHERITED::setDrawFilter(filter); |
1023 this->recordedDrawCommand(); | 1017 this->recordedDrawCommand(); |
1024 return filter; | 1018 return filter; |
1025 } | 1019 } |
1026 | 1020 |
1027 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { | 1021 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { |
1028 return this->drawingCanvas(); | 1022 return this->drawingCanvas(); |
1029 } | 1023 } |
OLD | NEW |