| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 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 | */ |
| reed@android.com | f76bacf | 2009-05-13 14:00:33 +0000 | [diff] [blame] | 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 | |
| 19 | SkPaint& paint() { return fPaint; } |
| 20 | const SkPaint& paint() const { return fPaint; } |
| 21 | |
| reed@android.com | f76bacf | 2009-05-13 14:00:33 +0000 | [diff] [blame] | 22 | protected: |
| 23 | SkPaintShape(SkFlattenableReadBuffer& buffer); |
| djsollen@google.com | 5492424 | 2012-03-29 15:18:04 +0000 | [diff] [blame] | 24 | virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; |
| reed@android.com | f76bacf | 2009-05-13 14:00:33 +0000 | [diff] [blame] | 25 | |
| 26 | private: |
| 27 | SkPaint fPaint; |
| 28 | |
| 29 | typedef SkShape INHERITED; |
| 30 | }; |
| 31 | |
| 32 | class SkRectShape : public SkPaintShape { |
| 33 | public: |
| 34 | SkRectShape(); |
| 35 | |
| 36 | void setRect(const SkRect&); |
| 37 | void setOval(const SkRect&); |
| 38 | void setCircle(SkScalar x, SkScalar y, SkScalar radius); |
| 39 | void setRRect(const SkRect&, SkScalar rx, SkScalar ry); |
| 40 | |
| djsollen@google.com | ba28d03 | 2012-03-26 17:57:35 +0000 | [diff] [blame] | 41 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRectShape) |
| reed@android.com | 0ad336f | 2009-06-29 16:02:20 +0000 | [diff] [blame] | 42 | |
| reed@android.com | f76bacf | 2009-05-13 14:00:33 +0000 | [diff] [blame] | 43 | protected: |
| 44 | SkRectShape(SkFlattenableReadBuffer&); |
| djsollen@google.com | 5492424 | 2012-03-29 15:18:04 +0000 | [diff] [blame] | 45 | virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; |
| reed@android.com | f76bacf | 2009-05-13 14:00:33 +0000 | [diff] [blame] | 46 | |
| 47 | // overrides |
| 48 | virtual void onDraw(SkCanvas*); |
| 49 | |
| 50 | private: |
| 51 | SkRect fBounds; |
| 52 | SkSize fRadii; |
| 53 | |
| reed@android.com | f76bacf | 2009-05-13 14:00:33 +0000 | [diff] [blame] | 54 | typedef SkPaintShape INHERITED; |
| 55 | }; |
| 56 | |
| 57 | #endif |