26 needed += vertex_count *
sizeof(
DlPoint);
27 if (flags.has_texture_coordinates) {
28 needed += vertex_count *
sizeof(
DlPoint);
30 if (flags.has_colors) {
31 needed += vertex_count *
sizeof(
DlColor);
33 if (index_count > 0) {
34 needed += index_count *
sizeof(uint16_t);
43 const DlPoint texture_coordinates[],
46 const uint16_t indices[],
50 texture_coordinates =
nullptr;
61 if (texture_coordinates) {
70 if (texture_coordinates) {
79 if (bounds !=
nullptr) {
83 return builder.
build();
88 {{texture_coordinates_offset_ > 0, colors_offset_ > 0}},
94 for (
int i = 0;
i < count;
i++) {
101 int unchecked_vertex_count,
103 const DlPoint* texture_coordinates,
104 const DlColor* colors,
105 int unchecked_index_count,
106 const uint16_t* indices,
109 vertex_count_(
std::max(unchecked_vertex_count, 0)),
110 index_count_(indices ?
std::max(unchecked_index_count, 0) : 0) {
111 bounds_ = bounds ? *bounds :
compute_bounds(vertices, vertex_count_);
113 char* pod =
reinterpret_cast<char*
>(
this);
114 size_t offset =
sizeof(DlVertices);
116 auto advance = [pod, &offset](
auto* src,
int count) {
117 if (src !=
nullptr && count > 0) {
118 size_t bytes = count *
sizeof(*src);
119 memcpy(pod + offset, src, bytes);
124 return static_cast<size_t>(0);
128 vertices_offset_ = advance(vertices, vertex_count_);
129 texture_coordinates_offset_ = advance(texture_coordinates, vertex_count_);
130 colors_offset_ = advance(colors, vertex_count_);
131 indices_offset_ = advance(indices, index_count_);
133 {{!!texture_coordinates, !!colors}},
137DlVertices::DlVertices(
const DlVertices* other)
138 : DlVertices(other->mode_,
139 other->vertex_count_,
140 other->vertex_data(),
141 other->texture_coordinate_data(),
147DlVertices::DlVertices(DlVertexMode mode,
148 int unchecked_vertex_count,
150 int unchecked_index_count)
152 vertex_count_(
std::max(unchecked_vertex_count, 0)),
153 index_count_(
std::max(unchecked_index_count, 0)) {
154 char* pod =
reinterpret_cast<char*
>(
this);
155 size_t offset =
sizeof(DlVertices);
157 auto advance = [pod, &offset](
size_t size,
int count) {
159 size_t bytes = count *
size;
160 memset(pod + offset, 0, bytes);
165 return static_cast<size_t>(0);
169 vertices_offset_ = advance(
sizeof(
DlPoint), vertex_count_);
170 texture_coordinates_offset_ = advance(
171 sizeof(
DlPoint), flags.has_texture_coordinates ? vertex_count_ : 0);
173 advance(
sizeof(DlColor), flags.has_colors ? vertex_count_ : 0);
174 indices_offset_ = advance(
sizeof(uint16_t), index_count_);
176 FML_DCHECK((vertex_count_ != 0) == (vertex_data() !=
nullptr));
177 FML_DCHECK((vertex_count_ != 0 && flags.has_texture_coordinates) ==
178 (texture_coordinate_data() !=
nullptr));
179 FML_DCHECK((vertex_count_ != 0 && flags.has_colors) == (colors() !=
nullptr));
180 FML_DCHECK((index_count_ != 0) == (indices() !=
nullptr));
184 auto lists_equal = [](
auto* a,
auto* b,
int count) {
185 if (a ==
nullptr || b ==
nullptr) {
188 for (
int i = 0;
i < count;
i++) {
196 mode_ == other.mode_ &&
197 vertex_count_ == other.vertex_count_ &&
198 lists_equal(vertex_data(), other.
vertex_data(), vertex_count_) &&
199 lists_equal(texture_coordinate_data(),
202 lists_equal(colors(), other.
colors(), vertex_count_) &&
203 index_count_ == other.index_count_ &&
204 lists_equal(indices(), other.
indices(), index_count_);
211 : needs_texture_coords_(flags.has_texture_coordinates),
212 needs_colors_(flags.has_colors),
213 needs_indices_(index_count > 0) {
218 vertices_.reset(
new (storage)
223static void store_points(
char* dst,
int offset,
const float* src,
int count) {
225 for (
int i = 0;
i < count;
i++) {
233 char* pod =
reinterpret_cast<char*
>(vertices_.get());
234 size_t bytes = vertices_->vertex_count_ *
sizeof(vertices[0]);
235 memcpy(pod + vertices_->vertices_offset_, vertices, bytes);
236 needs_vertices_ =
false;
242 char* pod =
reinterpret_cast<char*
>(vertices_.get());
243 store_points(pod, vertices_->vertices_offset_, vertices,
244 vertices_->vertex_count_);
245 needs_vertices_ =
false;
251 char* pod =
reinterpret_cast<char*
>(vertices_.get());
252 size_t bytes = vertices_->vertex_count_ *
sizeof(coords[0]);
253 memcpy(pod + vertices_->texture_coordinates_offset_, coords, bytes);
254 needs_texture_coords_ =
false;
260 char* pod =
reinterpret_cast<char*
>(vertices_.get());
261 store_points(pod, vertices_->texture_coordinates_offset_, coords,
262 vertices_->vertex_count_);
263 needs_texture_coords_ =
false;
269 char* pod =
reinterpret_cast<char*
>(vertices_.get());
270 size_t bytes = vertices_->vertex_count_ *
sizeof(
colors[0]);
271 memcpy(pod + vertices_->colors_offset_,
colors, bytes);
272 needs_colors_ =
false;
278 char* pod =
reinterpret_cast<char*
>(vertices_.get());
280 reinterpret_cast<DlColor*
>(pod + vertices_->colors_offset_);
281 for (
int i = 0;
i < vertices_->vertex_count_; ++
i) {
284 needs_colors_ =
false;
290 char* pod =
reinterpret_cast<char*
>(vertices_.get());
291 size_t bytes = vertices_->index_count_ *
sizeof(
indices[0]);
292 memcpy(pod + vertices_->indices_offset_,
indices, bytes);
293 needs_indices_ =
false;
297 vertices_->bounds_ = bounds;
298 needs_bounds_ =
false;
303 if (vertices_->vertex_count() <= 0) {
307 needs_vertices_ =
false;
316 compute_bounds(vertices_->vertex_data(), vertices_->vertex_count_);
319 return std::move(vertices_);
void accumulate(DlScalar x, DlScalar y)
A utility class to build up a |DlVertices| object one set of data at a time.
void store_vertices(const DlPoint vertices[])
Copies the indicated list of points as vertices.
void store_indices(const uint16_t indices[])
Copies the indicated list of 16-bit indices as vertex indices.
void store_texture_coordinates(const DlPoint points[])
Copies the indicated list of points as texture coordinates.
void store_bounds(DlRect bounds)
Overwrite the internal bounds with a precomputed bounding rect.
std::shared_ptr< DlVertices > build()
Finalizes and the constructed DlVertices object.
static constexpr Flags kHasColors
void store_colors(const DlColor colors[])
Copies the indicated list of colors as vertex colors.
static constexpr Flags kHasTextureCoordinates
Holds all of the data (both required and optional) for a DisplayList drawVertices call.
static std::shared_ptr< DlVertices > Make(DlVertexMode mode, int vertex_count, const DlPoint vertices[], const DlPoint texture_coordinates[], const DlColor colors[], int index_count=0, const uint16_t indices[]=nullptr, const DlRect *bounds=nullptr)
Constructs a DlVector with compact inline storage for all of its required and optional lists of data.
const DlPoint * texture_coordinate_data() const
const DlPoint * vertex_data() const
Returns a pointer to the vertex information. Should be non-null.
const DlColor * colors() const
DlVertexMode mode() const
size_t size() const
Returns the size of the object including all of the inlined data.
const uint16_t * indices() const
#define FML_DCHECK(condition)
static void DlVerticesDeleter(void *p)
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
static DlRect compute_bounds(const DlPoint *points, int count)
DlVertexMode
Defines the way in which the vertices of a DlVertices object are separated into triangles into which ...
static void store_points(char *dst, int offset, const float *src, int count)
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
static size_t bytes_needed(int vertex_count, Flags flags, int index_count)
std::vector< Point > points
flags to indicate/promise which of the optional texture coordinates or colors will be supplied during...