blob: 8e1105c31829bbc8a3b774bd8c3111b68a6393fd [file] [log] [blame]
Florin Malitac0034172018-01-08 16:42:59 -05001/*
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#ifndef SkSGOpacityEffect_DEFINED
9#define SkSGOpacityEffect_DEFINED
10
11#include "SkSGEffectNode.h"
12
13namespace sksg {
14
15/**
16 * Concrete Effect node, applying opacity to its descendants.
17 *
18 */
19class OpacityEffect final : public EffectNode {
20public:
21 static sk_sp<OpacityEffect> Make(sk_sp<RenderNode> child, float opacity = 1) {
22 return child ? sk_sp<OpacityEffect>(new OpacityEffect(std::move(child), opacity)) : nullptr;
23 }
24
25 SG_ATTRIBUTE(Opacity, float, fOpacity)
26
27protected:
28 OpacityEffect(sk_sp<RenderNode>, float);
29
Florin Malitac0132ff2018-08-09 07:40:01 -040030 void onRender(SkCanvas*, const RenderContext*) const override;
Florin Malitaeb46bd82019-02-12 09:33:21 -050031 const RenderNode* onNodeAt(const SkPoint&) const override;
Florin Malitac0034172018-01-08 16:42:59 -050032
33 SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
34
35private:
36 float fOpacity;
37
38 typedef EffectNode INHERITED;
39};
40
41} // namespace sksg
42
43#endif // SkSGOpacityEffect_DEFINED