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;
95 FML_DCHECK(texture_ || lazy_texture_ ||
98 if (!geometry_->HasVertexColors()) {
102 std::shared_ptr<Texture> texture;
105 texture = lazy_texture_(renderer);
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);
138 #ifdef IMPELLER_DEBUG
141 #endif // IMPELLER_DEBUG
145 options.primitive_type = geometry_result.
type;
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_);
174 FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
175 VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
177 return pass.
Draw().ok();
183 #ifdef IMPELLER_DEBUG
186 #endif // IMPELLER_DEBUG
190 options.primitive_type = geometry_result.
type;
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_);
208 FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
209 VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
211 return pass.
Draw().ok();