Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
GrMeshDrawOp::PatternHelper Class Reference

#include <GrMeshDrawOp.h>

Inheritance diagram for GrMeshDrawOp::PatternHelper:
GrMeshDrawOp::QuadHelper

Public Member Functions

 PatternHelper (GrMeshDrawTarget *, GrPrimitiveType, size_t vertexStride, sk_sp< const GrBuffer > indexBuffer, int verticesPerRepetition, int indicesPerRepetition, int repeatCount, int maxRepetitions)
 
void recordDraw (GrMeshDrawTarget *, const GrGeometryProcessor *) const
 
void recordDraw (GrMeshDrawTarget *, const GrGeometryProcessor *, const GrSurfaceProxy *const primProcProxies[]) const
 
void * vertices () const
 
GrSimpleMeshmesh ()
 

Protected Member Functions

 PatternHelper ()=default
 
void init (GrMeshDrawTarget *, GrPrimitiveType, size_t vertexStride, sk_sp< const GrBuffer > indexBuffer, int verticesPerRepetition, int indicesPerRepetition, int repeatCount, int maxRepetitions)
 

Detailed Description

Helper for rendering repeating meshes using a patterned index buffer. This class creates the space for the vertices and flushes the draws to the GrMeshDrawTarget.

Definition at line 55 of file GrMeshDrawOp.h.

Constructor & Destructor Documentation

◆ PatternHelper() [1/2]

GrMeshDrawOp::PatternHelper::PatternHelper ( GrMeshDrawTarget target,
GrPrimitiveType  primitiveType,
size_t  vertexStride,
sk_sp< const GrBuffer indexBuffer,
int  verticesPerRepetition,
int  indicesPerRepetition,
int  repeatCount,
int  maxRepetitions 
)

Definition at line 68 of file GrMeshDrawOp.cpp.

71 {
72 this->init(target, primitiveType, vertexStride, std::move(indexBuffer), verticesPerRepetition,
73 indicesPerRepetition, repeatCount, maxRepetitions);
74}
void init(GrMeshDrawTarget *, GrPrimitiveType, size_t vertexStride, sk_sp< const GrBuffer > indexBuffer, int verticesPerRepetition, int indicesPerRepetition, int repeatCount, int maxRepetitions)

◆ PatternHelper() [2/2]

GrMeshDrawOp::PatternHelper::PatternHelper ( )
protecteddefault

Member Function Documentation

◆ init()

void GrMeshDrawOp::PatternHelper::init ( GrMeshDrawTarget target,
GrPrimitiveType  primitiveType,
size_t  vertexStride,
sk_sp< const GrBuffer indexBuffer,
int  verticesPerRepetition,
int  indicesPerRepetition,
int  repeatCount,
int  maxRepetitions 
)
protected

Definition at line 76 of file GrMeshDrawOp.cpp.

79 {
81 if (!indexBuffer) {
82 return;
83 }
84 sk_sp<const GrBuffer> vertexBuffer;
85 int firstVertex;
86 int vertexCount = verticesPerRepetition * repeatCount;
87 fVertices = target->makeVertexSpace(vertexStride, vertexCount, &vertexBuffer, &firstVertex);
88 if (!fVertices) {
89 SkDebugf("Vertices could not be allocated for patterned rendering.");
90 return;
91 }
92 SkASSERT(vertexBuffer);
93 fMesh = target->allocMesh();
94 fPrimitiveType = primitiveType;
95
96 SkASSERT(maxRepetitions ==
97 static_cast<int>(indexBuffer->size() / (sizeof(uint16_t) * indicesPerRepetition)));
98 fMesh->setIndexedPatterned(std::move(indexBuffer), indicesPerRepetition, repeatCount,
99 maxRepetitions, std::move(vertexBuffer), verticesPerRepetition,
100 firstVertex);
101}
#define SkASSERT(cond)
Definition: SkAssert.h:116
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
virtual size_t size() const =0
uint32_t * target
void setIndexedPatterned(sk_sp< const GrBuffer > indexBuffer, int indexCount, int patternRepeatCount, int maxPatternRepetitionsInIndexBuffer, sk_sp< const GrBuffer > vertexBuffer, int patternVertexCount, int baseVertex)
Definition: GrSimpleMesh.h:77

◆ mesh()

GrSimpleMesh * GrMeshDrawOp::PatternHelper::mesh ( )
inline

Definition at line 67 of file GrMeshDrawOp.h.

67{ return fMesh; }

◆ recordDraw() [1/2]

void GrMeshDrawOp::PatternHelper::recordDraw ( GrMeshDrawTarget target,
const GrGeometryProcessor gp 
) const

Called to issue draws to the GrMeshDrawTarget.

Definition at line 103 of file GrMeshDrawOp.cpp.

104 {
105 target->recordDraw(gp, fMesh, 1, fPrimitiveType);
106}

◆ recordDraw() [2/2]

void GrMeshDrawOp::PatternHelper::recordDraw ( GrMeshDrawTarget target,
const GrGeometryProcessor gp,
const GrSurfaceProxy *const  primProcProxies[] 
) const

Definition at line 108 of file GrMeshDrawOp.cpp.

111 {
112 target->recordDraw(gp, fMesh, 1, primProcProxies, fPrimitiveType);
113}

◆ vertices()

void * GrMeshDrawOp::PatternHelper::vertices ( ) const
inline

Definition at line 66 of file GrMeshDrawOp.h.

66{ return fVertices; }

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