Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
skgpu::ganesh::PathCurveTessellator Class Referencefinal

#include <PathTessellator.h>

Inheritance diagram for skgpu::ganesh::PathCurveTessellator:
skgpu::ganesh::PathTessellator

Public Member Functions

 PathCurveTessellator (bool infinitySupport, PatchAttribs attribs=PatchAttribs::kNone)
 
void prepareWithTriangles (GrMeshDrawTarget *target, const SkMatrix &shaderMatrix, GrInnerFanTriangulator::BreadcrumbTriangleList *extraTriangles, const PathDrawList &pathDrawList, int totalCombinedPathVerbCnt)
 
void prepare (GrMeshDrawTarget *target, const SkMatrix &shaderMatrix, const PathDrawList &pathDrawList, int totalCombinedPathVerbCnt) final
 
void draw (GrOpFlushState *) const final
 
void drawHullInstances (GrOpFlushState *, sk_sp< const GrGpuBuffer > vertexBufferIfNeeded) const
 
- Public Member Functions inherited from skgpu::ganesh::PathTessellator
virtual ~PathTessellator ()
 
PatchAttribs patchAttribs () const
 
virtual void prepare (GrMeshDrawTarget *target, const SkMatrix &shaderMatrix, const PathDrawList &pathDrawList, int totalCombinedPathVerbCnt)=0
 
virtual void draw (GrOpFlushState *flushState) const =0
 

Static Public Member Functions

static PathCurveTessellatorMake (SkArenaAlloc *arena, bool infinitySupport, PatchAttribs attribs=PatchAttribs::kNone)
 

Additional Inherited Members

- Public Types inherited from skgpu::ganesh::PathTessellator
using PatchAttribs = tess::PatchAttribs
 
- Protected Member Functions inherited from skgpu::ganesh::PathTessellator
 PathTessellator (bool infinitySupport, PatchAttribs attribs)
 
- Protected Attributes inherited from skgpu::ganesh::PathTessellator
PatchAttribs fAttribs
 
GrVertexChunkArray fVertexChunkArray
 
int fMaxVertexCount = 0
 
sk_sp< const GrGpuBufferfFixedVertexBuffer
 
sk_sp< const GrGpuBufferfFixedIndexBuffer
 

Detailed Description

Definition at line 89 of file PathTessellator.h.

Constructor & Destructor Documentation

◆ PathCurveTessellator()

skgpu::ganesh::PathCurveTessellator::PathCurveTessellator ( bool  infinitySupport,
PatchAttribs  attribs = PatchAttribs::kNone 
)
inline

Definition at line 97 of file PathTessellator.h.

99 : PathTessellator(infinitySupport, attribs) {}
PathTessellator(bool infinitySupport, PatchAttribs attribs)

Member Function Documentation

◆ draw()

void skgpu::ganesh::PathCurveTessellator::draw ( GrOpFlushState flushState) const
finalvirtual

Implements skgpu::ganesh::PathTessellator.

Definition at line 220 of file PathTessellator.cpp.

220 {
222 return;
223 }
224 for (const GrVertexChunk& chunk : fVertexChunkArray) {
225 flushState->bindBuffers(fFixedIndexBuffer, chunk.fBuffer, fFixedVertexBuffer);
226 // The max vertex count is the logical number of vertices that the GPU needs to emit, so
227 // since we're using drawIndexedInstanced, it's provided as the "index count" parameter.
228 flushState->drawIndexedInstanced(fMaxVertexCount, 0, chunk.fCount, chunk.fBase, 0);
229 }
230}
void drawIndexedInstanced(int indexCount, int baseIndex, int instanceCount, int baseInstance, int baseVertex)
void bindBuffers(sk_sp< const GrBuffer > indexBuffer, sk_sp< const GrBuffer > instanceBuffer, sk_sp< const GrBuffer > vertexBuffer, GrPrimitiveRestart primitiveRestart=GrPrimitiveRestart::kNo)
GrVertexChunkArray fVertexChunkArray
sk_sp< const GrGpuBuffer > fFixedIndexBuffer
sk_sp< const GrGpuBuffer > fFixedVertexBuffer

◆ drawHullInstances()

void skgpu::ganesh::PathCurveTessellator::drawHullInstances ( GrOpFlushState flushState,
sk_sp< const GrGpuBuffer vertexBufferIfNeeded 
) const

Definition at line 232 of file PathTessellator.cpp.

233 {
234 for (const GrVertexChunk& chunk : fVertexChunkArray) {
235 flushState->bindBuffers(nullptr, chunk.fBuffer, vertexBufferIfNeeded);
236 flushState->drawInstanced(chunk.fCount, chunk.fBase, 4, 0);
237 }
238}
void drawInstanced(int instanceCount, int baseInstance, int vertexCount, int baseVertex)

◆ Make()

static PathCurveTessellator * skgpu::ganesh::PathCurveTessellator::Make ( SkArenaAlloc arena,
bool  infinitySupport,
PatchAttribs  attribs = PatchAttribs::kNone 
)
inlinestatic

