Flutter Engine
 
Loading...
Searching...
No Matches
flutter::DlVertices Class Reference

Holds all of the data (both required and optional) for a DisplayList drawVertices call. More...

#include <dl_vertices.h>

Classes

class  Builder
 A utility class to build up a |DlVertices| object one set of data at a time. More...
 

Public Member Functions

size_t size () const
 Returns the size of the object including all of the inlined data.
 
DlRect GetBounds () const
 Returns the bounds of the vertices.
 
DlVertexMode mode () const
 
int vertex_count () const
 
const DlPointvertex_data () const
 Returns a pointer to the vertex information. Should be non-null.
 
const DlPointtexture_coordinate_data () const
 
const DlColorcolors () const
 
int index_count () const
 
const uint16_t * indices () const
 
bool operator== (DlVertices const &other) const
 

Static Public Member Functions

static std::shared_ptr< DlVerticesMake (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.
 

Friends

class DisplayListBuilder
 

Detailed Description

Holds all of the data (both required and optional) for a DisplayList drawVertices call.

There are 4 main pices of data:

  • vertices(): the points on the rendering surface that define the pixels being rendered to in a series of triangles. These points can map to triangles in various ways depending on the supplied |DlVertexMode|.
  • texture_coordinates(): the points in the DlColorSource to map to the coordinates of the triangles in the vertices(). If missing, the vertex coordinates themselves will be used to map the source colors to the vertices.
  • colors(): colors to map to each triangle vertex. Note that each vertex is mapped to exactly 1 color even if the DlVertex
  • indices(): An indirection based on indices into the array of vertices (and by extension, their associated texture_coordinates and colors). Note that the DLVertexMode will still apply to the indices in the same way (and instead of the way) that it would normally be applied to the vertices themselves. The indices are useful, for example, to fill the vertices with a grid of points and then use the indices to define a triangular mesh that covers that grid without having to repeat the vertex (and texture coordinate and color) information for the times when a given grid coordinate gets reused in up to 4 mesh triangles.

Note that each vertex is mapped to exactly 1 texture_coordinate and color even if the DlVertexMode or indices specify that it contributes to more than one output triangle.

Definition at line 69 of file dl_vertices.h.

Member Function Documentation

◆ colors()

const DlColor * flutter::DlVertices::colors ( ) const
inline

Returns a pointer to the vertex colors or null if none were provided.

Definition at line 218 of file dl_vertices.h.

218 {
219 return static_cast<const DlColor*>(pod(colors_offset_));
220 }
flutter::DlColor DlColor

Referenced by Make(), operator==(), flutter::DlVertices::Builder::store_colors(), and flutter::DlVertices::Builder::store_colors().

◆ GetBounds()

DlRect flutter::DlVertices::GetBounds ( ) const
inline

Returns the bounds of the vertices.

Definition at line 195 of file dl_vertices.h.

195{ return bounds_; }

◆ index_count()

int flutter::DlVertices::index_count ( ) const
inline

Returns a pointer to the count of vertex indices or 0 if none were provided.

Definition at line 224 of file dl_vertices.h.

224{ return index_count_; }

Referenced by flutter::DlVertices::Builder::Builder(), and Make().

◆ indices()

const uint16_t * flutter::DlVertices::indices ( ) const
inline

Returns a pointer to the vertex indices or null if none were provided.

Definition at line 228 of file dl_vertices.h.

228 {
229 return static_cast<const uint16_t*>(pod(indices_offset_));
230 }

Referenced by Make(), operator==(), and flutter::DlVertices::Builder::store_indices().

◆ Make()

std::shared_ptr< DlVertices > flutter::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 
)
static

Constructs a DlVector with compact inline storage for all of its required and optional lists of data.

Vertices are always required. Optional texture coordinates and optional colors are stored if the arguments are non-null. Optional indices will be stored iff the array argument is non-null and the index_count is positive (>0).

Definition at line 39 of file dl_vertices.cc.

