5 #ifndef FLUTTER_IMPELLER_ENTITY_CONTENTS_COLOR_SOURCE_CONTENTS_H_
6 #define FLUTTER_IMPELLER_ENTITY_CONTENTS_COLOR_SOURCE_CONTENTS_H_
8 #include "fml/logging.h"
124 template <
typename VertexShaderT>
129 typename VertexShaderT::FrameInfo frame_info,
131 bool force_stencil =
false,
137 bool do_cover_draw =
false;
138 Rect cover_area = {};
140 bool is_stencil_then_cover =
143 if (!is_stencil_then_cover && force_stencil) {
145 is_stencil_then_cover =
true;
148 if (is_stencil_then_cover) {
159 options.primitive_type = stencil_geometry_result.
type;
162 switch (stencil_geometry_result.
mode) {
165 options.stencil_mode =
170 options.stencil_mode =
176 options.stencil_mode =
183 ClipPipeline::VertexShader::FrameInfo clip_frame_info;
185 clip_frame_info.mvp = stencil_geometry_result.
transform;
186 ClipPipeline::VertexShader::BindFrameInfo(
189 if (!pass.
Draw().ok()) {
198 if (!maybe_cover_area.has_value()) {
201 do_cover_draw =
true;
202 cover_area = maybe_cover_area.value();
208 geometry_result = create_geom_callback(renderer, entity, pass, &geom);
211 create_geom_callback(renderer, entity, pass,
GetGeometry());
218 options.primitive_type = geometry_result.
type;
227 frame_info.mvp = geometry_result.
transform;
236 options.stencil_mode =
241 VertexShaderT::BindFrameInfo(
248 if (!bind_fragment_callback(pass)) {
254 if (!pass.
Draw().ok()) {
270 const Geometry* geometry_ =
nullptr;
273 Scalar inherited_opacity_ = 1.0;
void SetInheritedOpacity(Scalar opacity) override
Inherit the provided opacity.
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
const Geometry * GetGeometry() const
Get the geometry that this contents will use to render.
Scalar GetOpacityFactor() const
Get the opacity factor for this color source.
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.
std::function< GeometryResult(const ContentContext &renderer, const Entity &entity, RenderPass &pass, const Geometry *geom)> CreateGeometryCallback
static GeometryResult DefaultCreateGeometryCallback(const ContentContext &renderer, const Entity &entity, RenderPass &pass, const Geometry *geom)
bool AppliesAlphaForStrokeCoverage(const Matrix &transform) const
Whether the entity should be treated as non-opaque due to stroke geometry requiring alpha for coverag...
~ColorSourceContents() override
void SetEffectTransform(Matrix matrix)
Set the effect transform for this color source.
const Matrix & GetInverseEffectTransform() const
Set the inverted effect transform for this color source.
virtual bool IsSolidColor() const
std::function< PipelineRef(ContentContextOptions)> PipelineBuilderCallback
std::function< bool(RenderPass &pass)> BindFragmentCallback
void SetOpacityFactor(Scalar opacity)
Set the opacity factor for this color source.
void SetGeometry(const Geometry *geometry)
Set the geometry that this contents will use to render.
HostBuffer & GetTransientsBuffer() const
Retrieve the currnent host buffer for transient storage.
PipelineRef GetClipPipeline(ContentContextOptions opts) const
BlendMode GetBlendMode() const
uint32_t GetClipDepth() const
float GetShaderClipDepth() const
virtual GeometryResult::Mode GetResultMode() const
virtual GeometryResult GetPositionBuffer(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const =0
virtual std::optional< Rect > GetCoverage(const Matrix &transform) const =0
BufferView EmplaceUniform(const UniformType &uniform)
Emplace uniform data onto the host buffer. Ensure that backend specific uniform alignment requirement...
Render passes encode render commands directed as one specific render target into an underlying comman...
virtual bool SetVertexBuffer(VertexBuffer buffer)
Specify the vertex and index buffer to use for this command.
virtual void SetStencilReference(uint32_t value)
virtual void SetPipeline(PipelineRef pipeline)
The pipeline to use for this command.
virtual fml::Status Draw()
Record the currently pending command.
virtual void SetCommandLabel(std::string_view label)
The debugging label to use for the command.
raw_ptr< Pipeline< PipelineDescriptor > > PipelineRef
A raw ptr to a pipeline object.
bool RenderClipRestore(const ContentContext &renderer, RenderPass &pass, uint32_t clip_depth, std::optional< Rect > restore_coverage)
Render a restore clip.
ContentContextOptions OptionsFromPassAndEntity(const RenderPass &pass, const Entity &entity)
@ kOverdrawPreventionIncrement
VertexBuffer vertex_buffer
A 4x4 matrix using column-major storage.