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 SkSGClipEffect_DEFINED 9 #define SkSGClipEffect_DEFINED 10 11 #include "SkSGEffectNode.h" 12 13 namespace sksg { 14 15 class GeometryNode; 16 17 /** 18 * Concrete Effect node, applying a clip to its descendants. 19 * 20 */ 21 class ClipEffect final : public EffectNode { 22 public: 23 static sk_sp<ClipEffect> Make(sk_sp<RenderNode> child, sk_sp<GeometryNode> clip, 24 bool aa = false) { 25 return (child && clip) 26 ? sk_sp<ClipEffect>(new ClipEffect(std::move(child), std::move(clip), aa)) 27 : nullptr; 28 } 29 30 ~ClipEffect() override; 31 32 protected: 33 ClipEffect(sk_sp<RenderNode>, sk_sp<GeometryNode>, bool aa); 34 35 void onRender(SkCanvas*) const override; 36 37 SkRect onRevalidate(InvalidationController*, const SkMatrix&) override; 38 39 private: 40 const sk_sp<GeometryNode> fClipNode; 41 const bool fAntiAlias; 42 43 bool fNoop = false; 44 45 typedef EffectNode INHERITED; 46 }; 47 48 } // namespace sksg 49 50 #endif // SkSGClipEffect_DEFINED 51