Skia
2D Graphics Library
SkSGMerge.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 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 SkSGMerge_DEFINED
9 #define SkSGMerge_DEFINED
10 
12 
13 #include "include/core/SkPath.h"
14 
15 #include <vector>
16 
17 class SkCanvas;
18 class SkPaint;
19 
20 namespace sksg {
21 
25 class Merge final : public GeometryNode {
26 public:
27  enum class Mode {
28  // Append path mode.
29  kMerge,
30 
31  // SkPathOp ops.
32  kUnion,
33  kIntersect,
36  kXOR,
37  };
38 
39  struct Rec {
42  };
43 
44  static sk_sp<Merge> Make(std::vector<Rec>&& recs) {
45  return sk_sp<Merge>(new Merge(std::move(recs)));
46  }
47 
48  ~Merge() override;
49 
50 protected:
51  void onClip(SkCanvas*, bool antiAlias) const override;
52  void onDraw(SkCanvas*, const SkPaint&) const override;
53  bool onContains(const SkPoint&) const override;
54 
56  SkPath onAsPath() const override;
57 
58 private:
59  Merge(std::vector<Rec>&& recs);
60 
61  const std::vector<Rec> fRecs;
62  SkPath fMerged;
63 
64  using INHERITED = GeometryNode;
65 };
66 
67 } // namespace sksg
68 
69 #endif // SkSGMerge_DEFINED
SkCanvas provides an interface for drawing, and how the drawing is clipped and transformed.
Definition: SkCanvas.h:99
SkMatrix holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:53
SkPaint controls options applied when drawing.
Definition: SkPaint.h:44
SkPath contain geometry.
Definition: SkPath.h:58
Shared pointer class to wrap classes that support a ref()/unref() interface.
Definition: SkRefCnt.h:220
Base class for nodes which provide 'geometry' (as opposed to paint) for drawing.
Definition: SkSGGeometryNode.h:25
Receiver for invalidation events.
Definition: SkSGInvalidationController.h:25
Concrete Geometry node, combining other geometries based on Mode.
Definition: SkSGMerge.h:25
static sk_sp< Merge > Make(std::vector< Rec > &&recs)
Definition: SkSGMerge.h:44
void onClip(SkCanvas *, bool antiAlias) const override
bool onContains(const SkPoint &) const override
SkRect onRevalidate(InvalidationController *, const SkMatrix &) override
~Merge() override
SkPath onAsPath() const override
Mode
Definition: SkSGMerge.h:27
void onDraw(SkCanvas *, const SkPaint &) const override
Base class for all scene graph nodes.
Definition: SkSGNode.h:32
Definition: Skottie.h:30
SkRect holds four float coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:582
Definition: SkSGMerge.h:39
sk_sp< GeometryNode > fGeo
Definition: SkSGMerge.h:40
Mode fMode
Definition: SkSGMerge.h:41