 |
Flutter Impeller
|
|
Go to the documentation of this file.
12 #include "impeller/entity/texture_fill.frag.h"
13 #include "impeller/entity/texture_fill.vert.h"
41 if (geometry_->
ShouldSkip() || alpha_ <= 0.0) {
50 const std::unique_ptr<const Sampler>& dst_sampler =
51 renderer.
GetContext()->GetSamplerLibrary()->GetSampler(
52 dst_sampler_descriptor);
56 using VS = TextureFillVertexShader;
57 using FS = TextureFillFragmentShader;
61 const std::unique_ptr<const Sampler>& dst_sampler =
62 renderer.
GetContext()->GetSamplerLibrary()->GetSampler(
63 dst_sampler_descriptor);
67 pipeline_options.depth_write_enabled =
74 #endif // IMPELLER_DEBUG
76 VS::FrameInfo frame_info;
78 frame_info.texture_sampler_y_coord_scale =
79 geometry_->
GetAtlas()->GetYCoordScale();
81 VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
83 FS::FragInfo frag_info;
84 frag_info.alpha = alpha_;
85 FS::BindFragInfo(pass, host_buffer.EmplaceUniform((frag_info)));
86 FS::BindTextureSampler(pass, geometry_->
GetAtlas(), dst_sampler);
87 return pass.
Draw().ok();
99 #endif // IMPELLER_DEBUG
104 FS::FragInfo frag_info;
105 VS::FrameInfo frame_info;
107 FS::BindTextureSamplerDst(pass, geometry_->
GetAtlas(), dst_sampler);
108 frame_info.texture_sampler_y_coord_scale =
109 geometry_->
GetAtlas()->GetYCoordScale();
111 frag_info.output_alpha = alpha_;
112 frag_info.input_alpha = 1.0;
114 auto inverted_blend_mode =
116 auto blend_coefficients =
118 frag_info.src_coeff = blend_coefficients[0];
119 frag_info.src_coeff_dst_alpha = blend_coefficients[1];
120 frag_info.dst_coeff = blend_coefficients[2];
121 frag_info.dst_coeff_src_alpha = blend_coefficients[3];
122 frag_info.dst_coeff_src_color = blend_coefficients[4];
127 FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
131 auto uniform_view = host_buffer.EmplaceUniform(frame_info);
132 VS::BindFrameInfo(pass, uniform_view);
134 return pass.
Draw().ok();
140 #ifdef IMPELLER_DEBUG
143 #endif // IMPELLER_DEBUG
147 FS::BindTextureSampler(pass, geometry_->
GetAtlas(), dst_sampler);
149 VUS::FrameInfo frame_info;
150 FS::FragInfo frag_info;
152 frame_info.texture_sampler_y_coord_scale =
153 geometry_->
GetAtlas()->GetYCoordScale();
156 frag_info.alpha = alpha_;
157 frag_info.blend_mode =
static_cast<int>(blend_mode);
163 FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
164 VUS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
166 return pass.
Draw().ok();
std::shared_ptr< Pipeline< PipelineDescriptor > > GetTexturePipeline(ContentContextOptions opts) const
FragmentShader_ FragmentShader
Matrix GetShaderTransform(const RenderPass &pass) const
Get the vertex shader transform used for drawing this Entity.
ContentContextOptions OptionsFromPass(const RenderPass &pass)
virtual bool ShouldUseBlend() const =0
const char * BlendModeToString(BlendMode blend_mode)
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
virtual BlendMode GetBlendMode() const =0
constexpr TRect TransformBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle.
std::optional< BlendMode > InvertPorterDuffBlend(BlendMode blend_mode)
virtual bool SetVertexBuffer(VertexBuffer buffer)
Specify the vertex and index buffer to use for this command.
virtual const SamplerDescriptor & GetSamplerDescriptor() const =0
virtual void SetCommandLabel(std::string_view label)
The debugging label to use for the command.
virtual bool ShouldSkip() const =0
virtual fml::Status Draw()
Record the currently pending command.
ContentContextOptions OptionsFromPassAndEntity(const RenderPass &pass, const Entity &entity)
virtual std::shared_ptr< Texture > GetAtlas() const =0
~AtlasContents() override
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
std::string SPrintF(const char *format,...)
virtual VertexBuffer CreateSimpleVertexBuffer(HostBuffer &host_buffer) const =0
std::shared_ptr< Context > GetContext() const
VertexShader_ VertexShader
SamplerAddressMode width_address_mode
constexpr std::array< std::array< Scalar, 5 >, 15 > kPorterDuffCoefficients
std::shared_ptr< Pipeline< PipelineDescriptor > > GetDrawVerticesUberShader(ContentContextOptions opts) const
virtual Rect ComputeBoundingBox() const =0
Render passes encode render commands directed as one specific render target into an underlying comman...
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.
void SetGeometry(AtlasGeometry *geometry)
const Capabilities & GetDeviceCapabilities() const
virtual VertexBuffer CreateBlendVertexBuffer(HostBuffer &host_buffer) const =0
void SetAlpha(Scalar alpha)
virtual void SetPipeline(const std::shared_ptr< Pipeline< PipelineDescriptor >> &pipeline)
The pipeline to use for this command.
virtual bool SupportsDecalSamplerAddressMode() const =0
Whether the context backend supports SamplerAddressMode::Decal.
HostBuffer & GetTransientsBuffer() const
Retrieve the currnent host buffer for transient storage.
std::shared_ptr< Pipeline< PipelineDescriptor > > GetPorterDuffBlendPipeline(ContentContextOptions opts) const
@ kDecal
decal sampling mode is only supported on devices that pass the Capabilities.SupportsDecalSamplerAddre...