Flutter Impeller
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 35 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 38 of file vertex_buffer_builder.h.

◆ VertexType

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

Definition at line 37 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 81 of file vertex_buffer_builder.h.

82  {
83  vertices_.reserve(vertices.size());
84  for (auto& vertex : vertices) {
85  vertices_.emplace_back(std::move(vertex));
86  }
87  return *this;
88  }

Referenced by impeller::testing::RendererDartTest::RenderDartToPlayground(), and impeller::testing::TEST_P().

◆ AppendIndex()

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

Definition at line 90 of file vertex_buffer_builder.h.

90  {
91  indices_.emplace_back(index);
92  return *this;
93  }

Referenced by impeller::testing::TEST_P().

◆ AppendVertex()

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

Definition at line 76 of file vertex_buffer_builder.h.

76  {
77  vertices_.emplace_back(std::move(vertex));
78  return *this;
79  }

◆ CreateVertexBuffer() [1/2]

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

Definition at line 104 of file vertex_buffer_builder.h.

104  {
105  VertexBuffer buffer;
106  // This can be merged into a single allocation.
107  buffer.vertex_buffer = CreateVertexBufferView(device_allocator);
108  buffer.index_buffer = CreateIndexBufferView(device_allocator);
109  buffer.vertex_count = GetIndexCount();
110  buffer.index_type = GetIndexType();
111  return buffer;
112  };
constexpr impeller::IndexType GetIndexType() const

References impeller::VertexBufferBuilder< VertexType_, IndexType_ >::GetIndexCount(), impeller::VertexBufferBuilder< VertexType_, IndexType_ >::GetIndexType(), impeller::VertexBuffer::index_buffer, impeller::VertexBuffer::index_type, impeller::VertexBuffer::vertex_buffer, and impeller::VertexBuffer::vertex_count.

◆ CreateVertexBuffer() [2/2]

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

Definition at line 95 of file vertex_buffer_builder.h.

95  {
96  VertexBuffer buffer;
97  buffer.vertex_buffer = CreateVertexBufferView(host_buffer);
98  buffer.index_buffer = CreateIndexBufferView(host_buffer);
99  buffer.vertex_count = GetIndexCount();
100  buffer.index_type = GetIndexType();
101  return buffer;
102  };

References impeller::VertexBufferBuilder< VertexType_, IndexType_ >::GetIndexCount(), impeller::VertexBufferBuilder< VertexType_, IndexType_ >::GetIndexType(), impeller::VertexBuffer::index_buffer, impeller::VertexBuffer::index_type, impeller::VertexBuffer::vertex_buffer, and impeller::VertexBuffer::vertex_count.

Referenced by impeller::testing::RendererDartTest::RenderDartToPlayground(), and impeller::testing::TEST_P().

◆ GetIndexCount()

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

Definition at line 67 of file vertex_buffer_builder.h.

67  {
68  return indices_.size() > 0 ? indices_.size() : vertices_.size();
69  }

Referenced by impeller::VertexBufferBuilder< VertexType_, IndexType_ >::CreateVertexBuffer(), and impeller::testing::TEST_P().

◆ GetIndexType()

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

Definition at line 44 of file vertex_buffer_builder.h.

44  {
45  if (indices_.size() == 0) {
47  }
48  if constexpr (sizeof(IndexType) == 2) {
50  }
51  if (sizeof(IndexType) == 4) {
53  }
55  }
@ kNone
Does not use the index buffer.

References impeller::k16bit, impeller::k32bit, impeller::kNone, and impeller::kUnknown.

Referenced by impeller::VertexBufferBuilder< VertexType_, IndexType_ >::CreateVertexBuffer(), and impeller::testing::TEST_P().

◆ GetVertexCount()

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

Definition at line 65 of file vertex_buffer_builder.h.

65 { return vertices_.size(); }

Referenced by impeller::testing::TEST_P().

◆ HasVertices()

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

Definition at line 63 of file vertex_buffer_builder.h.

63 { 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 114 of file vertex_buffer_builder.h.

114  {
115  for (auto& vertex : vertices_) {
116  iterator(vertex);
117  }
118  }

◆ Last()

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

Definition at line 71 of file vertex_buffer_builder.h.

71  {
72  FML_DCHECK(!vertices_.empty());
73  return vertices_.back();
74  }

◆ Reserve()

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

Definition at line 59 of file vertex_buffer_builder.h.

59 { return vertices_.reserve(count); }

◆ ReserveIndices()

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

Definition at line 61 of file vertex_buffer_builder.h.

61 { 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 57 of file vertex_buffer_builder.h.

57 { label_ = label; }

Referenced by impeller::testing::TEST_P().


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