102 {
104 alpha_ <= 0.0) {
105 return true;
106 }
107
109 if (colors_.empty()) {
111 }
112
113 constexpr size_t indices[6] = {0, 1, 2, 1, 2, 3};
114
116
117 VertexBufferBuilder<VS::PerVertexData> vtx_builder;
118 vtx_builder.Reserve(texture_coords_.size() * 6);
119 const auto texture_size = texture_->GetSize();
120 auto& host_buffer =
renderer.GetTransientsBuffer();
121 bool has_colors = !colors_.empty();
122 for (
size_t i = 0;
i < texture_coords_.size();
i++) {
123 auto sample_rect = texture_coords_[
i];
125 auto points = sample_rect.GetPoints();
126 auto transformed_points =
130 for (size_t j = 0; j < 6; j++) {
131 VS::PerVertexData
data;
132 data.vertices = transformed_points[indices[j]];
133 data.texture_coords =
points[indices[j]] / texture_size;
135 vtx_builder.AppendVertex(
data);
136 }
137 }
138
139 auto dst_sampler_descriptor = sampler_descriptor_;
140 if (
renderer.GetDeviceCapabilities().SupportsDecalSamplerAddressMode()) {
143 }
144 const std::unique_ptr<const Sampler>& dst_sampler =
145 renderer.GetContext()->GetSamplerLibrary()->GetSampler(
146 dst_sampler_descriptor);
147
150
151#ifdef IMPELLER_DEBUG
152 pass.SetCommandLabel(
154#endif
155 pass.SetVertexBuffer(vtx_builder.CreateVertexBuffer(host_buffer));
156 pass.SetPipeline(
158
159 FS::FragInfo frag_info;
160 VS::FrameInfo frame_info;
161
162 FS::BindTextureSamplerDst(pass, texture_, dst_sampler);
163 frame_info.texture_sampler_y_coord_scale = texture_->GetYCoordScale();
164
165 frag_info.output_alpha = alpha_;
166 frag_info.input_alpha = 1.0;
167
168 auto inverted_blend_mode =
170 auto blend_coefficients =
172 frag_info.src_coeff = blend_coefficients[0];
173 frag_info.src_coeff_dst_alpha = blend_coefficients[1];
174 frag_info.dst_coeff = blend_coefficients[2];
175 frag_info.dst_coeff_src_alpha = blend_coefficients[3];
176 frag_info.dst_coeff_src_color = blend_coefficients[4];
177
180
181 FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
182
183 frame_info.mvp = entity.GetShaderTransform(pass);
184
185 auto uniform_view = host_buffer.EmplaceUniform(frame_info);
186 VS::BindFrameInfo(pass, uniform_view);
187
188 return pass.Draw().ok();
189 }
190
193
194#ifdef IMPELLER_DEBUG
195 pass.SetCommandLabel(
197#endif
198 pass.SetVertexBuffer(vtx_builder.CreateVertexBuffer(host_buffer));
199
201 FS::BindTextureSampler(pass, texture_, dst_sampler);
202
203 VUS::FrameInfo frame_info;
204 FS::FragInfo frag_info;
205
206 frame_info.texture_sampler_y_coord_scale = texture_->GetYCoordScale();
207 frame_info.mvp = entity.GetShaderTransform(pass);
208
209 frag_info.alpha = alpha_;
210 frag_info.blend_mode = static_cast<int>(blend_mode);
211
212
215
216 FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
217 VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
218
219 return pass.Draw().ok();
220}
static const int points[]
VertexShader_ VertexShader
FragmentShader_ FragmentShader
unsigned useCenter Optional< SkMatrix > matrix
SK_API sk_sp< SkShader > Color(SkColor)
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)
ContentContextOptions OptionsFromPass(const RenderPass &pass)
static constexpr Color BlackTransparent()
SamplerAddressMode width_address_mode
constexpr std::array< TPoint< T >, 4 > GetTransformedPoints(const Matrix &transform) const
static constexpr TRect MakeSize(const TSize< U > &size)
std::shared_ptr< const fml::Mapping > data