Flutter Engine
The Flutter Engine
dl_vertices_geometry.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
13
14namespace impeller {
15
16static Rect ToRect(const SkRect& rect) {
17 return Rect::MakeLTRB(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
18}
19
21 switch (mode) {
28 };
29}
30
31std::shared_ptr<impeller::VerticesGeometry> MakeVertices(
32 const flutter::DlVertices* vertices) {
33 auto bounds = ToRect(vertices->bounds());
34 auto mode = ToVertexMode(vertices->mode());
35 std::vector<Point> positions(vertices->vertex_count());
36 for (auto i = 0; i < vertices->vertex_count(); i++) {
37 positions[i] = skia_conversions::ToPoint(vertices->vertices()[i]);
38 }
39
40 std::vector<uint16_t> indices(vertices->index_count());
41 for (auto i = 0; i < vertices->index_count(); i++) {
42 indices[i] = vertices->indices()[i];
43 }
44
45 std::vector<Color> colors;
46 if (vertices->colors()) {
47 colors.reserve(vertices->vertex_count());
48 for (auto i = 0; i < vertices->vertex_count(); i++) {
49 colors.push_back(
51 }
52 }
53 std::vector<Point> texture_coordinates;
54 if (vertices->texture_coordinates()) {
55 texture_coordinates.reserve(vertices->vertex_count());
56 for (auto i = 0; i < vertices->vertex_count(); i++) {
57 texture_coordinates.push_back(
59 }
60 }
61 return std::make_shared<VerticesGeometry>(
62 positions, indices, texture_coordinates, colors, bounds, mode);
63}
64
65} // namespace impeller
Holds all of the data (both required and optional) for a DisplayList drawVertices call.
Definition: dl_vertices.h:71
SkRect bounds() const
Returns the bounds of the vertices.
Definition: dl_vertices.h:194
const DlColor * colors() const
Definition: dl_vertices.h:217
int vertex_count() const
Definition: dl_vertices.h:202
DlVertexMode mode() const
Definition: dl_vertices.h:198
int index_count() const
Definition: dl_vertices.h:223
const SkPoint * vertices() const
Returns a pointer to the vertex information. Should be non-null.
Definition: dl_vertices.h:205
const uint16_t * indices() const
Definition: dl_vertices.h:227
const SkPoint * texture_coordinates() const
Definition: dl_vertices.h:211
Optional< SkRect > bounds
Definition: SkRecords.h:189
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
PODArray< SkColor > colors
Definition: SkRecords.h:276
DlVertexMode
Defines the way in which the vertices of a DlVertices object are separated into triangles into which ...
Definition: dl_vertices.h:20
@ kTriangles
The vertices are taken 3 at a time to form a triangle.
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
Definition: switches.h:228
Point ToPoint(const SkPoint &point)
Color ToColor(const flutter::DlColor &color)
static Rect ToRect(const SkRect &rect)
static VerticesGeometry::VertexMode ToVertexMode(flutter::DlVertexMode mode)
std::shared_ptr< impeller::VerticesGeometry > MakeVertices(const flutter::DlVertices *vertices)
constexpr Color Premultiply() const
Definition: color.h:214
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
Definition: rect.h:129