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
15class SkPaintShape : public SkShape {
16public:
17    SkPaintShape();
18
19    SkPaint& paint() { return fPaint; }
20    const SkPaint& paint() const { return fPaint; }
21
22    // overrides
23    virtual void flatten(SkFlattenableWriteBuffer&);
24
25protected:
26    SkPaintShape(SkFlattenableReadBuffer& buffer);
27
28private:
29    SkPaint fPaint;
30
31    typedef SkShape INHERITED;
32};
33
34class SkRectShape : public SkPaintShape {
35public:
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
52protected:
53    SkRectShape(SkFlattenableReadBuffer&);
54
55    // overrides
56    virtual void onDraw(SkCanvas*);
57
58private:
59    SkRect  fBounds;
60    SkSize  fRadii;
61
62    typedef SkPaintShape INHERITED;
63};
64
65#endif
66