5#ifndef FLUTTER_IMPELLER_RENDERER_VERTEX_BUFFER_BUILDER_H_
6#define FLUTTER_IMPELLER_RENDERER_VERTEX_BUFFER_BUILDER_H_
8#include <initializer_list>
20template <
class VertexType_,
class IndexType_ = u
int16_t>
31 if (indices_.size() == 0) {
43 void SetLabel(
const std::string& label) { label_ = label; }
54 return indices_.size() > 0 ? indices_.size() : vertices_.size();
59 return vertices_.back();
63 vertices_.emplace_back(std::move(vertex));
68 std::initializer_list<VertexType_> vertices) {
69 vertices_.reserve(vertices.size());
70 for (
auto& vertex : vertices) {
71 vertices_.emplace_back(std::move(vertex));
77 indices_.emplace_back(index);
83 buffer.vertex_buffer = CreateVertexBufferView(host_buffer);
84 buffer.index_buffer = CreateIndexBufferView(host_buffer);
93 buffer.vertex_buffer = CreateVertexBufferView(device_allocator);
94 buffer.index_buffer = CreateIndexBufferView(device_allocator);
101 for (
auto& vertex : vertices_) {
107 std::vector<VertexType> vertices_;
108 std::vector<IndexType> indices_;
112 return buffer.Emplace(vertices_.data(),
117 BufferView CreateVertexBufferView(
Allocator& allocator)
const {
118 auto buffer = allocator.CreateBufferWithCopy(
119 reinterpret_cast<const uint8_t*
>(vertices_.data()),
124 if (!label_.empty()) {
130 std::vector<IndexType> CreateIndexBuffer()
const {
return indices_; }
132 BufferView CreateIndexBufferView(HostBuffer&
buffer)
const {
133 const auto index_buffer = CreateIndexBuffer();
134 if (index_buffer.size() == 0) {
137 return buffer.Emplace(index_buffer.data(),
142 BufferView CreateIndexBufferView(
Allocator& allocator)
const {
143 const auto index_buffer = CreateIndexBuffer();
144 if (index_buffer.size() == 0) {
147 auto buffer = allocator.CreateBufferWithCopy(
148 reinterpret_cast<const uint8_t*
>(index_buffer.data()),
149 index_buffer.size() *
sizeof(
IndexType));
153 if (!label_.empty()) {
An object that allocates device memory.
static BufferView AsBufferView(std::shared_ptr< DeviceBuffer > buffer)
Create a buffer view of this entire buffer.
VertexBuffer CreateVertexBuffer(HostBuffer &host_buffer) const
size_t GetVertexCount() const
VertexBufferBuilder & AppendVertex(VertexType_ vertex)
const VertexType & Last() const
~VertexBufferBuilder()=default
VertexBufferBuilder()=default
size_t GetIndexCount() const
void ReserveIndices(size_t count)
void IterateVertices(const std::function< void(VertexType &)> &iterator)
void Reserve(size_t count)
VertexBuffer CreateVertexBuffer(Allocator &device_allocator) const
VertexBufferBuilder & AppendIndex(IndexType_ index)
void SetLabel(const std::string &label)
VertexBufferBuilder & AddVertices(std::initializer_list< VertexType_ > vertices)
constexpr impeller::IndexType GetIndexType() const
#define FML_DCHECK(condition)
Dart_NativeFunction function
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
@ kNone
Does not use the index buffer.
std::string SPrintF(const char *format,...)