Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
SkRegion::RunHead Struct Reference

#include <SkRegionPriv.h>

Public Member Functions

int getYSpanCount () const
 
int getIntervalCount () const
 
SkRegion::RunType * writable_runs ()
 
const SkRegion::RunType * readonly_runs () const
 
RunHeadensureWritable ()
 
SkRegion::RunType * findScanline (int y) const
 
void computeRunBounds (SkIRect *bounds)
 

Static Public Member Functions

static RunHeadAlloc (int count)
 
static RunHeadAlloc (int count, int yspancount, int intervalCount)
 
static SkRegion::RunType * SkipEntireScanline (const SkRegion::RunType runs[])
 

Public Attributes

std::atomic< int32_t > fRefCnt
 
int32_t fRunCount
 

Detailed Description

Definition at line 59 of file SkRegionPriv.h.

Member Function Documentation

◆ Alloc() [1/2]

static RunHead * SkRegion::RunHead::Alloc ( int  count)
inlinestatic

Definition at line 85 of file SkRegionPriv.h.

85 {
86 if (count < SkRegion::kRectRegionRuns) {
87 return nullptr;
88 }
89
90 const int64_t size = sk_64_mul(count, sizeof(RunType)) + sizeof(RunHead);
91 if (count < 0 || !SkTFitsIn<int32_t>(size)) { SK_ABORT("Invalid Size"); }
92
93 RunHead* head = (RunHead*)sk_malloc_throw(size);
94 head->fRefCnt = 1;
95 head->fRunCount = count;
96 // these must be filled in later, otherwise we will be invalid
97 head->fYSpanCount = 0;
98 head->fIntervalCount = 0;
99 return head;
100 }
int count
#define SK_ABORT(message,...)
Definition SkAssert.h:70
static void * sk_malloc_throw(size_t size)
Definition SkMalloc.h:67
static int64_t sk_64_mul(int64_t a, int64_t b)
Definition SkMath.h:33
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259

◆ Alloc() [2/2]

static RunHead * SkRegion::RunHead::Alloc ( int  count,
int  yspancount,
int  intervalCount 
)
inlinestatic

Definition at line 102 of file SkRegionPriv.h.

102 {
103 if (yspancount <= 0 || intervalCount <= 1) {
104 return nullptr;
105 }
106
107 RunHead* head = Alloc(count);
108 if (!head) {
109 return nullptr;
110 }
111 head->fYSpanCount = yspancount;
112 head->fIntervalCount = intervalCount;
113 return head;
114 }
static RunHead * Alloc(int count)

◆ computeRunBounds()

void SkRegion::RunHead::computeRunBounds ( SkIRect bounds)
inline

Definition at line 195 of file SkRegionPriv.h.

195 {
196 RunType* runs = this->writable_runs();
197 bounds->fTop = *runs++;
198
199 int bot;
200 int ySpanCount = 0;
201 int intervalCount = 0;
202 int left = SK_MaxS32;
203 int rite = SK_MinS32;
204
205 do {
206 bot = *runs++;
208 ySpanCount += 1;
209
210 const int intervals = *runs++;
211 SkASSERT(intervals >= 0);
213
214 if (intervals > 0) {
215#ifdef SK_DEBUG
216 {
217 int n = compute_intervalcount(runs);
218 SkASSERT(n == intervals);
219 }
220#endif
221 RunType L = runs[0];
223 if (left > L) {
224 left = L;
225 }
226
227 runs += intervals * 2;
228 RunType R = runs[-1];
230 if (rite < R) {
231 rite = R;
232 }
233
234 intervalCount += intervals;
235 }
237 runs += 1; // skip x-sentinel
238
239 // test Y-sentinel
240 } while (SkRegion_kRunTypeSentinel > *runs);
241
242#ifdef SK_DEBUG
243 // +1 to skip the last Y-sentinel
244 int runCount = SkToInt(runs - this->writable_runs() + 1);
245 SkASSERT(runCount == fRunCount);
246#endif
247
248 fYSpanCount = ySpanCount;
249 fIntervalCount = intervalCount;
250
251 bounds->fLeft = left;
252 bounds->fRight = rite;
253 bounds->fBottom = bot;
254 }
#define SkASSERT(cond)
Definition SkAssert.h:116
static constexpr int32_t SK_MinS32
Definition SkMath.h:22
static constexpr int32_t SK_MaxS32
Definition SkMath.h:21
static bool left(const SkPoint &p0, const SkPoint &p1)
static constexpr int SkRegion_kRunTypeSentinel
constexpr int SkToInt(S x)
Definition SkTo.h:29
#define R(r)
Optional< SkRect > bounds
Definition SkRecords.h:189
int32_t fTop
smaller y-axis bounds
Definition SkRect.h:34
SkRegion::RunType * writable_runs()

