Flutter Engine
 
Loading...
Searching...
No Matches
impeller::CircleContents Class Reference

#include <circle_contents.h>

Inheritance diagram for impeller::CircleContents:
impeller::ColorSourceContents impeller::Contents

Public Member Functions

bool Render (const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
 
std::optional< RectGetCoverage (const Entity &entity) const override
 Get the area of the render pass that will be affected when this contents is rendered.
 
- Public Member Functions inherited from impeller::ColorSourceContents
 ColorSourceContents ()
 
 ~ColorSourceContents () override
 
void SetGeometry (const Geometry *geometry)
 Set the geometry that this contents will use to render.
 
const GeometryGetGeometry () const
 Get the geometry that this contents will use to render.
 
void SetEffectTransform (Matrix matrix)
 Set the effect transform for this color source.
 
const MatrixGetInverseEffectTransform () const
 Set the inverted effect transform for this color source.
 
void SetOpacityFactor (Scalar opacity)
 Set the opacity factor for this color source.
 
Scalar GetOpacityFactor () const
 Get the opacity factor for this color source.
 
virtual bool IsSolidColor () const
 
std::optional< RectGetCoverage (const Entity &entity) const override
 Get the area of the render pass that will be affected when this contents is rendered.
 
void SetInheritedOpacity (Scalar opacity) override
 Inherit the provided opacity.
 
- Public Member Functions inherited from impeller::Contents
 Contents ()
 
virtual ~Contents ()
 
void SetCoverageHint (std::optional< Rect > coverage_hint)
 Hint that specifies the coverage area of this Contents that will actually be used during rendering. This is for optimization purposes only and can not be relied on as a clip. May optionally affect the result of GetCoverage().
 
const std::optional< Rect > & GetCoverageHint () const
 
virtual bool IsOpaque (const Matrix &transform) const
 Whether this Contents only emits opaque source colors from the fragment stage. This value does not account for any entity properties (e.g. the blend mode), clips/visibility culling, or inherited opacity.
 
virtual std::optional< SnapshotRenderToSnapshot (const ContentContext &renderer, const Entity &entity, const SnapshotOptions &options) const
 Render this contents to a snapshot, respecting the entity's transform, path, clip depth, and blend mode. The result texture size is always the size of GetCoverage(entity).
 
std::optional< SizeGetColorSourceSize () const
 Return the color source's intrinsic size, if available.
 
void SetColorSourceSize (Size size)
 
virtual std::optional< ColorAsBackgroundColor (const Entity &entity, ISize target_size) const
 Returns a color if this Contents will flood the given target_size with a color. This output color is the "Source" color that will be used for the Entity's blend operation.
 
virtual bool ApplyColorFilter (const ColorFilterProc &color_filter_proc)
 If possible, applies a color filter to this contents inputs on the CPU.
 

Static Public Member Functions

static std::unique_ptr< CircleContentsMake (std::unique_ptr< CircleGeometry > geometry, Color color, bool stroked)
 
- Static Public Member Functions inherited from impeller::ColorSourceContents
template<typename VertexShaderT >
static bool DrawGeometry (const Contents *contents, const Geometry *geometry, const ContentContext &renderer, const Entity &entity, RenderPass &pass, const PipelineBuilderCallback &pipeline_callback, typename VertexShaderT::FrameInfo frame_info, const BindFragmentCallback &bind_fragment_callback, bool force_stencil=false, const CreateGeometryCallback &create_geom_callback=DefaultCreateGeometryCallback)
 
- Static Public Member Functions inherited from impeller::Contents
static std::shared_ptr< ContentsMakeAnonymous (RenderProc render_proc, CoverageProc coverage_proc)
 

Additional Inherited Members

- Public Types inherited from impeller::ColorSourceContents
using BindFragmentCallback = std::function< bool(RenderPass &pass)>
 
using PipelineBuilderCallback = std::function< PipelineRef(ContentContextOptions)>
 
using CreateGeometryCallback = std::function< GeometryResult(const ContentContext &renderer, const Entity &entity, RenderPass &pass, const Geometry *geom)>
 
- Public Types inherited from impeller::Contents
using ColorFilterProc = std::function< Color(Color)>
 
using RenderProc = std::function< bool(const ContentContext &renderer, const Entity &entity, RenderPass &pass)>
 
using CoverageProc = std::function< std::optional< Rect >(const Entity &entity)>
 
- Protected Member Functions inherited from impeller::ColorSourceContents
bool AppliesAlphaForStrokeCoverage (const Matrix &transform) const
 Whether the entity should be treated as non-opaque due to stroke geometry requiring alpha for coverage.
 
template<typename VertexShaderT >
bool DrawGeometry (const ContentContext &renderer, const Entity &entity, RenderPass &pass, const PipelineBuilderCallback &pipeline_callback, typename VertexShaderT::FrameInfo frame_info, const BindFragmentCallback &bind_fragment_callback, bool force_stencil=false, const CreateGeometryCallback &create_geom_callback=DefaultCreateGeometryCallback) const
 
- Static Protected Member Functions inherited from impeller::ColorSourceContents
static GeometryResult DefaultCreateGeometryCallback (const ContentContext &renderer, const Entity &entity, RenderPass &pass, const Geometry *geom)
 

Detailed Description

Definition at line 15 of file circle_contents.h.

Member Function Documentation

◆ GetCoverage()

std::optional< Rect > impeller::CircleContents::GetCoverage ( const Entity entity) const
overridevirtual

Get the area of the render pass that will be affected when this contents is rendered.

During rendering, coverage coordinates count pixels from the top left corner of the framebuffer.

Returns
The coverage rectangle. An std::nullopt result means that rendering this contents has no effect on the output color.

Implements impeller::Contents.

Definition at line 88 of file circle_contents.cc.

88 {
89 return geometry_->GetCoverage(entity.GetTransform());
90}

References impeller::Entity::GetTransform().

◆ Make()

std::unique_ptr< CircleContents > impeller::CircleContents::Make ( std::unique_ptr< CircleGeometry geometry,
Color  color,
bool  stroked 
)
static

Definition at line 36 of file circle_contents.cc.

39 {
40 return std::unique_ptr<CircleContents>(
41 new CircleContents(std::move(geometry), color, stroked));
42}

◆ Render()

bool impeller::CircleContents::Render ( const ContentContext renderer,
const Entity entity,
RenderPass pass 
) const
overridevirtual

Implements impeller::Contents.

Definition at line 49 of file circle_contents.cc.

51 {
52 auto& data_host_buffer = renderer.GetTransientsDataBuffer();
53
54 VS::FrameInfo frame_info;
55 FS::FragInfo frag_info;
56 frag_info.color = color_.WithAlpha(color_.alpha * GetOpacityFactor());
57 frag_info.center = geometry_->GetCenter();
58 frag_info.radius = geometry_->GetRadius();
59 frag_info.stroke_width = geometry_->GetStrokeWidth();
60 frag_info.aa_pixels = 1.0;
61 frag_info.stroked = stroked_ ? 1.0f : 0.0f;
62
63 auto geometry_result =
64 CreateGeometry(renderer, entity, pass, geometry_.get());
65
66 PipelineBuilderCallback pipeline_callback =
67 [&renderer](ContentContextOptions options) {
68 return renderer.GetCirclePipeline(options);
69 };
70
71 return ColorSourceContents::DrawGeometry<VS>(
72 this, geometry_.get(), renderer, entity, pass, pipeline_callback,
73 frame_info,
74 /*bind_fragment_callback=*/
75 [&frag_info, &data_host_buffer](RenderPass& pass) {
76 FS::BindFragInfo(pass, data_host_buffer.EmplaceUniform(frag_info));
77 pass.SetCommandLabel("Circle");
78 return true;
79 },
80 /*force_stencil=*/false,
81 /*create_geom_callback=*/
82 [geometry_result = std::move(geometry_result)](
83 const ContentContext& renderer, const Entity& entity,
84 RenderPass& pass,
85 const Geometry* geometry) { return geometry_result; });
86}
Scalar GetOpacityFactor() const
Get the opacity factor for this color source.
std::function< PipelineRef(ContentContextOptions)> PipelineBuilderCallback
Scalar alpha
Definition color.h:143
constexpr Color WithAlpha(Scalar new_alpha) const
Definition color.h:278

References impeller::Color::alpha, impeller::ContentContext::GetCirclePipeline(), impeller::ColorSourceContents::GetOpacityFactor(), impeller::ContentContext::GetTransientsDataBuffer(), and impeller::Color::WithAlpha().


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