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"
107 template <
typename VertexShaderT>
114 typename VertexShaderT::FrameInfo frame_info,
116 bool force_stencil =
false,
122 bool do_cover_draw =
false;
123 Rect cover_area = {};
125 bool is_stencil_then_cover =
128 if (!is_stencil_then_cover && force_stencil) {
130 is_stencil_then_cover =
true;
133 if (is_stencil_then_cover) {
144 options.primitive_type = stencil_geometry_result.
type;
147 switch (stencil_geometry_result.
mode) {
150 options.stencil_mode =
155 options.stencil_mode =
161 options.stencil_mode =
168 ClipPipeline::VertexShader::FrameInfo clip_frame_info;
170 clip_frame_info.mvp = stencil_geometry_result.
transform;
171 ClipPipeline::VertexShader::BindFrameInfo(
175 if (!pass.
Draw().ok()) {
183 std::optional<Rect> maybe_cover_area = geometry->
GetCoverage({});
184 if (!maybe_cover_area.has_value()) {
187 do_cover_draw =
true;
188 cover_area = maybe_cover_area.value();
194 geometry_result = create_geom_callback(renderer, entity, pass, &geom);
196 geometry_result = create_geom_callback(renderer, entity, pass, geometry);
203 options.primitive_type = geometry_result.
type;
212 frame_info.mvp = geometry_result.
transform;
218 options.depth_write_enabled =
true;
223 VertexShaderT::BindFrameInfo(
230 if (!bind_fragment_callback(pass)) {
236 return pass.
Draw().ok();
252 template <
typename VertexShaderT>
257 typename VertexShaderT::FrameInfo frame_info,
259 bool force_stencil =
false,
263 return DrawGeometry<VertexShaderT>(
this,
270 bind_fragment_callback,
272 create_geom_callback);
278 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
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)
virtual const Geometry * GetGeometry() const =0
Get the geometry that this contents will use to render.
std::function< PipelineRef(ContentContextOptions)> PipelineBuilderCallback
std::function< bool(RenderPass &pass)> BindFragmentCallback
void SetOpacityFactor(Scalar opacity)
Set the opacity factor for this color source.
HostBuffer & GetTransientsDataBuffer() const
Retrieve the current host buffer for transient storage of other non-index data.
PipelineRef GetClipPipeline(ContentContextOptions opts) const
BlendMode GetBlendMode() 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.
@ kGreater
Comparison test passes if new_value > current_value.
ContentContextOptions OptionsFromPassAndEntity(const RenderPass &pass, const Entity &entity)
VertexBuffer vertex_buffer
A 4x4 matrix using column-major storage.