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"
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(
179 if (!pass.
Draw().ok()) {
187 std::optional<Rect> maybe_cover_area = geometry->
GetCoverage({});
188 if (!maybe_cover_area.has_value()) {
191 do_cover_draw =
true;
192 cover_area = maybe_cover_area.value();
198 geometry_result = create_geom_callback(renderer, entity, pass, &geom);
200 geometry_result = create_geom_callback(renderer, entity, pass, geometry);
207 options.primitive_type = geometry_result.
type;
216 frame_info.mvp = geometry_result.
transform;
225 options.stencil_mode =
230 VertexShaderT::BindFrameInfo(
237 if (!bind_fragment_callback(pass)) {
243 if (!pass.
Draw().ok()) {
271 template <
typename VertexShaderT>
276 typename VertexShaderT::FrameInfo frame_info,
278 bool force_stencil =
false,
282 return DrawGeometry<VertexShaderT>(
this,
289 bind_fragment_callback,
291 create_geom_callback);
295 const Geometry* geometry_ =
nullptr;
298 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 & GetTransientsBuffer() const
Retrieve the currnent host buffer for transient storage.
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 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.