blob: 87992a2caecc0c1f884edfa21b87dbde390fbf78 [file] [log] [blame]
Florin Malitab3418102020-10-15 18:10:29 -04001/*
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
14class SkSVGRenderContext;
15
16class SkSVGPattern final : public SkSVGHiddenContainer {
17public:
Florin Malitab3418102020-10-15 18:10:29 -040018 static sk_sp<SkSVGPattern> Make() {
19 return sk_sp<SkSVGPattern>(new SkSVGPattern());
20 }
21
22 void setX(const SkSVGLength&);
23 void setY(const SkSVGLength&);
24 void setWidth(const SkSVGLength&);
25 void setHeight(const SkSVGLength&);
26 void setHref(const SkSVGStringType&);
27 void setPatternTransform(const SkSVGTransformType&);
28
29protected:
30 SkSVGPattern();
31
32 void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
33
34 bool onAsPaint(const SkSVGRenderContext&, SkPaint*) const override;
35
36private:
37 struct PatternAttributes {
38 SkTLazy<SkSVGLength> fX,
39 fY,
40 fWidth,
41 fHeight;
42 SkTLazy<SkSVGTransformType> fPatternTransform;
43 } fAttributes;
44
45 SkSVGStringType fHref;
46
47 const SkSVGPattern* resolveHref(const SkSVGRenderContext&, PatternAttributes*) const;
48 const SkSVGPattern* hrefTarget(const SkSVGRenderContext&) const;
49
50 // TODO:
51 // - patternUnits
52 // - patternContentUnits
53
54 using INHERITED = SkSVGHiddenContainer;
55};
56
57#endif // SkSVGPattern_DEFINED