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

Unified Diff: src/core/SkCanvas.cpp

Issue 1224783002: add matrix options to drawDrawable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: modify gm Created 5 years, 5 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 88339ff4f387c8989a145dc37bb6d48d7b84734d..09bfa4593588a3ca41880e87d87fc09f56cab10a 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -2446,14 +2446,35 @@ void SkCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
LOOPER_END
}
-void SkCanvas::drawDrawable(SkDrawable* dr) {
- if (dr && !this->quickReject(dr->getBounds())) {
- this->onDrawDrawable(dr);
+void SkCanvas::drawDrawable(SkDrawable* dr, SkScalar x, SkScalar y) {
+ if (dr) {
+ if (x || y) {
+ SkMatrix matrix = SkMatrix::MakeTrans(x, y);
+ this->onDrawDrawable(dr, &matrix);
+ } else {
+ this->onDrawDrawable(dr, NULL);
+ }
}
}
-void SkCanvas::onDrawDrawable(SkDrawable* dr) {
- dr->draw(this);
+void SkCanvas::drawDrawable(SkDrawable* dr, const SkMatrix* matrix) {
+ if (dr) {
+ if (matrix && matrix->isIdentity()) {
+ matrix = NULL;
+ }
+ this->onDrawDrawable(dr, matrix);
+ }
+}
+
+void SkCanvas::onDrawDrawable(SkDrawable* dr, const SkMatrix* matrix) {
+ SkRect bounds = dr->getBounds();
+ if (matrix) {
+ matrix->mapRect(&bounds);
+ }
+ if (this->quickReject(bounds)) {
+ return;
+ }
+ dr->draw(this, matrix);
}
void SkCanvas::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
« no previous file with comments | « include/core/SkDrawable.h ('k') | src/core/SkDrawable.cpp » ('j') | src/core/SkRecords.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698