shapes checkpoint: move matrix into groupshape and out of shape
git-svn-id: http://skia.googlecode.com/svn/trunk@178 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/samplecode/SampleShapes.cpp b/samplecode/SampleShapes.cpp
index 131ba9e..77283fe 100644
--- a/samplecode/SampleShapes.cpp
+++ b/samplecode/SampleShapes.cpp
@@ -14,33 +14,26 @@
return rect;
}
-static SkShape* make_shape0(const SkMatrix* matrix = NULL) {
+static SkShape* make_shape0(bool red) {
SkRectShape* s = new SkRectShape;
s->setRect(make_rect(10, 10, 90, 90));
- if (matrix) {
- s->setMatrix(*matrix);
+ if (red) {
s->paint().setColor(SK_ColorRED);
}
return s;
}
-static SkShape* make_shape1(const SkMatrix* matrix = NULL) {
+static SkShape* make_shape1() {
SkRectShape* s = new SkRectShape;
s->setOval(make_rect(10, 10, 90, 90));
- if (matrix) {
- s->setMatrix(*matrix);
- }
s->paint().setColor(SK_ColorBLUE);
return s;
}
-static SkShape* make_shape2(const SkMatrix* matrix = NULL) {
+static SkShape* make_shape2() {
SkRectShape* s = new SkRectShape;
s->setRRect(make_rect(10, 10, 90, 90),
SkIntToScalar(20), SkIntToScalar(20));
- if (matrix) {
- s->setMatrix(*matrix);
- }
s->paint().setColor(SK_ColorGREEN);
return s;
}
@@ -52,15 +45,15 @@
public:
ShapesView() {
SkMatrix m;
- fGroup.appendShape(make_shape0())->unref();
+ fGroup.appendShape(make_shape0(false))->unref();
m.setRotate(SkIntToScalar(30), SkIntToScalar(50), SkIntToScalar(50));
m.postTranslate(0, SkIntToScalar(120));
- fGroup.appendShape(make_shape0(&m))->unref();
+ fGroup.appendShape(make_shape0(true), m)->unref();
m.setTranslate(SkIntToScalar(120), 0);
- fGroup.appendShape(make_shape1(&m))->unref();
+ fGroup.appendShape(make_shape1(), m)->unref();
m.postTranslate(0, SkIntToScalar(120));
- fGroup.appendShape(make_shape2(&m))->unref();
+ fGroup.appendShape(make_shape2(), m)->unref();
}
protected:
@@ -81,12 +74,20 @@
this->drawBG(canvas);
SkMatrix matrix;
+#if 1
+ SkGroupShape gs;
+ gs.appendShape(&fGroup);
+ matrix.setTranslate(0, SkIntToScalar(240));
+ gs.appendShape(&fGroup, matrix);
matrix.setTranslate(SkIntToScalar(240), 0);
matrix.preScale(SK_Scalar1*2, SK_Scalar1*2);
-
+ gs.appendShape(&fGroup, matrix);
+ canvas->drawShape(&gs);
+#else
fGroup.draw(canvas);
fGroup.drawXY(canvas, 0, SkIntToScalar(240));
fGroup.drawMatrix(canvas, matrix);
+#endif
}
private: