Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
GrGeometryProcessor::Attribute Class Reference

#include <GrGeometryProcessor.h>

Public Member Functions

constexpr Attribute ()=default
 
constexpr Attribute (const char *name, GrVertexAttribType cpuType, SkSLType gpuType)
 
constexpr Attribute (const char *name, GrVertexAttribType cpuType, SkSLType gpuType, size_t offset)
 
constexpr Attribute (const Attribute &)=default
 
Attributeoperator= (const Attribute &)=default
 
constexpr bool isInitialized () const
 
constexpr const char * name () const
 
constexpr GrVertexAttribType cpuType () const
 
constexpr SkSLType gpuType () const
 
std::optional< size_t > offset () const
 
constexpr size_t size () const
 
GrShaderVar asShaderVar () const
 

Static Public Member Functions

static constexpr size_t AlignOffset (size_t offset)
 

Detailed Description

Describes a vertex or instance attribute.

Definition at line 66 of file GrGeometryProcessor.h.

Constructor & Destructor Documentation

◆ Attribute() [1/4]

constexpr GrGeometryProcessor::Attribute::Attribute ( )
constexprdefault

◆ Attribute() [2/4]

constexpr GrGeometryProcessor::Attribute::Attribute ( const char *  name,
GrVertexAttribType  cpuType,
SkSLType  gpuType 
)
inlineconstexpr

Makes an attribute whose offset will be implicitly determined by the types and ordering of an array attributes.

Definition at line 75 of file GrGeometryProcessor.h.

78 : fName(name), fCPUType(cpuType), fGPUType(gpuType) {
80 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
constexpr GrVertexAttribType cpuType() const
constexpr const char * name() const
constexpr SkSLType gpuType() const

◆ Attribute() [3/4]

constexpr GrGeometryProcessor::Attribute::Attribute ( const char *  name,
GrVertexAttribType  cpuType,
SkSLType  gpuType,
size_t  offset 
)
inlineconstexpr

Makes an attribute with an explicit offset.

Definition at line 84 of file GrGeometryProcessor.h.

88 : fName(name), fCPUType(cpuType), fGPUType(gpuType), fOffset(SkToU32(offset)) {
91 }
constexpr uint32_t SkToU32(S x)
Definition: SkTo.h:26
std::optional< size_t > offset() const
static constexpr size_t AlignOffset(size_t offset)

◆ Attribute() [4/4]

constexpr GrGeometryProcessor::Attribute::Attribute ( const Attribute )
constexprdefault

Member Function Documentation

◆ AlignOffset()

static constexpr size_t GrGeometryProcessor::Attribute::AlignOffset ( size_t  offset)
inlinestaticconstexpr

Definition at line 68 of file GrGeometryProcessor.h.

68{ return SkAlign4(offset); }
static constexpr T SkAlign4(T x)
Definition: SkAlign.h:16

◆ asShaderVar()

GrShaderVar GrGeometryProcessor::Attribute::asShaderVar ( ) const
inline

Definition at line 116 of file GrGeometryProcessor.h.

116 {
117 return {fName, fGPUType, GrShaderVar::TypeModifier::In};
118 }

◆ cpuType()

constexpr GrVertexAttribType GrGeometryProcessor::Attribute::cpuType ( ) const
inlineconstexpr

Definition at line 99 of file GrGeometryProcessor.h.

99{ return fCPUType; }

◆ gpuType()

constexpr SkSLType GrGeometryProcessor::Attribute::gpuType ( ) const
inlineconstexpr

Definition at line 100 of file GrGeometryProcessor.h.

100{ return fGPUType; }

◆ isInitialized()

constexpr bool GrGeometryProcessor::Attribute::isInitialized ( ) const
inlineconstexpr

Definition at line 96 of file GrGeometryProcessor.h.

96{ return fGPUType != SkSLType::kVoid; }

◆ name()

constexpr const char * GrGeometryProcessor::Attribute::name ( ) const
inlineconstexpr

Definition at line 98 of file GrGeometryProcessor.h.

98{ return fName; }

◆ offset()

std::optional< size_t > GrGeometryProcessor::Attribute::offset ( ) const
inline

Returns the offset if attributes were specified with explicit offsets. Otherwise, offsets (and total vertex stride) are implicitly determined from attribute order and types.

Definition at line 106 of file GrGeometryProcessor.h.

106 {
107 if (fOffset != kImplicitOffset) {
108 SkASSERT(AlignOffset(fOffset) == fOffset);
109 return {fOffset};
110 }
111 return std::nullopt;
112 }

◆ operator=()

Attribute & GrGeometryProcessor::Attribute::operator= ( const Attribute )
default

◆ size()

constexpr size_t GrGeometryProcessor::Attribute::size ( ) const
inlineconstexpr

Definition at line 566 of file GrGeometryProcessor.h.

566 {
567 return GrVertexAttribTypeSize(fCPUType);
568}
static constexpr size_t GrVertexAttribTypeSize(GrVertexAttribType type)

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