 |
Flutter Impeller
|
|
Go to the documentation of this file.
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"
45 void SetGeometry(std::shared_ptr<Geometry> geometry);
50 const std::shared_ptr<Geometry>&
GetGeometry()
const;
112 std::function<std::shared_ptr<Pipeline<PipelineDescriptor>>(
115 template <
typename VertexShaderT>
120 typename VertexShaderT::FrameInfo frame_info,
122 bool enable_uvs =
false,
123 Rect texture_coverage = {},
124 const Matrix& effect_transform = {})
const {
130 const bool is_stencil_then_cover =
133 if (is_stencil_then_cover) {
138 GeometryResult stencil_geometry_result =
139 GetGeometry()->GetPositionBuffer(renderer, entity, pass);
140 if (stencil_geometry_result.vertex_buffer.vertex_count == 0u) {
143 pass.
SetVertexBuffer(std::move(stencil_geometry_result.vertex_buffer));
144 options.primitive_type = stencil_geometry_result.type;
147 switch (stencil_geometry_result.mode) {
150 options.stencil_mode =
155 options.stencil_mode =
162 ClipPipeline::VertexShader::FrameInfo clip_frame_info;
164 clip_frame_info.mvp = stencil_geometry_result.transform;
165 ClipPipeline::VertexShader::BindFrameInfo(
168 if (!pass.
Draw().ok()) {
176 std::optional<Rect> maybe_cover_area =
GetGeometry()->GetCoverage({});
177 if (!maybe_cover_area.has_value()) {
180 geometry = RectGeometry(maybe_cover_area.value());
183 GeometryResult geometry_result =
185 ? geometry.GetPositionUVBuffer(texture_coverage, effect_transform,
186 renderer, entity, pass)
187 : geometry.GetPositionBuffer(renderer, entity, pass);
188 if (geometry_result.vertex_buffer.vertex_count == 0u) {
192 options.primitive_type = geometry_result.type;
196 frame_info.mvp = geometry_result.transform;
203 options.stencil_mode =
212 VertexShaderT::BindFrameInfo(
219 if (!bind_fragment_callback(pass)) {
225 if (!pass.
Draw().ok()) {
233 auto restore = ClipRestoreContents();
236 Entity restore_entity = entity.
Clone();
238 return restore.Render(renderer, restore_entity, pass);
240 return restore.Render(renderer, entity, pass);
247 std::shared_ptr<Geometry> geometry_;
248 Matrix inverse_matrix_;
250 Scalar inherited_opacity_ = 1.0;
259 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_COLOR_SOURCE_CONTENTS_H_
std::function< std::shared_ptr< Pipeline< PipelineDescriptor > >(ContentContextOptions)> PipelineBuilderCallback
void SetClipDepth(uint32_t clip_depth)
Scalar GetOpacityFactor() const
Get the opacity factor for this color source.
virtual bool IsSolidColor() const
void SetInheritedOpacity(Scalar opacity) override
Inherit the provided opacity.
float GetShaderClipDepth() const
void SetGeometry(std::shared_ptr< Geometry > geometry)
Set the geometry that this contents will use to render.
void SetEffectTransform(Matrix matrix)
Set the effect transform for this color source.
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 enable_uvs=false, Rect texture_coverage={}, const Matrix &effect_transform={}) const
std::shared_ptr< Pipeline< PipelineDescriptor > > GetClipPipeline(ContentContextOptions opts) const
virtual bool SetVertexBuffer(VertexBuffer buffer)
Specify the vertex and index buffer to use for this command.
const std::shared_ptr< Geometry > & GetGeometry() const
Get the geometry that this contents will use to render.
bool CanInheritOpacity(const Entity &entity) const override
Whether or not this contents can accept the opacity peephole optimization.
virtual void SetCommandLabel(std::string_view label)
The debugging label to use for the command.
virtual fml::Status Draw()
Record the currently pending command.
static constexpr bool kEnableStencilThenCover
ContentContextOptions OptionsFromPassAndEntity(const RenderPass &pass, const Entity &entity)
~ColorSourceContents() override
@ kLegacyClipIncrement
Increment the stencil heightmap.
virtual void SetStencilReference(uint32_t value)
BlendMode GetBlendMode() const
Render passes encode render commands directed as one specific render target into an underlying comman...
uint32_t GetClipDepth() const
std::shared_ptr< Pipeline< PipelineDescriptor > >(impeller::ContentContext::*)(ContentContextOptions) const PipelineBuilderMethod
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< bool(RenderPass &pass)> BindFragmentCallback
BufferView EmplaceUniform(const UniformType &uniform)
Emplace uniform data onto the host buffer. Ensure that backend specific uniform alignment requirement...
virtual void SetPipeline(const std::shared_ptr< Pipeline< PipelineDescriptor >> &pipeline)
The pipeline to use for this command.
void SetOpacityFactor(Scalar opacity)
Set the opacity factor for this color source.
A 4x4 matrix using column-major storage.
const Matrix & GetInverseEffectTransform() const
Set the inverted effect transform for this color source.
HostBuffer & GetTransientsBuffer() const
Retrieve the currnent host buffer for transient storage.