Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSVGFeComposite.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
13
14bool SkSVGFeComposite::parseAndSetAttribute(const char* name, const char* value) {
16 // SkSVGFeInputType parsing defined in SkSVGFe.cpp:
17 this->setIn2(SkSVGAttributeParser::parse<SkSVGFeInputType>("in2", name, value)) ||
18 this->setK1(SkSVGAttributeParser::parse<SkSVGNumberType>("k1", name, value)) ||
19 this->setK2(SkSVGAttributeParser::parse<SkSVGNumberType>("k2", name, value)) ||
20 this->setK3(SkSVGAttributeParser::parse<SkSVGNumberType>("k3", name, value)) ||
21 this->setK4(SkSVGAttributeParser::parse<SkSVGNumberType>("k4", name, value)) ||
22 this->setOperator(
23 SkSVGAttributeParser::parse<SkSVGFeCompositeOperator>("operator", name, value));
24}
25
26SkBlendMode SkSVGFeComposite::BlendModeForOperator(SkSVGFeCompositeOperator op) {
27 switch (op) {
37 return SkBlendMode::kXor;
39 // Arithmetic is not handled with a blend
40 SkASSERT(false);
42 }
43
45}
46
48 const SkSVGFilterContext& fctx) const {
49 const SkRect cropRect = this->resolveFilterSubregion(ctx, fctx);
50 const SkSVGColorspace colorspace = this->resolveColorspace(ctx, fctx);
51 const sk_sp<SkImageFilter> background = fctx.resolveInput(ctx, fIn2, colorspace);
52 const sk_sp<SkImageFilter> foreground = fctx.resolveInput(ctx, this->getIn(), colorspace);
54 constexpr bool enforcePMColor = true;
56 fK1, fK2, fK3, fK4, enforcePMColor, background, foreground, cropRect);
57 } else {
59 BlendModeForOperator(fOperator), background, foreground, cropRect);
60 }
61}
62
64 static constexpr std::tuple<const char*, SkSVGFeCompositeOperator> gOpMap[] = {
71 };
72
73 return this->parseEnumMap(gOpMap, op) && this->parseEOSToken();
74}
#define SkUNREACHABLE
Definition SkAssert.h:135
#define SkASSERT(cond)
Definition SkAssert.h:116
SkBlendMode
Definition SkBlendMode.h:38
@ kSrcOut
r = s * (1-da)
@ kSrcOver
r = s + (1-sa)*d
@ kXor
r = s*(1-da) + d*(1-sa)
@ kSrcATop
r = s*da + d*(1-sa)
@ kSrcIn
r = s * da
SkSVGFeCompositeOperator
Definition SkSVGTypes.h:679
SkSVGColorspace
Definition SkSVGTypes.h:719
static sk_sp< SkImageFilter > Arithmetic(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4, bool enforcePMColor, sk_sp< SkImageFilter > background, sk_sp< SkImageFilter > foreground, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Blend(SkBlendMode mode, sk_sp< SkImageFilter > background, sk_sp< SkImageFilter > foreground=nullptr, const CropRect &cropRect={})
bool parse(SkSVGIntegerType *v)
sk_sp< SkImageFilter > onMakeImageFilter(const SkSVGRenderContext &, const SkSVGFilterContext &) const override
bool parseAndSetAttribute(const char *, const char *) override
SkRect resolveFilterSubregion(const SkSVGRenderContext &, const SkSVGFilterContext &) const
Definition SkSVGFe.cpp:54
bool parseAndSetAttribute(const char *, const char *) override
Definition SkSVGFe.cpp:93
virtual SkSVGColorspace resolveColorspace(const SkSVGRenderContext &, const SkSVGFilterContext &) const
Definition SkSVGFe.cpp:84
sk_sp< SkImageFilter > resolveInput(const SkSVGRenderContext &, const SkSVGFeInputType &) const
uint8_t value
const char * name
Definition fuchsia.cc:50