24 static std::atomic<uint32_t> nextID{1};
28 id = nextID.fetch_add(1, std::memory_order_relaxed);
53 if (
desc.fIndexCount) {
55 numFanTris =
desc.fIndexCount - 2;
57 numFanTris =
desc.fVertexCount - 2;
60 if (
desc.fVertexCount > (SkTo<int>(UINT16_MAX) + 1)) {
65 if (numFanTris <= 0) {
69 fISize = safe.
mul(numFanTris, 3 *
sizeof(uint16_t));
100 uint32_t builderFlags) {
103 this->init({
mode, vertexCount, indexCount, hasTexs, hasColors});
110void SkVertices::Builder::init(
const Desc&
desc) {
112 if (!sizes.isValid()) {
117 void* storage = ::operator
new (sizes.fTotal);
118 if (sizes.fBuilderTriFanISize) {
119 fIntermediateFanIndices.reset(
new uint8_t[sizes.fBuilderTriFanISize]);
125 char* ptr = (
char*)storage +
sizeof(
SkVertices);
128 auto advance = [&ptr](
size_t size) {
129 char* new_ptr =
size ? ptr :
nullptr;
134 fVertices->fPositions = (
SkPoint*) advance(sizes.fVSize);
135 fVertices->fTexs = (
SkPoint*) advance(sizes.fTSize);
136 fVertices->fColors = (
SkColor*) advance(sizes.fCSize);
137 fVertices->fIndices = (uint16_t*)advance(sizes.fISize);
139 fVertices->fVertexCount =
desc.fVertexCount;
140 fVertices->fIndexCount =
desc.fIndexCount;
141 fVertices->fMode =
desc.fMode;
148 fVertices->fBounds.
setBounds(fVertices->fPositions, fVertices->fVertexCount);
150 if (fIntermediateFanIndices) {
152 auto tempIndices = this->indices();
153 for (
int t = 0; t < fVertices->fIndexCount - 2; ++t) {
154 fVertices->fIndices[3 * t + 0] = tempIndices[0];
155 fVertices->fIndices[3 * t + 1] = tempIndices[t + 1];
156 fVertices->fIndices[3 * t + 2] = tempIndices[t + 2];
158 fVertices->fIndexCount = 3 * (fVertices->fIndexCount - 2);
161 for (
int t = 0; t < fVertices->fVertexCount - 2; ++t) {
162 fVertices->fIndices[3 * t + 0] = 0;
163 fVertices->fIndices[3 * t + 1] =
SkToU16(t + 1);
164 fVertices->fIndices[3 * t + 2] =
SkToU16(t + 2);
166 fVertices->fIndexCount = 3 * (fVertices->fVertexCount - 2);
170 fVertices->fUniqueID =
next_id();
171 return std::move(fVertices);
177 return fVertices ?
const_cast<SkPoint*
>(fVertices->fPositions) :
nullptr;
181 return fVertices ?
const_cast<SkPoint*
>(fVertices->fTexs) :
nullptr;
185 return fVertices ?
const_cast<SkColor*
>(fVertices->fColors) :
nullptr;
192 if (fIntermediateFanIndices) {
193 return reinterpret_cast<uint16_t*
>(fIntermediateFanIndices.get());
195 return const_cast<uint16_t*
>(fVertices->fIndices);
203 int indexCount,
const uint16_t indices[]) {
222 return this->getSizes().
fTotal;
226 Sizes sizes({fMode, fVertexCount, fIndexCount, !!fTexs, !!fColors});
236#define kMode_Mask 0x0FF
237#define kHasTexs_Mask 0x100
238#define kHasColors_Mask 0x200
242 uint32_t packed =
static_cast<uint32_t
>(fVertices->fMode);
244 if (fVertices->fTexs) {
247 if (fVertices->fColors) {
256 buffer.writeInt(fVertices->fVertexCount);
257 buffer.writeInt(fVertices->fIndexCount);
260 buffer.writeByteArray(fVertices->fPositions, sizes.
fVSize);
262 buffer.writeByteArray(fVertices->fColors, sizes.
fCSize);
264 buffer.writeByteArray(fVertices->fIndices, sizes.
fISize);
272 const uint32_t packed =
buffer.readUInt();
275 const int attrCount = hasCustomData ? safe.
checkGE(
buffer.readInt(), 0) : 0;
285 if (!safe || !
buffer.isValid() || attrCount ||
303 size_t customDataSize = 0;
304 buffer.skipByteArray(&customDataSize);
305 if (customDataSize != 0) {
317 if (indexCount > 0) {
319 const uint16_t* indices =
builder.indices();
320 for (
int i = 0;
i < indexCount; ++
i) {
321 if (indices[
i] >= (
unsigned)vertexCount) {
337void SkVertices::operator
delete(
void*
p) {
338 ::operator
delete(
p);
sk_bzero(glyphs, sizeof(glyphs))
static void * sk_careful_memcpy(void *dst, const void *src, size_t len)
constexpr uint16_t SkToU16(S x)
static constexpr bool SkToBool(const T &x)
static constexpr uint32_t SK_InvalidGenID
static uint32_t next_id()
@ kVerticesRemoveCustomData_Version
size_t add(size_t x, size_t y)
size_t mul(size_t x, size_t y)
int checkGE(int value, int min)
T checkLE(uint64_t value, T max)
void encode(SkWriteBuffer &) const
static sk_sp< SkVertices > Decode(SkReadBuffer &)
sk_sp< SkVertices > detach()
Builder(VertexMode mode, int vertexCount, int indexCount, uint32_t flags)
@ kHasTexCoords_BuilderFlag
static sk_sp< SkVertices > MakeCopy(VertexMode mode, int vertexCount, const SkPoint positions[], const SkPoint texs[], const SkColor colors[], int indexCount, const uint16_t indices[])
@ kTriangleFan_VertexMode
size_t approximateSize() const
PODArray< SkColor > colors
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 mode
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
static DecodeResult decode(std::string path)
void setBounds(const SkPoint pts[], int count)
size_t fBuilderTriFanISize