7 #include "fml/logging.h"
23 const Capabilities& capabilities) {
35 if (capabilities.SupportsDecalSamplerAddressMode()) {
51 std::shared_ptr<VerticesGeometry> geometry) {
52 geometry_ = std::move(geometry);
60 blend_mode_ = blend_mode;
64 texture_ = std::move(texture);
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;
93 lazy_texture_coverage_ = rect;
99 FML_DCHECK(texture_ || lazy_texture_ ||
102 if (!geometry_->HasVertexColors()) {
106 std::shared_ptr<Texture> texture;
109 texture = lazy_texture_(renderer);
117 auto dst_sampler_descriptor = descriptor_;
121 dst_sampler_descriptor.height_address_mode =
125 const std::unique_ptr<const Sampler>& dst_sampler =
126 renderer.
GetContext()->GetSamplerLibrary()->GetSampler(
127 dst_sampler_descriptor);
129 GeometryResult geometry_result = geometry_->GetPositionUVColorBuffer(
130 lazy_texture_coverage_.has_value() ? lazy_texture_coverage_.value()
132 inverse_matrix_, renderer, entity, pass);
142 #ifdef IMPELLER_DEBUG
145 #endif // IMPELLER_DEBUG
149 options.primitive_type = geometry_result.
type;
152 FS::BindTextureSamplerDst(pass, texture, dst_sampler);
154 VS::FrameInfo frame_info;
155 FS::FragInfo frag_info;
157 frame_info.texture_sampler_y_coord_scale = texture->GetYCoordScale();
158 frame_info.mvp = geometry_result.
transform;
160 frag_info.output_alpha = alpha_;
161 frag_info.input_alpha = 1.0;
163 auto inverted_blend_mode =
165 auto blend_coefficients =
167 frag_info.src_coeff = blend_coefficients[0];
168 frag_info.src_coeff_dst_alpha = blend_coefficients[1];
169 frag_info.dst_coeff = blend_coefficients[2];
170 frag_info.dst_coeff_src_alpha = blend_coefficients[3];
171 frag_info.dst_coeff_src_color = blend_coefficients[4];
174 frag_info.tmx =
static_cast<int>(tile_mode_x_);
175 frag_info.tmy =
static_cast<int>(tile_mode_y_);
178 FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
179 VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
181 return pass.
Draw().ok();
187 #ifdef IMPELLER_DEBUG
190 #endif // IMPELLER_DEBUG
194 options.primitive_type = geometry_result.
type;
197 FS::BindTextureSampler(pass, texture, dst_sampler);
199 VS::FrameInfo frame_info;
200 FS::FragInfo frag_info;
202 frame_info.texture_sampler_y_coord_scale = texture->GetYCoordScale();
203 frame_info.mvp = geometry_result.
transform;
204 frag_info.alpha = alpha_;
205 frag_info.blend_mode =
static_cast<int>(blend_mode);
208 frag_info.tmx =
static_cast<int>(tile_mode_x_);
209 frag_info.tmy =
static_cast<int>(tile_mode_y_);
212 FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
213 VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
215 return pass.
Draw().ok();