23 const Capabilities& capabilities) {
35 if (capabilities.SupportsDecalSamplerAddressMode()) {
51 std::shared_ptr<VerticesGeometry> geometry) {
52 geometry_ = std::move(geometry);
60 blend_mode_ = blend_mode;
68 const Entity& entity)
const {
74 descriptor_ = std::move(descriptor);
79 tile_mode_x_ = tile_mode_x;
80 tile_mode_y_ = tile_mode_y;
89 lazy_texture_ = lazy_texture;
98 if (!geometry_->HasVertexColors()) {
102 std::shared_ptr<Texture>
texture;
113 auto dst_sampler_descriptor = descriptor_;
117 dst_sampler_descriptor.height_address_mode =
121 const std::unique_ptr<const Sampler>& dst_sampler =
122 renderer.GetContext()->GetSamplerLibrary()->GetSampler(
123 dst_sampler_descriptor);
125 GeometryResult geometry_result = geometry_->GetPositionUVColorBuffer(
128 inverse_matrix_,
renderer, entity, pass);
148 FS::BindTextureSamplerDst(pass,
texture, dst_sampler);
150 VS::FrameInfo frame_info;
151 FS::FragInfo frag_info;
153 frame_info.texture_sampler_y_coord_scale =
texture->GetYCoordScale();
154 frame_info.mvp = geometry_result.
transform;
156 frag_info.output_alpha = alpha_;
157 frag_info.input_alpha = 1.0;
159 auto inverted_blend_mode =
161 auto blend_coefficients =
163 frag_info.src_coeff = blend_coefficients[0];
164 frag_info.src_coeff_dst_alpha = blend_coefficients[1];
165 frag_info.dst_coeff = blend_coefficients[2];
166 frag_info.dst_coeff_src_alpha = blend_coefficients[3];
167 frag_info.dst_coeff_src_color = blend_coefficients[4];
170 frag_info.tmx =
static_cast<int>(tile_mode_x_);
171 frag_info.tmy =
static_cast<int>(tile_mode_y_);
173 auto& host_buffer =
renderer.GetTransientsBuffer();
174 FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
175 VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
193 FS::BindTextureSampler(pass,
texture, dst_sampler);
195 VS::FrameInfo frame_info;
196 FS::FragInfo frag_info;
198 frame_info.texture_sampler_y_coord_scale =
texture->GetYCoordScale();
199 frame_info.mvp = geometry_result.
transform;
200 frag_info.alpha = alpha_;
201 frag_info.blend_mode =
static_cast<int>(blend_mode);
204 frag_info.tmx =
static_cast<int>(tile_mode_x_);
205 frag_info.tmy =
static_cast<int>(tile_mode_y_);
207 auto& host_buffer =
renderer.GetTransientsBuffer();
208 FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
209 VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
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(const std::shared_ptr< Pipeline< PipelineDescriptor > > &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
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)
~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 SetSamplerDescriptor(SamplerDescriptor descriptor)
void SetAlpha(Scalar alpha)
VerticesSimpleBlendContents()
#define FML_DCHECK(condition)
const char * BlendModeToString(BlendMode blend_mode)
@ kDecal
decal sampling mode is only supported on devices that pass the Capabilities.SupportsDecalSamplerAddre...
std::string SPrintF(const char *format,...)
constexpr std::array< std::array< Scalar, 5 >, 15 > kPorterDuffCoefficients
std::optional< BlendMode > InvertPorterDuffBlend(BlendMode blend_mode)
static std::optional< SamplerAddressMode > TileModeToAddressMode(Entity::TileMode tile_mode, const Capabilities &capabilities)
ContentContextOptions OptionsFromPassAndEntity(const RenderPass &pass, const Entity &entity)
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
@ 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)