| Flutter Impeller |

Public Member Functions | Static Public Member Functions | Static Protected Member Functions | List of all members
impeller::Geometry Class Referenceabstract

`#include <geometry.h>`

Inheritance diagram for impeller::Geometry:

## Public Member Functions
virtual GeometryResult | GetPositionBuffer (const ContentContext &renderer, const Entity &entity, RenderPass &pass) const =0
virtual GeometryResult | GetPositionUVBuffer (Rect texture_coverage, Matrix effect_transform, const ContentContext &renderer, const Entity &entity, RenderPass &pass) const =0
virtual GeometryResult::Mode | GetResultMode () const
virtual GeometryVertexType | GetVertexType () const =0
virtual std::optional< Rect > | GetCoverage (const Matrix &transform) const =0
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

## Static Public Member Functions
static std::shared_ptr< Geometry > | MakeFillPath (const Path &path, std::optional< Rect > inner_rect=std::nullopt)
static std::shared_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::shared_ptr< Geometry > | MakeCover ()
static std::shared_ptr< Geometry > | MakeRect (const Rect &rect)
static std::shared_ptr< Geometry > | MakeOval (const Rect &rect)
static std::shared_ptr< Geometry > | MakeLine (const Point &p0, const Point &p1, Scalar width, Cap cap)
static std::shared_ptr< Geometry > | MakeCircle (const Point &center, Scalar radius)
static std::shared_ptr< Geometry > | MakeStrokedCircle (const Point &center, Scalar radius, Scalar stroke_width)
static std::shared_ptr< Geometry > | MakeRoundRect (const Rect &rect, const Size &radii)
static std::shared_ptr< Geometry > | MakePointField (std::vector< Point > points, Scalar radius, bool round)

## Static Protected Member Functions
static GeometryResult | ComputePositionGeometry (const ContentContext &renderer, const Tessellator::VertexGenerator &generator, const Entity &entity, RenderPass &pass)
static GeometryResult | ComputePositionUVGeometry (const ContentContext &renderer, const Tessellator::VertexGenerator &generator, const Matrix &uv_transform, const Entity &entity, RenderPass &pass)

## Detailed Description

Definition at line 83 of file geometry.h.

## Member Function Documentation

## ◆ CanApplyMaskFilter()

bool impeller::Geometry::CanApplyMaskFilter | ( |  | ) | const
| virtual

Reimplemented in impeller::CoverGeometry.

Definition at line 243 of file geometry.cc.

243 {
244 return true;
245 }

## ◆ ComputePositionGeometry()

GeometryResult impeller::Geometry::ComputePositionGeometry | ( | const ContentContext & | renderer,
|  | const Tessellator::VertexGenerator & | generator,
|  | const Entity & | entity,
|  | RenderPass & | pass
| ) |  |
| static protected

Definition at line 25 of file geometry.cc.

29 {
30 using VT = SolidFillVertexShader::PerVertexData;
31
32 size_t count = generator.GetVertexCount();
33
34 return GeometryResult{
35 .type = generator.GetTriangleType(),
36 .vertex_buffer =
37 {
38 .vertex_buffer = renderer.GetTransientsBuffer().Emplace(
39 count * sizeof(VT), alignof(VT),
40 [&generator](uint8_t* buffer) {
41 auto vertices = reinterpret_cast<VT*>(buffer);
42 generator.GenerateVertices([&vertices](const Point& p) {
43 *vertices++ = {
44 .position = p,
45 };
46 });
47 FML_DCHECK(vertices == reinterpret_cast<VT*>(buffer) +
48 generator.GetVertexCount());
49 }),
50 .vertex_count = count,
51 .index_type = IndexType::kNone,
52 },
53 .transform = entity.GetShaderTransform(pass),
54 };
55 }

References impeller::HostBuffer::Emplace(), impeller::Tessellator::VertexGenerator::GenerateVertices(), impeller::Entity::GetShaderTransform(), impeller::ContentContext::GetTransientsBuffer(), impeller::Tessellator::VertexGenerator::GetTriangleType(), impeller::Tessellator::VertexGenerator::GetVertexCount(), impeller::kNone, and impeller::GeometryResult::type.

## ◆ ComputePositionUVGeometry()

GeometryResult impeller::Geometry::ComputePositionUVGeometry | ( | const ContentContext & | renderer,
|  | const Tessellator::VertexGenerator & | generator,
|  | const Matrix & | uv_transform,
|  | const Entity & | entity,
|  | RenderPass & | pass
| ) |  |
| static protected

