blob: 309127f3ed0e8e705d5584a6ee51f1002f669832 [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
Florin Malitac0132ff2018-08-09 07:40:01 -040035 void onRender(SkCanvas*, const RenderContext*) const override;
Florin Malitaeb46bd82019-02-12 09:33:21 -050036 const RenderNode* onNodeAt(const SkPoint&) const override;
Florin Malita38ea40e2018-01-29 16:31:14 -050037
38 SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
39
40private:
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