Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Unified Diff: src/core/SkCanvas.cpp

Issue 448793004: add drawPicture variant that takes a matrix and paint (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: pass paint to transformBounds in bbox Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/core/SkCanvas.cpp
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 757e7110196ce87f68f624450ed07f9402c19f3d..e51c1cd6f4fabb3f0c91a50e609b8eb2b8c21831 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -2397,23 +2397,48 @@ void SkCanvas::EXPERIMENTAL_optimize(const SkPicture* picture) {
void SkCanvas::drawPicture(const SkPicture* picture) {
if (NULL != picture) {
- this->onDrawPicture(picture);
+ this->onDrawPicture(picture, NULL, NULL);
}
}
-void SkCanvas::onDrawPicture(const SkPicture* picture) {
- SkASSERT(NULL != picture);
+void SkCanvas::drawPicture(const SkPicture* picture, const SkMatrix* matrix, const SkPaint* paint) {
+ if (NULL != picture) {
+ if (matrix && matrix->isIdentity()) {
bsalomon 2014/08/08 13:49:38 What is this saving? Don't most of our matrix meth
reed1 2014/08/08 13:57:29 save()/restore()
bsalomon 2014/08/08 13:59:42 Ah, that makes sense!
+ matrix = NULL;
+ }
+ this->onDrawPicture(picture, matrix, paint);
+ }
+}
+
+void SkCanvas::onDrawPicture(const SkPicture* pic, const SkMatrix* matrix, const SkPaint* paint) {
+ SkASSERT(NULL != pic);
robertphillips 2014/08/08 14:59:53 I think the save/saveLayer needs to be moved to af
+
robertphillips 2014/08/08 14:59:53 Move bounds computation into "if (paint) {" block
+ SkRect bounds = SkRect::MakeWH(SkIntToScalar(pic->width()), SkIntToScalar(pic->height()));
+ if (matrix) {
+ matrix->mapRect(&bounds);
+ }
+
+ SkAutoCanvasRestore acr(this, false);
+
+ if (paint) {
+ this->SkCanvas::saveLayer(&bounds, paint);
+ } else if (matrix) {
+ this->SkCanvas::save();
+ }
+
+ if (matrix) {
+ this->SkCanvas::concat(*matrix);
+ }
SkBaseDevice* device = this->getTopDevice();
if (NULL != device) {
// Canvas has to first give the device the opportunity to render
// the picture itself.
robertphillips 2014/08/08 15:01:18 Can we add matrix & paint to this too?
- if (device->EXPERIMENTAL_drawPicture(this, picture)) {
+ if (device->EXPERIMENTAL_drawPicture(this, pic)) {
return; // the device has rendered the entire picture
}
}
-
- picture->draw(this);
+ pic->draw(this);
}
///////////////////////////////////////////////////////////////////////////////

Powered by Google App Engine
This is Rietveld 408576698