1 /* 2 * Copyright 2021 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 SkSVGMask_DEFINED 9 #define SkSVGMask_DEFINED 10 11 #include "modules/svg/include/SkSVGHiddenContainer.h" 12 #include "modules/svg/include/SkSVGTypes.h" 13 14 class SkSVGMask final : public SkSVGHiddenContainer { 15 public: Make()16 static sk_sp<SkSVGMask> Make() { 17 return sk_sp<SkSVGMask>(new SkSVGMask()); 18 } 19 20 SVG_ATTR(X , SkSVGLength, SkSVGLength(-10, SkSVGLength::Unit::kPercentage)) 21 SVG_ATTR(Y , SkSVGLength, SkSVGLength(-10, SkSVGLength::Unit::kPercentage)) 22 SVG_ATTR(Width , SkSVGLength, SkSVGLength(120, SkSVGLength::Unit::kPercentage)) 23 SVG_ATTR(Height, SkSVGLength, SkSVGLength(120, SkSVGLength::Unit::kPercentage)) 24 25 SVG_ATTR(MaskUnits, SkSVGObjectBoundingBoxUnits, 26 SkSVGObjectBoundingBoxUnits(SkSVGObjectBoundingBoxUnits::Type::kObjectBoundingBox)) 27 SVG_ATTR(MaskContentUnits, SkSVGObjectBoundingBoxUnits, 28 SkSVGObjectBoundingBoxUnits(SkSVGObjectBoundingBoxUnits::Type::kUserSpaceOnUse)) 29 30 private: 31 friend class SkSVGRenderContext; 32 SkSVGMask()33 SkSVGMask() : INHERITED(SkSVGTag::kMask) {} 34 35 bool parseAndSetAttribute(const char*, const char*) override; 36 37 SkRect bounds(const SkSVGRenderContext&) const; 38 void renderMask(const SkSVGRenderContext&) const; 39 40 using INHERITED = SkSVGHiddenContainer; 41 }; 42 43 #endif // SkSVGMask_DEFINED 44