Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
impeller::VertexBufferBuilder< VertexType_, IndexType_ > Class Template Reference

#include <vertex_buffer_builder.h>

Public Types

using VertexType = VertexType_
 
using IndexType = IndexType_
 

Public Member Functions

 VertexBufferBuilder ()=default
 
 ~VertexBufferBuilder ()=default
 
constexpr impeller::IndexType GetIndexType () const
 
void SetLabel (const std::string &label)
 
void Reserve (size_t count)
 
void ReserveIndices (size_t count)
 
bool HasVertices () const
 
size_t GetVertexCount () const
 
size_t GetIndexCount () const
 
const VertexTypeLast () const
 
VertexBufferBuilderAppendVertex (VertexType_ vertex)
 
VertexBufferBuilderAddVertices (std::initializer_list< VertexType_ > vertices)
 
VertexBufferBuilderAppendIndex (IndexType_ index)
 
VertexBuffer CreateVertexBuffer (HostBuffer &host_buffer) const
 
VertexBuffer CreateVertexBuffer (Allocator &device_allocator) const
 
void IterateVertices (const std::function< void(VertexType &)> &iterator)
 

Detailed Description

template<class VertexType_, class IndexType_ = uint16_t>
class impeller::VertexBufferBuilder< VertexType_, IndexType_ >

Definition at line 24 of file vertex_buffer_builder.h.

Member Typedef Documentation

◆ IndexType

template<class VertexType_ , class IndexType_ = uint16_t>
using impeller::VertexBufferBuilder< VertexType_, IndexType_ >::IndexType = IndexType_

Definition at line 27 of file vertex_buffer_builder.h.

◆ VertexType

template<class VertexType_ , class IndexType_ = uint16_t>
using impeller::VertexBufferBuilder< VertexType_, IndexType_ >::VertexType = VertexType_

Definition at line 26 of file vertex_buffer_builder.h.

Constructor & Destructor Documentation

◆ VertexBufferBuilder()

template<class VertexType_ , class IndexType_ = uint16_t>
impeller::VertexBufferBuilder< VertexType_, IndexType_ >::VertexBufferBuilder ( )
default

◆ ~VertexBufferBuilder()

template<class VertexType_ , class IndexType_ = uint16_t>
impeller::VertexBufferBuilder< VertexType_, IndexType_ >::~VertexBufferBuilder ( )
default

Member Function Documentation

◆ AddVertices()

template<class VertexType_ , class IndexType_ = uint16_t>
VertexBufferBuilder & impeller::VertexBufferBuilder< VertexType_, IndexType_ >::AddVertices ( std::initializer_list< VertexType_ >  vertices)
inline

Definition at line 70 of file vertex_buffer_builder.h.

71 {
72 vertices_.reserve(vertices.size());
73 for (auto& vertex : vertices) {
74 vertices_.emplace_back(std::move(vertex));
75 }
76 return *this;
77 }

◆ AppendIndex()

template<class VertexType_ , class IndexType_ = uint16_t>
VertexBufferBuilder & impeller::VertexBufferBuilder< VertexType_, IndexType_ >::AppendIndex ( IndexType_  index)
inline

Definition at line 79 of file vertex_buffer_builder.h.

79 {
80 indices_.emplace_back(index);
81 return *this;
82 }

◆ AppendVertex()

template<class VertexType_ , class IndexType_ = uint16_t>
VertexBufferBuilder & impeller::VertexBufferBuilder< VertexType_, IndexType_ >::AppendVertex ( VertexType_  vertex)
inline

Definition at line 65 of file vertex_buffer_builder.h.

65 {
66 vertices_.emplace_back(std::move(vertex));
67 return *this;
68 }

◆ CreateVertexBuffer() [1/2]

template<class VertexType_ , class IndexType_ = uint16_t>
VertexBuffer impeller::VertexBufferBuilder< VertexType_, IndexType_ >::CreateVertexBuffer ( Allocator device_allocator) const
inline

Definition at line 93 of file vertex_buffer_builder.h.

