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

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: more dummies so we can land 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
« no previous file with comments | « src/core/SkBBoxRecord.cpp ('k') | src/core/SkCanvasPriv.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkCanvas.cpp
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index cf7050fbeb85da1aadc037b87098f2bab37fa14b..c6b57396e0dcf08a4e81d5160c0aa019b027a4fb 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -7,6 +7,7 @@
#include "SkCanvas.h"
+#include "SkCanvasPriv.h"
#include "SkBitmapDevice.h"
#include "SkDeviceImageFilterProxy.h"
#include "SkDraw.h"
@@ -2397,22 +2398,32 @@ 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()) {
+ matrix = NULL;
+ }
+ this->onDrawPicture(picture, matrix, paint);
+ }
+}
+void SkCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix,
+ const SkPaint* paint) {
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, picture, matrix, paint)) {
return; // the device has rendered the entire picture
}
}
+ SkAutoCanvasMatrixPaint acmp(this, matrix, paint, picture->width(), picture->height());
+
picture->draw(this);
}
@@ -2511,3 +2522,29 @@ SkCanvas* SkCanvas::NewRasterDirect(const SkImageInfo& info, void* pixels, size_
}
return SkNEW_ARGS(SkCanvas, (bitmap));
}
+
+///////////////////////////////////////////////////////////////////////////////
+
+SkAutoCanvasMatrixPaint::SkAutoCanvasMatrixPaint(SkCanvas* canvas, const SkMatrix* matrix,
+ const SkPaint* paint, int width, int height)
+ : fCanvas(canvas)
+ , fSaveCount(canvas->getSaveCount())
+{
+ if (NULL != paint) {
+ SkRect bounds = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
+ if (matrix) {
+ matrix->mapRect(&bounds);
+ }
+ canvas->saveLayer(&bounds, paint);
+ } else if (NULL != matrix) {
+ canvas->save();
+ }
+
+ if (NULL != matrix) {
+ canvas->concat(*matrix);
+ }
+}
+
+SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
+ fCanvas->restoreToCount(fSaveCount);
+}
« no previous file with comments | « src/core/SkBBoxRecord.cpp ('k') | src/core/SkCanvasPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698