◆ ensureWritable()

RunHead * SkRegion::RunHead::ensureWritable ( )
inline

Definition at line 125 of file SkRegionPriv.h.

125 {
126 RunHead* writable = this;
127 if (fRefCnt > 1) {
128 // We need to alloc & copy the current region before decrease
129 // the refcount because it could be freed in the meantime.
130 writable = Alloc(fRunCount, fYSpanCount, fIntervalCount);
131 memcpy(writable->writable_runs(), this->readonly_runs(),
132 fRunCount * sizeof(RunType));
133
134 // fRefCount might have changed since we last checked.
135 // If we own the last reference at this point, we need to
136 // free the memory.
137 if (--fRefCnt == 0) {
138 sk_free(this);
139 }
140 }
141 return writable;
142 }
SK_API void sk_free(void *)
std::atomic< int32_t > fRefCnt

◆ findScanline()

SkRegion::RunType * SkRegion::RunHead::findScanline ( int  y) const
inline

Return the scanline that contains the Y value. This requires that the Y value is already known to be contained within the bounds of the region, and so this routine never returns nullptr.

It returns the beginning of the scanline, starting with its Bottom value.

Definition at line 174 of file SkRegionPriv.h.

174 {
175 const RunType* runs = this->readonly_runs();
176
177 // if the top-check fails, we didn't do a quick check on the bounds
178 SkASSERT(y >= runs[0]);
179
180 runs += 1; // skip top-Y
181 for (;;) {
182 int bottom = runs[0];
183 // If we hit this, we've walked off the region, and our bounds check
184 // failed.
186 if (y < bottom) {
187 break;
188 }
189 runs = SkipEntireScanline(runs);
190 }
191 return const_cast<SkRegion::RunType*>(runs);
192 }
double y
const SkRegion::RunType * readonly_runs() const
static SkRegion::RunType * SkipEntireScanline(const SkRegion::RunType runs[])

◆ getIntervalCount()

int SkRegion::RunHead::getIntervalCount ( ) const
inline

Number of intervals in the entire region. This equals the number of rects that would be returned by the Iterator. In the logical case of a rect, this would return 1, and an empty region would return 0.

Definition at line 81 of file SkRegionPriv.h.

81 {
82 return fIntervalCount;
83 }

◆ getYSpanCount()

int SkRegion::RunHead::getYSpanCount ( ) const
inline

Number of spans with different Y values. This does not count the initial Top value, nor does it count the final Y-Sentinel value. In the logical case of a rectangle, this would return 1, and an empty region would return 0.

Definition at line 72 of file SkRegionPriv.h.

72 {
73 return fYSpanCount;
74 }

◆ readonly_runs()

const SkRegion::RunType * SkRegion::RunHead::readonly_runs ( ) const
inline

Definition at line 121 of file SkRegionPriv.h.

121 {
122 return (const SkRegion::RunType*)(this + 1);
123 }

◆ SkipEntireScanline()

static SkRegion::RunType * SkRegion::RunHead::SkipEntireScanline ( const SkRegion::RunType  runs[])
inlinestatic

Given a scanline (including its Bottom value at runs[0]), return the next scanline. Asserts that there is one (i.e. runs[0] < Sentinel)

Definition at line 148 of file SkRegionPriv.h.

148 {
149 // we are not the Y Sentinel
151
152 const int intervals = runs[1];
153 SkASSERT(runs[2 + intervals * 2] == SkRegion_kRunTypeSentinel);
154#ifdef SK_DEBUG
155 {
156 int n = compute_intervalcount(&runs[2]);
157 SkASSERT(n == intervals);
158 }
159#endif
160
161 // skip the entire line [B N [L R] S]
162 runs += 1 + 1 + intervals * 2 + 1;
163 return const_cast<SkRegion::RunType*>(runs);
164 }

◆ writable_runs()

SkRegion::RunType * SkRegion::RunHead::writable_runs ( )
inline

Definition at line 116 of file SkRegionPriv.h.

116 {
117 SkASSERT(fRefCnt == 1);
118 return (SkRegion::RunType*)(this + 1);
119 }

Member Data Documentation

◆ fRefCnt

std::atomic<int32_t> SkRegion::RunHead::fRefCnt

Definition at line 63 of file SkRegionPriv.h.

◆ fRunCount

int32_t SkRegion::RunHead::fRunCount

Definition at line 64 of file SkRegionPriv.h.


The documentation for this struct was generated from the following file: