7 #include "fml/logging.h"
24 const Capabilities& capabilities) {
36 if (capabilities.SupportsDecalSamplerAddressMode()) {
52 std::shared_ptr<VerticesGeometry> geometry) {
53 geometry_ = std::move(geometry);
61 blend_mode_ = blend_mode;
65 texture_ = std::move(texture);
69 const Entity& entity)
const {
75 descriptor_ = descriptor;
80 tile_mode_x_ = tile_mode_x;
81 tile_mode_y_ = tile_mode_y;
90 lazy_texture_ = lazy_texture;
94 lazy_texture_coverage_ = rect;
100 FML_DCHECK(texture_ || lazy_texture_ || blend_mode_ ==
BlendMode::kDst);
102 if (!geometry_->HasVertexColors()) {
106 std::shared_ptr<Texture> texture;
109 texture = lazy_texture_(renderer);
117 VALIDATION_LOG <<
"Missing texture for VerticesSimpleBlendContents";
121 auto dst_sampler_descriptor = descriptor_;
125 dst_sampler_descriptor.height_address_mode =
130 renderer.
GetContext()->GetSamplerLibrary()->GetSampler(
131 dst_sampler_descriptor);
133 GeometryResult geometry_result = geometry_->GetPositionUVColorBuffer(
134 lazy_texture_coverage_.has_value() ? lazy_texture_coverage_.value()
136 inverse_matrix_, renderer, entity, pass);
146 #ifdef IMPELLER_DEBUG
153 options.primitive_type = geometry_result.
type;
154 auto inverted_blend_mode =
159 FS::BindTextureSamplerDst(pass, texture, dst_sampler);
161 VS::FrameInfo frame_info;
162 FS::FragInfo frag_info;
164 frame_info.texture_sampler_y_coord_scale = texture->GetYCoordScale();
165 frame_info.mvp = geometry_result.
transform;
167 frag_info.input_alpha_output_alpha_tmx_tmy =
168 Vector4(1, alpha_,
static_cast<int>(tile_mode_x_),
169 static_cast<int>(tile_mode_y_));
170 frag_info.use_strict_source_rect = 0.0;
173 FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
174 VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
176 return pass.
Draw().ok();
182 #ifdef IMPELLER_DEBUG
189 options.primitive_type = geometry_result.
type;
192 FS::BindTextureSampler(pass, texture, dst_sampler);
194 VS::FrameInfo frame_info;
195 FS::FragInfo frag_info;
197 frame_info.texture_sampler_y_coord_scale = texture->GetYCoordScale();
198 frame_info.mvp = geometry_result.
transform;
199 frag_info.alpha = alpha_;
200 frag_info.blend_mode =
static_cast<int>(blend_mode);
203 frag_info.tmx =
static_cast<int>(tile_mode_x_);
204 frag_info.tmy =
static_cast<int>(tile_mode_y_);
207 FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
208 VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
210 return pass.
Draw().ok();
HostBuffer & GetTransientsBuffer() const
Retrieve the currnent host buffer for transient storage.
PipelineRef GetPorterDuffPipeline(BlendMode mode, ContentContextOptions opts) const
std::shared_ptr< Texture > GetEmptyTexture() const
const Capabilities & GetDeviceCapabilities() const
std::shared_ptr< Context > GetContext() const
PipelineRef GetDrawVerticesUberPipeline(BlendMode blend_mode, ContentContextOptions opts) const
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
static constexpr BlendMode kLastPipelineBlendMode
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 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.
VertexShader_ VertexShader
FragmentShader_ FragmentShader
void SetSamplerDescriptor(const SamplerDescriptor &descriptor)
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 SetBlendMode(BlendMode blend_mode)
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
void SetTileMode(Entity::TileMode tile_mode_x, Entity::TileMode tile_mode_y)
void SetLazyTexture(const LazyTexture &lazy_texture)
void SetLazyTextureCoverage(Rect rect)
~VerticesSimpleBlendContents() override
std::function< std::shared_ptr< Texture >(const ContentContext &renderer)> LazyTexture
void SetEffectTransform(Matrix transform)
void SetTexture(std::shared_ptr< Texture > texture)
void SetGeometry(std::shared_ptr< VerticesGeometry > geometry)
void SetAlpha(Scalar alpha)
VerticesSimpleBlendContents()
A wrapper around a raw ptr that adds additional unopt mode only checks.
@ kDecal
decal sampling mode is only supported on devices that pass the Capabilities.SupportsDecalSamplerAddre...
const char * BlendModeToString(BlendMode blend_mode)
std::string SPrintF(const char *format,...)
LinePipeline::FragmentShader FS
static std::optional< SamplerAddressMode > TileModeToAddressMode(Entity::TileMode tile_mode, const Capabilities &capabilities)
std::optional< BlendMode > InvertPorterDuffBlend(BlendMode blend_mode)
LinePipeline::VertexShader VS
ContentContextOptions OptionsFromPassAndEntity(const RenderPass &pass, const Entity &entity)
@ kNormal
The geometry has no overlapping triangles.
VertexBuffer vertex_buffer
A 4x4 matrix using column-major storage.
SamplerAddressMode width_address_mode
constexpr static TRect MakeSize(const TSize< U > &size)