reed@android.com | f76bacf | 2009-05-13 14:00:33 +0000 | [diff] [blame^] | 1 | #ifndef SkShape_DEFINED |
| 2 | #define SkShape_DEFINED |
| 3 | |
| 4 | #include "SkFlattenable.h" |
| 5 | #include "SkMatrix.h" |
| 6 | |
| 7 | class SkCanvas; |
| 8 | class SkWStream; |
| 9 | |
| 10 | class SkShape : public SkFlattenable { |
| 11 | public: |
| 12 | SkShape() : fMatrix(NULL) {} |
| 13 | virtual ~SkShape(); |
| 14 | |
| 15 | void getMatrix(SkMatrix*) const; |
| 16 | void setMatrix(const SkMatrix&); |
| 17 | void resetMatrix(); |
| 18 | |
| 19 | void draw(SkCanvas*); |
| 20 | |
| 21 | /** Draw the shape translated by (dx,dy), which is applied before the |
| 22 | shape's matrix (if any). |
| 23 | */ |
| 24 | void drawXY(SkCanvas*, SkScalar dx, SkScalar dy); |
| 25 | |
| 26 | /** Draw the shape with the specified matrix, applied before the shape's |
| 27 | matrix (if any). |
| 28 | */ |
| 29 | void drawMatrix(SkCanvas*, const SkMatrix&); |
| 30 | |
| 31 | // overrides |
| 32 | virtual void flatten(SkFlattenableWriteBuffer&); |
| 33 | |
| 34 | protected: |
| 35 | virtual void onDraw(SkCanvas*) = 0; |
| 36 | |
| 37 | SkShape(SkFlattenableReadBuffer&); |
| 38 | |
| 39 | private: |
| 40 | SkMatrix* fMatrix; |
| 41 | |
| 42 | static SkFlattenable* CreateProc(SkFlattenableReadBuffer&); |
| 43 | |
| 44 | typedef SkFlattenable INHERITED; |
| 45 | }; |
| 46 | |
| 47 | #endif |