1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright 2016 Google Inc. 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci * found in the LICENSE file. 6cb93a386Sopenharmony_ci */ 7cb93a386Sopenharmony_ci 8cb93a386Sopenharmony_ci#include "modules/svg/include/SkSVGClipPath.h" 9cb93a386Sopenharmony_ci 10cb93a386Sopenharmony_ci#include "modules/svg/include/SkSVGRenderContext.h" 11cb93a386Sopenharmony_ci 12cb93a386Sopenharmony_ciSkSVGClipPath::SkSVGClipPath() : INHERITED(SkSVGTag::kClipPath) {} 13cb93a386Sopenharmony_ci 14cb93a386Sopenharmony_cibool SkSVGClipPath::parseAndSetAttribute(const char* n, const char* v) { 15cb93a386Sopenharmony_ci return INHERITED::parseAndSetAttribute(n, v) || 16cb93a386Sopenharmony_ci this->setClipPathUnits( 17cb93a386Sopenharmony_ci SkSVGAttributeParser::parse<SkSVGObjectBoundingBoxUnits>("clipPathUnits", n, v)); 18cb93a386Sopenharmony_ci} 19cb93a386Sopenharmony_ci 20cb93a386Sopenharmony_ciSkPath SkSVGClipPath::resolveClip(const SkSVGRenderContext& ctx) const { 21cb93a386Sopenharmony_ci auto clip = this->asPath(ctx); 22cb93a386Sopenharmony_ci 23cb93a386Sopenharmony_ci const auto obbt = ctx.transformForCurrentOBB(fClipPathUnits); 24cb93a386Sopenharmony_ci const auto m = SkMatrix::Translate(obbt.offset.x, obbt.offset.y) 25cb93a386Sopenharmony_ci * SkMatrix::Scale(obbt.scale.x, obbt.scale.y); 26cb93a386Sopenharmony_ci clip.transform(m); 27cb93a386Sopenharmony_ci 28cb93a386Sopenharmony_ci return clip; 29cb93a386Sopenharmony_ci} 30