Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSVGFilter.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2020 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
15
16bool SkSVGFilter::parseAndSetAttribute(const char* name, const char* value) {
18 this->setX(SkSVGAttributeParser::parse<SkSVGLength>("x", name, value)) ||
19 this->setY(SkSVGAttributeParser::parse<SkSVGLength>("y", name, value)) ||
20 this->setWidth(SkSVGAttributeParser::parse<SkSVGLength>("width", name, value)) ||
21 this->setHeight(SkSVGAttributeParser::parse<SkSVGLength>("height", name, value)) ||
22 this->setFilterUnits(SkSVGAttributeParser::parse<SkSVGObjectBoundingBoxUnits>(
23 "filterUnits", name, value)) ||
24 this->setPrimitiveUnits(SkSVGAttributeParser::parse<SkSVGObjectBoundingBoxUnits>(
25 "primitiveUnits", name, value));
26}
27
29
32 SkSVGFilterContext fctx(ctx.resolveOBBRect(fX, fY, fWidth, fHeight, fFilterUnits),
33 fPrimitiveUnits);
34 SkSVGRenderContext localCtx(ctx);
35 this->applyProperties(&localCtx);
37 for (const auto& child : fChildren) {
38 if (!SkSVGFe::IsFilterEffect(child)) {
39 continue;
40 }
41
42 const auto& feNode = static_cast<const SkSVGFe&>(*child);
43 const auto& feResultType = feNode.getResult();
44
45 // Propagate any inherited properties that may impact filter effect behavior (e.g.
46 // color-interpolation-filters). We call this explicitly here because the SkSVGFe
47 // nodes do not participate in the normal onRender path, which is when property
48 // propagation currently occurs.
49 SkSVGRenderContext localChildCtx(localCtx);
50 feNode.applyProperties(&localChildCtx);
51
52 const SkRect filterSubregion = feNode.resolveFilterSubregion(localChildCtx, fctx);
53 cs = feNode.resolveColorspace(localChildCtx, fctx);
54 filter = feNode.makeImageFilter(localChildCtx, fctx);
55
56 if (!feResultType.isEmpty()) {
57 fctx.registerResult(feResultType, filter, filterSubregion, cs);
58 }
59
60 // Unspecified 'in' and 'in2' inputs implicitly resolve to the previous filter's result.
61 fctx.setPreviousResult(filter, filterSubregion, cs);
62 }
63
64 // Convert to final destination colorspace
65 if (cs != SkSVGColorspace::kSRGB) {
67 }
68
69 return filter;
70}
SkSVGColorspace
Definition SkSVGTypes.h:719
static sk_sp< SkColorFilter > LinearToSRGBGamma()
static sk_sp< SkImageFilter > ColorFilter(sk_sp< SkColorFilter > cf, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
skia_private::STArray< 1, sk_sp< SkSVGNode >, true > fChildren
static bool IsFilterEffect(const sk_sp< SkSVGNode > &node)
Definition SkSVGFe.h:20
void registerResult(const SkSVGStringType &, const sk_sp< SkImageFilter > &, const SkRect &, SkSVGColorspace)
void setPreviousResult(const sk_sp< SkImageFilter > &, const SkRect &, SkSVGColorspace)
bool parseAndSetAttribute(const char *, const char *) override
sk_sp< SkImageFilter > buildFilterDAG(const SkSVGRenderContext &) const
void applyProperties(SkSVGRenderContext *) const
virtual bool parseAndSetAttribute(const char *name, const char *value)
Definition SkSVGNode.cpp:90
SkRect resolveOBBRect(const SkSVGLength &x, const SkSVGLength &y, const SkSVGLength &w, const SkSVGLength &h, SkSVGObjectBoundingBoxUnits) const
bool onPrepareToRender(SkSVGRenderContext *) const override
uint8_t value
const char * name
Definition fuchsia.cc:50