/src/skia/modules/svg/src/SkSVGFeMerge.cpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2024 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/SkSVGFeMerge.h" |
9 | | |
10 | | #include "include/core/SkImageFilter.h" |
11 | | #include "include/effects/SkImageFilters.h" |
12 | | #include "include/private/base/SkTArray.h" |
13 | | #include "modules/svg/include/SkSVGFilterContext.h" |
14 | | #include "modules/svg/include/SkSVGNode.h" |
15 | | |
16 | 2 | bool SkSVGFeMergeNode::parseAndSetAttribute(const char* name, const char* value) { |
17 | 2 | return INHERITED::parseAndSetAttribute(name, value) || |
18 | 2 | this->setIn(SkSVGAttributeParser::parse<SkSVGFeInputType>("in", name, value)); |
19 | 2 | } |
20 | | |
21 | | sk_sp<SkImageFilter> SkSVGFeMerge::onMakeImageFilter(const SkSVGRenderContext& ctx, |
22 | 11 | const SkSVGFilterContext& fctx) const { |
23 | 11 | const SkSVGColorspace colorspace = this->resolveColorspace(ctx, fctx); |
24 | | |
25 | 11 | skia_private::STArray<8, sk_sp<SkImageFilter>> merge_node_filters; |
26 | 11 | merge_node_filters.reserve(fChildren.size()); |
27 | | |
28 | 22 | this->forEachChild<SkSVGFeMergeNode>([&](const SkSVGFeMergeNode* child) { |
29 | 22 | merge_node_filters.push_back(fctx.resolveInput(ctx, child->getIn(), colorspace)); |
30 | 22 | }); |
31 | | |
32 | 11 | return SkImageFilters::Merge(merge_node_filters.data(), |
33 | 11 | merge_node_filters.size(), |
34 | 11 | this->resolveFilterSubregion(ctx, fctx)); |
35 | 11 | } |
36 | | |
37 | 22 | std::vector<SkSVGFeInputType> SkSVGFeMerge::getInputs() const { |
38 | 22 | std::vector<SkSVGFeInputType> inputs; |
39 | 22 | inputs.reserve(fChildren.size()); |
40 | | |
41 | 44 | this->forEachChild<SkSVGFeMergeNode>([&](const SkSVGFeMergeNode* child) { |
42 | 44 | inputs.push_back(child->getIn()); |
43 | 44 | }); |
44 | | |
45 | 22 | return inputs; |
46 | 22 | } |