Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
skgpu::ganesh::StrokeTessellator Class Reference

#include <StrokeTessellator.h>

Classes

struct  PathStrokeList
 

Public Types

using PatchAttribs = tess::PatchAttribs
 

Public Member Functions

 StrokeTessellator (PatchAttribs attribs)
 
void prepare (GrMeshDrawTarget *, const SkMatrix &shaderMatrix, PathStrokeList *, int totalCombinedStrokeVerbCnt)
 
void draw (GrOpFlushState *) const
 

Protected Attributes

const PatchAttribs fAttribs
 
GrVertexChunkArray fVertexChunkArray
 
int fVertexCount = 0
 
sk_sp< const GrGpuBufferfVertexBufferIfNoIDSupport
 

Detailed Description

Definition at line 28 of file StrokeTessellator.h.

Member Typedef Documentation

◆ PatchAttribs

Definition at line 30 of file StrokeTessellator.h.

Constructor & Destructor Documentation

◆ StrokeTessellator()

skgpu::ganesh::StrokeTessellator::StrokeTessellator ( PatchAttribs  attribs)
inline

Definition at line 41 of file StrokeTessellator.h.

41: fAttribs(attribs | PatchAttribs::kJoinControlPoint) {}

Member Function Documentation

◆ draw()

void skgpu::ganesh::StrokeTessellator::draw ( GrOpFlushState flushState) const

Definition at line 191 of file StrokeTessellator.cpp.

191 {
192 if (fVertexChunkArray.empty() || fVertexCount <= 0) {
193 return;
194 }
195 if (!flushState->caps().shaderCaps()->fVertexIDSupport &&
197 return;
198 }
199 for (const auto& instanceChunk : fVertexChunkArray) {
200 flushState->bindBuffers(nullptr, instanceChunk.fBuffer, fVertexBufferIfNoIDSupport);
201 flushState->drawInstanced(instanceChunk.fCount,
202 instanceChunk.fBase,
204 0);
205 }
206}
const GrShaderCaps * shaderCaps() const
Definition: GrCaps.h:63
void bindBuffers(sk_sp< const GrBuffer > indexBuffer, sk_sp< const GrBuffer > instanceBuffer, sk_sp< const GrBuffer > vertexBuffer, GrPrimitiveRestart primitiveRestart=GrPrimitiveRestart::kNo)
void drawInstanced(int instanceCount, int baseInstance, int vertexCount, int baseVertex)
const GrCaps & caps() const final
sk_sp< const GrGpuBuffer > fVertexBufferIfNoIDSupport
bool empty() const
Definition: SkTArray.h:199
bool fVertexIDSupport
Definition: GrShaderCaps.h:36

◆ prepare()

void skgpu::ganesh::StrokeTessellator::prepare ( GrMeshDrawTarget target,
const SkMatrix shaderMatrix,
PathStrokeList pathStrokeList,
int  totalCombinedStrokeVerbCnt 
)

Definition at line 165 of file StrokeTessellator.cpp.

168 {
169 LinearTolerances worstCase;
170 const int preallocCount = FixedCountStrokes::PreallocCount(totalCombinedStrokeVerbCnt);
171 StrokeWriter patchWriter{fAttribs, &worstCase, target, &fVertexChunkArray, preallocCount};
172
173 write_fixed_count_patches(std::move(patchWriter), shaderMatrix, pathStrokeList);
175
176 if (!target->caps().shaderCaps()->fVertexIDSupport) {
177 // Our shader won't be able to use sk_VertexID. Bind a fallback vertex buffer with the IDs
178 // in it instead.
180
181 SKGPU_DEFINE_STATIC_UNIQUE_KEY(gVertexIDFallbackBufferKey);
182
183 fVertexBufferIfNoIDSupport = target->resourceProvider()->findOrMakeStaticBuffer(
186 gVertexIDFallbackBufferKey,
188 }
189}
#define SKGPU_DEFINE_STATIC_UNIQUE_KEY(name)
Definition: ResourceKey.h:324
static constexpr int PreallocCount(int totalCombinedPathVerbCnt)
static void WriteVertexBuffer(VertexWriter, size_t bufferSize)
static constexpr int kMaxEdgesNoVertexIDs
static int VertexCount(const LinearTolerances &tolerances)
static constexpr size_t VertexBufferSize()
uint32_t * target
static float min(float r, float g, float b)
Definition: hsl.cpp:48

Member Data Documentation

◆ fAttribs

const PatchAttribs skgpu::ganesh::StrokeTessellator::fAttribs
protected

Definition at line 56 of file StrokeTessellator.h.

◆ fVertexBufferIfNoIDSupport

sk_sp<const GrGpuBuffer> skgpu::ganesh::StrokeTessellator::fVertexBufferIfNoIDSupport
protected

Definition at line 63 of file StrokeTessellator.h.

◆ fVertexChunkArray

GrVertexChunkArray skgpu::ganesh::StrokeTessellator::fVertexChunkArray
protected

Definition at line 58 of file StrokeTessellator.h.

◆ fVertexCount

int skgpu::ganesh::StrokeTessellator::fVertexCount = 0
protected

Definition at line 60 of file StrokeTessellator.h.


The documentation for this class was generated from the following files: