SkMatrix& m = *this;
m = matrix;
}
+
+ SkMatrix& operator=(const SkMatrix& matrix) {
+ SkMatrix& m = *this;
+ m = matrix;
+ return m;
+ }
};
class SkGroupShape : public SkShape {
owner count of the index'd shape. If index is out of range, returns NULL
*/
SkShape* getShape(int index, SkMatrixRef** = NULL) const;
+
+ /** Helper function to return the matrixref of the specified shape.
+ */
+ SkMatrixRef* getShapeMatrixRef(int index) const {
+ SkMatrixRef* mr = NULL;
+ (void)this->getShape(index, &mr);
+ return mr;
+ }
/** Ref the specified shape, and insert it into the child list at the
specified index. If index == countShapes(), then the shape will be
class ShapesView : public SkView {
SkGroupShape fGroup;
+ SkMatrixRef* fMatrixRefs[4];
public:
ShapesView() {
SkMatrix m;
fGroup.appendShape(make_shape1(), m)->unref();
m.postTranslate(0, SkIntToScalar(120));
fGroup.appendShape(make_shape2(), m)->unref();
+
+ for (size_t i = 0; i < SK_ARRAY_COUNT(fMatrixRefs); i++) {
+ SkSafeRef(fMatrixRefs[i] = fGroup.getShapeMatrixRef(i));
+ }
+
+ fAngle = 0;
+ }
+
+ virtual ~ShapesView() {
+ for (size_t i = 0; i < SK_ARRAY_COUNT(fMatrixRefs); i++) {
+ SkSafeUnref(fMatrixRefs[i]);
+ }
}
protected:
canvas->drawColor(0xFFDDDDDD);
}
+ int fAngle;
+
virtual void onDraw(SkCanvas* canvas) {
this->drawBG(canvas);
+ SkMatrix saveM = *fMatrixRefs[3];
+ fAngle = (fAngle + 5) % 360;
+ SkScalar c = SkIntToScalar(50);
+ fMatrixRefs[3]->preRotate(SkIntToScalar(fAngle), c, c);
+
SkMatrix matrix;
#if 1
SkGroupShape gs;
gs.appendShape(&fGroup);
- matrix.setTranslate(0, SkIntToScalar(240));
+ matrix.setScale(-SK_Scalar1, SK_Scalar1);
+ matrix.postTranslate(SkIntToScalar(220), SkIntToScalar(240));
gs.appendShape(&fGroup, matrix);
matrix.setTranslate(SkIntToScalar(240), 0);
matrix.preScale(SK_Scalar1*2, SK_Scalar1*2);
fGroup.drawXY(canvas, 0, SkIntToScalar(240));
fGroup.drawMatrix(canvas, matrix);
#endif
- }
+
+ *fMatrixRefs[3] = saveM;
+ this->inval(NULL);
+}
private:
typedef SkView INHERITED;