5#include "flutter/display_list/dl_vertices.h"
7#include "flutter/display_list/utils/dl_accumulation_rect.h"
8#include "flutter/fml/logging.h"
26 needed += vertex_count *
sizeof(
SkPoint);
27 if (
flags.has_texture_coordinates) {
28 needed += vertex_count *
sizeof(
SkPoint);
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 SkPoint texture_coordinates[],
46 const uint16_t indices[]) {
84 {{texture_coordinates_offset_ > 0, colors_offset_ > 0}},
93 return accumulator.
bounds();
97 int unchecked_vertex_count,
99 const SkPoint* texture_coordinates,
101 int unchecked_index_count,
102 const uint16_t* indices,
105 vertex_count_(
std::
max(unchecked_vertex_count, 0)),
106 index_count_(indices ?
std::
max(unchecked_index_count, 0) : 0) {
109 char* pod =
reinterpret_cast<char*
>(
this);
110 size_t offset =
sizeof(DlVertices);
114 size_t bytes =
count *
sizeof(*src);
120 return static_cast<size_t>(0);
124 vertices_offset_ = advance(vertices, vertex_count_);
125 texture_coordinates_offset_ = advance(texture_coordinates, vertex_count_);
126 colors_offset_ = advance(
colors, vertex_count_);
127 indices_offset_ = advance(indices, index_count_);
129 {{!!texture_coordinates, !!
colors}},
133DlVertices::DlVertices(
const DlVertices* other)
134 : DlVertices(other->mode_,
135 other->vertex_count_,
137 other->texture_coordinates(),
144 int unchecked_vertex_count,
146 int unchecked_index_count)
148 vertex_count_(
std::
max(unchecked_vertex_count, 0)),
149 index_count_(
std::
max(unchecked_index_count, 0)) {
150 char* pod =
reinterpret_cast<char*
>(
this);
151 size_t offset =
sizeof(DlVertices);
156 memset(pod +
offset, 0, bytes);
161 return static_cast<size_t>(0);
165 vertices_offset_ = advance(
sizeof(
SkPoint), vertex_count_);
166 texture_coordinates_offset_ = advance(
167 sizeof(
SkPoint),
flags.has_texture_coordinates ? vertex_count_ : 0);
169 advance(
sizeof(
DlColor),
flags.has_colors ? vertex_count_ : 0);
170 indices_offset_ = advance(
sizeof(uint16_t), index_count_);
172 FML_DCHECK((vertex_count_ != 0) == (vertices() !=
nullptr));
174 (texture_coordinates() !=
nullptr));
176 FML_DCHECK((index_count_ != 0) == (indices() !=
nullptr));
180 auto lists_equal = [](
auto*
a,
auto*
b,
int count) {
181 if (
a ==
nullptr ||
b ==
nullptr) {
192 mode_ == other.mode_ &&
193 vertex_count_ == other.vertex_count_ &&
194 lists_equal(vertices(), other.
vertices(), vertex_count_) &&
198 index_count_ == other.index_count_ &&
199 lists_equal(indices(), other.
indices(), index_count_);
206 : needs_texture_coords_(
flags.has_texture_coordinates),
207 needs_colors_(
flags.has_colors),
208 needs_indices_(index_count > 0) {
213 vertices_.reset(
new (storage)
228 char* pod =
reinterpret_cast<char*
>(vertices_.get());
229 size_t bytes = vertices_->vertex_count_ *
sizeof(
vertices[0]);
230 memcpy(pod + vertices_->vertices_offset_,
vertices, bytes);
231 needs_vertices_ =
false;
237 char* pod =
reinterpret_cast<char*
>(vertices_.get());
239 vertices_->vertex_count_);
240 needs_vertices_ =
false;
246 char* pod =
reinterpret_cast<char*
>(vertices_.get());
247 size_t bytes = vertices_->vertex_count_ *
sizeof(coords[0]);
248 memcpy(pod + vertices_->texture_coordinates_offset_, coords, bytes);
249 needs_texture_coords_ =
false;
255 char* pod =
reinterpret_cast<char*
>(vertices_.get());
256 store_points(pod, vertices_->texture_coordinates_offset_, coords,
257 vertices_->vertex_count_);
258 needs_texture_coords_ =
false;
264 char* pod =
reinterpret_cast<char*
>(vertices_.get());
265 size_t bytes = vertices_->vertex_count_ *
sizeof(
colors[0]);
266 memcpy(pod + vertices_->colors_offset_,
colors, bytes);
267 needs_colors_ =
false;
273 char* pod =
reinterpret_cast<char*
>(vertices_.get());
274 size_t bytes = vertices_->index_count_ *
sizeof(
indices[0]);
275 memcpy(pod + vertices_->indices_offset_,
indices, bytes);
276 needs_indices_ =
false;
281 if (vertices_->vertex_count() <= 0) {
285 needs_vertices_ =
false;
295 return std::move(vertices_);
static const int points[]
static bool is_valid(SkISize dim)
void accumulate(SkScalar x, SkScalar y)
A utility class to build up a |DlVertices| object one set of data at a time.
void store_texture_coordinates(const SkPoint points[])
Copies the indicated list of points as texture coordinates.
void store_vertices(const SkPoint points[])
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.
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 SkPoint vertices[], const SkPoint texture_coordinates[], const DlColor colors[], int index_count=0, const uint16_t indices[]=nullptr)
Constructs a DlVector with compact inline storage for all of its required and optional lists of data.
const DlColor * colors() const
DlVertexMode mode() const
const SkPoint * vertices() const
Returns a pointer to the vertex information. Should be non-null.
size_t size() const
Returns the size of the object including all of the inlined data.
const uint16_t * indices() const
const SkPoint * texture_coordinates() const
FlutterSemanticsFlag flags
#define FML_CHECK(condition)
#define FML_DCHECK(condition)
static float max(float r, float g, float b)
Optional< SkRect > bounds
PODArray< SkColor > colors
DlVertices::Builder Builder
static void DlVerticesDeleter(void *p)
DlVertices::Builder::Flags Flags
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 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
it will be possible to load the file into Perfetto s trace viewer 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 SkRect compute_bounds(const SkPoint *points, int count)
static size_t bytes_needed(int vertex_count, Flags flags, int index_count)
bool operator==(C p1, const scoped_nsprotocol< C > &p2)
static constexpr SkPoint Make(float x, float y)
flags to indicate/promise which of the optional texture coordinates or colors will be supplied during...