| 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 screen space bounding rectangle that this contents affects. 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 StencilCoverage | GetStencilCoverage (const Entity &entity, const std::optional< Rect > &current_stencil_coverage) const
| Given the current screen space bounding rectangle of the stencil, return the expected stencil coverage after this draw call. This should only be implemented for contents that may write to the stencil 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, stencil 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 > &stencil_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 23 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 screen space bounding rectangle that this contents affects.

Implements impeller::Contents.

Definition at line 25 of file vertices_contents.cc.

25 {
26 return geometry_->GetCoverage(entity.GetTransformation());
27 };

References impeller::Entity::GetTransformation().

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

## ◆ GetGeometry()

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

Definition at line 37 of file vertices_contents.cc.

37 {
38 return geometry_;
39 }

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

## ◆ GetSourceContents()

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

Definition at line 49 of file vertices_contents.cc.

49 {
50 return src_contents_;
51 }

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

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

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

41 {
42 alpha_ = alpha;
43 }

## ◆ SetBlendMode()

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

Definition at line 45 of file vertices_contents.cc.

45 {
46 blend_mode_ = blend_mode;
47 }

## ◆ SetGeometry()

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

Definition at line 29 of file vertices_contents.cc.

29 {
30 geometry_ = std::move(geometry);
31 }

## ◆ SetSourceContents()

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

Definition at line 33 of file vertices_contents.cc.

33 {
34 src_contents_ = std::move(contents);
35 }

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::Contents::GetCoverageHint
const std::optional< Rect > & GetCoverageHint() const
Definition: contents.cc:155
impeller::BlendMode::kDestination
@ kDestination
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