Coverage Report

Created: 2021-08-22 09:07

/src/skia/modules/sksg/src/SkSGPaint.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2017 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 "modules/sksg/include/SkSGPaint.h"
9
10
#include "include/private/SkTPin.h"
11
#include "modules/sksg/include/SkSGRenderEffect.h"
12
13
namespace sksg {
14
15
// Paint nodes don't generate damage on their own, but via their aggregation ancestor Draw nodes.
16
255k
PaintNode::PaintNode() : INHERITED(kBubbleDamage_Trait) {}
17
18
224k
SkPaint PaintNode::makePaint() const {
19
224k
    SkASSERT(!this->hasInval());
20
21
224k
    SkPaint paint;
22
23
224k
    paint.setAntiAlias(fAntiAlias);
24
224k
    paint.setBlendMode(fBlendMode);
25
224k
    paint.setStyle(fStyle);
26
224k
    paint.setStrokeWidth(fStrokeWidth);
27
224k
    paint.setStrokeMiter(fStrokeMiter);
28
224k
    paint.setStrokeJoin(fStrokeJoin);
29
224k
    paint.setStrokeCap(fStrokeCap);
30
31
224k
    this->onApplyToPaint(&paint);
32
33
    // Compose opacity on top of the subclass value.
34
224k
    paint.setAlpha(SkScalarRoundToInt(paint.getAlpha() * SkTPin<SkScalar>(fOpacity, 0, 1)));
35
36
224k
    return paint;
37
224k
}
38
39
244k
sk_sp<Color> Color::Make(SkColor c) {
40
244k
    return sk_sp<Color>(new Color(c));
41
244k
}
42
43
244k
Color::Color(SkColor c) : fColor(c) {}
44
45
193k
SkRect Color::onRevalidate(InvalidationController* ic, const SkMatrix& ctm) {
46
193k
    SkASSERT(this->hasInval());
47
48
193k
    return SkRect::MakeEmpty();
49
193k
}
50
51
215k
void Color::onApplyToPaint(SkPaint* paint) const {
52
215k
    paint->setColor(fColor);
53
215k
}
54
55
11.1k
sk_sp<ShaderPaint> ShaderPaint::Make(sk_sp<Shader> sh) {
56
11.1k
    return sh ? sk_sp<ShaderPaint>(new ShaderPaint(std::move(sh)))
57
0
              : nullptr;
58
11.1k
}
59
60
ShaderPaint::ShaderPaint(sk_sp<Shader> sh)
61
11.1k
    : fShader(std::move(sh)) {
62
11.1k
    this->observeInval(fShader);
63
11.1k
}
64
65
11.1k
ShaderPaint::~ShaderPaint() {
66
11.1k
    this->unobserveInval(fShader);
67
11.1k
}
68
69
9.10k
SkRect ShaderPaint::onRevalidate(InvalidationController* ic, const SkMatrix& ctm) {
70
9.10k
    SkASSERT(this->hasInval());
71
72
9.10k
    return fShader->revalidate(ic, ctm);
73
9.10k
}
74
75
9.27k
void ShaderPaint::onApplyToPaint(SkPaint* paint) const {
76
9.27k
    paint->setShader(fShader->getShader());
77
9.27k
}
78
79
} // namespace sksg