93 {
95 // This can be merged into a single allocation.
96 buffer.vertex_buffer = CreateVertexBufferView(device_allocator);
97 buffer.index_buffer = CreateIndexBufferView(device_allocator);
98 buffer.vertex_count = GetIndexCount();
99 buffer.index_type = GetIndexType();
100 return buffer;
101 };
constexpr impeller::IndexType GetIndexType() const
static const uint8_t buffer[]

◆ CreateVertexBuffer() [2/2]

template<class VertexType_ , class IndexType_ = uint16_t>
VertexBuffer impeller::VertexBufferBuilder< VertexType_, IndexType_ >::CreateVertexBuffer ( HostBuffer host_buffer) const
inline

Definition at line 84 of file vertex_buffer_builder.h.

84 {
86 buffer.vertex_buffer = CreateVertexBufferView(host_buffer);
87 buffer.index_buffer = CreateIndexBufferView(host_buffer);
88 buffer.vertex_count = GetIndexCount();
89 buffer.index_type = GetIndexType();
90 return buffer;
91 };

◆ GetIndexCount()

template<class VertexType_ , class IndexType_ = uint16_t>
size_t impeller::VertexBufferBuilder< VertexType_, IndexType_ >::GetIndexCount ( ) const
inline

Definition at line 56 of file vertex_buffer_builder.h.

56 {
57 return indices_.size() > 0 ? indices_.size() : vertices_.size();
58 }

◆ GetIndexType()

template<class VertexType_ , class IndexType_ = uint16_t>
constexpr impeller::IndexType impeller::VertexBufferBuilder< VertexType_, IndexType_ >::GetIndexType ( ) const
inlineconstexpr

Definition at line 33 of file vertex_buffer_builder.h.

33 {
34 if (indices_.size() == 0) {
36 }
37 if constexpr (sizeof(IndexType) == 2) {
39 }
40 if (sizeof(IndexType) == 4) {
42 }
44 }
@ kNone
Does not use the index buffer.

◆ GetVertexCount()

template<class VertexType_ , class IndexType_ = uint16_t>
size_t impeller::VertexBufferBuilder< VertexType_, IndexType_ >::GetVertexCount ( ) const
inline

Definition at line 54 of file vertex_buffer_builder.h.

54{ return vertices_.size(); }

◆ HasVertices()

template<class VertexType_ , class IndexType_ = uint16_t>
bool impeller::VertexBufferBuilder< VertexType_, IndexType_ >::HasVertices ( ) const
inline

Definition at line 52 of file vertex_buffer_builder.h.

52{ return !vertices_.empty(); }

◆ IterateVertices()

template<class VertexType_ , class IndexType_ = uint16_t>
void impeller::VertexBufferBuilder< VertexType_, IndexType_ >::IterateVertices ( const std::function< void(VertexType &)> &  iterator)
inline

Definition at line 103 of file vertex_buffer_builder.h.

103 {
104 for (auto& vertex : vertices_) {
105 iterator(vertex);
106 }
107 }

◆ Last()

template<class VertexType_ , class IndexType_ = uint16_t>
const VertexType & impeller::VertexBufferBuilder< VertexType_, IndexType_ >::Last ( ) const
inline

Definition at line 60 of file vertex_buffer_builder.h.

60 {
61 FML_DCHECK(!vertices_.empty());
62 return vertices_.back();
63 }
#define FML_DCHECK(condition)
Definition logging.h:103

◆ Reserve()

template<class VertexType_ , class IndexType_ = uint16_t>
void impeller::VertexBufferBuilder< VertexType_, IndexType_ >::Reserve ( size_t  count)
inline

Definition at line 48 of file vertex_buffer_builder.h.

48{ return vertices_.reserve(count); }
int count

◆ ReserveIndices()

template<class VertexType_ , class IndexType_ = uint16_t>
void impeller::VertexBufferBuilder< VertexType_, IndexType_ >::ReserveIndices ( size_t  count)
inline

Definition at line 50 of file vertex_buffer_builder.h.

50{ return indices_.reserve(count); }

◆ SetLabel()

template<class VertexType_ , class IndexType_ = uint16_t>
void impeller::VertexBufferBuilder< VertexType_, IndexType_ >::SetLabel ( const std::string &  label)
inline

Definition at line 46 of file vertex_buffer_builder.h.

46{ label_ = label; }

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