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()) { |
mtklein
2014/08/07 21:25:20
Sort of weird? Can't we just not do this?
reed1
2014/08/08 13:57:29
Possibly, though null saves us having to do a save
|
+ matrix = NULL; |
+ } |
+ this->onDrawPicture(picture, matrix, paint); |
+ } |
+} |
+ |
+void SkCanvas::onDrawPicture(const SkPicture* pic, const SkMatrix* matrix, const SkPaint* paint) { |
+ SkASSERT(NULL != pic); |
+ |
+ 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. |
- 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); |
} |
/////////////////////////////////////////////////////////////////////////////// |