Flutter Engine
The Flutter Engine
GrVertexChunkArray.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2021 Google LLC.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
9
11
13 if (!fChunks->empty()) {
14 fTarget->putBackVertices(fCurrChunkVertexCapacity - fCurrChunkVertexCount, fStride);
15 fChunks->back().fCount = fCurrChunkVertexCount;
16 }
17}
18
19bool GrVertexChunkBuilder::allocChunk(int minCount) {
20 if (!fChunks->empty()) {
21 // No need to put back vertices; the buffer is full.
22 fChunks->back().fCount = fCurrChunkVertexCount;
23 }
24 fCurrChunkVertexCount = 0;
25 GrVertexChunk* chunk = &fChunks->push_back();
26 int minAllocCount = std::max(minCount, fMinVerticesPerChunk);
27 fCurrChunkVertexWriter = fTarget->makeVertexWriterAtLeast(fStride, minAllocCount,
28 minAllocCount, &chunk->fBuffer,
29 &chunk->fBase,
30 &fCurrChunkVertexCapacity);
31 if (!fCurrChunkVertexWriter || !chunk->fBuffer || fCurrChunkVertexCapacity < minCount) {
32 SkDebugf("WARNING: Failed to allocate vertex buffer for GrVertexChunk.\n");
33 fChunks->pop_back();
34 SkASSERT(fCurrChunkVertexCount == 0);
35 fCurrChunkVertexCapacity = 0;
36 return false;
37 }
38 fMinVerticesPerChunk *= 2;
39 return true;
40}
#define SkASSERT(cond)
Definition: SkAssert.h:116
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
skgpu::VertexWriter makeVertexWriterAtLeast(size_t vertexSize, int minVertexCount, int fallbackVertexCount, sk_sp< const GrBuffer > *, int *startVertex, int *actualVertexCount)
virtual void putBackVertices(int vertices, size_t vertexStride)=0
bool empty() const
Definition: SkTArray.h:199
static float max(float r, float g, float b)
Definition: hsl.cpp:49
sk_sp< const GrBuffer > fBuffer