Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Functions
SkRegion_path.cpp File Reference
#include "include/core/SkColor.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPath.h"
#include "include/core/SkRect.h"
#include "include/core/SkRegion.h"
#include "include/core/SkScalar.h"
#include "include/core/SkTypes.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkMalloc.h"
#include "include/private/base/SkMath.h"
#include "include/private/base/SkPoint_impl.h"
#include "include/private/base/SkTDArray.h"
#include "include/private/base/SkTFitsIn.h"
#include "include/private/base/SkTo.h"
#include "src/base/SkSafeMath.h"
#include "src/base/SkTSort.h"
#include "src/core/SkBlitter.h"
#include "src/core/SkRegionPriv.h"
#include "src/core/SkScan.h"
#include <algorithm>
#include <cstdint>
#include <cstring>
#include <iterator>

Go to the source code of this file.

Classes

class  SkRgnBuilder
 
struct  Edge
 
struct  EdgeLT
 

Functions

static bool sk_memeq32 (const int32_t *SK_RESTRICT a, const int32_t *SK_RESTRICT b, int count)
 
static unsigned verb_to_initial_last_index (unsigned verb)
 
static unsigned verb_to_max_edges (unsigned verb)
 
static int count_path_runtype_values (const SkPath &path, int *itop, int *ibot)
 
static bool check_inverse_on_empty_return (SkRegion *dst, const SkPath &path, const SkRegion &clip)
 
static void find_link (Edge *base, Edge *stop)
 
static int extract_path (Edge *edge, Edge *stop, SkPath *path)
 

Function Documentation

◆ check_inverse_on_empty_return()

static bool check_inverse_on_empty_return ( SkRegion dst,
const SkPath path,
const SkRegion clip 
)
static

Definition at line 330 of file SkRegion_path.cpp.

330 {
331 if (path.isInverseFillType()) {
332 return dst->set(clip);
333 } else {
334 return dst->setEmpty();
335 }
336}
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition SkPath.cpp:3824
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
dst
Definition cp.py:12

◆ count_path_runtype_values()

static int count_path_runtype_values ( const SkPath path,
int itop,
int ibot 
)
static

Definition at line 291 of file SkRegion_path.cpp.

291 {
292 SkPath::Iter iter(path, true);
293 SkPoint pts[4];
294 SkPath::Verb verb;
295
296 int maxEdges = 0;
299
300 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
301 maxEdges += verb_to_max_edges(verb);
302
303 int lastIndex = verb_to_initial_last_index(verb);
304 if (lastIndex > 0) {
305 for (int i = 1; i <= lastIndex; i++) {
306 if (top > pts[i].fY) {
307 top = pts[i].fY;
308 } else if (bot < pts[i].fY) {
309 bot = pts[i].fY;
310 }
311 }
312 } else if (SkPath::kMove_Verb == verb) {
313 if (top > pts[0].fY) {
314 top = pts[0].fY;
315 } else if (bot < pts[0].fY) {
316 bot = pts[0].fY;
317 }
318 }
319 }
320 if (0 == maxEdges) {
321 return 0; // we have only moves+closes
322 }
323
324 SkASSERT(top <= bot);
325 *itop = SkScalarRoundToInt(top);
326 *ibot = SkScalarRoundToInt(bot);
327 return maxEdges;
328}
#define SkASSERT(cond)
Definition SkAssert.h:116
static constexpr int16_t SK_MaxS16
Definition SkMath.h:18
static constexpr int16_t SK_MinS16
Definition SkMath.h:19
static unsigned verb_to_initial_last_index(unsigned verb)
static unsigned verb_to_max_edges(unsigned verb)
#define SkScalarRoundToInt(x)
Definition SkScalar.h:37
#define SkIntToScalar(x)
Definition SkScalar.h:57
@ kMove_Verb
Definition SkPath.h:1458
@ kDone_Verb
Definition SkPath.h:1464
float SkScalar
Definition extension.cpp:12
float fY
y-axis value

◆ extract_path()

static int extract_path ( Edge edge,
Edge stop,
SkPath path 
)
static

Definition at line 515 of file SkRegion_path.cpp.

