Flutter Engine
The Flutter Engine
SkSVGFeBlend.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 SkSVGFeBlend::parseAndSetAttribute(const char* name, const char* value) {
18 this->setIn2(SkSVGAttributeParser::parse<SkSVGFeInputType>("in2", name, value)) ||
19 this->setMode(SkSVGAttributeParser::parse<SkSVGFeBlend::Mode>("mode", name, value));
20}
21
23 switch (mode) {
34 }
35
37}
38
40 const SkSVGFilterContext& fctx) const {
41 const SkRect cropRect = this->resolveFilterSubregion(ctx, fctx);
42 const SkBlendMode blendMode = GetBlendMode(this->getMode());
43 const SkSVGColorspace colorspace = this->resolveColorspace(ctx, fctx);
44 const sk_sp<SkImageFilter> background = fctx.resolveInput(ctx, fIn2, colorspace);
45 const sk_sp<SkImageFilter> foreground = fctx.resolveInput(ctx, this->getIn(), colorspace);
46 return SkImageFilters::Blend(blendMode, background, foreground, cropRect);
47}
48
49template <>
50bool SkSVGAttributeParser::parse<SkSVGFeBlend::Mode>(
52 static constexpr std::tuple<const char*, SkSVGFeBlend::Mode> gMap[] = {
53 { "normal" , SkSVGFeBlend::Mode::kNormal },
54 { "multiply", SkSVGFeBlend::Mode::kMultiply },
55 { "screen" , SkSVGFeBlend::Mode::kScreen },
56 { "darken" , SkSVGFeBlend::Mode::kDarken },
57 { "lighten" , SkSVGFeBlend::Mode::kLighten },
58 };
59
60 return this->parseEnumMap(gMap, mode) && this->parseEOSToken();
61}
#define SkUNREACHABLE
Definition: SkAssert.h:135
SkBlendMode
Definition: SkBlendMode.h:38
@ kLighten
rc = s + d - min(s*da, d*sa), ra = kSrcOver
@ kMultiply
r = s*(1-da) + d*(1-sa) + s*d
@ kScreen
r = s + d - s*d
@ kSrcOver
r = s + (1-sa)*d
@ kDarken
rc = s + d - max(s*da, d*sa), ra = kSrcOver
static SkBlendMode GetBlendMode(SkSVGFeBlend::Mode mode)
SkSVGColorspace
Definition: SkSVGTypes.h:719
static sk_sp< SkImageFilter > Blend(SkBlendMode mode, sk_sp< SkImageFilter > background, sk_sp< SkImageFilter > foreground=nullptr, const CropRect &cropRect={})
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
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228