Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
impeller::VerticesGeometry Class Referencefinal

A geometry that is created from a vertices object. More...

#include <vertices_geometry.h>

Inheritance diagram for impeller::VerticesGeometry:
impeller::Geometry

Public Types

enum class  VertexMode { kTriangles , kTriangleStrip , kTriangleFan }
 

Public Member Functions

 VerticesGeometry (std::vector< Point > vertices, std::vector< uint16_t > indices, std::vector< Point > texture_coordinates, std::vector< Color > colors, Rect bounds, VerticesGeometry::VertexMode vertex_mode)
 
 ~VerticesGeometry ()=default
 
GeometryResult GetPositionUVColorBuffer (Rect texture_coverage, Matrix effect_transform, const ContentContext &renderer, const Entity &entity, RenderPass &pass) const
 
GeometryResult GetPositionBuffer (const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
 
std::optional< RectGetCoverage (const Matrix &transform) const override
 
bool HasVertexColors () const
 
bool HasTextureCoordinates () const
 
std::optional< RectGetTextureCoordinateCoverge () const
 
- Public Member Functions inherited from impeller::Geometry
virtual GeometryResult::Mode GetResultMode () const
 
virtual bool CoversArea (const Matrix &transform, const Rect &rect) const
 Determines if this geometry, transformed by the given transform, will completely cover all surface area of the given rect.
 
virtual bool IsAxisAlignedRect () const
 
virtual bool CanApplyMaskFilter () const
 

Additional Inherited Members

- Static Public Member Functions inherited from impeller::Geometry
static std::shared_ptr< GeometryMakeFillPath (const Path &path, std::optional< Rect > inner_rect=std::nullopt)
 
static std::shared_ptr< GeometryMakeStrokePath (const Path &path, Scalar stroke_width=0.0, Scalar miter_limit=4.0, Cap stroke_cap=Cap::kButt, Join stroke_join=Join::kMiter)
 
static std::shared_ptr< GeometryMakeCover ()
 
static std::shared_ptr< GeometryMakeRect (const Rect &rect)
 
static std::shared_ptr< GeometryMakeOval (const Rect &rect)
 
static std::shared_ptr< GeometryMakeLine (const Point &p0, const Point &p1, Scalar width, Cap cap)
 
static std::shared_ptr< GeometryMakeCircle (const Point &center, Scalar radius)
 
static std::shared_ptr< GeometryMakeStrokedCircle (const Point &center, Scalar radius, Scalar stroke_width)
 
static std::shared_ptr< GeometryMakeRoundRect (const Rect &rect, const Size &radii)
 
static std::shared_ptr< GeometryMakePointField (std::vector< Point > points, Scalar radius, bool round)
 
- Static Protected Member Functions inherited from impeller::Geometry
static GeometryResult ComputePositionGeometry (const ContentContext &renderer, const Tessellator::VertexGenerator &generator, const Entity &entity, RenderPass &pass)
 

Detailed Description

A geometry that is created from a vertices object.

Definition at line 13 of file vertices_geometry.h.

Member Enumeration Documentation

◆ VertexMode

Enumerator
kTriangles 
kTriangleStrip 
kTriangleFan 

Definition at line 15 of file vertices_geometry.h.

Constructor & Destructor Documentation

◆ VerticesGeometry()

impeller::VerticesGeometry::VerticesGeometry ( std::vector< Point vertices,
std::vector< uint16_t >  indices,
std::vector< Point texture_coordinates,
std::vector< Color colors,
Rect  bounds,
VerticesGeometry::VertexMode  vertex_mode 
)

Definition at line 57 of file vertices_geometry.cc.

63 : vertices_(std::move(vertices)),
64 colors_(std::move(colors)),
65 texture_coordinates_(std::move(texture_coordinates)),
66 indices_(std::move(indices)),
67 bounds_(bounds),
68 vertex_mode_(vertex_mode) {
69 NormalizeIndices();
70}

◆ ~VerticesGeometry()

impeller::VerticesGeometry::~VerticesGeometry ( )
default

Member Function Documentation

◆ GetCoverage()

std::optional< Rect > impeller::VerticesGeometry::GetCoverage ( const Matrix transform) const
overridevirtual

Implements impeller::Geometry.

Definition at line 202 of file vertices_geometry.cc.

203 {
204 return bounds_.TransformBounds(transform);
205}
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition p3.cpp:47
constexpr TRect TransformBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle.
Definition rect.h:440

◆ GetPositionBuffer()

GeometryResult impeller::VerticesGeometry::GetPositionBuffer ( const ContentContext renderer,
const Entity entity,
RenderPass pass 
) const
overridevirtual

Implements impeller::Geometry.

Definition at line 113 of file vertices_geometry.cc.

116 {
117 auto index_count = indices_.size();
118 auto vertex_count = vertices_.size();
119
120 size_t total_vtx_bytes = vertex_count * sizeof(float) * 2;
121 size_t total_idx_bytes = index_count * sizeof(uint16_t);
122
123 auto vertex_buffer = renderer.GetTransientsBuffer().Emplace(
124 reinterpret_cast<const uint8_t*>(vertices_.data()), total_vtx_bytes,
125 alignof(float));
126
127 BufferView index_buffer = {};
128 if (index_count) {
129 index_buffer = renderer.GetTransientsBuffer().Emplace(
130 indices_.data(), total_idx_bytes, alignof(uint16_t));
131 }
132
133 return GeometryResult{
134 .type = GetPrimitiveType(),
135 .vertex_buffer =
136 {
137 .vertex_buffer = vertex_buffer,
138 .index_buffer = index_buffer,
139 .vertex_count = index_count > 0 ? index_count : vertex_count,
140 .index_type =
141 index_count > 0 ? IndexType::k16bit : IndexType::kNone,
142 },
143 .transform = entity.GetShaderTransform(pass),
144 };
145}
@ kNone
Does not use the index buffer.

◆ GetPositionUVColorBuffer()

GeometryResult impeller::VerticesGeometry::GetPositionUVColorBuffer ( Rect  texture_coverage,
Matrix  effect_transform,
const ContentContext renderer,
const Entity entity,
RenderPass pass 
) const

Definition at line 147 of file vertices_geometry.cc.

152 {
154
155 auto vertex_count = vertices_.size();
156 auto uv_transform =
157 texture_coverage.GetNormalizingTransform() * effect_transform;
158 auto has_texture_coordinates = HasTextureCoordinates();
159 auto has_colors = HasVertexColors();
160
161 size_t total_vtx_bytes = vertices_.size() * sizeof(VS::PerVertexData);
162 auto vertex_buffer = renderer.GetTransientsBuffer().Emplace(
163 total_vtx_bytes, alignof(VS::PerVertexData), [&](uint8_t* data) {
164 VS::PerVertexData* vtx_contents =
165 reinterpret_cast<VS::PerVertexData*>(data);
166 for (auto i = 0u; i < vertices_.size(); i++) {
167 auto vertex = vertices_[i];
168 auto texture_coord =
169 has_texture_coordinates ? texture_coordinates_[i] : vertices_[i];
170 auto uv = uv_transform * texture_coord;
171 VS::PerVertexData vertex_data = {
172 .vertices = vertex,
173 .texture_coords = uv,
174 .color = has_colors ? colors_[i] : Color::BlackTransparent(),
175 };
176 std::memcpy(vtx_contents++, &vertex_data, sizeof(VS::PerVertexData));
177 }
178 });
179
180 BufferView index_buffer = {};
181 auto index_count = indices_.size();
182 size_t total_idx_bytes = index_count * sizeof(uint16_t);
183 if (index_count > 0) {
184 index_buffer = renderer.GetTransientsBuffer().Emplace(
185 indices_.data(), total_idx_bytes, alignof(uint16_t));
186 }
187
188 return GeometryResult{
189 .type = GetPrimitiveType(),
190 .vertex_buffer =
191 {
192 .vertex_buffer = vertex_buffer,
193 .index_buffer = index_buffer,
194 .vertex_count = index_count > 0 ? index_count : vertex_count,
195 .index_type =
196 index_count > 0 ? IndexType::k16bit : IndexType::kNone,
197 },
198 .transform = entity.GetShaderTransform(pass),
199 };
200}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41
SolidFillVertexShader VS
static constexpr Color BlackTransparent()
Definition color.h:262

◆ GetTextureCoordinateCoverge()

std::optional< Rect > impeller::VerticesGeometry::GetTextureCoordinateCoverge ( ) const

Definition at line 100 of file vertices_geometry.cc.

100 {
101 if (!HasTextureCoordinates()) {
102 return std::nullopt;
103 }
104 auto vertex_count = vertices_.size();
105 if (vertex_count == 0) {
106 return std::nullopt;
107 }
108
109 return Rect::MakePointBounds(texture_coordinates_.begin(),
110 texture_coordinates_.end());
111}
static constexpr std::optional< TRect > MakePointBounds(const U &value)
Definition rect.h:151

◆ HasTextureCoordinates()

bool impeller::VerticesGeometry::HasTextureCoordinates ( ) const

Definition at line 96 of file vertices_geometry.cc.

96 {
97 return texture_coordinates_.size() > 0;
98}

◆ HasVertexColors()

bool impeller::VerticesGeometry::HasVertexColors ( ) const

Definition at line 92 of file vertices_geometry.cc.

92 {
93 return colors_.size() > 0;
94}

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