| Flutter Impeller |

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

`#include <shadow_vertices_contents.h>`

Inheritance diagram for impeller::ShadowVerticesContents:

## Public Member Functions
void | SetColor (Color color) override
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
| ShadowVerticesContents (const std::shared_ptr< ShadowVertices > &geometry)
| ~ShadowVerticesContents () override
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()`. More...
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. More...
virtual std::optional< Snapshot > | RenderToSnapshot (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)`. More...
std::optional< Size > | GetColorSourceSize () const
| Return the color source's intrinsic size, if available. More...
void | SetColorSourceSize (Size size)
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 bool | ApplyColorFilter (const ColorFilterProc &color_filter_proc)
| If possible, applies a color filter to this contents inputs on the CPU. More...

## Static Public Member Functions
static std::shared_ptr< ShadowVerticesContents > | Make (const std::shared_ptr< ShadowVertices > &geometry)
Static Public Member Functions inherited from impeller::Contents
static std::shared_ptr< Contents > | MakeAnonymous (RenderProc render_proc, CoverageProc coverage_proc)

## 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)>

## Detailed Description

A vertices contents for (optional) per-color vertices + texture and any blend mode.

Definition at line 20 of file shadow_vertices_contents.h.

## Constructor & Destructor Documentation

## ◆ ShadowVerticesContents()

impeller::ShadowVerticesContents::ShadowVerticesContents | ( | const std::shared_ptr< ShadowVertices > & | geometry | ) |
| explicit

Definition at line 26 of file shadow_vertices_contents.cc.

28 : geometry_(geometry) {}

## ◆ ~ShadowVerticesContents()

impeller::ShadowVerticesContents::~ShadowVerticesContents | ( |  | ) |
| override

Definition at line 30 of file shadow_vertices_contents.cc.

30 {}

## Member Function Documentation

## ◆ GetCoverage()

std::optional< Rect > impeller::ShadowVerticesContents::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 37 of file shadow_vertices_contents.cc.

38 {
39 return geometry_->GetBounds();
40 }

## ◆ Make()

std::shared_ptr< ShadowVerticesContents > impeller::ShadowVerticesContents::Make | ( | const std::shared_ptr< ShadowVertices > & | geometry | ) |
| static

Definition at line 32 of file shadow_vertices_contents.cc.

33 {
34 return std::make_shared<ShadowVerticesContents>(geometry);
35 }

Referenced by impeller::Canvas::PathBlurShape::BuildBlurContent().

## ◆ Render()

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

Implements impeller::Contents.

Definition at line 46 of file shadow_vertices_contents.cc.

48 {
49 using VS = ShadowVerticesVertexShader;
50 using FS = ShadowVerticesFragmentShader;
51
52 GeometryResult geometry_result =
53 geometry_->GetPositionBuffer(renderer, entity, pass);
54 if (geometry_result.vertex_buffer.vertex_count == 0) {
55 return true;
56 }
57 FML_DCHECK(geometry_result.mode == GeometryResult::Mode::kNormal);
58
59 #ifdef IMPELLER_DEBUG
60 pass.SetCommandLabel("DrawShadow VertexMesh");
61 #endif // IMPELLER_DEBUG
62
63 pass.SetVertexBuffer(std::move(geometry_result.vertex_buffer));
64
65 auto options = OptionsFromPassAndEntity(pass, entity);
66 options.primitive_type = geometry_result.type;
67 pass.SetPipeline(renderer.GetDrawShadowVerticesPipeline(options));
68
69 VS::FrameInfo frame_info;
70 FS::FragInfo frag_info;
71
72 frame_info.mvp = entity.GetShaderTransform(pass);
73
74 frag_info.shadow_color = shadow_color_.Premultiply();
75
76 auto& host_buffer = renderer.GetTransientsDataBuffer();
77 FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
78 VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
79
80 return pass.Draw().ok();
81 }
impeller::FS
LinePipeline::FragmentShader FS
Definition: line_contents.cc:14
impeller::VS
LinePipeline::VertexShader VS
Definition: line_contents.cc:13
impeller::OptionsFromPassAndEntity
ContentContextOptions OptionsFromPassAndEntity(const RenderPass &pass, const Entity &entity)
Definition: contents.cc:34
impeller::Color::Premultiply
constexpr Color Premultiply() const
Definition: color.h:212
impeller::GeometryResult::Mode::kNormal
@ kNormal
The geometry has no overlapping triangles.

References impeller::RenderPass::Draw(), impeller::ContentContext::GetDrawShadowVerticesPipeline(), impeller::Entity::GetShaderTransform(), impeller::ContentContext::GetTransientsDataBuffer(), impeller::GeometryResult::kNormal, impeller::GeometryResult::mode, impeller::OptionsFromPassAndEntity(), impeller::Color::Premultiply(), impeller::RenderPass::SetCommandLabel(), impeller::RenderPass::SetPipeline(), impeller::RenderPass::SetVertexBuffer(), impeller::GeometryResult::type, impeller::GeometryResult::vertex_buffer, and impeller::VertexBuffer::vertex_count.

## ◆ SetColor()

void impeller::ShadowVerticesContents::SetColor | ( | Color | color | ) |
| override virtual

Implements impeller::SolidBlurContents.

Definition at line 42 of file shadow_vertices_contents.cc.

42 {
43 shadow_color_ = color;
44 }

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

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