Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SkOpBuilder Class Reference

#include <SkPathOps.h>

Public Member Functions

void add (const SkPath &path, SkPathOp _operator)
 
bool resolve (SkPath *result)
 

Detailed Description

Perform a series of path operations, optimized for unioning many paths together.

Definition at line 86 of file SkPathOps.h.

Member Function Documentation

◆ add()

void SkOpBuilder::add ( const SkPath path,
SkPathOp  _operator 
)

Add one or more paths and their operand. The builder is empty before the first path is added, so the result of a single add is (emptyPath OP path).

Parameters
pathThe second operand.
_operatorThe operator to apply to the existing and supplied paths.

Definition at line 126 of file SkOpBuilder.cpp.

126 {
127 if (fOps.empty() && op != kUnion_SkPathOp) {
128 fPathRefs.push_back() = SkPath();
129 *fOps.append() = kUnion_SkPathOp;
130 }
131 fPathRefs.push_back() = path;
132 *fOps.append() = op;
133}
@ kUnion_SkPathOp
union (inclusive-or) the two paths
Definition SkPathOps.h:25
bool empty() const
Definition SkTDArray.h:135
T * append()
Definition SkTDArray.h:191
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

◆ resolve()

bool SkOpBuilder::resolve ( SkPath result)

Computes the sum of all paths and operands, and resets the builder to its initial state.

Parameters
resultThe product of the operands.
Returns
True if the operation succeeded.

Definition at line 143 of file SkOpBuilder.cpp.

143 {
144 SkPath original = *result;
145 int count = fOps.size();
146 bool allUnion = true;
148 for (int index = 0; index < count; ++index) {
149 SkPath* test = &fPathRefs[index];
150 if (kUnion_SkPathOp != fOps[index] || test->isInverseFillType()) {
151 allUnion = false;
152 break;
153 }
154 // If all paths are convex, track direction, reversing as needed.
155 if (test->isConvex()) {
158 allUnion = false;
159 break;
160 }
161 if (firstDir == SkPathFirstDirection::kUnknown) {
162 firstDir = dir;
163 } else if (firstDir != dir) {
164 ReversePath(test);
165 }
166 continue;
167 }
168 // If the path is not convex but its bounds do not intersect the others, simplify is enough.
169 const SkRect& testBounds = test->getBounds();
170 for (int inner = 0; inner < index; ++inner) {
171 // OPTIMIZE: check to see if the contour bounds do not intersect other contour bounds?
172 if (SkRect::Intersects(fPathRefs[inner].getBounds(), testBounds)) {
173 allUnion = false;
174 break;
175 }
176 }
177 }
178 if (!allUnion) {
179 *result = fPathRefs[0];
180 for (int index = 1; index < count; ++index) {
181 if (!Op(*result, fPathRefs[index], fOps[index], result)) {
182 reset();
183 *result = original;
184 return false;
185 }
186 }
187 reset();
188 return true;
189 }
190 SkPath sum;
191 for (int index = 0; index < count; ++index) {
192 if (!Simplify(fPathRefs[index], &fPathRefs[index])) {
193 reset();
194 *result = original;
195 return false;
196 }
197 if (!fPathRefs[index].isEmpty()) {
198 // convert the even odd result back to winding form before accumulating it
199 if (!FixWinding(&fPathRefs[index])) {
200 *result = original;
201 return false;
202 }
203 sum.addPath(fPathRefs[index]);
204 }
205 }
206 reset();
207 bool success = Simplify(sum, result);
208 if (!success) {
209 *result = original;
210 }
211 return success;
212}
int count
SkPathFirstDirection
Definition SkPathEnums.h:19
bool SK_API Simplify(const SkPath &path, SkPath *result)
static SkPathFirstDirection ComputeFirstDirection(const SkPath &)
Definition SkPath.cpp:2563
SkPath & addPath(const SkPath &src, SkScalar dx, SkScalar dy, AddPathMode mode=kAppend_AddPathMode)
Definition SkPath.cpp:1442
int size() const
Definition SkTDArray.h:138
GAsyncResult * result
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 to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir
Definition switches.h:145

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