Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
sksg::Merge Class Referencefinal

#include <SkSGMerge.h>

Inheritance diagram for sksg::Merge:
sksg::GeometryNode sksg::Node SkRefCnt SkRefCntBase

Classes

struct  Rec
 

Public Types

enum class  Mode {
  kMerge , kUnion , kIntersect , kDifference ,
  kReverseDifference , kXOR
}
 

Public Member Functions

 ~Merge () override
 
- Public Member Functions inherited from sksg::GeometryNode
void clip (SkCanvas *, bool antiAlias) const
 
void draw (SkCanvas *, const SkPaint &) const
 
bool contains (const SkPoint &) const
 
SkPath asPath () const
 
- Public Member Functions inherited from sksg::Node
const SkRectrevalidate (InvalidationController *, const SkMatrix &)
 
void invalidate (bool damage=true)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static sk_sp< MergeMake (std::vector< Rec > &&recs)
 

Protected Member Functions

void onClip (SkCanvas *, bool antiAlias) const override
 
void onDraw (SkCanvas *, const SkPaint &) const override
 
bool onContains (const SkPoint &) const override
 
SkRect onRevalidate (InvalidationController *, const SkMatrix &) override
 
SkPath onAsPath () const override
 
- Protected Member Functions inherited from sksg::GeometryNode
 GeometryNode ()
 
- Protected Member Functions inherited from sksg::Node
 Node (uint32_t invalTraits)
 
 ~Node () override
 
const SkRectbounds () const
 
bool hasInval () const
 
void observeInval (const sk_sp< Node > &)
 
void unobserveInval (const sk_sp< Node > &)
 

Additional Inherited Members

- Protected Types inherited from sksg::Node
enum  InvalTraits { kBubbleDamage_Trait = 1 << 0 , kOverrideDamage_Trait = 1 << 1 }
 

Detailed Description

Concrete Geometry node, combining other geometries based on Mode.

Definition at line 30 of file SkSGMerge.h.

Member Enumeration Documentation

◆ Mode

enum class sksg::Merge::Mode
strong
Enumerator
kMerge 
kUnion 
kIntersect 
kDifference 
kReverseDifference 
kXOR 

Definition at line 32 of file SkSGMerge.h.

32 {
33 // Append path mode.
34 kMerge,
35
36 // SkPathOp ops.
37 kUnion,
41 kXOR,
42 };

Constructor & Destructor Documentation

◆ ~Merge()

sksg::Merge::~Merge ( )
override

Definition at line 29 of file SkSGMerge.cpp.

29 {
30 for (const auto& rec : fRecs) {
31 this->unobserveInval(rec.fGeo);
32 }
33}
void unobserveInval(const sk_sp< Node > &)
Definition SkSGNode.cpp:84

Member Function Documentation

◆ Make()

static sk_sp< Merge > sksg::Merge::Make ( std::vector< Rec > &&  recs)
inlinestatic

Definition at line 49 of file SkSGMerge.h.

49 {
50 return sk_sp<Merge>(new Merge(std::move(recs)));
51 }

◆ onAsPath()

SkPath sksg::Merge::onAsPath ( ) const
overrideprotectedvirtual

Implements sksg::GeometryNode.

Definition at line 47 of file SkSGMerge.cpp.

47 {
48 return fMerged;
49}

◆ onClip()

void sksg::Merge::onClip ( SkCanvas canvas,
bool  antiAlias 
) const
overrideprotectedvirtual

Implements sksg::GeometryNode.

Definition at line 35 of file SkSGMerge.cpp.

35 {
36 canvas->clipPath(fMerged, SkClipOp::kIntersect, antiAlias);
37}
void clipPath(const SkPath &path, SkClipOp op, bool doAntiAlias)

◆ onContains()

bool sksg::Merge::onContains ( const SkPoint p) const
overrideprotectedvirtual

Implements sksg::GeometryNode.

Definition at line 43 of file SkSGMerge.cpp.

43 {
44 return fMerged.contains(p.x(), p.y());
45}
bool contains(SkScalar x, SkScalar y) const
Definition SkPath.cpp:3054

◆ onDraw()

void sksg::Merge::onDraw ( SkCanvas canvas,
const SkPaint paint 
) const
overrideprotectedvirtual

Implements sksg::GeometryNode.

Definition at line 39 of file SkSGMerge.cpp.

39 {
40 canvas->drawPath(fMerged, paint);
41}
void drawPath(const SkPath &path, const SkPaint &paint)
const Paint & paint

◆ onRevalidate()

SkRect sksg::Merge::onRevalidate ( InvalidationController ic,
const SkMatrix ctm 
)
overrideprotectedvirtual

Implements sksg::Node.

Definition at line 70 of file SkSGMerge.cpp.

70 {
71 SkASSERT(this->hasInval());
72
74
75 fMerged.reset();
76 bool in_builder = false;
77
78 auto append = [&](const SkPath& path) {
79 if (in_builder) {
80 builder.resolve(&fMerged);
81 in_builder = false;
82 }
83
84 if (fMerged.isEmpty()) {
85 // First merge path determines the fill type.
86 fMerged = path;
87 } else {
88 fMerged.addPath(path);
89 }
90 };
91
92 for (const auto& rec : fRecs) {
93 rec.fGeo->revalidate(ic, ctm);
94
95 if (rec.fMode == Mode::kMerge) {
96 // Merge (append) is not supported by SkOpBuidler.
97 append(rec.fGeo->asPath());
98 continue;
99 }
100
101 if (!in_builder) {
102 builder.add(fMerged, kUnion_SkPathOp);
103 in_builder = true;
104 }
105
106 builder.add(rec.fGeo->asPath(), mode_to_op(rec.fMode));
107 }
108
109 if (in_builder) {
110 builder.resolve(&fMerged);
111 }
112
113 SkPathPriv::ShrinkToFit(&fMerged);
114
115 return fMerged.computeTightBounds();
116}
#define SkASSERT(cond)
Definition SkAssert.h:116
@ kUnion_SkPathOp
union (inclusive-or) the two paths
Definition SkPathOps.h:25
static void ShrinkToFit(SkPath *path)
Definition SkPathPriv.h:130
bool isEmpty() const
Definition SkPath.cpp:406
SkPath & addPath(const SkPath &src, SkScalar dx, SkScalar dy, AddPathMode mode=kAppend_AddPathMode)
Definition SkPath.cpp:1442
SkRect computeTightBounds() const
Definition SkPath.cpp:3378
SkPath & reset()
Definition SkPath.cpp:360
bool hasInval() const
Definition SkSGNode.h:60
static void append(char **dst, size_t *count, const char *src, size_t n)
Definition editor.cpp:211
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57
static SkPathOp mode_to_op(Merge::Mode mode)
Definition SkSGMerge.cpp:51

The documentation for this class was generated from the following files: