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

Unified Diff: gm/drawable.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
« no previous file with comments | « no previous file | include/core/SkCanvas.h » ('j') | src/core/SkRecords.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/drawable.cpp
diff --git a/gm/drawable.cpp b/gm/drawable.cpp
index 375ce73cbe6dc6fe9ca98fa377067c41b6fdbec0..3847ba5a3228ee33f11df29d83524a111b02964e 100644
--- a/gm/drawable.cpp
+++ b/gm/drawable.cpp
@@ -10,9 +10,7 @@
#include "SkDrawable.h"
struct MyDrawable : public SkDrawable {
- SkRect onGetBounds() override {
- return SkRect::MakeWH(640, 480);
- }
+ SkRect onGetBounds() override { return SkRect::MakeWH(50, 100); }
void onDraw(SkCanvas* canvas) override {
SkPath path;
@@ -29,7 +27,20 @@ struct MyDrawable : public SkDrawable {
}
};
-DEF_SIMPLE_GM(Drawables, canvas, 640, 480) {
- SkAutoTUnref<SkDrawable> d(new MyDrawable);
- canvas->drawDrawable(d);
+/*
+ * Test calling drawables w/ translate and matrices
+ */
+DEF_SIMPLE_GM(drawable, canvas, 180, 275) {
+ SkAutoTUnref<SkDrawable> drawable(new MyDrawable);
+
+ canvas->translate(10, 10);
+ canvas->drawDrawable(drawable);
+ canvas->drawDrawable(drawable, 0, 150);
+
+ SkMatrix m = SkMatrix::MakeScale(1.5f, 0.8f);
+ m.postTranslate(70, 0);
+ canvas->drawDrawable(drawable, &m);
+
+ m.postTranslate(0, 150);
+ canvas->drawDrawable(drawable, &m);
}
« no previous file with comments | « no previous file | include/core/SkCanvas.h » ('j') | src/core/SkRecords.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698