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