Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
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.
const DlColor * colors() const
int vertex_count() const
DlVertexMode mode() const
int index_count() const
const SkPoint * vertices() const
Returns a pointer to the vertex information. Should be non-null.
const uint16_t * indices() const
const SkPoint * texture_coordinates() const
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.
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