7#ifndef GrQuadBuffer_DEFINED
8#define GrQuadBuffer_DEFINED
27 fData.
reserve(this->entrySize(fDeviceType,
nullptr));
38 int entrySize = this->entrySize(fDeviceType, needsLocals ? &fLocalType :
nullptr);
44 int count()
const {
return fCount; }
68 : fDeviceQuad(
SkRect::MakeEmpty())
69 , fLocalQuad(
SkRect::MakeEmpty())
71 , fCurrentEntry(nullptr)
73 SkDEBUGCODE(fExpectedCount =
buffer->count();)
78 const T&
metadata()
const { this->validate();
return *(fBuffer->metadata(fCurrentEntry)); }
94 return fBuffer->header(fCurrentEntry)->fHasLocals;
104 const char* fCurrentEntry;
107 const char* fNextEntry;
109 SkDEBUGCODE(
int fExpectedCount;)
111 void validate()
const {
112 SkDEBUGCODE(fBuffer->validate(fCurrentEntry, fExpectedCount);)
125 , fCurrentEntry(nullptr) {
126 SkDEBUGCODE(fExpectedCount = list->
count();)
139 SkDEBUGCODE(
int fExpectedCount;)
141 void validate()
const {
142 SkDEBUGCODE(fBuffer->validate(fCurrentEntry, fExpectedCount);)
149 struct alignas(int32_t)
Header {
150 unsigned fDeviceType : 2;
151 unsigned fLocalType : 2;
152 unsigned fHasLocals : 1;
156 static_assert(
sizeof(
Header) ==
sizeof(int32_t),
"Header should be 4 bytes");
158 inline static constexpr unsigned kSentinel = 0xbaffe;
159 inline static constexpr int kMetaSize =
sizeof(
Header) +
sizeof(
T);
160 inline static constexpr int k2DQuadFloats = 8;
161 inline static constexpr int k3DQuadFloats = 12;
185 int size = kMetaSize;
187 : k2DQuadFloats) *
sizeof(
float);
190 : k2DQuadFloats) *
sizeof(
float);
194 inline int entrySize(
const Header* header)
const {
205 return static_cast<Header*
>(
static_cast<void*
>(entry));
208 return static_cast<const Header*
>(
static_cast<const void*
>(entry));
212 return static_cast<T*
>(
static_cast<void*
>(entry +
sizeof(
Header)));
214 inline const T*
metadata(
const char* entry)
const {
215 return static_cast<const T*
>(
static_cast<const void*
>(entry +
sizeof(
Header)));
218 inline float* coords(
char* entry) {
219 return static_cast<float*
>(
static_cast<void*
>(entry + kMetaSize));
221 inline const float* coords(
const char* entry)
const {
222 return static_cast<const float*
>(
static_cast<const void*
>(entry + kMetaSize));
227 float* packQuad(
const GrQuad& quad,
float* coords);
231 void validate(
const char* entry,
int expectedCount)
const;
245 memcpy(coords, quad.
xs(), k3DQuadFloats *
sizeof(
float));
246 return coords + k3DQuadFloats;
248 memcpy(coords, quad.
xs(), k2DQuadFloats *
sizeof(
float));
249 return coords + k2DQuadFloats;
258 memcpy(quad->
xs(), coords, k3DQuadFloats *
sizeof(
float));
259 coords = coords + k3DQuadFloats;
262 memcpy(quad->
xs(), coords, k2DQuadFloats *
sizeof(
float));
263 coords = coords + k2DQuadFloats;
273 int entrySize = this->entrySize(deviceQuad.
quadType(), localQuad ? &localType :
nullptr);
276 char* entry = fData.
append(entrySize);
278 Header*
h = this->header(entry);
279 h->fDeviceType =
static_cast<unsigned>(deviceQuad.
quadType());
280 h->fHasLocals =
static_cast<unsigned>(localQuad !=
nullptr);
281 h->fLocalType =
static_cast<unsigned>(localQuad ? localQuad->
quadType()
286 static_assert(
alignof(
T) == 4,
"Metadata must be 4 byte aligned");
290 float* coords = this->coords(entry);
291 coords = this->packQuad(deviceQuad, coords);
293 coords = this->packQuad(*localQuad, coords);
295 SkASSERT((
char*)coords - entry == entrySize);
299 if (deviceQuad.
quadType() > fDeviceType) {
300 fDeviceType = deviceQuad.
quadType();
302 if (localQuad && localQuad->
quadType() > fLocalType) {
310 fCount += that.fCount;
311 if (that.fDeviceType > fDeviceType) {
312 fDeviceType = that.fDeviceType;
314 if (that.fLocalType > fLocalType) {
315 fLocalType = that.fLocalType;
329 SkASSERT(this->header(entry)->fSentinel == kSentinel);
340 if (fNextEntry >= fBuffer->fData.
end()) {
344 fCurrentEntry = fNextEntry;
347 const Header*
h = fBuffer->header(fCurrentEntry);
348 const float* coords = fBuffer->coords(fCurrentEntry);
349 coords = fBuffer->unpackQuad(
static_cast<GrQuad::Type>(
h->fDeviceType), coords, &fDeviceQuad);
351 coords = fBuffer->unpackQuad(
static_cast<GrQuad::Type>(
h->fLocalType), coords, &fLocalQuad);
355 fNextEntry =
static_cast<const char*
>(
static_cast<const void*
>(coords));
356 SkASSERT((fNextEntry - fCurrentEntry) == fBuffer->entrySize(
h));
364 if (fCurrentEntry < fBuffer->fData.
end()) {
365 const Header*
h = fBuffer->header(fCurrentEntry);
366 fCurrentEntry += fBuffer->entrySize(
h);
370 fCurrentEntry = fBuffer->fData.
begin();
373 return fCurrentEntry < fBuffer->fData.
end();
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
Iter(const GrQuadBuffer< T > *buffer)
bool isLocalValid() const
const T & metadata() const
void append(const GrQuad &deviceQuad, T &&metadata, const GrQuad *localQuad=nullptr)
GrQuadBuffer(int count, bool needsLocals=false)
GrQuad::Type deviceQuadType() const
void concat(const GrQuadBuffer< T > &that)
GrQuad::Type localQuadType() const
bool hasPerspective() const
void setQuadType(Type newType)
static const char * begin(const StringSlice &s)
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 buffer
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