1 2 /* 3 * Copyright 2011 Google Inc. 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 #ifndef SkRectShape_DEFINED 9 #define SkRectShape_DEFINED 10 11 #include "SkShape.h" 12 #include "SkPaint.h" 13 #include "SkSize.h" 14 15 class SkPaintShape : public SkShape { 16 public: 17 SkPaintShape(); 18 paint()19 SkPaint& paint() { return fPaint; } paint()20 const SkPaint& paint() const { return fPaint; } 21 22 // overrides 23 virtual void flatten(SkFlattenableWriteBuffer&); 24 25 protected: 26 SkPaintShape(SkFlattenableReadBuffer& buffer); 27 28 private: 29 SkPaint fPaint; 30 31 typedef SkShape INHERITED; 32 }; 33 34 class SkRectShape : public SkPaintShape { 35 public: 36 SkRectShape(); 37 38 void setRect(const SkRect&); 39 void setOval(const SkRect&); 40 void setCircle(SkScalar x, SkScalar y, SkScalar radius); 41 void setRRect(const SkRect&, SkScalar rx, SkScalar ry); 42 43 // overrides 44 virtual Factory getFactory(); 45 virtual void flatten(SkFlattenableWriteBuffer&); 46 47 // public for Registrar 48 static SkFlattenable* CreateProc(SkFlattenableReadBuffer&); 49 50 SK_DECLARE_FLATTENABLE_REGISTRAR() 51 52 protected: 53 SkRectShape(SkFlattenableReadBuffer&); 54 55 // overrides 56 virtual void onDraw(SkCanvas*); 57 58 private: 59 SkRect fBounds; 60 SkSize fRadii; 61 62 typedef SkPaintShape INHERITED; 63 }; 64 65 #endif 66