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