Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [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 | |
| 11 | #include "modules/svg/include/SkSVGShape.h" |
| 12 | #include "modules/svg/include/SkSVGTypes.h" |
| 13 | |
| 14 | class SkRRect; |
| 15 | |
| 16 | class SkSVGRect final : public SkSVGShape { |
| 17 | public: |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 18 | static sk_sp<SkSVGRect> Make() { return sk_sp<SkSVGRect>(new SkSVGRect()); } |
| 19 | |
Tyler Denniston | 52d9475 | 2021-02-05 10:23:34 -0500 | [diff] [blame^] | 20 | SVG_ATTR(X , SkSVGLength, SkSVGLength(0)) |
| 21 | SVG_ATTR(Y , SkSVGLength, SkSVGLength(0)) |
| 22 | SVG_ATTR(Width , SkSVGLength, SkSVGLength(0)) |
| 23 | SVG_ATTR(Height, SkSVGLength, SkSVGLength(0)) |
| 24 | SVG_ATTR(Rx , SkSVGLength, SkSVGLength(0)) |
| 25 | SVG_ATTR(Ry , SkSVGLength, SkSVGLength(0)) |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 26 | |
| 27 | protected: |
Tyler Denniston | 52d9475 | 2021-02-05 10:23:34 -0500 | [diff] [blame^] | 28 | bool parseAndSetAttribute(const char*, const char*) override; |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 29 | |
| 30 | void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&, |
| 31 | SkPathFillType) const override; |
| 32 | |
| 33 | SkPath onAsPath(const SkSVGRenderContext&) const override; |
| 34 | |
Tyler Denniston | f548a02 | 2020-10-27 15:02:02 -0400 | [diff] [blame] | 35 | SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override; |
| 36 | |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 37 | private: |
| 38 | SkSVGRect(); |
| 39 | |
| 40 | SkRRect resolve(const SkSVGLengthContext&) const; |
| 41 | |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 42 | using INHERITED = SkSVGShape; |
| 43 | }; |
| 44 | |
| 45 | #endif // SkSVGRect_DEFINED |