blob: 674edb2b5cc7fb66560c58a525eca23847a7174e [file] [log] [blame]
Florin Malita38ea40e2018-01-29 16:31:14 -05001/*
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
13namespace sksg {
14
15class GeometryNode;
16
17/**
18 * Concrete Effect node, applying a clip to its descendants.
19 *
20 */
21class ClipEffect final : public EffectNode {
22public:
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
32protected:
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
39private:
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