Flutter Engine
The Flutter Engine
SkSVGFeFlood.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
14SkColor SkSVGFeFlood::resolveFloodColor(const SkSVGRenderContext& ctx) const {
15 const auto floodColor = this->getFloodColor();
16 const auto floodOpacity = this->getFloodOpacity();
17 // Uninherited presentation attributes should have a concrete value by now.
18 if (!floodColor.isValue() || !floodOpacity.isValue()) {
19 SkDebugf("unhandled: flood-color or flood-opacity has no value\n");
20 return SK_ColorBLACK;
21 }
22
23 const SkColor color = ctx.resolveSvgColor(*floodColor);
24 return SkColorSetA(color, SkScalarRoundToInt(*floodOpacity * 255));
25}
26
28 const SkSVGFilterContext& fctx) const {
29 return SkImageFilters::Shader(SkShaders::Color(resolveFloodColor(ctx)),
30 this->resolveFilterSubregion(ctx, fctx));
31}
uint32_t SkColor
Definition: SkColor.h:37
static constexpr SkColor SkColorSetA(SkColor c, U8CPU a)
Definition: SkColor.h:82
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
#define SkScalarRoundToInt(x)
Definition: SkScalar.h:37
static sk_sp< SkImageFilter > Shader(sk_sp< SkShader > shader, const CropRect &cropRect={})
sk_sp< SkImageFilter > onMakeImageFilter(const SkSVGRenderContext &, const SkSVGFilterContext &) const override
SkRect resolveFilterSubregion(const SkSVGRenderContext &, const SkSVGFilterContext &) const
Definition: SkSVGFe.cpp:54
SkSVGColorType resolveSvgColor(const SkSVGColor &) const
DlColor color
SK_API sk_sp< SkShader > Color(SkColor)