515 {
516 while (0 == edge->fFlags) {
517 edge++; // skip over "used" edges
518 }
519
520 SkASSERT(edge < stop);
521
522 Edge* base = edge;
523 Edge* prev = edge;
524 edge = edge->fNext;
525 SkASSERT(edge != base);
526
527 int count = 1;
528 path->moveTo(SkIntToScalar(prev->fX), SkIntToScalar(prev->fY0));
529 prev->fFlags = 0;
530 do {
531 if (prev->fX != edge->fX || prev->fY1 != edge->fY0) { // skip collinear
532 path->lineTo(SkIntToScalar(prev->fX), SkIntToScalar(prev->fY1)); // V
533 path->lineTo(SkIntToScalar(edge->fX), SkIntToScalar(edge->fY0)); // H
534 }
535 prev = edge;
536 edge = edge->fNext;
537 count += 1;
538 prev->fFlags = 0;
539 } while (edge != base);
540 path->lineTo(SkIntToScalar(prev->fX), SkIntToScalar(prev->fY1)); // V
541 path->close();
542 return count;
543}
int count
static float prev(float f)
uint8_t fFlags
SkRegionPriv::RunType fX
SkRegionPriv::RunType fY0
Edge * fNext

◆ find_link()

static void find_link ( Edge base,
Edge stop 
)
static

Definition at line 473 of file SkRegion_path.cpp.

473 {
474 SkASSERT(base < stop);
475
476 if (base->fFlags == Edge::kCompleteLink) {
477 SkASSERT(base->fNext);
478 return;
479 }
480
481 SkASSERT(base + 1 < stop);
482
483 int y0 = base->fY0;
484 int y1 = base->fY1;
485
486 Edge* e = base;
487 if ((base->fFlags & Edge::kY0Link) == 0) {
488 for (;;) {
489 e += 1;
490 if ((e->fFlags & Edge::kY1Link) == 0 && y0 == e->fY1) {
491 SkASSERT(nullptr == e->fNext);
492 e->fNext = base;
493 e->fFlags = SkToU8(e->fFlags | Edge::kY1Link);
494 break;
495 }
496 }
497 }
498
499 e = base;
500 if ((base->fFlags & Edge::kY1Link) == 0) {
501 for (;;) {
502 e += 1;
503 if ((e->fFlags & Edge::kY0Link) == 0 && y1 == e->fY0) {
504 SkASSERT(nullptr == base->fNext);
505 base->fNext = e;
506 e->fFlags = SkToU8(e->fFlags | Edge::kY0Link);
507 break;
508 }
509 }
510 }
511
512 base->fFlags = Edge::kCompleteLink;
513}
constexpr uint8_t SkToU8(S x)
Definition SkTo.h:22

◆ sk_memeq32()

static bool sk_memeq32 ( const int32_t *SK_RESTRICT  a,
const int32_t *SK_RESTRICT  b,
int  count 
)
static

Definition at line 35 of file SkRegion_path.cpp.

35 {
36 for (int i = 0; i < count; ++i) {
37 if (a[i] != b[i]) {
38 return false;
39 }
40 }
41 return true;
42}
static bool b
struct MyStruct a[10]

◆ verb_to_initial_last_index()

static unsigned verb_to_initial_last_index ( unsigned  verb)
static

Definition at line 262 of file SkRegion_path.cpp.

262 {
263 static const uint8_t gPathVerbToInitialLastIndex[] = {
264 0, // kMove_Verb
265 1, // kLine_Verb
266 2, // kQuad_Verb
267 2, // kConic_Verb
268 3, // kCubic_Verb
269 0, // kClose_Verb
270 0 // kDone_Verb
271 };
272 SkASSERT((unsigned)verb < std::size(gPathVerbToInitialLastIndex));
273 return gPathVerbToInitialLastIndex[verb];
274}

◆ verb_to_max_edges()

static unsigned verb_to_max_edges ( unsigned  verb)
static

Definition at line 276 of file SkRegion_path.cpp.

276 {
277 static const uint8_t gPathVerbToMaxEdges[] = {
278 0, // kMove_Verb
279 1, // kLine_Verb
280 2, // kQuad_VerbB
281 2, // kConic_VerbB
282 3, // kCubic_Verb
283 0, // kClose_Verb
284 0 // kDone_Verb
285 };
286 SkASSERT((unsigned)verb < std::size(gPathVerbToMaxEdges));
287 return gPathVerbToMaxEdges[verb];
288}