Home | History | Annotate | Download | only in effects
      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 SkSGMaskEffect_DEFINED
      9 #define SkSGMaskEffect_DEFINED
     10 
     11 #include "SkSGEffectNode.h"
     12 
     13 namespace sksg {
     14 
     15 /**
     16  * Concrete Effect node, applying a mask to its descendants.
     17  *
     18  */
     19 class MaskEffect final : public EffectNode {
     20 public:
     21     static sk_sp<MaskEffect> Make(sk_sp<RenderNode> child, sk_sp<RenderNode> mask) {
     22         return (child && mask)
     23             ? sk_sp<MaskEffect>(new MaskEffect(std::move(child), std::move(mask)))
     24             : nullptr;
     25     }
     26 
     27     ~MaskEffect() override;
     28 
     29 protected:
     30     MaskEffect(sk_sp<RenderNode>, sk_sp<RenderNode> mask);
     31 
     32     void onRender(SkCanvas*) const override;
     33 
     34     SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
     35 
     36 private:
     37     sk_sp<RenderNode> fMaskNode;
     38 
     39     typedef EffectNode INHERITED;
     40 };
     41 
     42 } // namespace sksg
     43 
     44 #endif // SkSGMaskEffect_DEFINED
     45