Flutter Engine
The Flutter Engine
VertexChunkPatchAllocator.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 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
8#ifndef VertexChunkPatchAllocator_DEFINED
9#define VertexChunkPatchAllocator_DEFINED
10
13
14namespace skgpu::ganesh {
15
16// An adapter around GrVertexChunkBuilder that fits the API requirements of
17// skgpu::tess::PatchWriter's PatchAllocator template parameter.
19public:
20 // 'stride' is provided by PatchWriter.
21 // 'worstCaseTolerances' is used to accumulate the LinearTolerances from each append().
22 // 'target', 'chunks', and 'minVerticesPerChunk' are forwarded from the PatchWriter's ctor and
23 // are used to construct a GrVertexChunkBuilder matching the PatchWriter's stride.
25 tess::LinearTolerances* worstCaseTolerances,
27 GrVertexChunkArray* chunks,
28 int minVerticesPerChunk)
29 : fWorstCaseTolerances(worstCaseTolerances)
30 , fBuilder(target, chunks, stride, minVerticesPerChunk) {}
31
33 fWorstCaseTolerances->accumulate(tolerances);
34 return fBuilder.appendVertices(1);
35 }
36
37private:
38 tess::LinearTolerances* fWorstCaseTolerances;
39 GrVertexChunkBuilder fBuilder;
40};
41
42} // namespace skgpu::ganesh
43
44#endif // VertexChunkPatchAllocator_DEFINED
SK_ALWAYS_INLINE skgpu::VertexWriter appendVertices(int count)
VertexChunkPatchAllocator(size_t stride, tess::LinearTolerances *worstCaseTolerances, GrMeshDrawTarget *target, GrVertexChunkArray *chunks, int minVerticesPerChunk)
VertexWriter append(const tess::LinearTolerances &tolerances)
void accumulate(const LinearTolerances &tolerances)
uint32_t * target