| Flutter Impeller |

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

`#include <vertices_contents.h>`

Inheritance diagram for impeller::VerticesContents:

## Public Member Functions
| VerticesContents ()
| ~VerticesContents () override
void | SetGeometry (std::shared_ptr< VerticesGeometry > geometry)
void | SetAlpha (Scalar alpha)
void | SetBlendMode (BlendMode blend_mode)
void | SetSourceContents (std::shared_ptr< Contents > contents)
std::shared_ptr< VerticesGeometry > | GetGeometry () const
const std::shared_ptr< Contents > & | GetSourceContents () const
std::optional< Rect > | GetCoverage (const Entity &entity) const override
| Get the area of the render pass that will be affected when this contents is rendered. More...
bool | Render (const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Public Member Functions inherited from impeller::Contents
| Contents ()
virtual | ~Contents ()
virtual void | PopulateGlyphAtlas (const std::shared_ptr< LazyGlyphAtlas > &lazy_glyph_atlas, Scalar scale)
| Add any text data to the specified lazy atlas. The scale parameter must be used again later when drawing the text. More...
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()`. More...
const std::optional< Rect > & | GetCoverageHint () const
virtual bool | IsOpaque () 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. More...
virtual ClipCoverage | GetClipCoverage (const Entity &entity, const std::optional< Rect > &current_clip_coverage) const
| Given the current pass space bounding rectangle of the clip buffer, return the expected clip coverage after this draw call. This should only be implemented for contents that may write to the clip buffer. More...
virtual std::optional< Snapshot > | RenderToSnapshot (const ContentContext &renderer, const Entity &entity, std::optional< Rect > coverage_limit=std::nullopt, const std::optional< SamplerDescriptor > &sampler_descriptor=std::nullopt, bool msaa_enabled=true, const std::string &label="Snapshot") 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)`. More...
virtual bool | ShouldRender (const Entity &entity, const std::optional< Rect > clip_coverage) const
std::optional< Size > | GetColorSourceSize () const
| Return the color source's intrinsic size, if available. More...
void | SetColorSourceSize (Size size)
virtual bool | CanInheritOpacity (const Entity &entity) const
| Whether or not this contents can accept the opacity peephole optimization. More...
virtual void | SetInheritedOpacity (Scalar opacity)
| Inherit the provided opacity. More...
virtual std::optional< Color > | AsBackgroundColor (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. More...
virtual const FilterContents * | AsFilter () const
| Cast to a filter. Returns `nullptr` if this Contents is not a filter. More...
virtual bool | ApplyColorFilter (const ColorFilterProc &color_filter_proc)
| If possible, applies a color filter to this contents inputs on the CPU. More...

## Additional Inherited Members
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)>
Static Public Member Functions inherited from impeller::Contents
static std::shared_ptr< Contents > | MakeAnonymous (RenderProc render_proc, CoverageProc coverage_proc)

## Detailed Description

Definition at line 24 of file vertices_contents.h.

## Constructor & Destructor Documentation

## ◆ VerticesContents()

impeller::VerticesContents::VerticesContents | ( |  | ) |
| default

## ◆ ~VerticesContents()

impeller::VerticesContents::~VerticesContents | ( |  | ) |
| override default

## Member Function Documentation

## ◆ GetCoverage()

std::optional< Rect > impeller::VerticesContents::GetCoverage | ( | const Entity & | entity | ) | const
| override virtual

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 20 of file vertices_contents.cc.

20 {
21 return geometry_->GetCoverage(entity.GetTransform());
22 };

References impeller::Entity::GetTransform().

Referenced by impeller::VerticesColorContents::GetCoverage(), and impeller::VerticesUVContents::GetCoverage().

## ◆ GetGeometry()

std::shared_ptr< VerticesGeometry > impeller::VerticesContents::GetGeometry | ( |  | ) | const

Definition at line 32 of file vertices_contents.cc.

32 {
33 return geometry_;
34 }

Referenced by impeller::VerticesColorContents::Render(), and impeller::VerticesUVContents::Render().

## ◆ GetSourceContents()

const std::shared_ptr< Contents > & impeller::VerticesContents::GetSourceContents | ( |  | ) | const

Definition at line 44 of file vertices_contents.cc.

44 {
45 return src_contents_;
46 }

Referenced by impeller::VerticesUVContents::Render().

## ◆ Render()

bool impeller::VerticesContents::Render | ( | const ContentContext & | renderer,
|  | const Entity & | entity,
|  | RenderPass & | pass
| ) |  | const
| override virtual

Implements impeller::Contents.

Definition at line 48 of file vertices_contents.cc.

50 {
51 if (blend_mode_ == BlendMode::kClear) {
52 return true;
53 }
54 std::shared_ptr<Contents> src_contents = src_contents_;
55 src_contents->SetCoverageHint(GetCoverageHint());
56 if (geometry_->HasTextureCoordinates()) {
57 auto contents = std::make_shared<VerticesUVContents>(*this);
58 contents->SetCoverageHint(GetCoverageHint());
59 if (!geometry_->HasVertexColors()) {
60 contents->SetAlpha(alpha_);
61 return contents->Render(renderer, entity, pass);
62 }
63 src_contents = contents;
64 }
65
66 auto dst_contents = std::make_shared<VerticesColorContents>(*this);
67 dst_contents->SetCoverageHint(GetCoverageHint());
68
69 std::shared_ptr<Contents> contents;
70 if (blend_mode_ == BlendMode::kDestination) {
71 dst_contents->SetAlpha(alpha_);
72 contents = dst_contents;
73 } else {
74 auto color_filter_contents = ColorFilterContents::MakeBlend(
75 blend_mode_, {FilterInput::Make(dst_contents, false),
76 FilterInput::Make(src_contents, false)});
77 color_filter_contents->SetAlpha(alpha_);
78 color_filter_contents->SetCoverageHint(GetCoverageHint());
79 contents = color_filter_contents;
80 }
81
82 FML_DCHECK(contents->GetCoverageHint() == GetCoverageHint());
83 return contents->Render(renderer, entity, pass);
84 }

References impeller::Contents::GetCoverageHint(), impeller::kClear, impeller::kDestination, impeller::FilterInput::Make(), and impeller::ColorFilterContents::MakeBlend().

## ◆ SetAlpha()

void impeller::VerticesContents::SetAlpha | ( | Scalar | alpha | ) |

Definition at line 36 of file vertices_contents.cc.

36 {
37 alpha_ = alpha;
38 }

## ◆ SetBlendMode()

void impeller::VerticesContents::SetBlendMode | ( | BlendMode | blend_mode | ) |

Definition at line 40 of file vertices_contents.cc.

40 {
41 blend_mode_ = blend_mode;
42 }

## ◆ SetGeometry()

void impeller::VerticesContents::SetGeometry | ( | std::shared_ptr< VerticesGeometry > | geometry | ) |

Definition at line 24 of file vertices_contents.cc.

24 {
25 geometry_ = std::move(geometry);
26 }

## ◆ SetSourceContents()

void impeller::VerticesContents::SetSourceContents | ( | std::shared_ptr< Contents > | contents | ) |

Definition at line 28 of file vertices_contents.cc.

28 {
29 src_contents_ = std::move(contents);
30 }

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

- impeller/entity/contents/vertices_contents.h
- impeller/entity/contents/vertices_contents.cc

impeller::FilterInput::Make
static FilterInput::Ref Make(Variant input, bool msaa_enabled=true)
Definition: filter_input.cc:19
impeller::BlendMode::kDestination
@ kDestination
impeller::Contents::GetCoverageHint
const std::optional< Rect > & GetCoverageHint() const
Definition: contents.cc:152
impeller::BlendMode::kClear
@ kClear
impeller::ColorFilterContents::MakeBlend
static std::shared_ptr< ColorFilterContents > MakeBlend(BlendMode blend_mode, FilterInput::Vector inputs, std::optional< Color > foreground_color=std::nullopt)
the [inputs] are expected to be in the order of dst, src.
Definition: color_filter_contents.cc:17