47 {
48 if (!vertices || vertex_count <= 0) {
49 vertex_count = 0;
50 texture_coordinates = nullptr;
51 colors = nullptr;
52 }
53 if (!indices || index_count <= 0) {
54 index_count = 0;
55 indices = nullptr;
56 }
57
58 Flags flags;
59 FML_DCHECK(!flags.has_texture_coordinates);
60 FML_DCHECK(!flags.has_colors);
61 if (texture_coordinates) {
63 }
64 if (colors) {
65 flags |= Builder::kHasColors;
66 }
67 Builder builder(mode, vertex_count, flags, index_count);
68
69 builder.store_vertices(vertices);
70 if (texture_coordinates) {
71 builder.store_texture_coordinates(texture_coordinates);
72 }
73 if (colors) {
74 builder.store_colors(colors);
75 }
76 if (indices) {
77 builder.store_indices(indices);
78 }
79 if (bounds != nullptr) {
80 builder.store_bounds(*bounds);
81 }
82
83 return builder.build();
84}
static constexpr Flags kHasColors
Definition dl_vertices.h:96
static constexpr Flags kHasTextureCoordinates
Definition dl_vertices.h:95
const DlColor * colors() const
int vertex_count() const
DlVertexMode mode() const
int index_count() const
const uint16_t * indices() const
#define FML_DCHECK(condition)
Definition logging.h:122
DlVertices::Builder Builder
DlVertices::Builder::Flags Flags

References flutter::DlVertices::Builder::build(), colors(), FML_DCHECK, index_count(), indices(), flutter::DlVertices::Builder::kHasColors, flutter::DlVertices::Builder::kHasTextureCoordinates, mode(), flutter::DlVertices::Builder::store_bounds(), flutter::DlVertices::Builder::store_colors(), flutter::DlVertices::Builder::store_indices(), flutter::DlVertices::Builder::store_texture_coordinates(), flutter::DlVertices::Builder::store_vertices(), and vertex_count().

Referenced by flutter::testing::GetTestVertices(), flutter::DlVertexPainter::IntoVertices(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), and impeller::testing::TEST_P().

◆ mode()

DlVertexMode flutter::DlVertices::mode ( ) const
inline

Returns the vertex mode that defines how the vertices (or the indices) are turned into triangles.

Definition at line 199 of file dl_vertices.h.

199{ return mode_; }

Referenced by flutter::DlVertices::Builder::Builder(), and Make().

◆ operator==()

bool flutter::DlVertices::operator== ( DlVertices const &  other) const

Definition at line 183 of file dl_vertices.cc.

183 {
184 auto lists_equal = [](auto* a, auto* b, int count) {
185 if (a == nullptr || b == nullptr) {
186 return a == b;
187 }
188 for (int i = 0; i < count; i++) {
189 if (a[i] != b[i]) {
190 return false;
191 }
192 }
193 return true;
194 };
195 return //
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(), //
200 other.texture_coordinate_data(), //
201 vertex_count_) && //
202 lists_equal(colors(), other.colors(), vertex_count_) && //
203 index_count_ == other.index_count_ && //
204 lists_equal(indices(), other.indices(), index_count_);
205}
const DlPoint * texture_coordinate_data() const
const DlPoint * vertex_data() const
Returns a pointer to the vertex information. Should be non-null.

References colors(), i, indices(), texture_coordinate_data(), and vertex_data().

◆ size()

size_t flutter::DlVertices::size ( ) const

Returns the size of the object including all of the inlined data.

Definition at line 86 of file dl_vertices.cc.

86 {
87 return bytes_needed(vertex_count_,
88 {{texture_coordinates_offset_ > 0, colors_offset_ > 0}},
89 index_count_);
90}
static size_t bytes_needed(int vertex_count, Flags flags, int index_count)

References flutter::bytes_needed().

◆ texture_coordinate_data()

const DlPoint * flutter::DlVertices::texture_coordinate_data ( ) const
inline

Returns a pointer to the vertex texture coordinate or null if none were provided.

Definition at line 212 of file dl_vertices.h.

212 {
213 return static_cast<const DlPoint*>(pod(texture_coordinates_offset_));
214 }
impeller::Point DlPoint

Referenced by operator==().

◆ vertex_count()

int flutter::DlVertices::vertex_count ( ) const
inline

Returns the number of vertices, which also applies to the number of texture coordinate and colors if they are provided.

Definition at line 203 of file dl_vertices.h.

203{ return vertex_count_; }

Referenced by flutter::DlVertices::Builder::Builder(), and Make().

◆ vertex_data()

const DlPoint * flutter::DlVertices::vertex_data ( ) const
inline

Returns a pointer to the vertex information. Should be non-null.

Definition at line 206 of file dl_vertices.h.

206 {
207 return static_cast<const DlPoint*>(pod(vertices_offset_));
208 }

Referenced by operator==().

Friends And Related Symbol Documentation

◆ DisplayListBuilder

friend class DisplayListBuilder
friend

Definition at line 281 of file dl_vertices.h.


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