 |
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"
46 void SetGeometry(std::shared_ptr<Geometry> geometry);
51 const std::shared_ptr<Geometry>&
GetGeometry()
const;
113 std::function<std::shared_ptr<Pipeline<PipelineDescriptor>>(
129 template <
typename VertexShaderT>
134 typename VertexShaderT::FrameInfo frame_info,
136 bool force_stencil =
false,
144 bool is_stencil_then_cover =
147 if (!is_stencil_then_cover && force_stencil) {
149 is_stencil_then_cover =
true;
152 if (is_stencil_then_cover) {
158 GetGeometry()->GetPositionBuffer(renderer, entity, pass);
163 options.primitive_type = stencil_geometry_result.
type;
166 switch (stencil_geometry_result.
mode) {
169 options.stencil_mode =
174 options.stencil_mode =
180 options.stencil_mode =
187 ClipPipeline::VertexShader::FrameInfo clip_frame_info;
189 clip_frame_info.mvp = stencil_geometry_result.
transform;
190 ClipPipeline::VertexShader::BindFrameInfo(
193 if (!pass.
Draw().ok()) {
201 std::optional<Rect> maybe_cover_area =
GetGeometry()->GetCoverage({});
202 if (!maybe_cover_area.has_value()) {
209 create_geom_callback(renderer, entity, pass, geometry);
214 options.primitive_type = geometry_result.
type;
218 frame_info.mvp = geometry_result.
transform;
225 options.stencil_mode =
230 VertexShaderT::BindFrameInfo(
237 if (!bind_fragment_callback(pass)) {
243 if (!pass.
Draw().ok()) {
254 return restore.
Render(renderer, restore_entity, pass);
260 std::shared_ptr<Geometry> geometry_;
263 Scalar inherited_opacity_ = 1.0;
272 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_COLOR_SOURCE_CONTENTS_H_
std::function< std::shared_ptr< Pipeline< PipelineDescriptor > >(ContentContextOptions)> PipelineBuilderCallback
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.
@ kOverdrawPreventionIncrement
static GeometryResult DefaultCreateGeometryCallback(const ContentContext &renderer, const Entity &entity, RenderPass &pass, const Geometry &geom)
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.
std::function< GeometryResult(const ContentContext &renderer, const Entity &entity, RenderPass &pass, const Geometry &geom)> CreateGeometryCallback
virtual void SetCommandLabel(std::string_view label)
The debugging label to use for the command.
virtual fml::Status Draw()
Record the currently pending command.
ContentContextOptions OptionsFromPassAndEntity(const RenderPass &pass, const Entity &entity)
~ColorSourceContents() override
bool Render(const ContentContext &renderer, RenderPass &parent_pass) const
virtual GeometryResult GetPositionBuffer(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const =0
virtual void SetStencilReference(uint32_t value)
BlendMode GetBlendMode() const
Render passes encode render commands directed as one specific render target into an underlying comman...
std::shared_ptr< Pipeline< PipelineDescriptor > >(impeller::ContentContext::*)(ContentContextOptions) const PipelineBuilderMethod
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
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.
VertexBuffer vertex_buffer
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.