Definition at line 57 of file geometry.cc.

62 {
63 using VT = TextureFillVertexShader::PerVertexData;
64
65 size_t count = generator.GetVertexCount();
66
67 return GeometryResult{
68 .type = generator.GetTriangleType(),
69 .vertex_buffer =
70 {
71 .vertex_buffer = renderer.GetTransientsBuffer().Emplace(
72 count * sizeof(VT), alignof(VT),
73 [&generator, &uv_transform](uint8_t* buffer) {
74 auto vertices = reinterpret_cast<VT*>(buffer);
75 generator.GenerateVertices(
76 [&vertices, &uv_transform](const Point& p) { //
77 *vertices++ = {
78 .position = p,
79 .texture_coords = uv_transform * p,
80 };
81 });
82 FML_DCHECK(vertices == reinterpret_cast<VT*>(buffer) +
83 generator.GetVertexCount());
84 }),
85 .vertex_count = count,
86 .index_type = IndexType::kNone,
87 },
88 .transform = entity.GetShaderTransform(pass),
89 };
90 }

References impeller::HostBuffer::Emplace(), impeller::Tessellator::VertexGenerator::GenerateVertices(), impeller::Entity::GetShaderTransform(), impeller::ContentContext::GetTransientsBuffer(), impeller::Tessellator::VertexGenerator::GetTriangleType(), impeller::Tessellator::VertexGenerator::GetVertexCount(), impeller::kNone, and impeller::GeometryResult::type.

## ◆ CoversArea()

bool impeller::Geometry::CoversArea | ( | const Matrix & | transform,
|  | const Rect & | rect
| ) |  | const
| virtual

Determines if this geometry, transformed by the given `transform`, will completely cover all surface area of the given `rect`.

This is a conservative estimate useful for certain optimizations.

Returns
  `true` if the transformed geometry is guaranteed to cover the given `rect`. May return `false` in many undetected cases where the transformed geometry does in fact cover the `rect`.

Reimplemented in impeller::CircleGeometry, impeller::FillPathGeometry, impeller::EllipseGeometry, impeller::RoundRectGeometry, impeller::LineGeometry, impeller::CoverGeometry, and impeller::RectGeometry.

Definition at line 235 of file geometry.cc.

235 {
236 return false;
237 }

## ◆ GetCoverage()

virtual std::optional<Rect> impeller::Geometry::GetCoverage | ( | const Matrix & | transform | ) | const
| pure virtual

Implemented in impeller::VerticesGeometry, and impeller::RectGeometry.

## ◆ GetPositionBuffer()

virtual GeometryResult impeller::Geometry::GetPositionBuffer | ( | const ContentContext & | renderer,
|  | const Entity & | entity,
|  | RenderPass & | pass
| ) |  | const
| pure virtual

Implemented in impeller::VerticesGeometry, and impeller::RectGeometry.

## ◆ GetPositionUVBuffer()

GeometryResult impeller::Geometry::GetPositionUVBuffer | ( | Rect | texture_coverage,
|  | Matrix | effect_transform,
|  | const ContentContext & | renderer,
|  | const Entity & | entity,
|  | RenderPass & | pass
| ) |  | const
| pure virtual

Implemented in impeller::RectGeometry, and impeller::VerticesGeometry.

Definition at line 163 of file geometry.cc.

167 {
168 return {};
169 }

## ◆ GetResultMode()

GeometryResult::Mode impeller::Geometry::GetResultMode | ( |  | ) | const
| virtual

Definition at line 171 of file geometry.cc.

171 {
172 return GeometryResult::Mode::kNormal;
173 }

References impeller::GeometryResult::kNormal.

## ◆ GetVertexType()

virtual GeometryVertexType impeller::Geometry::GetVertexType | ( |  | ) | const
| pure virtual

Implemented in impeller::VerticesGeometry, and impeller::RectGeometry.

## ◆ IsAxisAlignedRect()

bool impeller::Geometry::IsAxisAlignedRect | ( |  | ) | const
| virtual

Reimplemented in impeller::CircleGeometry, impeller::EllipseGeometry, impeller::RoundRectGeometry, impeller::LineGeometry, and impeller::RectGeometry.

Definition at line 239 of file geometry.cc.

239 {
240 return false;
241 }

