1 /*
2  * Copyright 2016 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkSVGRect_DEFINED
9 #define SkSVGRect_DEFINED
10 
11 #include "SkSVGShape.h"
12 #include "SkSVGTypes.h"
13 
14 class SkRRect;
15 
16 class SkSVGRect final : public SkSVGShape {
17 public:
18     ~SkSVGRect() override = default;
Make()19     static sk_sp<SkSVGRect> Make() { return sk_sp<SkSVGRect>(new SkSVGRect()); }
20 
21     void setX(const SkSVGLength&);
22     void setY(const SkSVGLength&);
23     void setWidth(const SkSVGLength&);
24     void setHeight(const SkSVGLength&);
25     void setRx(const SkSVGLength&);
26     void setRy(const SkSVGLength&);
27 
28 protected:
29     void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
30 
31     void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
32                 SkPath::FillType) const override;
33 
34     SkPath onAsPath(const SkSVGRenderContext&) const override;
35 
36 private:
37     SkSVGRect();
38 
39     SkRRect resolve(const SkSVGLengthContext&) const;
40 
41     SkSVGLength fX      = SkSVGLength(0);
42     SkSVGLength fY      = SkSVGLength(0);
43     SkSVGLength fWidth  = SkSVGLength(0);
44     SkSVGLength fHeight = SkSVGLength(0);
45 
46     // The x radius for rounded rects.
47     SkSVGLength fRx     = SkSVGLength(0);
48     // The y radius for rounded rects.
49     SkSVGLength fRy     = SkSVGLength(0);
50 
51     typedef SkSVGShape INHERITED;
52 };
53 
54 #endif // SkSVGRect_DEFINED
55