Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
GrQuadBuffer< T > Class Template Reference

#include <GrQuadBuffer.h>

Classes

class  Iter
 
class  MetadataIter
 

Public Member Functions

 GrQuadBuffer ()
 
 GrQuadBuffer (int count, bool needsLocals=false)
 
int count () const
 
GrQuad::Type deviceQuadType () const
 
GrQuad::Type localQuadType () const
 
void append (const GrQuad &deviceQuad, T &&metadata, const GrQuad *localQuad=nullptr)
 
void concat (const GrQuadBuffer< T > &that)
 
Iter iterator () const
 
MetadataIter metadata ()
 

Detailed Description

template<typename T>
class GrQuadBuffer< T >

Definition at line 20 of file GrQuadBuffer.h.

Constructor & Destructor Documentation

◆ GrQuadBuffer() [1/2]

template<typename T >
GrQuadBuffer< T >::GrQuadBuffer ( )
inline

Definition at line 22 of file GrQuadBuffer.h.

23 : fCount(0)
24 , fDeviceType(GrQuad::Type::kAxisAligned)
25 , fLocalType(GrQuad::Type::kAxisAligned) {
26 // Pre-allocate space for 1 2D device-space quad, metadata, and header
27 fData.reserve(this->entrySize(fDeviceType, nullptr));
28 }
void reserve(int n)
Definition SkTDArray.h:187

◆ GrQuadBuffer() [2/2]

template<typename T >
GrQuadBuffer< T >::GrQuadBuffer ( int  count,
bool  needsLocals = false 
)
inline

Definition at line 34 of file GrQuadBuffer.h.

35 : fCount(0)
36 , fDeviceType(GrQuad::Type::kAxisAligned)
37 , fLocalType(GrQuad::Type::kAxisAligned) {
38 int entrySize = this->entrySize(fDeviceType, needsLocals ? &fLocalType : nullptr);
39 fData.reserve(count * entrySize);
40 }
int count() const

Member Function Documentation

◆ append()

template<typename T >
void GrQuadBuffer< T >::append ( const GrQuad deviceQuad,
T &&  metadata,
const GrQuad localQuad = nullptr 
)

Definition at line 271 of file GrQuadBuffer.h.

271 {
272 GrQuad::Type localType = localQuad ? localQuad->quadType() : GrQuad::Type::kAxisAligned;
273 int entrySize = this->entrySize(deviceQuad.quadType(), localQuad ? &localType : nullptr);
274
275 // Fill in the entry, as described in fData's declaration
276 char* entry = fData.append(entrySize);
277 // First the header
278 Header* h = this->header(entry);
279 h->fDeviceType = static_cast<unsigned>(deviceQuad.quadType());
280 h->fHasLocals = static_cast<unsigned>(localQuad != nullptr);
281 h->fLocalType = static_cast<unsigned>(localQuad ? localQuad->quadType()
283 SkDEBUGCODE(h->fSentinel = static_cast<unsigned>(kSentinel);)
284
285 // Second, the fixed-size metadata
286 static_assert(alignof(T) == 4, "Metadata must be 4 byte aligned");
287 *(this->metadata(entry)) = std::move(metadata);
288
289 // Then the variable blocks of x, y, and w float coordinates
290 float* coords = this->coords(entry);
291 coords = this->packQuad(deviceQuad, coords);
292 if (localQuad) {
293 coords = this->packQuad(*localQuad, coords);
294 }
295 SkASSERT((char*)coords - entry == entrySize);
296
297 // Entry complete, update buffer-level state
298 fCount++;
299 if (deviceQuad.quadType() > fDeviceType) {
300 fDeviceType = deviceQuad.quadType();
301 }
302 if (localQuad && localQuad->quadType() > fLocalType) {
303 fLocalType = localQuad->quadType();
304 }
305}
#define SkASSERT(cond)
Definition SkAssert.h:116
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
MetadataIter metadata()
Type quadType() const
Definition GrQuad.h:118
T * append()
Definition SkTDArray.h:191
SkScalar h
#define T
static const char header[]
Definition skpbench.cpp:88

◆ concat()

template<typename T >
void GrQuadBuffer< T >::concat ( const GrQuadBuffer< T > &  that)

Definition at line 308 of file GrQuadBuffer.h.

308 {
309 fData.append(that.fData.size(), that.fData.begin());
310 fCount += that.fCount;
311 if (that.fDeviceType > fDeviceType) {
312 fDeviceType = that.fDeviceType;
313 }
314 if (that.fLocalType > fLocalType) {
315 fLocalType = that.fLocalType;
316 }
317}
int size() const
Definition SkTDArray.h:138
T * begin()
Definition SkTDArray.h:150

◆ count()

template<typename T >
int GrQuadBuffer< T >::count ( ) const
inline

Definition at line 44 of file GrQuadBuffer.h.

44{ return fCount; }

◆ deviceQuadType()

template<typename T >
GrQuad::Type GrQuadBuffer< T >::deviceQuadType ( ) const
inline

Definition at line 47 of file GrQuadBuffer.h.

47{ return fDeviceType; }

◆ iterator()

template<typename T >
Iter GrQuadBuffer< T >::iterator ( ) const
inline

Definition at line 116 of file GrQuadBuffer.h.

116{ return Iter(this); }

◆ localQuadType()

template<typename T >
GrQuad::Type GrQuadBuffer< T >::localQuadType ( ) const
inline

Definition at line 51 of file GrQuadBuffer.h.

51{ return fLocalType; }

◆ metadata()

template<typename T >
MetadataIter GrQuadBuffer< T >::metadata ( )
inline

Definition at line 146 of file GrQuadBuffer.h.

146{ return MetadataIter(this); }

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