fmalita | bffc256 | 2016-08-03 10:21:11 -0700 | [diff] [blame] | 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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "experimental/svg/model/SkSVGShape.h" |
| 12 | #include "experimental/svg/model/SkSVGTypes.h" |
fmalita | bffc256 | 2016-08-03 10:21:11 -0700 | [diff] [blame] | 13 | |
Florin Malita | ce8840e | 2016-12-08 09:26:47 -0500 | [diff] [blame] | 14 | class SkRRect; |
| 15 | |
fmalita | bffc256 | 2016-08-03 10:21:11 -0700 | [diff] [blame] | 16 | class SkSVGRect final : public SkSVGShape { |
| 17 | public: |
Brian Salomon | d3b6597 | 2017-03-22 12:05:03 -0400 | [diff] [blame] | 18 | ~SkSVGRect() override = default; |
fmalita | bffc256 | 2016-08-03 10:21:11 -0700 | [diff] [blame] | 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&); |
fmalita | 286a865 | 2016-08-10 17:11:29 -0700 | [diff] [blame] | 25 | void setRx(const SkSVGLength&); |
| 26 | void setRy(const SkSVGLength&); |
fmalita | bffc256 | 2016-08-03 10:21:11 -0700 | [diff] [blame] | 27 | |
| 28 | protected: |
| 29 | void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override; |
| 30 | |
Florin Malita | e932d4b | 2016-12-01 13:35:11 -0500 | [diff] [blame] | 31 | void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&, |
| 32 | SkPath::FillType) const override; |
fmalita | bffc256 | 2016-08-03 10:21:11 -0700 | [diff] [blame] | 33 | |
Florin Malita | ce8840e | 2016-12-08 09:26:47 -0500 | [diff] [blame] | 34 | SkPath onAsPath(const SkSVGRenderContext&) const override; |
| 35 | |
fmalita | bffc256 | 2016-08-03 10:21:11 -0700 | [diff] [blame] | 36 | private: |
| 37 | SkSVGRect(); |
| 38 | |
Florin Malita | ce8840e | 2016-12-08 09:26:47 -0500 | [diff] [blame] | 39 | SkRRect resolve(const SkSVGLengthContext&) const; |
| 40 | |
fmalita | bffc256 | 2016-08-03 10:21:11 -0700 | [diff] [blame] | 41 | SkSVGLength fX = SkSVGLength(0); |
| 42 | SkSVGLength fY = SkSVGLength(0); |
| 43 | SkSVGLength fWidth = SkSVGLength(0); |
| 44 | SkSVGLength fHeight = SkSVGLength(0); |
| 45 | |
fmalita | 286a865 | 2016-08-10 17:11:29 -0700 | [diff] [blame] | 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 | |
fmalita | bffc256 | 2016-08-03 10:21:11 -0700 | [diff] [blame] | 51 | typedef SkSVGShape INHERITED; |
| 52 | }; |
| 53 | |
| 54 | #endif // SkSVGRect_DEFINED |