| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "gm.h" | 8 #include "gm.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkDrawable.h" | 10 #include "SkDrawable.h" |
| 11 | 11 |
| 12 struct MyDrawable : public SkDrawable { | 12 struct MyDrawable : public SkDrawable { |
| 13 SkRect onGetBounds() override { | 13 SkRect onGetBounds() override { return SkRect::MakeWH(50, 100); } |
| 14 return SkRect::MakeWH(640, 480); | |
| 15 } | |
| 16 | 14 |
| 17 void onDraw(SkCanvas* canvas) override { | 15 void onDraw(SkCanvas* canvas) override { |
| 18 SkPath path; | 16 SkPath path; |
| 19 path.moveTo(10, 10); | 17 path.moveTo(10, 10); |
| 20 path.conicTo(10, 90, 50, 90, 0.9f); | 18 path.conicTo(10, 90, 50, 90, 0.9f); |
| 21 | 19 |
| 22 SkPaint paint; | 20 SkPaint paint; |
| 23 paint.setColor(SK_ColorBLUE); | 21 paint.setColor(SK_ColorBLUE); |
| 24 canvas->drawRect(path.getBounds(), paint); | 22 canvas->drawRect(path.getBounds(), paint); |
| 25 | 23 |
| 26 paint.setAntiAlias(true); | 24 paint.setAntiAlias(true); |
| 27 paint.setColor(SK_ColorWHITE); | 25 paint.setColor(SK_ColorWHITE); |
| 28 canvas->drawPath(path, paint); | 26 canvas->drawPath(path, paint); |
| 29 } | 27 } |
| 30 }; | 28 }; |
| 31 | 29 |
| 32 DEF_SIMPLE_GM(Drawables, canvas, 640, 480) { | 30 /* |
| 33 SkAutoTUnref<SkDrawable> d(new MyDrawable); | 31 * Test calling drawables w/ translate and matrices |
| 34 canvas->drawDrawable(d); | 32 */ |
| 33 DEF_SIMPLE_GM(drawable, canvas, 180, 275) { |
| 34 SkAutoTUnref<SkDrawable> drawable(new MyDrawable); |
| 35 |
| 36 canvas->translate(10, 10); |
| 37 canvas->drawDrawable(drawable); |
| 38 canvas->drawDrawable(drawable, 0, 150); |
| 39 |
| 40 SkMatrix m = SkMatrix::MakeScale(1.5f, 0.8f); |
| 41 m.postTranslate(70, 0); |
| 42 canvas->drawDrawable(drawable, &m); |
| 43 |
| 44 m.postTranslate(0, 150); |
| 45 canvas->drawDrawable(drawable, &m); |
| 35 } | 46 } |
| OLD | NEW |