5#ifndef FLUTTER_IMPELLER_ENTITY_CONTENTS_COLOR_SOURCE_CONTENTS_H_
6#define FLUTTER_IMPELLER_ENTITY_CONTENTS_COLOR_SOURCE_CONTENTS_H_
112 template <
typename VertexShaderT>
119 typename VertexShaderT::FrameInfo frame_info,
121 bool force_stencil =
false,
127 bool do_cover_draw =
false;
128 Rect cover_area = {};
130 bool is_stencil_then_cover =
133 if (!is_stencil_then_cover && force_stencil) {
135 is_stencil_then_cover =
true;
138 if (is_stencil_then_cover) {
149 options.primitive_type = stencil_geometry_result.
type;
152 switch (stencil_geometry_result.
mode) {
155 options.stencil_mode =
160 options.stencil_mode =
166 options.stencil_mode =
173 ClipPipeline::VertexShader::FrameInfo clip_frame_info;
175 clip_frame_info.mvp = stencil_geometry_result.
transform;
176 ClipPipeline::VertexShader::BindFrameInfo(
188 std::optional<Rect> maybe_cover_area = geometry->
GetCoverage({});
189 if (!maybe_cover_area.has_value()) {
192 do_cover_draw =
true;
193 cover_area = maybe_cover_area.value();
199 geometry_result = create_geom_callback(renderer, entity, pass, &geom);
201 geometry_result = create_geom_callback(renderer, entity, pass, geometry);
208 options.primitive_type = geometry_result.
type;
217 frame_info.mvp = geometry_result.
transform;
226 options.stencil_mode =
231 VertexShaderT::BindFrameInfo(
238 if (!bind_fragment_callback(pass)) {
272 template <
typename VertexShaderT>
277 typename VertexShaderT::FrameInfo frame_info,
279 bool force_stencil =
false,
283 return DrawGeometry<VertexShaderT>(
this,
290 bind_fragment_callback,
292 create_geom_callback);
296 const Geometry* geometry_ =
nullptr;
299 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
static bool DrawGeometry(const Contents *contents, const Geometry *geometry, 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)
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 & GetTransientsDataBuffer() const
Retrieve the current host buffer for transient storage of other non-index data.
PipelineRef GetClipPipeline(ContentContextOptions opts) const
virtual std::optional< Rect > GetCoverage(const Entity &entity) const =0
Get the area of the render pass that will be affected when this contents is rendered.
BlendMode GetBlendMode() const
uint32_t GetClipDepth() const
float GetShaderClipDepth() const
virtual std::optional< Rect > GetCoverage(const Matrix &transform) const =0
virtual GeometryResult::Mode GetResultMode() const
virtual GeometryResult GetPositionBuffer(const ContentContext &renderer, const Entity &entity, RenderPass &pass) 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.
#define FML_UNREACHABLE()
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.