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 #include "modules/svg/include/SkSVGClipPath.h" 9 10 #include "include/core/SkM44.h" 11 #include "include/core/SkMatrix.h" 12 #include "modules/svg/include/SkSVGAttributeParser.h" 13 #include "modules/svg/include/SkSVGRenderContext.h" 14 SkSVGClipPath()15SkSVGClipPath::SkSVGClipPath() : INHERITED(SkSVGTag::kClipPath) {} 16 parseAndSetAttribute(const char * n,const char * v)17bool SkSVGClipPath::parseAndSetAttribute(const char* n, const char* v) { 18 return INHERITED::parseAndSetAttribute(n, v) || 19 this->setClipPathUnits( 20 SkSVGAttributeParser::parse<SkSVGObjectBoundingBoxUnits>("clipPathUnits", n, v)); 21 } 22 resolveClip(const SkSVGRenderContext & ctx) const23SkPath SkSVGClipPath::resolveClip(const SkSVGRenderContext& ctx) const { 24 auto clip = this->asPath(ctx); 25 26 const auto obbt = ctx.transformForCurrentOBB(fClipPathUnits); 27 const auto m = SkMatrix::Translate(obbt.offset.x, obbt.offset.y) 28 * SkMatrix::Scale(obbt.scale.x, obbt.scale.y); 29 clip.transform(m); 30 31 return clip; 32 } 33