26 const Capabilities& capabilities) {
38 if (capabilities.SupportsDecalSamplerAddressMode()) {
54 std::shared_ptr<VerticesGeometry> geometry) {
55 geometry_ = std::move(geometry);
63 blend_mode_ = blend_mode;
71 const Entity& entity)
const {
77 descriptor_ = descriptor;
82 tile_mode_x_ = tile_mode_x;
83 tile_mode_y_ = tile_mode_y;
92 lazy_texture_ = lazy_texture;
96 lazy_texture_coverage_ = rect;
104 if (!geometry_->HasVertexColors()) {
108 std::shared_ptr<Texture>
texture;
111 texture = lazy_texture_(renderer);
119 VALIDATION_LOG <<
"Missing texture for VerticesSimpleBlendContents";
123 auto dst_sampler_descriptor = descriptor_;
127 dst_sampler_descriptor.height_address_mode =
132 renderer.
GetContext()->GetSamplerLibrary()->GetSampler(
133 dst_sampler_descriptor);
135 GeometryResult geometry_result = geometry_->GetPositionUVColorBuffer(
136 lazy_texture_coverage_.has_value() ? lazy_texture_coverage_.value()
138 inverse_matrix_, renderer, entity, pass);
145 using VS = PorterDuffBlendPipeline::VertexShader;
146 using FS = PorterDuffBlendPipeline::FragmentShader;
155 options.primitive_type = geometry_result.
type;
156 auto inverted_blend_mode =
161 FS::BindTextureSamplerDst(pass,
texture, dst_sampler);
163 VS::FrameInfo frame_info;
164 FS::FragInfo frag_info;
166 frame_info.texture_sampler_y_coord_scale =
texture->GetYCoordScale();
167 frame_info.mvp = geometry_result.
transform;
169 frag_info.input_alpha_output_alpha_tmx_tmy =
170 Vector4(1, alpha_,
static_cast<int>(tile_mode_x_),
171 static_cast<int>(tile_mode_y_));
172 frag_info.use_strict_source_rect = 0.0;
175 FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
176 VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
181 using VS = VerticesUber1Shader::VertexShader;
182 using FS = VerticesUber1Shader::FragmentShader;
191 options.primitive_type = geometry_result.
type;
194 FS::BindTextureSampler(pass,
texture, dst_sampler);
196 VS::FrameInfo frame_info;
197 FS::FragInfo frag_info;
199 frame_info.texture_sampler_y_coord_scale =
texture->GetYCoordScale();
200 frame_info.mvp = geometry_result.
transform;
201 frag_info.alpha = alpha_;
202 frag_info.blend_mode =
static_cast<int>(blend_mode);
205 frag_info.tmx =
static_cast<int>(tile_mode_x_);
206 frag_info.tmy =
static_cast<int>(tile_mode_y_);
209 FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
210 VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
HostBuffer & GetTransientsDataBuffer() const
Retrieve the current host buffer for transient storage of other non-index data.
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.
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.
#define FML_DCHECK(condition)
@ kDecal
decal sampling mode is only supported on devices that pass the Capabilities.SupportsDecalSamplerAddre...
const char * BlendModeToString(BlendMode blend_mode)
LinePipeline::FragmentShader FS
std::optional< BlendMode > InvertPorterDuffBlend(BlendMode blend_mode)
static std::optional< SamplerAddressMode > TileModeToAddressMode(Entity::TileMode tile_mode, const Capabilities &capabilities)
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
static constexpr TRect MakeSize(const TSize< U > &size)