Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
skgpu::VertexColor Class Reference

#include <BufferWriter.h>

Public Member Functions

 VertexColor ()=default
 
 VertexColor (const SkPMColor4f &color, bool wideColor)
 
void set (const SkPMColor4f &color, bool wideColor)
 
size_t size () const
 

Friends

template<typename T >
VertexWriteroperator<< (VertexWriter &, const T &)
 

Detailed Description

VertexColor is a helper for writing colors to a vertex buffer. It outputs either four bytes or or four float32 channels, depending on the wideColor parameter. Note that the GP needs to have been constructed with the correct attribute type for colors, to match the usage here.

Definition at line 340 of file BufferWriter.h.

Constructor & Destructor Documentation

◆ VertexColor() [1/2]

skgpu::VertexColor::VertexColor ( )
default

◆ VertexColor() [2/2]

skgpu::VertexColor::VertexColor ( const SkPMColor4f color,
bool  wideColor 
)
inlineexplicit

Definition at line 344 of file BufferWriter.h.

344 {
345 this->set(color, wideColor);
346 }
SkColor4f color
void set(const SkPMColor4f &color, bool wideColor)

Member Function Documentation

◆ set()

void skgpu::VertexColor::set ( const SkPMColor4f color,
bool  wideColor 
)
inline

Definition at line 348 of file BufferWriter.h.

348 {
349 if (wideColor) {
350 memcpy(fColor, color.vec(), sizeof(fColor));
351 } else {
352 fColor[0] = color.toBytes_RGBA();
353 }
354 fWideColor = wideColor;
355 }

◆ size()

size_t skgpu::VertexColor::size ( ) const
inline

Definition at line 357 of file BufferWriter.h.

357{ return fWideColor ? 16 : 4; }

Friends And Related Symbol Documentation

◆ operator<<

template<typename T >
VertexWriter & operator<< ( VertexWriter w,
const T val 
)
friend

Definition at line 277 of file BufferWriter.h.

277 {
278 static_assert(std::is_trivially_copyable<T>::value, "");
279 w.validate(sizeof(T));
280 memcpy(w.fPtr, &val, sizeof(T));
281 w = w.makeOffset(sizeof(T));
282 return w;
283}
SkScalar w
#define T

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