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

#include <SkRegion.h>

Public Member Functions

 Iterator ()
 
 Iterator (const SkRegion &region)
 
bool rewind ()
 
void reset (const SkRegion &region)
 
bool done () const
 
void next ()
 
const SkIRectrect () const
 
const SkRegionrgn () const
 

Detailed Description

Returns sequence of rectangles, sorted along y-axis, then x-axis, that make up SkRegion.

Definition at line 447 of file SkRegion.h.

Constructor & Destructor Documentation

◆ Iterator() [1/2]

SkRegion::Iterator::Iterator ( )
inline

Initializes SkRegion::Iterator with an empty SkRegion. done() on SkRegion::Iterator returns true. Call reset() to initialized SkRegion::Iterator at a later time.

Returns
empty SkRegion iterator

Definition at line 456 of file SkRegion.h.

456: fRgn(nullptr), fDone(true) {}

◆ Iterator() [2/2]

SkRegion::Iterator::Iterator ( const SkRegion region)

Sets SkRegion::Iterator to return elements of SkIRect array in region.

Parameters
regionSkRegion to iterate
Returns
SkRegion iterator

example: https://fiddle.skia.org/c/@Region_Iterator_copy_const_SkRegion

Definition at line 1357 of file SkRegion.cpp.

1357 {
1358 this->reset(rgn);
1359}
m reset()
const SkRegion * rgn() const
Definition SkRegion.h:507

Member Function Documentation

◆ done()

bool SkRegion::Iterator::done ( ) const
inline

Returns true if SkRegion::Iterator is pointing to final SkIRect in SkRegion.

Returns
true if data parsing is complete

Definition at line 488 of file SkRegion.h.

488{ return fDone; }

◆ next()

void SkRegion::Iterator::next ( )

Advances SkRegion::Iterator to next SkIRect in SkRegion if it is not done.

example: https://fiddle.skia.org/c/@Region_Iterator_next

Definition at line 1387 of file SkRegion.cpp.

1387 {
1388 if (fDone) {
1389 return;
1390 }
1391
1392 if (fRuns == nullptr) { // rect case
1393 fDone = true;
1394 return;
1395 }
1396
1397 const RunType* runs = fRuns;
1398
1399 if (runs[0] < SkRegion_kRunTypeSentinel) { // valid X value
1400 fRect.fLeft = runs[0];
1401 fRect.fRight = runs[1];
1402 runs += 2;
1403 } else { // we're at the end of a line
1404 runs += 1;
1405 if (runs[0] < SkRegion_kRunTypeSentinel) { // valid Y value
1406 int intervals = runs[1];
1407 if (0 == intervals) { // empty line
1408 fRect.fTop = runs[0];
1409 runs += 3;
1410 } else {
1411 fRect.fTop = fRect.fBottom;
1412 }
1413
1414 fRect.fBottom = runs[0];
1415 assert_sentinel(runs[2], false);
1416 assert_sentinel(runs[3], false);
1417 fRect.fLeft = runs[2];
1418 fRect.fRight = runs[3];
1419 runs += 4;
1420 } else { // end of rgn
1421 fDone = true;
1422 }
1423 }
1424 fRuns = runs;
1425}
#define assert_sentinel(value, isSentinel)
static constexpr int SkRegion_kRunTypeSentinel
int32_t fBottom
larger y-axis bounds
Definition SkRect.h:36
int32_t fTop
smaller y-axis bounds
Definition SkRect.h:34
int32_t fLeft
smaller x-axis bounds
Definition SkRect.h:33
int32_t fRight
larger x-axis bounds
Definition SkRect.h:35

◆ rect()

const SkIRect & SkRegion::Iterator::rect ( ) const
inline

Returns SkIRect element in SkRegion. Does not return predictable results if SkRegion is empty.

Returns
part of SkRegion as SkIRect

Definition at line 501 of file SkRegion.h.

501{ return fRect; }

◆ reset()

void SkRegion::Iterator::reset ( const SkRegion region)

Resets iterator, using the new SkRegion.

Parameters
regionSkRegion to iterate

example: https://fiddle.skia.org/c/@Region_Iterator_reset

Definition at line 1369 of file SkRegion.cpp.

1369 {
1370 fRgn = &rgn;
1371 if (rgn.isEmpty()) {
1372 fDone = true;
1373 } else {
1374 fDone = false;
1375 if (rgn.isRect()) {
1376 fRect = rgn.fBounds;
1377 fRuns = nullptr;
1378 } else {
1379 fRuns = rgn.fRunHead->readonly_runs();
1380 fRect.setLTRB(fRuns[3], fRuns[0], fRuns[4], fRuns[1]);
1381 fRuns += 5;
1382 // Now fRuns points to the 2nd interval (or x-sentinel)
1383 }
1384 }
1385}
bool isRect() const
Definition SkRegion.h:152
bool isEmpty() const
Definition SkRegion.h:146
void setLTRB(int32_t left, int32_t top, int32_t right, int32_t bottom)
Definition SkRect.h:253
const SkRegion::RunType * readonly_runs() const

◆ rewind()

bool SkRegion::Iterator::rewind ( )

SkPoint SkRegion::Iterator to start of SkRegion. Returns true if SkRegion was set; otherwise, returns false.

Returns
true if SkRegion was set

example: https://fiddle.skia.org/c/@Region_Iterator_rewind

Definition at line 1361 of file SkRegion.cpp.

1361 {
1362 if (fRgn) {
1363 this->reset(*fRgn);
1364 return true;
1365 }
1366 return false;
1367}

◆ rgn()

const SkRegion * SkRegion::Iterator::rgn ( ) const
inline

Returns SkRegion if set; otherwise, returns nullptr.

Returns
iterated SkRegion

Definition at line 507 of file SkRegion.h.

507{ return fRgn; }

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