Home | History | Annotate | Download | only in include
      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 
     11 #include "SkSGEffectNode.h"
     12 
     13 namespace sksg {
     14 
     15 /**
     16  * Concrete Effect node, applying opacity to its descendants.
     17  *
     18  */
     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:
     28     OpacityEffect(sk_sp<RenderNode>, float);
     29 
     30     void onRender(SkCanvas*, const RenderContext*) const override;
     31     const RenderNode* onNodeAt(const SkPoint&)     const override;
     32 
     33     SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
     34 
     35 private:
     36     float fOpacity;
     37 
     38     typedef EffectNode INHERITED;
     39 };
     40 
     41 } // namespace sksg
     42 
     43 #endif // SkSGOpacityEffect_DEFINED
     44