aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/multipicturedraw.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-09-29 05:07:39 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-09-29 05:07:39 -0700
commitaa0c837667306babf7dc284c1b8da77127b993a1 (patch)
tree1d7cba50ebd24f7c2f03dc478c211cc3739fa0f9 /gm/multipicturedraw.cpp
parentd46b8d2bab7cfba8458432248e1568ac377429e9 (diff)
Make pictures in multipicturedraw GM fit in 0,0..W,H range
Having the picture contents not actually reside in the 0,0..W,H range wrecks havoc with the layer hoisting. The hoisting works correctly but since the picture don't fulfill their contract the results look incorrect. This CL just translates the picture's contents to the right so they are within the picture bound. R=egdaniel@google.com Author: robertphillips@google.com Review URL: https://codereview.chromium.org/594363003
Diffstat (limited to 'gm/multipicturedraw.cpp')
-rw-r--r--gm/multipicturedraw.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/gm/multipicturedraw.cpp b/gm/multipicturedraw.cpp
index 75a4c89196..e763e2f4a0 100644
--- a/gm/multipicturedraw.cpp
+++ b/gm/multipicturedraw.cpp
@@ -91,7 +91,7 @@ static SkPath make_tri_path(SkScalar originX, SkScalar originY) {
}
static const SkPicture* make_tri_picture() {
- SkPath tri = make_tri_path(0, 0);
+ SkPath tri = make_tri_path(SkScalarHalf(kTriSide), 0);
SkPaint fill;
fill.setStyle(SkPaint::kFill_Style);
@@ -122,15 +122,18 @@ static const SkPicture* make_sub_picture(const SkPicture* tri) {
canvas->scale(1.0f/2.0f, 1.0f/2.0f);
+ canvas->save();
+ canvas->translate(SkScalarHalf(kTriSide), 0);
canvas->drawPicture(tri);
+ canvas->restore();
canvas->save();
- canvas->translate(SkScalarHalf(kTriSide), 1.5f * kTriSide / kRoot3);
+ canvas->translate(SkIntToScalar(kTriSide), 1.5f * kTriSide / kRoot3);
canvas->drawPicture(tri);
canvas->restore();
canvas->save();
- canvas->translate(-SkScalarHalf(kTriSide), 1.5f * kTriSide / kRoot3);
+ canvas->translate(0, 1.5f * kTriSide / kRoot3);
canvas->drawPicture(tri);
canvas->restore();
@@ -152,7 +155,7 @@ static const SkPicture* make_sierpinski_picture() {
static const int kNumLevels = 4;
for (int i = 0; i < kNumLevels; ++i) {
canvas->save();
- canvas->translate(-i*kTriSide / 2.0f, 0);
+ canvas->translate(kPicWidth/2 - (i+1) * (kTriSide/2.0f), 0.0f);
for (int j = 0; j < i+1; ++j) {
canvas->drawPicture(pic);
canvas->translate(SkIntToScalar(kTriSide), 0);
@@ -254,11 +257,10 @@ static void invpath_clip(SkCanvas* canvas, const SkPicture* pictures[kNumPicture
// Reuse a single base (triangular) picture a _lot_ (rotated, scaled and translated).
static void sierpinski(SkCanvas* canvas, const SkPicture* pictures[kNumPictures]) {
canvas->save();
- canvas->translate(kPicWidth / 2.0f, 0.0f);
canvas->drawPicture(pictures[2]);
canvas->rotate(180.0f);
- canvas->translate(0.0f, -SkIntToScalar(kPicHeight));
+ canvas->translate(-SkIntToScalar(kPicWidth), -SkIntToScalar(kPicHeight));
canvas->drawPicture(pictures[2]);
canvas->restore();
}