Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
impeller::ShadowVerticesContents Class Referencefinal

#include <shadow_vertices_contents.h>

Inheritance diagram for impeller::ShadowVerticesContents:
impeller::SolidBlurContents impeller::Contents

Public Member Functions

void SetColor (Color color) 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.
 
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().
 
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 void SetInheritedOpacity (Scalar opacity)
 Inherit the provided opacity.
 
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::shared_ptr< ShadowVerticesContentsMake (const std::shared_ptr< ShadowVertices > &geometry)
 
- 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::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
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 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
overridevirtual

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}
#define FML_DCHECK(condition)
Definition logging.h:122
LinePipeline::FragmentShader FS
LinePipeline::VertexShader VS
ContentContextOptions OptionsFromPassAndEntity(const RenderPass &pass, const Entity &entity)
Definition contents.cc:34
constexpr Color Premultiply() const
Definition color.h:212
@ kNormal
The geometry has no overlapping triangles.

References impeller::RenderPass::Draw(), FML_DCHECK, impeller::ContentContext::GetDrawShadowVerticesPipeline(), impeller::Entity::GetShaderTransform(), impeller::ContentContext::GetTransientsDataBuffer(), impeller::GeometryResult::kNormal, impeller::GeometryResult::mode, fml::Status::ok(), 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)
overridevirtual

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: