Coverage Report

Created: 2024-05-20 07:14

/src/skia/modules/svg/src/SkSVGFeFlood.cpp
Line
Count
Source (jump to first uncovered line)
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
8
#include "include/effects/SkImageFilters.h"
9
#include "modules/svg/include/SkSVGFeFlood.h"
10
#include "modules/svg/include/SkSVGFilterContext.h"
11
#include "modules/svg/include/SkSVGRenderContext.h"
12
#include "modules/svg/include/SkSVGValue.h"
13
14
0
SkColor SkSVGFeFlood::resolveFloodColor(const SkSVGRenderContext& ctx) const {
15
0
    const auto floodColor = this->getFloodColor();
16
0
    const auto floodOpacity = this->getFloodOpacity();
17
    // Uninherited presentation attributes should have a concrete value by now.
18
0
    if (!floodColor.isValue() || !floodOpacity.isValue()) {
19
0
        SkDebugf("unhandled: flood-color or flood-opacity has no value\n");
20
0
        return SK_ColorBLACK;
21
0
    }
22
23
0
    const SkColor color = ctx.resolveSvgColor(*floodColor);
24
0
    return SkColorSetA(color, SkScalarRoundToInt(*floodOpacity * 255));
25
0
}
26
27
sk_sp<SkImageFilter> SkSVGFeFlood::onMakeImageFilter(const SkSVGRenderContext& ctx,
28
0
                                                     const SkSVGFilterContext& fctx) const {
29
0
    return SkImageFilters::Shader(SkShaders::Color(resolveFloodColor(ctx)),
30
0
                                  this->resolveFilterSubregion(ctx, fctx));
31
0
}