| 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 |
|
| 15 |
SkSVGClipPath::SkSVGClipPath() : INHERITED(SkSVGTag::kClipPath) {} |
| 16 |
|
| 17 |
bool 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 |
|
| 23 |
SkPath 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 |
return clip.makeTransform(m); |
| 30 |
} |