Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 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 SkSVGPattern_DEFINED |
| 9 | #define SkSVGPattern_DEFINED |
| 10 | |
| 11 | #include "modules/svg/include/SkSVGHiddenContainer.h" |
| 12 | #include "modules/svg/include/SkSVGTypes.h" |
| 13 | |
| 14 | class SkSVGRenderContext; |
| 15 | |
| 16 | class SkSVGPattern final : public SkSVGHiddenContainer { |
| 17 | public: |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 18 | static sk_sp<SkSVGPattern> Make() { |
| 19 | return sk_sp<SkSVGPattern>(new SkSVGPattern()); |
| 20 | } |
| 21 | |
Tyler Denniston | e71f547 | 2021-01-27 13:30:59 -0500 | [diff] [blame] | 22 | SVG_ATTR(Href, SkSVGIRI, SkSVGIRI()) |
Tyler Denniston | 627c6d2 | 2021-02-08 13:30:45 -0500 | [diff] [blame] | 23 | SVG_OPTIONAL_ATTR(X , SkSVGLength) |
| 24 | SVG_OPTIONAL_ATTR(Y , SkSVGLength) |
| 25 | SVG_OPTIONAL_ATTR(Width , SkSVGLength) |
| 26 | SVG_OPTIONAL_ATTR(Height , SkSVGLength) |
| 27 | SVG_OPTIONAL_ATTR(PatternTransform, SkSVGTransformType) |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 28 | |
| 29 | protected: |
| 30 | SkSVGPattern(); |
| 31 | |
Tyler Denniston | e71f547 | 2021-01-27 13:30:59 -0500 | [diff] [blame] | 32 | bool parseAndSetAttribute(const char*, const char*) override; |
| 33 | |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 34 | bool onAsPaint(const SkSVGRenderContext&, SkPaint*) const override; |
| 35 | |
| 36 | private: |
| 37 | struct PatternAttributes { |
| 38 | SkTLazy<SkSVGLength> fX, |
| 39 | fY, |
| 40 | fWidth, |
| 41 | fHeight; |
| 42 | SkTLazy<SkSVGTransformType> fPatternTransform; |
Tyler Denniston | 627c6d2 | 2021-02-08 13:30:45 -0500 | [diff] [blame] | 43 | }; |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 44 | |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 45 | const SkSVGPattern* resolveHref(const SkSVGRenderContext&, PatternAttributes*) const; |
| 46 | const SkSVGPattern* hrefTarget(const SkSVGRenderContext&) const; |
| 47 | |
| 48 | // TODO: |
| 49 | // - patternUnits |
| 50 | // - patternContentUnits |
| 51 | |
| 52 | using INHERITED = SkSVGHiddenContainer; |
| 53 | }; |
| 54 | |
| 55 | #endif // SkSVGPattern_DEFINED |