blob: a0c07a19577d454db7e2e09ad43d0c570b0e0f72 [file] [log] [blame]
fmalitabffc2562016-08-03 10:21:11 -07001/*
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
Florin Malitace8840e2016-12-08 09:26:47 -050014class SkRRect;
15
fmalitabffc2562016-08-03 10:21:11 -070016class SkSVGRect final : public SkSVGShape {
17public:
18 virtual ~SkSVGRect() = default;
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&);
fmalita286a8652016-08-10 17:11:29 -070025 void setRx(const SkSVGLength&);
26 void setRy(const SkSVGLength&);
fmalitabffc2562016-08-03 10:21:11 -070027
28protected:
29 void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
30
Florin Malitae932d4b2016-12-01 13:35:11 -050031 void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
32 SkPath::FillType) const override;
fmalitabffc2562016-08-03 10:21:11 -070033
Florin Malitace8840e2016-12-08 09:26:47 -050034 SkPath onAsPath(const SkSVGRenderContext&) const override;
35
fmalitabffc2562016-08-03 10:21:11 -070036private:
37 SkSVGRect();
38
Florin Malitace8840e2016-12-08 09:26:47 -050039 SkRRect resolve(const SkSVGLengthContext&) const;
40
fmalitabffc2562016-08-03 10:21:11 -070041 SkSVGLength fX = SkSVGLength(0);
42 SkSVGLength fY = SkSVGLength(0);
43 SkSVGLength fWidth = SkSVGLength(0);
44 SkSVGLength fHeight = SkSVGLength(0);
45
fmalita286a8652016-08-10 17:11:29 -070046 // The x radius for rounded rects.
47 SkSVGLength fRx = SkSVGLength(0);
48 // The y radius for rounded rects.
49 SkSVGLength fRy = SkSVGLength(0);
50
fmalitabffc2562016-08-03 10:21:11 -070051 typedef SkSVGShape INHERITED;
52};
53
54#endif // SkSVGRect_DEFINED