## ◆ MakeCircle()

std::shared_ptr< Geometry > impeller::Geometry::MakeCircle | ( | const Point & | center,
|  | Scalar | radius
| ) |  |
| static

Definition at line 219 of file geometry.cc.

220 {
221 return std::make_shared<CircleGeometry>(center, radius);
222 }

## ◆ MakeCover()

std::shared_ptr< Geometry > impeller::Geometry::MakeCover | ( |  | ) |
| static

Definition at line 200 of file geometry.cc.

200 {
201 return std::make_shared<CoverGeometry>();
202 }

Referenced by impeller::testing::TEST_P().

## ◆ MakeFillPath()

std::shared_ptr< Geometry > impeller::Geometry::MakeFillPath | ( | const Path & | path,
|  | std::optional< Rect > | inner_rect = `std::nullopt`
| ) |  |
| static

Definition at line 175 of file geometry.cc.

177 {
178 return std::make_shared<FillPathGeometry>(path, inner_rect);
179 }

Referenced by impeller::SolidColorContents::Make(), impeller::testing::TEST(), and impeller::testing::TEST_P().

## ◆ MakeLine()

std::shared_ptr< Geometry > impeller::Geometry::MakeLine | ( | const Point & | p0,
|  | const Point & | p1,
|  | Scalar | width,
|  | Cap | cap
| ) |  |
| static

Definition at line 212 of file geometry.cc.

215 {
216 return std::make_shared<LineGeometry>(p0, p1, width, cap);
217 }

Referenced by impeller::testing::TEST().

## ◆ MakeOval()

std::shared_ptr< Geometry > impeller::Geometry::MakeOval | ( | const Rect & | rect | ) |
| static

Definition at line 208 of file geometry.cc.

208 {
209 return std::make_shared<EllipseGeometry>(rect);
210 }

## ◆ MakePointField()

std::shared_ptr< Geometry > impeller::Geometry::MakePointField | ( | std::vector< Point > | points,
|  | Scalar | radius,
|  | bool | round
| ) |  |
| static

Definition at line 181 of file geometry.cc.

183 {
184 return std::make_shared<PointFieldGeometry>(std::move(points), radius, round);
185 }

Referenced by impeller::testing::TEST_P().

## ◆ MakeRect()

std::shared_ptr< Geometry > impeller::Geometry::MakeRect | ( | const Rect & | rect | ) |
| static

Definition at line 204 of file geometry.cc.

204 {
205 return std::make_shared<RectGeometry>(rect);
206 }

Referenced by impeller::Paint::MaskBlurDescriptor::CreateMaskBlur(), impeller::PipelineBlend(), impeller::testing::TEST(), and impeller::testing::TEST_P().

## ◆ MakeRoundRect()

std::shared_ptr< Geometry > impeller::Geometry::MakeRoundRect | ( | const Rect & | rect,
|  | const Size & | radii
| ) |  |
| static

Definition at line 230 of file geometry.cc.

231 {
232 return std::make_shared<RoundRectGeometry>(rect, radii);
233 }

Referenced by impeller::testing::TEST().

## ◆ MakeStrokedCircle()

std::shared_ptr< Geometry > impeller::Geometry::MakeStrokedCircle | ( | const Point & | center,
|  | Scalar | radius,
|  | Scalar | stroke_width
| ) |  |
| static

Definition at line 224 of file geometry.cc.

226 {
227 return std::make_shared<CircleGeometry>(center, radius, stroke_width);
228 }

References stroke_width.

## ◆ MakeStrokePath()

std::shared_ptr< Geometry > impeller::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

Definition at line 187 of file geometry.cc.

191 {
192 // Skia behaves like this.
193 if (miter_limit < 0) {
194 miter_limit = 4.0;
195 }
196 return std::make_shared<StrokePathGeometry>(path, stroke_width, miter_limit,
197 stroke_cap, stroke_join);
198 }

References stroke_width.

Referenced by impeller::testing::TEST_P().

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

- impeller/entity/geometry/geometry.h
- impeller/entity/geometry/geometry.cc

impeller::GeometryResult::Mode::kNormal
@ kNormal
The geometry has no overlapping triangles.
stroke_width
const Scalar stroke_width
Definition: stroke_path_geometry.cc:293
impeller::Point
TPoint< Scalar > Point
Definition: point.h:316
impeller::IndexType::kNone
@ kNone
Does not use the index buffer.