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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 return immediateDevice()->accessBitmap(false); | 468 return immediateDevice()->accessBitmap(false); |
469 } | 469 } |
470 | 470 |
471 SkDevice* DeferredDevice::onCreateCompatibleDevice( | 471 SkDevice* DeferredDevice::onCreateCompatibleDevice( |
472 SkBitmap::Config config, int width, int height, bool isOpaque, | 472 SkBitmap::Config config, int width, int height, bool isOpaque, |
473 Usage usage) { | 473 Usage usage) { |
474 | 474 |
475 // Save layer usage not supported, and not required by SkDeferredCanvas. | 475 // Save layer usage not supported, and not required by SkDeferredCanvas. |
476 SkASSERT(usage != kSaveLayer_Usage); | 476 SkASSERT(usage != kSaveLayer_Usage); |
477 // Create a compatible non-deferred device. | 477 // Create a compatible non-deferred device. |
478 SkAutoTUnref<SkDevice> compatibleDevice | 478 // We do not create a deferred device because we know the new device |
479 (immediateDevice()->createCompatibleDevice(config, width, height, | 479 // will not be used with a deferred canvas (there is no API for that). |
480 isOpaque)); | 480 // And connecting a DeferredDevice to non-deferred canvas can result |
481 DeferredDevice* device = SkNEW_ARGS(DeferredDevice, (compatibleDevice)); | 481 // in unpredictable behavior. |
482 device->setNotificationClient(fNotificationClient); | 482 return immediateDevice()->createCompatibleDevice(config, width, height, isOp
aque); |
483 return device; | |
484 } | 483 } |
485 | 484 |
486 bool DeferredDevice::onReadPixels( | 485 bool DeferredDevice::onReadPixels( |
487 const SkBitmap& bitmap, int x, int y, SkCanvas::Config8888 config8888) { | 486 const SkBitmap& bitmap, int x, int y, SkCanvas::Config8888 config8888) { |
488 this->flushPendingCommands(kNormal_PlaybackMode); | 487 this->flushPendingCommands(kNormal_PlaybackMode); |
489 return fImmediateCanvas->readPixels(const_cast<SkBitmap*>(&bitmap), | 488 return fImmediateCanvas->readPixels(const_cast<SkBitmap*>(&bitmap), |
490 x, y, config8888); | 489 x, y, config8888); |
491 } | 490 } |
492 | 491 |
493 class AutoImmediateDrawIfNeeded { | 492 class AutoImmediateDrawIfNeeded { |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { | 968 SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) { |
970 this->drawingCanvas()->setDrawFilter(filter); | 969 this->drawingCanvas()->setDrawFilter(filter); |
971 this->INHERITED::setDrawFilter(filter); | 970 this->INHERITED::setDrawFilter(filter); |
972 this->recordedDrawCommand(); | 971 this->recordedDrawCommand(); |
973 return filter; | 972 return filter; |
974 } | 973 } |
975 | 974 |
976 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { | 975 SkCanvas* SkDeferredCanvas::canvasForDrawIter() { |
977 return this->drawingCanvas(); | 976 return this->drawingCanvas(); |
978 } | 977 } |
OLD | NEW |