Definition at line 91 of file PathTessellator.h.

93 {
94 return arena->make<PathCurveTessellator>(infinitySupport, attribs);
95 }
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
Definition: SkArenaAlloc.h:120
PathCurveTessellator(bool infinitySupport, PatchAttribs attribs=PatchAttribs::kNone)

◆ prepare()

void skgpu::ganesh::PathCurveTessellator::prepare ( GrMeshDrawTarget target,
const SkMatrix shaderMatrix,
const PathDrawList pathDrawList,
int  totalCombinedPathVerbCnt 
)
inlinefinalvirtual

Implements skgpu::ganesh::PathTessellator.

Definition at line 107 of file PathTessellator.h.

110 {
111 this->prepareWithTriangles(target,
112 shaderMatrix,
113 nullptr, // no extra triangles by default
114 pathDrawList,
115 totalCombinedPathVerbCnt);
116 }
void prepareWithTriangles(GrMeshDrawTarget *target, const SkMatrix &shaderMatrix, GrInnerFanTriangulator::BreadcrumbTriangleList *extraTriangles, const PathDrawList &pathDrawList, int totalCombinedPathVerbCnt)

◆ prepareWithTriangles()

void skgpu::ganesh::PathCurveTessellator::prepareWithTriangles ( GrMeshDrawTarget target,
const SkMatrix shaderMatrix,
GrInnerFanTriangulator::BreadcrumbTriangleList extraTriangles,
const PathDrawList pathDrawList,
int  totalCombinedPathVerbCnt 
)

Definition at line 156 of file PathTessellator.cpp.

161 {
162#if !defined(SK_ENABLE_OPTIMIZE_SIZE)
163 int patchPreallocCount = FixedCountCurves::PreallocCount(totalCombinedPathVerbCnt) +
164 (extraTriangles ? extraTriangles->count() : 0);
165#else
166 SkASSERT(!extraTriangles);
167 int patchPreallocCount = FixedCountCurves::PreallocCount(totalCombinedPathVerbCnt);
168#endif
169
170
171 if (patchPreallocCount) {
172 LinearTolerances worstCase;
173 CurveWriter writer{fAttribs, &worstCase, target, &fVertexChunkArray, patchPreallocCount};
174
175#if !defined(SK_ENABLE_OPTIMIZE_SIZE)
176 // Write out extra space-filling triangles to connect the curve patches with any external
177 // source of geometry (e.g. inner triangulation that handles winding explicitly).
178 if (extraTriangles) {
179 SkDEBUGCODE(int breadcrumbCount = 0;)
180 for (const auto* tri = extraTriangles->head(); tri; tri = tri->fNext) {
181 SkDEBUGCODE(++breadcrumbCount;)
182 auto p0 = skvx::float2::Load(tri->fPts);
183 auto p1 = skvx::float2::Load(tri->fPts + 1);
184 auto p2 = skvx::float2::Load(tri->fPts + 2);
185 if (any((p0 == p1) & (p1 == p2))) {
186 // Cull completely horizontal or vertical triangles. GrTriangulator can't always
187 // get these breadcrumb edges right when they run parallel to the sweep
188 // direction because their winding is undefined by its current definition.
189 // FIXME(skia:12060): This seemed safe, but if there is a view matrix it will
190 // introduce T-junctions.
191 continue;
192 }
193 writer.writeTriangle(p0, p1, p2);
194 }
195 SkASSERT(breadcrumbCount == extraTriangles->count());
196 }
197#endif
198
199 write_curve_patches(std::move(writer), shaderMatrix, pathDrawList);
201 }
202
203 GrResourceProvider* rp = target->resourceProvider();
204
205 SKGPU_DEFINE_STATIC_UNIQUE_KEY(gFixedCountCurveVertexBufferKey);
206
209 gFixedCountCurveVertexBufferKey,
211
212 SKGPU_DEFINE_STATIC_UNIQUE_KEY(gFixedCountCurveIndexBufferKey);
213
216 gFixedCountCurveIndexBufferKey,
218}
#define SKGPU_DEFINE_STATIC_UNIQUE_KEY(name)
Definition: ResourceKey.h:324
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
sk_sp< const GrGpuBuffer > findOrMakeStaticBuffer(GrGpuBufferType intendedType, size_t size, const skgpu::UniqueKey &key, InitializeBufferFn)
static void WriteIndexBuffer(VertexWriter, size_t bufferSize)
static constexpr size_t VertexBufferSize()
static int VertexCount(const LinearTolerances &tolerances)
static constexpr int PreallocCount(int totalCombinedPathVerbCnt)
static constexpr size_t IndexBufferSize()
static void WriteVertexBuffer(VertexWriter, size_t bufferSize)
uint32_t * target
SIT bool any(const Vec< 1, T > &x)
Definition: SkVx.h:530
static SKVX_ALWAYS_INLINE Vec Load(const void *ptr)
Definition: SkVx.h:109

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