| Flutter Impeller |

Public Member Functions | List of all members
impeller::DlVerticesGeometry Class Referencefinal

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

`#include <dl_vertices_geometry.h>`

Inheritance diagram for impeller::DlVerticesGeometry:

## Public Member Functions
| DlVerticesGeometry (const std::shared_ptr< const flutter::DlVertices > &vertices, const ContentContext &renderer)
| ~DlVerticesGeometry ()=default
GeometryResult | GetPositionUVColorBuffer (Rect texture_coverage, Matrix effect_transform, const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
GeometryResult | GetPositionBuffer (const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
std::optional< Rect > | GetCoverage (const Matrix &transform) const override
bool | HasVertexColors () const override
bool | HasTextureCoordinates () const override
std::optional< Rect > | GetTextureCoordinateCoverge () const override
Public Member Functions inherited from impeller::Geometry
virtual | ~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`. More...
virtual bool | IsAxisAlignedRect () const
virtual bool | CanApplyMaskFilter () const
virtual Scalar | ComputeAlphaCoverage (const Matrix &transform) const

## Additional Inherited Members
Static Public Member Functions inherited from impeller::Geometry
static std::unique_ptr< Geometry > | MakeFillPath (const Path &path, std::optional< Rect > inner_rect=std::nullopt)
static std::unique_ptr< Geometry > | MakeStrokePath (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::unique_ptr< Geometry > | MakeCover ()
static std::unique_ptr< Geometry > | MakeRect (const Rect &rect)
static std::unique_ptr< Geometry > | MakeOval (const Rect &rect)
static std::unique_ptr< Geometry > | MakeLine (const Point &p0, const Point &p1, Scalar width, Cap cap)
static std::unique_ptr< Geometry > | MakeCircle (const Point &center, Scalar radius)
static std::unique_ptr< Geometry > | MakeStrokedCircle (const Point &center, Scalar radius, Scalar stroke_width)
static std::unique_ptr< Geometry > | MakeRoundRect (const Rect &rect, const Size &radii)
static std::unique_ptr< Geometry > | MakePointField (std::vector< Point > points, Scalar radius, bool round)
static Scalar | ComputeStrokeAlphaCoverage (const Matrix &entity, Scalar stroke_width)
| Compute an alpha value to simulate lower coverage of fractional pixel strokes. More...
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 DlVertices object.

Definition at line 15 of file dl_vertices_geometry.h.

## Constructor & Destructor Documentation

## ◆ DlVerticesGeometry()

impeller::DlVerticesGeometry::DlVerticesGeometry | ( | const std::shared_ptr< const flutter::DlVertices > & | vertices,
|  | const ContentContext & | renderer
| ) |  |

Definition at line 60 of file dl_vertices_geometry.cc.

63 : vertices_(vertices) {
64 performed_normalization_ = MaybePerformIndexNormalization(renderer);
65 bounds_ = skia_conversions::ToRect(vertices_->bounds());
66 }

References impeller::skia_conversions::ToRect().

## ◆ ~DlVerticesGeometry()

impeller::DlVerticesGeometry::~DlVerticesGeometry | ( |  | ) |
| default

## Member Function Documentation

## ◆ GetCoverage()

std::optional< Rect > impeller::DlVerticesGeometry::GetCoverage | ( | const Matrix & | transform | ) | const
| overridevirtual

Implements impeller::Geometry.

Definition at line 208 of file dl_vertices_geometry.cc.

209 {
210 return bounds_.TransformBounds(transform);
211 }

References transform, and impeller::TRect< T >::TransformBounds().

## ◆ GetPositionBuffer()

GeometryResult impeller::DlVerticesGeometry::GetPositionBuffer | ( | const ContentContext & | renderer,
|  | const Entity & | entity,
|  | RenderPass & | pass
| ) |  | const
| overridevirtual

Implements impeller::Geometry.

Definition at line 115 of file dl_vertices_geometry.cc.

118 {
119 int vertex_count = vertices_->vertex_count();
120 BufferView vertex_buffer = renderer.GetTransientsBuffer().Emplace(
121 vertices_->vertices(), vertex_count * sizeof(SkPoint), alignof(SkPoint));
122
123 BufferView index_buffer = {};
124 auto index_count =
125 performed_normalization_ ? indices_.size() : vertices_->index_count();
126 const uint16_t* indices_data =
127 performed_normalization_ ? indices_.data() : vertices_->indices();
128 if (index_count) {
129 index_buffer = renderer.GetTransientsBuffer().Emplace(
130 indices_data, index_count * sizeof(uint16_t), 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 }

References impeller::HostBuffer::Emplace(), impeller::Entity::GetShaderTransform(), impeller::ContentContext::GetTransientsBuffer(), impeller::k16bit, impeller::kNone, and impeller::GeometryResult::type.

## ◆ GetPositionUVColorBuffer()

GeometryResult impeller::DlVerticesGeometry::GetPositionUVColorBuffer | ( | Rect | texture_coverage,
|  | Matrix | effect_transform,
|  | const ContentContext & | renderer,
|  | const Entity & | entity,
|  | RenderPass & | pass
| ) |  | const
| overridevirtual

Implements impeller::VerticesGeometry.

Definition at line 147 of file dl_vertices_geometry.cc.

152 {
153 using VS = PorterDuffBlendPipeline::VertexShader;
154
155 int vertex_count = vertices_->vertex_count();
156 Matrix uv_transform =
157 texture_coverage.GetNormalizingTransform() * effect_transform;
158 bool has_texture_coordinates = HasTextureCoordinates();
159 bool has_colors = HasVertexColors();
160
161 const SkPoint* coordinates = has_texture_coordinates
162 ? vertices_->texture_coordinates()
163 : vertices_->vertices();
164 BufferView vertex_buffer = renderer.GetTransientsBuffer().Emplace(
165 vertex_count * sizeof(VS::PerVertexData), alignof(VS::PerVertexData),
166 [&](uint8_t* data) {
167 VS::PerVertexData* vtx_contents =
168 reinterpret_cast<VS::PerVertexData*>(data);
169 for (auto i = 0; i < vertex_count; i++) {
170 Point texture_coord = skia_conversions::ToPoint(coordinates[i]);
171 Point uv = uv_transform * texture_coord;
172 Color color = has_colors
173 ? skia_conversions::ToColor(vertices_->colors()[i])
174 .Premultiply()
175 : Color::BlackTransparent();
176 VS::PerVertexData vertex_data = {
177 .vertices = skia_conversions::ToPoint(vertices_->vertices()[i]),
178 .texture_coords = uv,
179 .color = color};
180 vtx_contents[i] = vertex_data;
181 }
182 });
183
184 BufferView index_buffer = {};
185 auto index_count =
186 performed_normalization_ ? indices_.size() : vertices_->index_count();
187 const uint16_t* indices_data =
188 performed_normalization_ ? indices_.data() : vertices_->indices();
189 if (index_count) {
190 index_buffer = renderer.GetTransientsBuffer().Emplace(
191 indices_data, index_count * sizeof(uint16_t), alignof(uint16_t));
192 }
193
194 return GeometryResult{
195 .type = GetPrimitiveType(),
196 .vertex_buffer =
197 {
198 .vertex_buffer = vertex_buffer,
199 .index_buffer = index_buffer,
200 .vertex_count = index_count > 0 ? index_count : vertex_count,
201 .index_type =
202 index_count > 0 ? IndexType::k16bit : IndexType::kNone,
203 },
204 .transform = entity.GetShaderTransform(pass),
205 };
206 }

References impeller::Color::BlackTransparent(), color, data, impeller::HostBuffer::Emplace(), impeller::TRect< T >::GetNormalizingTransform(), impeller::Entity::GetShaderTransform(), impeller::ContentContext::GetTransientsBuffer(), HasTextureCoordinates(), HasVertexColors(), impeller::k16bit, impeller::kNone, impeller::Color::Premultiply(), impeller::skia_conversions::ToColor(), impeller::skia_conversions::ToPoint(), and impeller::GeometryResult::type.

## ◆ GetTextureCoordinateCoverge()

std::optional< Rect > impeller::DlVerticesGeometry::GetTextureCoordinateCoverge | ( |  | ) | const
| overridevirtual

Implements impeller::VerticesGeometry.

Definition at line 91 of file dl_vertices_geometry.cc.

91 {
92 if (!HasTextureCoordinates()) {
93 return std::nullopt;
94 }
95 auto vertex_count = vertices_->vertex_count();
96 if (vertex_count == 0) {
97 return std::nullopt;
98 }
99
100 auto first = vertices_->texture_coordinates();
101 auto left = first->x();
102 auto top = first->y();
103 auto right = first->x();
104 auto bottom = first->y();
105 int i = 1;
106 for (auto it = first + 1; i < vertex_count; ++it, i++) {
107 left = std::min(left, it->x());
108 top = std::min(top, it->y());
109 right = std::max(right, it->x());
110 bottom = std::max(bottom, it->y());
111 }
112 return Rect::MakeLTRB(left, top, right, bottom);
113 }

References HasTextureCoordinates(), and impeller::TRect< Scalar >::MakeLTRB().

## ◆ HasTextureCoordinates()

bool impeller::DlVerticesGeometry::HasTextureCoordinates | ( |  | ) | const
| overridevirtual

Implements impeller::VerticesGeometry.

Definition at line 87 of file dl_vertices_geometry.cc.

87 {
88 return vertices_->texture_coordinates() != nullptr;
89 }

Referenced by GetPositionUVColorBuffer(), and GetTextureCoordinateCoverge().

## ◆ HasVertexColors()

bool impeller::DlVerticesGeometry::HasVertexColors | ( |  | ) | const
| overridevirtual

Implements impeller::VerticesGeometry.

Definition at line 83 of file dl_vertices_geometry.cc.

83 {
84 return vertices_->colors() != nullptr;
85 }

Referenced by GetPositionUVColorBuffer().

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

- impeller/display_list/dl_vertices_geometry.h
- impeller/display_list/dl_vertices_geometry.cc

impeller::IndexType::k16bit
@ k16bit
data
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63
impeller::TRect::TransformBounds
constexpr TRect TransformBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle.
Definition: rect.h:466
impeller::DlVerticesGeometry::HasVertexColors
bool HasVertexColors() const override
Definition: dl_vertices_geometry.cc:83
impeller::skia_conversions::ToColor
Color ToColor(const flutter::DlColor &color)
Definition: skia_conversions.cc:106
impeller::skia_conversions::ToRect
Rect ToRect(const SkRect &rect)
Definition: skia_conversions.cc:30
impeller::VS
SolidFillVertexShader VS
Definition: stroke_path_geometry.cc:16
impeller::Point
TPoint< Scalar > Point
Definition: point.h:327
transform
Matrix transform
Definition: gaussian_blur_filter_contents.cc:213
impeller::DlVerticesGeometry::HasTextureCoordinates
bool HasTextureCoordinates() const override
Definition: dl_vertices_geometry.cc:87
impeller::RenderPipelineHandle::VertexShader
VertexShader_ VertexShader
Definition: pipeline.h:106
impeller::IndexType::kNone
@ kNone
Does not use the index buffer.
impeller::skia_conversions::ToPoint
Point ToPoint(const SkPoint &point)
Definition: skia_conversions.cc:98
impeller::Color::BlackTransparent
static constexpr Color BlackTransparent()
Definition: color.h:269
color
DlColor color
Definition: dl_golden_blur_unittests.cc:24
impeller::TRect< Scalar >::MakeLTRB
constexpr static TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
Definition: rect.h:129
impeller::Color::Premultiply
constexpr Color Premultiply() const
Definition: color.h:211