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

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

#include <stroke_path_geometry.h>

Inheritance diagram for impeller::StrokePathGeometry:
impeller::Geometry

Public Member Functions

 StrokePathGeometry (const Path &path, Scalar stroke_width, Scalar miter_limit, Cap stroke_cap, Join stroke_join)
 
 ~StrokePathGeometry ()
 
Scalar GetStrokeWidth () const
 
Scalar GetMiterLimit () const
 
Cap GetStrokeCap () const
 
Join GetStrokeJoin () const
 
- Public Member Functions inherited from impeller::Geometry
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
 

Private Member Functions

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

Friends

class ImpellerBenchmarkAccessor
 
class ImpellerEntityUnitTestAccessor
 

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

Definition at line 13 of file stroke_path_geometry.h.

Constructor & Destructor Documentation

◆ StrokePathGeometry()

impeller::StrokePathGeometry::StrokePathGeometry ( const Path path,
Scalar  stroke_width,
Scalar  miter_limit,
Cap  stroke_cap,
Join  stroke_join 
)

Definition at line 484 of file stroke_path_geometry.cc.

489 : path_(path),
490 stroke_width_(stroke_width),
491 miter_limit_(miter_limit),
492 stroke_cap_(stroke_cap),
493 stroke_join_(stroke_join) {}
const Scalar stroke_width

◆ ~StrokePathGeometry()

impeller::StrokePathGeometry::~StrokePathGeometry ( )
default

Member Function Documentation

◆ GetCoverage()

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

Implements impeller::Geometry.

Definition at line 561 of file stroke_path_geometry.cc.

562 {
563 auto path_bounds = path_.GetBoundingBox();
564 if (!path_bounds.has_value()) {
565 return std::nullopt;
566 }
567
568 Scalar max_radius = 0.5;
569 if (stroke_cap_ == Cap::kSquare) {
570 max_radius = max_radius * kSqrt2;
571 }
572 if (stroke_join_ == Join::kMiter) {
573 max_radius = std::max(max_radius, miter_limit_ * 0.5f);
574 }
575 Scalar determinant = transform.GetDeterminant();
576 if (determinant == 0) {
577 return std::nullopt;
578 }
579 Scalar min_size = 1.0f / sqrt(std::abs(determinant));
580 max_radius *= std::max(stroke_width_, min_size);
581 return path_bounds->Expand(max_radius).TransformBounds(transform);
582}
std::optional< Rect > GetBoundingBox() const
Definition path.cc:339
float Scalar
Definition scalar.h:18
constexpr float kSqrt2
Definition constants.h:47
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
Definition SkVx.h:706
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition p3.cpp:47

◆ GetMiterLimit()

Scalar impeller::StrokePathGeometry::GetMiterLimit ( ) const

Definition at line 501 of file stroke_path_geometry.cc.

501 {
502 return miter_limit_;
503}

◆ GetPositionBuffer()

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

Implements impeller::Geometry.

Definition at line 513 of file stroke_path_geometry.cc.

516 {
517 if (stroke_width_ < 0.0) {
518 return {};
519 }
520 auto determinant = entity.GetTransform().GetDeterminant();
521 if (determinant == 0) {
522 return {};
523 }
524
525 Scalar min_size = 1.0f / sqrt(std::abs(determinant));
526 Scalar stroke_width = std::max(stroke_width_, min_size);
527
528 auto& host_buffer = renderer.GetTransientsBuffer();
529 auto scale = entity.GetTransform().GetMaxBasisLength();
530
531 PositionWriter position_writer;
532 auto polyline = renderer.GetTessellator()->CreateTempPolyline(path_, scale);
533 CreateSolidStrokeVertices(position_writer, polyline, stroke_width,
534 miter_limit_ * stroke_width_ * 0.5f,
535 GetJoinProc<PositionWriter>(stroke_join_),
536 GetCapProc<PositionWriter>(stroke_cap_), scale);
537
538 BufferView buffer_view =
539 host_buffer.Emplace(position_writer.GetData().data(),
540 position_writer.GetData().size() *
541 sizeof(SolidFillVertexShader::PerVertexData),
542 alignof(SolidFillVertexShader::PerVertexData));
543
544 return GeometryResult{
546 .vertex_buffer =
547 {
548 .vertex_buffer = buffer_view,
549 .vertex_count = position_writer.GetData().size(),
550 .index_type = IndexType::kNone,
551 },
552 .transform = entity.GetShaderTransform(pass),
554 };
555}
@ kNone
Does not use the index buffer.
const Scalar scale
const Path::Polyline & polyline

◆ GetResultMode()

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

Reimplemented from impeller::Geometry.

Definition at line 557 of file stroke_path_geometry.cc.

◆ GetStrokeCap()

Cap impeller::StrokePathGeometry::GetStrokeCap ( ) const

Definition at line 505 of file stroke_path_geometry.cc.

505 {
506 return stroke_cap_;
507}

◆ GetStrokeJoin()

Join impeller::StrokePathGeometry::GetStrokeJoin ( ) const

Definition at line 509 of file stroke_path_geometry.cc.

509 {
510 return stroke_join_;
511}

◆ GetStrokeWidth()

Scalar impeller::StrokePathGeometry::GetStrokeWidth ( ) const

Definition at line 497 of file stroke_path_geometry.cc.

497 {
498 return stroke_width_;
499}

Friends And Related Symbol Documentation

◆ ImpellerBenchmarkAccessor

friend class ImpellerBenchmarkAccessor
friend

Definition at line 52 of file stroke_path_geometry.h.

◆ ImpellerEntityUnitTestAccessor

friend class ImpellerEntityUnitTestAccessor
friend

Definition at line 53 of file stroke_path_geometry.h.


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