Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
10
11class SkCanvas;
12class SkMatrix;
13struct SkPoint;
14
15namespace sksg {
16class InvalidationController;
17
19 : INHERITED(std::move(child))
20 , fOpacity(opacity) {}
21
22void 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
39 return (fOpacity > 0) ? this->INHERITED::onNodeAt(p) : nullptr;
40}
41
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
#define SkASSERT(cond)
Definition SkAssert.h:116
const RenderNode * onNodeAt(const SkPoint &) const override
void onRender(SkCanvas *, const RenderContext *) const override
SkRect onRevalidate(InvalidationController *, const SkMatrix &) override
bool hasInval() const
Definition SkSGNode.h:60
void onRender(SkCanvas *, const RenderContext *) const override
OpacityEffect(sk_sp< RenderNode >, float)
SkRect onRevalidate(InvalidationController *, const SkMatrix &) override
const RenderNode * onNodeAt(const SkPoint &) const override
ScopedRenderContext && modulateOpacity(float opacity)
Definition Skottie.h:32
Definition ref_ptr.h:256
static constexpr SkRect MakeEmpty()
Definition SkRect.h:595