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

A geometry that is created from a filled path object. More...

#include <fill_path_geometry.h>

Inheritance diagram for impeller::FillPathGeometry:
impeller::Geometry

Public Member Functions

 FillPathGeometry (const Path &path, std::optional< Rect > inner_rect=std::nullopt)
 
 ~FillPathGeometry ()=default
 
bool CoversArea (const Matrix &transform, const Rect &rect) const override
 Determines if this geometry, transformed by the given transform, will completely cover all surface area of the given rect.
 
- Public Member Functions inherited from impeller::Geometry
virtual bool IsAxisAlignedRect () const
 
virtual bool CanApplyMaskFilter () const
 

Private Member Functions

GeometryResult GetPositionBuffer (const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
 
std::optional< RectGetCoverage (const Matrix &transform) const override
 
GeometryResult::Mode GetResultMode () const override
 

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 filled path object.

Definition at line 16 of file fill_path_geometry.h.

Constructor & Destructor Documentation

◆ FillPathGeometry()

impeller::FillPathGeometry::FillPathGeometry ( const Path path,
std::optional< Rect inner_rect = std::nullopt 
)
explicit

Definition at line 15 of file fill_path_geometry.cc.

17 : path_(path), inner_rect_(inner_rect) {}

◆ ~FillPathGeometry()

impeller::FillPathGeometry::~FillPathGeometry ( )
default

Member Function Documentation

◆ CoversArea()

bool impeller::FillPathGeometry::CoversArea ( const Matrix transform,
const Rect rect 
) const
overridevirtual

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 from impeller::Geometry.

Definition at line 79 of file fill_path_geometry.cc.

80 {
81 if (!inner_rect_.has_value()) {
82 return false;
83 }
84 if (!transform.IsTranslationScaleOnly()) {
85 return false;
86 }
87 Rect coverage = inner_rect_->TransformBounds(transform);
88 return coverage.Contains(rect);
89}
TRect< Scalar > Rect
Definition rect.h:746
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition p3.cpp:47

◆ GetCoverage()

std::optional< Rect > impeller::FillPathGeometry::GetCoverage ( const Matrix transform) const
overrideprivatevirtual

Implements impeller::Geometry.

Definition at line 74 of file fill_path_geometry.cc.

75 {
77}
std::optional< Rect > GetTransformedBoundingBox(const Matrix &transform) const
Definition path.cc:343

◆ GetPositionBuffer()

GeometryResult impeller::FillPathGeometry::GetPositionBuffer ( const ContentContext renderer,
const Entity entity,
RenderPass pass 
) const
overrideprivatevirtual

Implements impeller::Geometry.

Definition at line 19 of file fill_path_geometry.cc.

22 {
23 auto& host_buffer = renderer.GetTransientsBuffer();
24
25 const auto& bounding_box = path_.GetBoundingBox();
26 if (bounding_box.has_value() && bounding_box->IsEmpty()) {
27 return GeometryResult{
29 .vertex_buffer =
31 .vertex_buffer = {},
32 .vertex_count = 0,
33 .index_type = IndexType::k16bit,
34 },
35 .transform = pass.GetOrthographicTransform() * entity.GetTransform(),
36 };
37 }
38
39 VertexBuffer vertex_buffer;
40
41 auto points = renderer.GetTessellator()->TessellateConvex(
42 path_, entity.GetTransform().GetMaxBasisLength());
43
44 vertex_buffer.vertex_buffer = host_buffer.Emplace(
45 points.data(), points.size() * sizeof(Point), alignof(Point));
46 vertex_buffer.index_buffer = {}, vertex_buffer.vertex_count = points.size();
47 vertex_buffer.index_type = IndexType::kNone;
48
49 return GeometryResult{
51 .vertex_buffer = vertex_buffer,
52 .transform = entity.GetShaderTransform(pass),
53 .mode = GetResultMode(),
54 };
55}
static const int points[]
virtual size_t size() const =0
GeometryResult::Mode GetResultMode() const override
std::optional< Rect > GetBoundingBox() const
Definition path.cc:339
@ kNone
Does not use the index buffer.
TPoint< Scalar > Point
Definition point.h:316

◆ GetResultMode()

GeometryResult::Mode impeller::FillPathGeometry::GetResultMode ( ) const
overrideprivatevirtual

Reimplemented from impeller::Geometry.

Definition at line 57 of file fill_path_geometry.cc.

57 {
58 const auto& bounding_box = path_.GetBoundingBox();
59 if (path_.IsConvex() ||
60 (bounding_box.has_value() && bounding_box->IsEmpty())) {
62 }
63
64 switch (path_.GetFillType()) {
67 case FillType::kOdd:
69 }
70
72}
FillType GetFillType() const
Definition path.cc:51
bool IsConvex() const
Definition path.cc:55
#define FML_UNREACHABLE()
Definition logging.h:109
@ kNormal
The geometry has no overlapping triangles.

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