Flutter Engine
The Flutter Engine
third_party
skia
modules
sksg
src
SkSGOpacityEffect.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2018 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/private/base/SkAssert.h
"
9
#include "
modules/sksg/include/SkSGOpacityEffect.h
"
10
11
class
SkCanvas
;
12
class
SkMatrix
;
13
struct
SkPoint
;
14
15
namespace
sksg
{
16
class
InvalidationController;
17
18
OpacityEffect::OpacityEffect
(
sk_sp<RenderNode>
child,
float
opacity)
19
:
INHERITED
(
std
::move(child))
20
, fOpacity(opacity) {}
21
22
void
OpacityEffect::onRender
(
SkCanvas
* canvas,
const
RenderContext
* ctx)
const
{
23
// opacity <= 0 disables rendering
24
if
(fOpacity <= 0)
25
return
;
26
27
// opacity >= 1 has no effect
28
if
(fOpacity >= 1) {
29
this->
INHERITED::onRender
(canvas, ctx);
30
return
;
31
}
32
33
const
auto
local_context =
ScopedRenderContext
(canvas, ctx).
modulateOpacity
(fOpacity);
34
35
this->
INHERITED::onRender
(canvas, local_context);
36
}
37
38
const
RenderNode
*
OpacityEffect::onNodeAt
(
const
SkPoint
&
p
)
const
{
39
return
(fOpacity > 0) ? this->
INHERITED::onNodeAt
(p) :
nullptr
;
40
}
41
42
SkRect
OpacityEffect::onRevalidate
(
InvalidationController
* ic,
const
SkMatrix
& ctm) {
43
SkASSERT
(this->
hasInval
());
44
45
// opacity <= 0 disables rendering AND revalidation for the sub-DAG
46
return
fOpacity > 0 ? this->
INHERITED::onRevalidate
(ic, ctm) :
SkRect::MakeEmpty
();
47
}
48
49
}
// namespace sksg
SkAssert.h
SkASSERT
#define SkASSERT(cond)
Definition:
SkAssert.h:116
SkSGOpacityEffect.h
SkCanvas
Definition:
SkCanvas.h:106
SkMatrix
Definition:
SkMatrix.h:54
sk_sp
Definition:
SkRefCnt.h:220
sksg::EffectNode::onNodeAt
const RenderNode * onNodeAt(const SkPoint &) const override
Definition:
SkSGEffectNode.cpp:35
sksg::EffectNode::onRender
void onRender(SkCanvas *, const RenderContext *) const override
Definition:
SkSGEffectNode.cpp:31
sksg::EffectNode::onRevalidate
SkRect onRevalidate(InvalidationController *, const SkMatrix &) override
Definition:
SkSGEffectNode.cpp:39
sksg::InvalidationController
Definition:
SkSGInvalidationController.h:24
sksg::Node::hasInval
bool hasInval() const
Definition:
SkSGNode.h:60
sksg::OpacityEffect::onRender
void onRender(SkCanvas *, const RenderContext *) const override
Definition:
SkSGOpacityEffect.cpp:22
sksg::OpacityEffect::OpacityEffect
OpacityEffect(sk_sp< RenderNode >, float)
Definition:
SkSGOpacityEffect.cpp:18
sksg::OpacityEffect::onRevalidate
SkRect onRevalidate(InvalidationController *, const SkMatrix &) override
Definition:
SkSGOpacityEffect.cpp:42
sksg::OpacityEffect::onNodeAt
const RenderNode * onNodeAt(const SkPoint &) const override
Definition:
SkSGOpacityEffect.cpp:38
sksg::RenderNode::ScopedRenderContext
Definition:
SkSGRenderNode.h:75
sksg::RenderNode::ScopedRenderContext::modulateOpacity
ScopedRenderContext && modulateOpacity(float opacity)
Definition:
SkSGRenderNode.cpp:140
sksg::RenderNode
Definition:
SkSGRenderNode.h:34
dart_profiler_symbols.p
p
Definition:
dart_profiler_symbols.py:55
sksg
Definition:
Skottie.h:32
std
Definition:
ref_ptr.h:256
SkPoint
Definition:
SkPoint_impl.h:163
SkRect
Definition:
extension.cpp:13
SkRect::MakeEmpty
static constexpr SkRect MakeEmpty()
Definition:
SkRect.h:595
sksg::RenderNode::RenderContext
Definition:
SkSGRenderNode.h:60
Generated on Sun Jun 23 2024 21:56:07 for Flutter Engine by
1.9.4