Coverage Report

Created: 2021-08-22 09:07

/src/skia/modules/svg/src/SkSVGClipPath.cpp
Line
Count
Source
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
12
4.00k
SkSVGClipPath::SkSVGClipPath() : INHERITED(SkSVGTag::kClipPath) {}
13
14
813
bool SkSVGClipPath::parseAndSetAttribute(const char* n, const char* v) {
15
813
    return INHERITED::parseAndSetAttribute(n, v) ||
16
453
           this->setClipPathUnits(
17
453
                SkSVGAttributeParser::parse<SkSVGObjectBoundingBoxUnits>("clipPathUnits", n, v));
18
813
}
19
20
7.79k
SkPath SkSVGClipPath::resolveClip(const SkSVGRenderContext& ctx) const {
21
7.79k
    auto clip = this->asPath(ctx);
22
23
7.79k
    const auto obbt = ctx.transformForCurrentOBB(fClipPathUnits);
24
7.79k
    const auto m = SkMatrix::Translate(obbt.offset.x, obbt.offset.y)
25
7.79k
                 * SkMatrix::Scale(obbt.scale.x, obbt.scale.y);
26
7.79k
    clip.transform(m);
27
28
7.79k
    return clip;
29
7.79k
}