Skia
2D Graphics Library
SkSGOpacityEffect.h
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 #ifndef SkSGOpacityEffect_DEFINED
9 #define SkSGOpacityEffect_DEFINED
10 
12 
13 namespace sksg {
14 
19 class OpacityEffect final : public EffectNode {
20 public:
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 
27 protected:
29 
30  void onRender(SkCanvas*, const RenderContext*) const override;
31  const RenderNode* onNodeAt(const SkPoint&) const override;
32 
34 
35 private:
36  float fOpacity;
37 
38  using INHERITED = EffectNode;
39 };
40 
41 } // namespace sksg
42 
43 #endif // SkSGOpacityEffect_DEFINED
#define SG_ATTRIBUTE(attr_name, attr_type, attr_container)
Definition: SkSGNode.h:99
SkCanvas provides an interface for drawing, and how the drawing is clipped and transformed.
Definition: SkCanvas.h:99
SkMatrix holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:53
Shared pointer class to wrap classes that support a ref()/unref() interface.
Definition: SkRefCnt.h:220
Base class for nodes which apply some transformation when rendering their descendants.
Definition: SkSGEffectNode.h:21
EffectNode(sk_sp< RenderNode >, uint32_t inval_traits=0)
Receiver for invalidation events.
Definition: SkSGInvalidationController.h:25
Concrete Effect node, applying opacity to its descendants.
Definition: SkSGOpacityEffect.h:19
const RenderNode * onNodeAt(const SkPoint &) const override
void onRender(SkCanvas *, const RenderContext *) const override
static sk_sp< OpacityEffect > Make(sk_sp< RenderNode > child, float opacity=1)
Definition: SkSGOpacityEffect.h:21
OpacityEffect(sk_sp< RenderNode >, float)
SkRect onRevalidate(InvalidationController *, const SkMatrix &) override
Base class for nodes which can render to a canvas.
Definition: SkSGRenderNode.h:27
Definition: Skottie.h:30
SkRect holds four float coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:582
Definition: SkSGRenderNode.h:53