Florin Malita | 38ea40e | 2018-01-29 16:31:14 -0500 | [diff] [blame] | 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 | |
Florin Malita | c0132ff | 2018-08-09 07:40:01 -0400 | [diff] [blame] | 35 | void onRender(SkCanvas*, const RenderContext*) const override; |
Florin Malita | eb46bd8 | 2019-02-12 09:33:21 -0500 | [diff] [blame] | 36 | const RenderNode* onNodeAt(const SkPoint&) const override; |
Florin Malita | 38ea40e | 2018-01-29 16:31:14 -0500 | [diff] [blame] | 37 | |
| 38 | SkRect onRevalidate(InvalidationController*, const SkMatrix&) override; |
| 39 | |
| 40 | private: |
| 41 | const sk_sp<GeometryNode> fClipNode; |
| 42 | const bool fAntiAlias; |
| 43 | |
| 44 | bool fNoop = false; |
| 45 | |
| 46 | typedef EffectNode INHERITED; |
| 47 | }; |
| 48 | |
| 49 | } // namespace sksg |
| 50 | |
| 51 | #endif // SkSGClipEffect_DEFINED |