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 (std::string label)
 
void Reserve (size_t count)
 
void ReserveIndices (size_t count)
 
bool HasVertices () const
 
size_t GetVertexCount () const
 
size_t GetIndexCount () 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 23 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 26 of file vertex_buffer_builder.h.

◆ VertexType

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

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

65  {
66  vertices_.reserve(vertices.size());
67  for (auto& vertex : vertices) {
68  vertices_.emplace_back(std::move(vertex));
69  }
70  return *this;
71  }

Referenced by impeller::AdvancedBlend(), impeller::scene::CuboidGeometry::GetVertexBuffer(), impeller::PipelineBlend(), impeller::CheckerboardContents::Render(), impeller::ClipContents::Render(), impeller::SolidRRectBlurContents::Render(), impeller::TextureContents::Render(), impeller::ClipRestoreContents::Render(), 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 73 of file vertex_buffer_builder.h.

73  {
74  indices_.emplace_back(index);
75  return *this;
76  }

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 59 of file vertex_buffer_builder.h.

59  {
60  vertices_.emplace_back(std::move(vertex));
61  return *this;
62  }

Referenced by impeller::ComputeUVGeometryCPU(), impeller::AtlasContents::Render(), impeller::AtlasTextureContents::Render(), impeller::AtlasColorContents::Render(), and impeller::testing::TEST_P().

◆ CreateVertexBuffer() [1/2]

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

Definition at line 87 of file vertex_buffer_builder.h.

87  {
88  VertexBuffer buffer;
89  // This can be merged into a single allocation.
90  buffer.vertex_buffer = CreateVertexBufferView(device_allocator);
91  buffer.index_buffer = CreateIndexBufferView(device_allocator);
92  buffer.vertex_count = GetIndexCount();
93  buffer.index_type = GetIndexType();
94  return buffer;
95  };

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]

◆ GetIndexCount()

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

Definition at line 55 of file vertex_buffer_builder.h.

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

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 32 of file vertex_buffer_builder.h.

32  {
33  if (indices_.size() == 0) {
35  }
36  if constexpr (sizeof(IndexType) == 2) {
38  }
39  if (sizeof(IndexType) == 4) {
41  }
43  }

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 53 of file vertex_buffer_builder.h.

53 { return vertices_.size(); }

Referenced by impeller::ComputeUVGeometryCPU(), and impeller::testing::TEST_P().

◆ HasVertices()

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

Definition at line 51 of file vertex_buffer_builder.h.

51 { return !vertices_.empty(); }

Referenced by impeller::AtlasTextureContents::Render(), and impeller::AtlasColorContents::Render().

◆ IterateVertices()

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

Definition at line 97 of file vertex_buffer_builder.h.

97  {
98  for (auto& vertex : vertices_) {
99  iterator(vertex);
100  }
101  }

Referenced by impeller::ComputeUVGeometryCPU().

◆ Reserve()

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

◆ ReserveIndices()

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

Definition at line 49 of file vertex_buffer_builder.h.

49 { return indices_.reserve(count); }

◆ SetLabel()

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

Definition at line 45 of file vertex_buffer_builder.h.

45 { label_ = std::move(label); }

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


The documentation for this class was generated from the following file:
impeller::IndexType::k16bit
@ k16bit
impeller::IndexType::k32bit
@ k32bit
impeller::VertexBufferBuilder::GetIndexCount
size_t GetIndexCount() const
Definition: vertex_buffer_builder.h:55
impeller::IndexType::kNone
@ kNone
Does not use the index buffer.
impeller::VertexBufferBuilder::IndexType
IndexType_ IndexType
Definition: vertex_buffer_builder.h:26
impeller::VertexBufferBuilder::GetIndexType
constexpr impeller::IndexType GetIndexType() const
Definition: vertex_buffer_builder.h:32
impeller::IndexType::kUnknown
@ kUnknown