| Flutter Impeller |

content_context.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "impeller/entity/contents/content_context.h"
6
7 #include <format>
8 #include <memory>
9 #include <utility>
10
11 #include "fml/trace_event.h"
12 #include "impeller/base/validation.h"
13 #include "impeller/core/formats.h"
14 #include "impeller/core/texture_descriptor.h"
15 #include "impeller/entity/contents/framebuffer_blend_contents.h"
16 #include "impeller/entity/contents/pipelines.h"
17 #include "impeller/entity/contents/text_shadow_cache.h"
18 #include "impeller/entity/entity.h"
19 #include "impeller/entity/render_target_cache.h"
20 #include "impeller/renderer/command_buffer.h"
21 #include "impeller/renderer/pipeline.h"
22 #include "impeller/renderer/pipeline_descriptor.h"
23 #include "impeller/renderer/pipeline_library.h"
24 #include "impeller/renderer/render_target.h"
25 #include "impeller/renderer/texture_util.h"
26 #include "impeller/tessellator/tessellator.h"
27 #include "impeller/typographer/typographer_context.h"
28
29 namespace impeller {
30
31 namespace {
32
33 /// A generic version of `Variants` which mostly exists to reduce code size.
34 class GenericVariants {
35 public:
36 void Set(const ContentContextOptions& options,
37 std::unique_ptr<GenericRenderPipelineHandle> pipeline) {
38 uint64_t p_key = options.ToKey();
39 for (const auto& [key, pipeline] : pipelines_) {
40 if (key == p_key) {
41 return;
42 }
43 }
44 pipelines_.push_back(std::make_pair(p_key, std::move(pipeline)));
45 }
46
47 void SetDefault(const ContentContextOptions& options,
48 std::unique_ptr<GenericRenderPipelineHandle> pipeline) {
49 default_options_ = options;
50 if (pipeline) {
51 Set(options, std::move(pipeline));
52 }
53 }
54
55 GenericRenderPipelineHandle* Get(const ContentContextOptions& options) const {
56 uint64_t p_key = options.ToKey();
57 for (const auto& [key, pipeline] : pipelines_) {
58 if (key == p_key) {
59 return pipeline.get();
60 }
61 }
62 return nullptr;
63 }
64
65 void SetDefaultDescriptor(std::optional<PipelineDescriptor> desc) {
66 desc_ = std::move(desc);
67 }
68
69 size_t GetPipelineCount() const { return pipelines_.size(); }
70
71 bool IsDefault(const ContentContextOptions& opts) {
72 return default_options_.has_value() &&
73 opts.ToKey() == default_options_.value().ToKey();
74 }
75
76 protected:
77 std::optional<PipelineDescriptor> desc_;
78 std::optional<ContentContextOptions> default_options_;
79 std::vector<std::pair<uint64_t, std::unique_ptr<GenericRenderPipelineHandle>>>
80 pipelines_;
81 };
82
83 /// Holds multiple Pipelines associated with the same PipelineHandle types.
84 ///
85 /// For example, it may have multiple
86 /// RenderPipelineHandle<SolidFillVertexShader, SolidFillFragmentShader>
87 /// instances for different blend modes. From them you can access the
88 /// Pipeline.
89 ///
90 /// See also:
91 /// - impeller::ContentContextOptions - options from which variants are
92 /// created.
93 /// - impeller::Pipeline::CreateVariant
94 /// - impeller::RenderPipelineHandle<> - The type of objects this typically
95 /// contains.
96 template <class PipelineHandleT>
97 class Variants : public GenericVariants {
98 static_assert(
99 ShaderStageCompatibilityChecker<
100 typename PipelineHandleT::VertexShader,
101 typename PipelineHandleT::FragmentShader>::Check(),
102 "The output slots for the fragment shader don't have matches in the "
103 "vertex shader's output slots. This will result in a linker error.");
104
105 public:
106 Variants() = default;
107
108 void Set(const ContentContextOptions& options,
109 std::unique_ptr<PipelineHandleT> pipeline) {
110 GenericVariants::Set(options, std::move(pipeline));
111 }
112
113 void SetDefault(const ContentContextOptions& options,
114 std::unique_ptr<PipelineHandleT> pipeline) {
115 GenericVariants::SetDefault(options, std::move(pipeline));
116 }
117
118 void CreateDefault(const Context& context,
119 const ContentContextOptions& options,
120 const std::vector<Scalar>& constants = {}) {
121 std::optional<PipelineDescriptor> desc =
122 PipelineHandleT::Builder::MakeDefaultPipelineDescriptor(context,
123 constants);
124 if (!desc.has_value()) {
125 VALIDATION_LOG << "Failed to create default pipeline.";
126 return;
127 }
128 options.ApplyToPipelineDescriptor(*desc);
129 desc_ = desc;
130 if (context.GetFlags().lazy_shader_mode) {
131 SetDefault(options, nullptr);
132 } else {
133 SetDefault(options, std::make_unique<PipelineHandleT>(context, desc_,
134 /*async=*/true));
135 }
136 }
137
138 PipelineHandleT* Get(const ContentContextOptions& options) const {
139 return static_cast<PipelineHandleT*>(GenericVariants::Get(options));
140 }
141
142 PipelineHandleT* GetDefault(const Context& context) {
143 if (!default_options_.has_value()) {
144 return nullptr;
145 }
146 PipelineHandleT* result = Get(default_options_.value());
147 if (result != nullptr) {
148 return result;
149 }
150 SetDefault(default_options_.value(), std::make_unique<PipelineHandleT>(
151 context, desc_, /*async=*/false));
152 // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
153 return Get(default_options_.value());
154 }
155
156 private:
157 Variants(const Variants&) = delete;
158
159 Variants& operator=(const Variants&) = delete;
160 };
161
162 template <class RenderPipelineHandleT>
163 RenderPipelineHandleT* CreateIfNeeded(
164 const ContentContext* context,
165 Variants<RenderPipelineHandleT>& container,
166 ContentContextOptions opts) {
167 if (!context->IsValid()) {
168 return nullptr;
169 }
170
171 if (RenderPipelineHandleT* found = container.Get(opts)) {
172 return found;
173 }
174
175 RenderPipelineHandleT* default_handle =
176 container.GetDefault(*context->GetContext());
177 if (container.IsDefault(opts)) {
178 return default_handle;
179 }
180
181 // The default must always be initialized in the constructor.
182 FML_CHECK(default_handle != nullptr);
183
184 const std::shared_ptr<Pipeline<PipelineDescriptor>>& pipeline =
185 default_handle->WaitAndGet();
186 if (!pipeline) {
187 return nullptr;
188 }
189
190 auto variant_future = pipeline->CreateVariant(
191 /*async=*/false, [&opts, variants_count = container.GetPipelineCount()](
192 PipelineDescriptor& desc) {
193 opts.ApplyToPipelineDescriptor(desc);
194 desc.SetLabel(std::format("{} V#{}", desc.GetLabel(), variants_count));
195 });
196 std::unique_ptr<RenderPipelineHandleT> variant =
197 std::make_unique<RenderPipelineHandleT>(std::move(variant_future));
198 container.Set(opts, std::move(variant));
199 return container.Get(opts);
200 }
201
202 template <class TypedPipeline>
203 PipelineRef GetPipeline(const ContentContext* context,
204 Variants<TypedPipeline>& container,
205 ContentContextOptions opts) {
206 TypedPipeline* pipeline = CreateIfNeeded(context, container, opts);
207 if (!pipeline) {
208 return raw_ptr<Pipeline<PipelineDescriptor>>();
209 }
210 return raw_ptr(pipeline->WaitAndGet());
211 }
212
213 } // namespace
214
215 struct ContentContext::Pipelines {
216 // clang-format off
217 Variants<BlendColorBurnPipeline> blend_colorburn;
218 Variants<BlendColorDodgePipeline> blend_colordodge;
219 Variants<BlendColorPipeline> blend_color;
220 Variants<BlendDarkenPipeline> blend_darken;
221 Variants<BlendDifferencePipeline> blend_difference;
222 Variants<BlendExclusionPipeline> blend_exclusion;
223 Variants<BlendHardLightPipeline> blend_hardlight;
224 Variants<BlendHuePipeline> blend_hue;
225 Variants<BlendLightenPipeline> blend_lighten;
226 Variants<BlendLuminosityPipeline> blend_luminosity;
227 Variants<BlendMultiplyPipeline> blend_multiply;
228 Variants<BlendOverlayPipeline> blend_overlay;
229 Variants<BlendSaturationPipeline> blend_saturation;
230 Variants<BlendScreenPipeline> blend_screen;
231 Variants<BlendSoftLightPipeline> blend_softlight;
232 Variants<BorderMaskBlurPipeline> border_mask_blur;
233 Variants<CirclePipeline> circle;
234 Variants<ClipPipeline> clip;
235 Variants<ColorMatrixColorFilterPipeline> color_matrix_color_filter;
236 Variants<ConicalGradientFillConicalPipeline> conical_gradient_fill;
237 Variants<ConicalGradientFillRadialPipeline> conical_gradient_fill_radial;
238 Variants<ConicalGradientFillStripPipeline> conical_gradient_fill_strip;
239 Variants<ConicalGradientFillStripRadialPipeline> conical_gradient_fill_strip_and_radial;
240 Variants<ConicalGradientSSBOFillPipeline> conical_gradient_ssbo_fill;
241 Variants<ConicalGradientSSBOFillPipeline> conical_gradient_ssbo_fill_radial;
242 Variants<ConicalGradientSSBOFillPipeline> conical_gradient_ssbo_fill_strip_and_radial;
243 Variants<ConicalGradientSSBOFillPipeline> conical_gradient_ssbo_fill_strip;
244 Variants<ConicalGradientUniformFillConicalPipeline> conical_gradient_uniform_fill;
245 Variants<ConicalGradientUniformFillRadialPipeline> conical_gradient_uniform_fill_radial;
246 Variants<ConicalGradientUniformFillStripPipeline> conical_gradient_uniform_fill_strip;
247 Variants<ConicalGradientUniformFillStripRadialPipeline> conical_gradient_uniform_fill_strip_and_radial;
248 Variants<FastGradientPipeline> fast_gradient;
249 Variants<FramebufferBlendColorBurnPipeline> framebuffer_blend_colorburn;
250 Variants<FramebufferBlendColorDodgePipeline> framebuffer_blend_colordodge;
251 Variants<FramebufferBlendColorPipeline> framebuffer_blend_color;
252 Variants<FramebufferBlendDarkenPipeline> framebuffer_blend_darken;
253 Variants<FramebufferBlendDifferencePipeline> framebuffer_blend_difference;
254 Variants<FramebufferBlendExclusionPipeline> framebuffer_blend_exclusion;
255 Variants<FramebufferBlendHardLightPipeline> framebuffer_blend_hardlight;
256 Variants<FramebufferBlendHuePipeline> framebuffer_blend_hue;
257 Variants<FramebufferBlendLightenPipeline> framebuffer_blend_lighten;
258 Variants<FramebufferBlendLuminosityPipeline> framebuffer_blend_luminosity;
259 Variants<FramebufferBlendMultiplyPipeline> framebuffer_blend_multiply;
260 Variants<FramebufferBlendOverlayPipeline> framebuffer_blend_overlay;
261 Variants<FramebufferBlendSaturationPipeline> framebuffer_blend_saturation;
262 Variants<FramebufferBlendScreenPipeline> framebuffer_blend_screen;
263 Variants<FramebufferBlendSoftLightPipeline> framebuffer_blend_softlight;
264 Variants<GaussianBlurPipeline> gaussian_blur;
265 Variants<GlyphAtlasPipeline> glyph_atlas;
266 Variants<LinePipeline> line;
267 Variants<LinearGradientFillPipeline> linear_gradient_fill;
268 Variants<LinearGradientSSBOFillPipeline> linear_gradient_ssbo_fill;
269 Variants<LinearGradientUniformFillPipeline> linear_gradient_uniform_fill;
270 Variants<LinearToSrgbFilterPipeline> linear_to_srgb_filter;
271 Variants<MorphologyFilterPipeline> morphology_filter;
272 Variants<PorterDuffBlendPipeline> clear_blend;
273 Variants<PorterDuffBlendPipeline> destination_a_top_blend;
274 Variants<PorterDuffBlendPipeline> destination_blend;
275 Variants<PorterDuffBlendPipeline> destination_in_blend;
276 Variants<PorterDuffBlendPipeline> destination_out_blend;
277 Variants<PorterDuffBlendPipeline> destination_over_blend;
278 Variants<PorterDuffBlendPipeline> modulate_blend;
279 Variants<PorterDuffBlendPipeline> plus_blend;
280 Variants<PorterDuffBlendPipeline> screen_blend;
281 Variants<PorterDuffBlendPipeline> source_a_top_blend;
282 Variants<PorterDuffBlendPipeline> source_blend;
283 Variants<PorterDuffBlendPipeline> source_in_blend;
284 Variants<PorterDuffBlendPipeline> source_out_blend;
285 Variants<PorterDuffBlendPipeline> source_over_blend;
286 Variants<PorterDuffBlendPipeline> xor_blend;
287 Variants<RadialGradientFillPipeline> radial_gradient_fill;
288 Variants<RadialGradientSSBOFillPipeline> radial_gradient_ssbo_fill;
289 Variants<RadialGradientUniformFillPipeline> radial_gradient_uniform_fill;
290 Variants<RRectBlurPipeline> rrect_blur;
291 Variants<RSuperellipseBlurPipeline> rsuperellipse_blur;
292 Variants<SolidFillPipeline> solid_fill;
293 Variants<SrgbToLinearFilterPipeline> srgb_to_linear_filter;
294 Variants<SweepGradientFillPipeline> sweep_gradient_fill;
295 Variants<SweepGradientSSBOFillPipeline> sweep_gradient_ssbo_fill;
296 Variants<SweepGradientUniformFillPipeline> sweep_gradient_uniform_fill;
297 Variants<TextureDownsamplePipeline> texture_downsample;
298 Variants<TexturePipeline> texture;
299 Variants<TextureStrictSrcPipeline> texture_strict_src;
300 Variants<TiledTexturePipeline> tiled_texture;
301 Variants<VerticesUber1Shader> vertices_uber_1_;
302 Variants<VerticesUber2Shader> vertices_uber_2_;
303 Variants<YUVToRGBFilterPipeline> yuv_to_rgb_filter;
304
305 #ifdef IMPELLER_ENABLE_OPENGLES
306 Variants<TiledTextureExternalPipeline> tiled_texture_external;
307 Variants<TextureDownsampleGlesPipeline> texture_downsample_gles;
308 Variants<TiledTextureUvExternalPipeline> tiled_texture_uv_external;
309 #endif // IMPELLER_ENABLE_OPENGLES
310 // clang-format on
311 };
312
313 void ContentContextOptions::ApplyToPipelineDescriptor(
314 PipelineDescriptor& desc) const {
315 auto pipeline_blend = blend_mode;
316 if (blend_mode > Entity::kLastPipelineBlendMode) {
317 VALIDATION_LOG << "Cannot use blend mode " << static_cast<int>(blend_mode)
318 << " as a pipeline blend.";
319 pipeline_blend = BlendMode::kSrcOver;
320 }
321
322 desc.SetSampleCount(sample_count);
323
324 ColorAttachmentDescriptor color0 = *desc.GetColorAttachmentDescriptor(0u);
325 color0.format = color_attachment_pixel_format;
326 color0.alpha_blend_op = BlendOperation::kAdd;
327 color0.color_blend_op = BlendOperation::kAdd;
328 color0.write_mask = ColorWriteMaskBits::kAll;
329
330 switch (pipeline_blend) {
331 case BlendMode::kClear:
332 if (is_for_rrect_blur_clear) {
333 color0.alpha_blend_op = BlendOperation::kReverseSubtract;
334 color0.color_blend_op = BlendOperation::kReverseSubtract;
335 color0.dst_alpha_blend_factor = BlendFactor::kOne;
336 color0.dst_color_blend_factor = BlendFactor::kOne;
337 color0.src_alpha_blend_factor = BlendFactor::kDestinationColor;
338 color0.src_color_blend_factor = BlendFactor::kDestinationColor;
339 } else {
340 color0.dst_alpha_blend_factor = BlendFactor::kZero;
341 color0.dst_color_blend_factor = BlendFactor::kZero;
342 color0.src_alpha_blend_factor = BlendFactor::kZero;
343 color0.src_color_blend_factor = BlendFactor::kZero;
344 }
345 break;
346 case BlendMode::kSrc:
347 color0.blending_enabled = false;
348 color0.dst_alpha_blend_factor = BlendFactor::kZero;
349 color0.dst_color_blend_factor = BlendFactor::kZero;
350 color0.src_alpha_blend_factor = BlendFactor::kOne;
351 color0.src_color_blend_factor = BlendFactor::kOne;
352 break;
353 case BlendMode::kDst:
354 color0.dst_alpha_blend_factor = BlendFactor::kOne;
355 color0.dst_color_blend_factor = BlendFactor::kOne;
356 color0.src_alpha_blend_factor = BlendFactor::kZero;
357 color0.src_color_blend_factor = BlendFactor::kZero;
358 color0.write_mask = ColorWriteMaskBits::kNone;
359 break;
360 case BlendMode::kSrcOver:
361 color0.dst_alpha_blend_factor = BlendFactor::kOneMinusSourceAlpha;
362 color0.dst_color_blend_factor = BlendFactor::kOneMinusSourceAlpha;
363 color0.src_alpha_blend_factor = BlendFactor::kOne;
364 color0.src_color_blend_factor = BlendFactor::kOne;
365 break;
366 case BlendMode::kDstOver:
367 color0.dst_alpha_blend_factor = BlendFactor::kOne;
368 color0.dst_color_blend_factor = BlendFactor::kOne;
369 color0.src_alpha_blend_factor = BlendFactor::kOneMinusDestinationAlpha;
370 color0.src_color_blend_factor = BlendFactor::kOneMinusDestinationAlpha;
371 break;
372 case BlendMode::kSrcIn:
373 color0.dst_alpha_blend_factor = BlendFactor::kZero;
374 color0.dst_color_blend_factor = BlendFactor::kZero;
375 color0.src_alpha_blend_factor = BlendFactor::kDestinationAlpha;
376 color0.src_color_blend_factor = BlendFactor::kDestinationAlpha;
377 break;
378 case BlendMode::kDstIn:
379 color0.dst_alpha_blend_factor = BlendFactor::kSourceAlpha;
380 color0.dst_color_blend_factor = BlendFactor::kSourceAlpha;
381 color0.src_alpha_blend_factor = BlendFactor::kZero;
382 color0.src_color_blend_factor = BlendFactor::kZero;
383 break;
384 case BlendMode::kSrcOut:
385 color0.dst_alpha_blend_factor = BlendFactor::kZero;
386 color0.dst_color_blend_factor = BlendFactor::kZero;
387 color0.src_alpha_blend_factor = BlendFactor::kOneMinusDestinationAlpha;
388 color0.src_color_blend_factor = BlendFactor::kOneMinusDestinationAlpha;
389 break;
390 case BlendMode::kDstOut:
391 color0.dst_alpha_blend_factor = BlendFactor::kOneMinusSourceAlpha;
392 color0.dst_color_blend_factor = BlendFactor::kOneMinusSourceAlpha;
393 color0.src_alpha_blend_factor = BlendFactor::kZero;
394 color0.src_color_blend_factor = BlendFactor::kZero;
395 break;
396 case BlendMode::kSrcATop:
397 color0.dst_alpha_blend_factor = BlendFactor::kOneMinusSourceAlpha;
398 color0.dst_color_blend_factor = BlendFactor::kOneMinusSourceAlpha;
399 color0.src_alpha_blend_factor = BlendFactor::kDestinationAlpha;
400 color0.src_color_blend_factor = BlendFactor::kDestinationAlpha;
401 break;
402 case BlendMode::kDstATop:
403 color0.dst_alpha_blend_factor = BlendFactor::kSourceAlpha;
404 color0.dst_color_blend_factor = BlendFactor::kSourceAlpha;
405 color0.src_alpha_blend_factor = BlendFactor::kOneMinusDestinationAlpha;
406 color0.src_color_blend_factor = BlendFactor::kOneMinusDestinationAlpha;
407 break;
408 case BlendMode::kXor:
409 color0.dst_alpha_blend_factor = BlendFactor::kOneMinusSourceAlpha;
410 color0.dst_color_blend_factor = BlendFactor::kOneMinusSourceAlpha;
411 color0.src_alpha_blend_factor = BlendFactor::kOneMinusDestinationAlpha;
412 color0.src_color_blend_factor = BlendFactor::kOneMinusDestinationAlpha;
413 break;
414 case BlendMode::kPlus:
415 color0.dst_alpha_blend_factor = BlendFactor::kOne;
416 color0.dst_color_blend_factor = BlendFactor::kOne;
417 color0.src_alpha_blend_factor = BlendFactor::kOne;
418 color0.src_color_blend_factor = BlendFactor::kOne;
419 break;
420 case BlendMode::kModulate:
421 color0.dst_alpha_blend_factor = BlendFactor::kSourceAlpha;
422 color0.dst_color_blend_factor = BlendFactor::kSourceColor;
423 color0.src_alpha_blend_factor = BlendFactor::kZero;
424 color0.src_color_blend_factor = BlendFactor::kZero;
425 break;
426 default:
427 FML_UNREACHABLE();
428 }
429 desc.SetColorAttachmentDescriptor(0u, color0);
430
431 if (!has_depth_stencil_attachments) {
432 desc.ClearDepthAttachment();
433 desc.ClearStencilAttachments();
434 }
435
436 auto maybe_stencil = desc.GetFrontStencilAttachmentDescriptor();
437 auto maybe_depth = desc.GetDepthStencilAttachmentDescriptor();
438 FML_DCHECK(has_depth_stencil_attachments == maybe_depth.has_value())
439 << "Depth attachment doesn't match expected pipeline state. "
440 "has_depth_stencil_attachments="
441 << has_depth_stencil_attachments;
442 FML_DCHECK(has_depth_stencil_attachments == maybe_stencil.has_value())
443 << "Stencil attachment doesn't match expected pipeline state. "
444 "has_depth_stencil_attachments="
445 << has_depth_stencil_attachments;
446 if (maybe_stencil.has_value()) {
447 StencilAttachmentDescriptor front_stencil = maybe_stencil.value();
448 StencilAttachmentDescriptor back_stencil = front_stencil;
449
450 switch (stencil_mode) {
451 case StencilMode::kIgnore:
452 front_stencil.stencil_compare = CompareFunction::kAlways;
453 front_stencil.depth_stencil_pass = StencilOperation::kKeep;
454 desc.SetStencilAttachmentDescriptors(front_stencil);
455 break;
456 case StencilMode::kStencilNonZeroFill:
457 // The stencil ref should be 0 on commands that use this mode.
458 front_stencil.stencil_compare = CompareFunction::kAlways;
459 front_stencil.depth_stencil_pass = StencilOperation::kIncrementWrap;
460 back_stencil.stencil_compare = CompareFunction::kAlways;
461 back_stencil.depth_stencil_pass = StencilOperation::kDecrementWrap;
462 desc.SetStencilAttachmentDescriptors(front_stencil, back_stencil);
463 break;
464 case StencilMode::kStencilEvenOddFill:
465 // The stencil ref should be 0 on commands that use this mode.
466 front_stencil.stencil_compare = CompareFunction::kEqual;
467 front_stencil.depth_stencil_pass = StencilOperation::kIncrementWrap;
468 front_stencil.stencil_failure = StencilOperation::kDecrementWrap;
469 desc.SetStencilAttachmentDescriptors(front_stencil);
470 break;
471 case StencilMode::kCoverCompare:
472 // The stencil ref should be 0 on commands that use this mode.
473 front_stencil.stencil_compare = CompareFunction::kNotEqual;
474 front_stencil.depth_stencil_pass =
475 StencilOperation::kSetToReferenceValue;
476 desc.SetStencilAttachmentDescriptors(front_stencil);
477 break;
478 case StencilMode::kCoverCompareInverted:
479 // The stencil ref should be 0 on commands that use this mode.
480 front_stencil.stencil_compare = CompareFunction::kEqual;
481 front_stencil.stencil_failure = StencilOperation::kSetToReferenceValue;
482 desc.SetStencilAttachmentDescriptors(front_stencil);
483 break;
484 case StencilMode::kOverdrawPreventionIncrement:
485 front_stencil.stencil_compare = CompareFunction::kEqual;
486 front_stencil.depth_stencil_pass = StencilOperation::kIncrementClamp;
487 desc.SetStencilAttachmentDescriptors(front_stencil);
488 break;
489 case StencilMode::kOverdrawPreventionRestore:
490 front_stencil.stencil_compare = CompareFunction::kLess;
491 front_stencil.depth_stencil_pass =
492 StencilOperation::kSetToReferenceValue;
493 desc.SetStencilAttachmentDescriptors(front_stencil);
494 break;
495 }
496 }
497 if (maybe_depth.has_value()) {
498 DepthAttachmentDescriptor depth = maybe_depth.value();
499 depth.depth_write_enabled = depth_write_enabled;
500 depth.depth_compare = depth_compare;
501 desc.SetDepthStencilAttachmentDescriptor(depth);
502 }
503
504 desc.SetPrimitiveType(primitive_type);
505 desc.SetPolygonMode(PolygonMode::kFill);
506 }
507
508 std::array<std::vector<Scalar>, 15> GetPorterDuffSpecConstants(
509 bool supports_decal) {
510 Scalar x = supports_decal ? 1 : 0;
511 return {{
512 {x, 0, 0, 0, 0, 0}, // Clear
513 {x, 1, 0, 0, 0, 0}, // Source
514 {x, 0, 0, 1, 0, 0}, // Destination
515 {x, 1, 0, 1, -1, 0}, // SourceOver
516 {x, 1, -1, 1, 0, 0}, // DestinationOver
517 {x, 0, 1, 0, 0, 0}, // SourceIn
518 {x, 0, 0, 0, 1, 0}, // DestinationIn
519 {x, 1, -1, 0, 0, 0}, // SourceOut
520 {x, 0, 0, 1, -1, 0}, // DestinationOut
521 {x, 0, 1, 1, -1, 0}, // SourceATop
522 {x, 1, -1, 0, 1, 0}, // DestinationATop
523 {x, 1, -1, 1, -1, 0}, // Xor
524 {x, 1, 0, 1, 0, 0}, // Plus
525 {x, 0, 0, 0, 0, 1}, // Modulate
526 {x, 0, 0, 1, 0, -1}, // Screen
527 }};
528 }
529
530 template <typename PipelineT>
531 static std::unique_ptr<PipelineT> CreateDefaultPipeline(
532 const Context& context) {
533 auto desc = PipelineT::Builder::MakeDefaultPipelineDescriptor(context);
534 if (!desc.has_value()) {
535 return nullptr;
536 }
537 // Apply default ContentContextOptions to the descriptor.
538 const auto default_color_format =
539 context.GetCapabilities()->GetDefaultColorFormat();
540 ContentContextOptions{.sample_count = SampleCount::kCount4,
541 .primitive_type = PrimitiveType::kTriangleStrip,
542 .color_attachment_pixel_format = default_color_format}
543 .ApplyToPipelineDescriptor(*desc);
544 return std::make_unique<PipelineT>(context, desc);
545 }
546
547 ContentContext::ContentContext(
548 std::shared_ptr<Context> context,
549 std::shared_ptr<TypographerContext> typographer_context,
550 std::shared_ptr<RenderTargetAllocator> render_target_allocator)
551 : context_(std::move(context)),
552 lazy_glyph_atlas_(
553 std::make_shared<LazyGlyphAtlas>(std::move(typographer_context))),
554 pipelines_(new Pipelines()),
555 tessellator_(std::make_shared<Tessellator>(
556 context_->GetCapabilities()->Supports32BitPrimitiveIndices())),
557 render_target_cache_(render_target_allocator == nullptr
558 ? std::make_shared<RenderTargetCache>(
559 context_->GetResourceAllocator())
560 : std::move(render_target_allocator)),
561 data_host_buffer_(HostBuffer::Create(
562 context_->GetResourceAllocator(),
563 context_->GetIdleWaiter(),
564 context_->GetCapabilities()->GetMinimumUniformAlignment())),
565 text_shadow_cache_(std::make_unique<TextShadowCache>()) {
566 if (!context_ || !context_->IsValid()) {
567 return;
568 }
569
570 // On most backends, indexes and other data can be allocated into the same
571 // buffers. However, some backends (namely WebGL) require indexes used in
572 // indexed draws to be allocated separately from other data. For those
573 // backends, we allocate a separate host buffer just for indexes.
574 indexes_host_buffer_ =
575 context_->GetCapabilities()->NeedsPartitionedHostBuffer()
576 ? HostBuffer::Create(
577 context_->GetResourceAllocator(), context_->GetIdleWaiter(),
578 context_->GetCapabilities()->GetMinimumUniformAlignment())
579 : data_host_buffer_;
580 {
581 TextureDescriptor desc;
582 desc.storage_mode = StorageMode::kDevicePrivate;
583 desc.format = PixelFormat::kR8G8B8A8UNormInt;
584 desc.size = ISize{1, 1};
585 empty_texture_ = GetContext()->GetResourceAllocator()->CreateTexture(desc);
586
587 std::array<uint8_t, 4> data = Color::BlackTransparent().ToR8G8B8A8();
588 std::shared_ptr<CommandBuffer> cmd_buffer =
589 GetContext()->CreateCommandBuffer();
590 std::shared_ptr<BlitPass> blit_pass = cmd_buffer->CreateBlitPass();
591 HostBuffer& data_host_buffer = GetTransientsDataBuffer();
592 BufferView buffer_view = data_host_buffer.Emplace(data);
593 blit_pass->AddCopy(buffer_view, empty_texture_);
594
595 if (!blit_pass->EncodeCommands() || !GetContext()
596 ->GetCommandQueue()
597 ->Submit({std::move(cmd_buffer)})
598 .ok()) {
599 VALIDATION_LOG << "Failed to create empty texture.";
600 }
601 }
602
603 auto options = ContentContextOptions{
604 .sample_count = SampleCount::kCount4,
605 .color_attachment_pixel_format =
606 context_->GetCapabilities()->GetDefaultColorFormat()};
607 auto options_trianglestrip = ContentContextOptions{
608 .sample_count = SampleCount::kCount4,
609 .primitive_type = PrimitiveType::kTriangleStrip,
610 .color_attachment_pixel_format =
611 context_->GetCapabilities()->GetDefaultColorFormat()};
612 auto options_no_msaa_no_depth_stencil = ContentContextOptions{
613 .sample_count = SampleCount::kCount1,
614 .primitive_type = PrimitiveType::kTriangleStrip,
615 .color_attachment_pixel_format =
616 context_->GetCapabilities()->GetDefaultColorFormat(),
617 .has_depth_stencil_attachments = false};
618 const auto supports_decal = static_cast<Scalar>(
619 context_->GetCapabilities()->SupportsDecalSamplerAddressMode());
620
621 // Futures for the following pipelines may block in case the first frame is
622 // rendered without the pipelines being ready. Put pipelines that are more
623 // likely to be used first.
624 {
625 pipelines_->glyph_atlas.CreateDefault(
626 *context_, options,
627 {static_cast<Scalar>(
628 GetContext()->GetCapabilities()->GetDefaultGlyphAtlasFormat() ==
629 PixelFormat::kA8UNormInt)});
630 pipelines_->solid_fill.CreateDefault(*context_, options);
631 pipelines_->texture.CreateDefault(*context_, options);
632 pipelines_->fast_gradient.CreateDefault(*context_, options);
633 pipelines_->line.CreateDefault(*context_, options);
634 pipelines_->circle.CreateDefault(*context_, options);
635
636 if (context_->GetCapabilities()->SupportsSSBO()) {
637 pipelines_->linear_gradient_ssbo_fill.CreateDefault(*context_, options);
638 pipelines_->radial_gradient_ssbo_fill.CreateDefault(*context_, options);
639 pipelines_->conical_gradient_ssbo_fill.CreateDefault(*context_, options,
640 {3.0});
641 pipelines_->conical_gradient_ssbo_fill_radial.CreateDefault(
642 *context_, options, {1.0});
643 pipelines_->conical_gradient_ssbo_fill_strip.CreateDefault(
644 *context_, options, {2.0});
645 pipelines_->conical_gradient_ssbo_fill_strip_and_radial.CreateDefault(
646 *context_, options, {0.0});
647 pipelines_->sweep_gradient_ssbo_fill.CreateDefault(*context_, options);
648 } else {
649 pipelines_->linear_gradient_uniform_fill.CreateDefault(*context_,
650 options);
651 pipelines_->radial_gradient_uniform_fill.CreateDefault(*context_,
652 options);
653 pipelines_->conical_gradient_uniform_fill.CreateDefault(*context_,
654 options);
655 pipelines_->conical_gradient_uniform_fill_radial.CreateDefault(*context_,
656 options);
657 pipelines_->conical_gradient_uniform_fill_strip.CreateDefault(*context_,
658 options);
659 pipelines_->conical_gradient_uniform_fill_strip_and_radial.CreateDefault(
660 *context_, options);
661 pipelines_->sweep_gradient_uniform_fill.CreateDefault(*context_, options);
662
663 pipelines_->linear_gradient_fill.CreateDefault(*context_, options);
664 pipelines_->radial_gradient_fill.CreateDefault(*context_, options);
665 pipelines_->conical_gradient_fill.CreateDefault(*context_, options);
666 pipelines_->conical_gradient_fill_radial.CreateDefault(*context_,
667 options);
668 pipelines_->conical_gradient_fill_strip.CreateDefault(*context_, options);
669 pipelines_->conical_gradient_fill_strip_and_radial.CreateDefault(
670 *context_, options);
671 pipelines_->sweep_gradient_fill.CreateDefault(*context_, options);
672 }
673
674 /// Setup default clip pipeline.
675 auto clip_pipeline_descriptor =
676 ClipPipeline::Builder::MakeDefaultPipelineDescriptor(*context_);
677 if (!clip_pipeline_descriptor.has_value()) {
678 return;
679 }
680 ContentContextOptions{
681 .sample_count = SampleCount::kCount4,
682 .color_attachment_pixel_format =
683 context_->GetCapabilities()->GetDefaultColorFormat()}
684 .ApplyToPipelineDescriptor(*clip_pipeline_descriptor);
685 // Disable write to all color attachments.
686 auto clip_color_attachments =
687 clip_pipeline_descriptor->GetColorAttachmentDescriptors();
688 for (auto& color_attachment : clip_color_attachments) {
689 color_attachment.second.write_mask = ColorWriteMaskBits::kNone;
690 }
691 clip_pipeline_descriptor->SetColorAttachmentDescriptors(
692 std::move(clip_color_attachments));
693 if (GetContext()->GetFlags().lazy_shader_mode) {
694 pipelines_->clip.SetDefaultDescriptor(clip_pipeline_descriptor);
695 pipelines_->clip.SetDefault(options, nullptr);
696 } else {
697 pipelines_->clip.SetDefault(
698 options,
699 std::make_unique<ClipPipeline>(*context_, clip_pipeline_descriptor));
700 }
701 pipelines_->texture_downsample.CreateDefault(
702 *context_, options_no_msaa_no_depth_stencil);
703 pipelines_->rrect_blur.CreateDefault(*context_, options_trianglestrip);
704 pipelines_->rsuperellipse_blur.CreateDefault(*context_,
705 options_trianglestrip);
706 pipelines_->texture_strict_src.CreateDefault(*context_, options);
707 pipelines_->tiled_texture.CreateDefault(*context_, options,
708 {supports_decal});
709 pipelines_->gaussian_blur.CreateDefault(
710 *context_, options_no_msaa_no_depth_stencil, {supports_decal});
711 pipelines_->border_mask_blur.CreateDefault(*context_,
712 options_trianglestrip);
713 pipelines_->color_matrix_color_filter.CreateDefault(*context_,
714 options_trianglestrip);
715 pipelines_->vertices_uber_1_.CreateDefault(*context_, options,
716 {supports_decal});
717 pipelines_->vertices_uber_2_.CreateDefault(*context_, options,
718 {supports_decal});
719
720 const std::array<std::vector<Scalar>, 15> porter_duff_constants =
721 GetPorterDuffSpecConstants(supports_decal);
722 pipelines_->clear_blend.CreateDefault(*context_, options_trianglestrip,
723 porter_duff_constants[0]);
724 pipelines_->source_blend.CreateDefault(*context_, options_trianglestrip,
725 porter_duff_constants[1]);
726 pipelines_->destination_blend.CreateDefault(
727 *context_, options_trianglestrip, porter_duff_constants[2]);
728 pipelines_->source_over_blend.CreateDefault(
729 *context_, options_trianglestrip, porter_duff_constants[3]);
730 pipelines_->destination_over_blend.CreateDefault(
731 *context_, options_trianglestrip, porter_duff_constants[4]);
732 pipelines_->source_in_blend.CreateDefault(*context_, options_trianglestrip,
733 porter_duff_constants[5]);
734 pipelines_->destination_in_blend.CreateDefault(
735 *context_, options_trianglestrip, porter_duff_constants[6]);
736 pipelines_->source_out_blend.CreateDefault(*context_, options_trianglestrip,
737 porter_duff_constants[7]);
738 pipelines_->destination_out_blend.CreateDefault(
739 *context_, options_trianglestrip, porter_duff_constants[8]);
740 pipelines_->source_a_top_blend.CreateDefault(
741 *context_, options_trianglestrip, porter_duff_constants[9]);
742 pipelines_->destination_a_top_blend.CreateDefault(
743 *context_, options_trianglestrip, porter_duff_constants[10]);
744 pipelines_->xor_blend.CreateDefault(*context_, options_trianglestrip,
745 porter_duff_constants[11]);
746 pipelines_->plus_blend.CreateDefault(*context_, options_trianglestrip,
747 porter_duff_constants[12]);
748 pipelines_->modulate_blend.CreateDefault(*context_, options_trianglestrip,
749 porter_duff_constants[13]);
750 pipelines_->screen_blend.CreateDefault(*context_, options_trianglestrip,
751 porter_duff_constants[14]);
752 }
753
754 if (context_->GetCapabilities()->SupportsFramebufferFetch()) {
755 pipelines_->framebuffer_blend_color.CreateDefault(
756 *context_, options_trianglestrip,
757 {static_cast<Scalar>(BlendSelectValues::kColor), supports_decal});
758 pipelines_->framebuffer_blend_colorburn.CreateDefault(
759 *context_, options_trianglestrip,
760 {static_cast<Scalar>(BlendSelectValues::kColorBurn), supports_decal});
761 pipelines_->framebuffer_blend_colordodge.CreateDefault(
762 *context_, options_trianglestrip,
763 {static_cast<Scalar>(BlendSelectValues::kColorDodge), supports_decal});
764 pipelines_->framebuffer_blend_darken.CreateDefault(
765 *context_, options_trianglestrip,
766 {static_cast<Scalar>(BlendSelectValues::kDarken), supports_decal});
767 pipelines_->framebuffer_blend_difference.CreateDefault(
768 *context_, options_trianglestrip,
769 {static_cast<Scalar>(BlendSelectValues::kDifference), supports_decal});
770 pipelines_->framebuffer_blend_exclusion.CreateDefault(
771 *context_, options_trianglestrip,
772 {static_cast<Scalar>(BlendSelectValues::kExclusion), supports_decal});
773 pipelines_->framebuffer_blend_hardlight.CreateDefault(
774 *context_, options_trianglestrip,
775 {static_cast<Scalar>(BlendSelectValues::kHardLight), supports_decal});
776 pipelines_->framebuffer_blend_hue.CreateDefault(
777 *context_, options_trianglestrip,
778 {static_cast<Scalar>(BlendSelectValues::kHue), supports_decal});
779 pipelines_->framebuffer_blend_lighten.CreateDefault(
780 *context_, options_trianglestrip,
781 {static_cast<Scalar>(BlendSelectValues::kLighten), supports_decal});
782 pipelines_->framebuffer_blend_luminosity.CreateDefault(
783 *context_, options_trianglestrip,
784 {static_cast<Scalar>(BlendSelectValues::kLuminosity), supports_decal});
785 pipelines_->framebuffer_blend_multiply.CreateDefault(
786 *context_, options_trianglestrip,
787 {static_cast<Scalar>(BlendSelectValues::kMultiply), supports_decal});
788 pipelines_->framebuffer_blend_overlay.CreateDefault(
789 *context_, options_trianglestrip,
790 {static_cast<Scalar>(BlendSelectValues::kOverlay), supports_decal});
791 pipelines_->framebuffer_blend_saturation.CreateDefault(
792 *context_, options_trianglestrip,
793 {static_cast<Scalar>(BlendSelectValues::kSaturation), supports_decal});
794 pipelines_->framebuffer_blend_screen.CreateDefault(
795 *context_, options_trianglestrip,
796 {static_cast<Scalar>(BlendSelectValues::kScreen), supports_decal});
797 pipelines_->framebuffer_blend_softlight.CreateDefault(
798 *context_, options_trianglestrip,
799 {static_cast<Scalar>(BlendSelectValues::kSoftLight), supports_decal});
800 } else {
801 pipelines_->blend_color.CreateDefault(
802 *context_, options_trianglestrip,
803 {static_cast<Scalar>(BlendSelectValues::kColor), supports_decal});
804 pipelines_->blend_colorburn.CreateDefault(
805 *context_, options_trianglestrip,
806 {static_cast<Scalar>(BlendSelectValues::kColorBurn), supports_decal});
807 pipelines_->blend_colordodge.CreateDefault(
808 *context_, options_trianglestrip,
809 {static_cast<Scalar>(BlendSelectValues::kColorDodge), supports_decal});
810 pipelines_->blend_darken.CreateDefault(
811 *context_, options_trianglestrip,
812 {static_cast<Scalar>(BlendSelectValues::kDarken), supports_decal});
813 pipelines_->blend_difference.CreateDefault(
814 *context_, options_trianglestrip,
815 {static_cast<Scalar>(BlendSelectValues::kDifference), supports_decal});
816 pipelines_->blend_exclusion.CreateDefault(
817 *context_, options_trianglestrip,
818 {static_cast<Scalar>(BlendSelectValues::kExclusion), supports_decal});
819 pipelines_->blend_hardlight.CreateDefault(
820 *context_, options_trianglestrip,
821 {static_cast<Scalar>(BlendSelectValues::kHardLight), supports_decal});
822 pipelines_->blend_hue.CreateDefault(
823 *context_, options_trianglestrip,
824 {static_cast<Scalar>(BlendSelectValues::kHue), supports_decal});
825 pipelines_->blend_lighten.CreateDefault(
826 *context_, options_trianglestrip,
827 {static_cast<Scalar>(BlendSelectValues::kLighten), supports_decal});
828 pipelines_->blend_luminosity.CreateDefault(
829 *context_, options_trianglestrip,
830 {static_cast<Scalar>(BlendSelectValues::kLuminosity), supports_decal});
831 pipelines_->blend_multiply.CreateDefault(
832 *context_, options_trianglestrip,
833 {static_cast<Scalar>(BlendSelectValues::kMultiply), supports_decal});
834 pipelines_->blend_overlay.CreateDefault(
835 *context_, options_trianglestrip,
836 {static_cast<Scalar>(BlendSelectValues::kOverlay), supports_decal});
837 pipelines_->blend_saturation.CreateDefault(
838 *context_, options_trianglestrip,
839 {static_cast<Scalar>(BlendSelectValues::kSaturation), supports_decal});
840 pipelines_->blend_screen.CreateDefault(
841 *context_, options_trianglestrip,
842 {static_cast<Scalar>(BlendSelectValues::kScreen), supports_decal});
843 pipelines_->blend_softlight.CreateDefault(
844 *context_, options_trianglestrip,
845 {static_cast<Scalar>(BlendSelectValues::kSoftLight), supports_decal});
846 }
847
848 pipelines_->morphology_filter.CreateDefault(*context_, options_trianglestrip,
849 {supports_decal});
850 pipelines_->linear_to_srgb_filter.CreateDefault(*context_,
851 options_trianglestrip);
852 pipelines_->srgb_to_linear_filter.CreateDefault(*context_,
853 options_trianglestrip);
854 pipelines_->yuv_to_rgb_filter.CreateDefault(*context_, options_trianglestrip);
855
856 #if defined(IMPELLER_ENABLE_OPENGLES)
857 if (GetContext()->GetBackendType() == Context::BackendType::kOpenGLES) {
858 #if !defined(FML_OS_MACOSX)
859 // GLES only shader that is unsupported on macOS.
860 pipelines_->tiled_texture_external.CreateDefault(*context_, options);
861 pipelines_->tiled_texture_uv_external.CreateDefault(*context_, options);
862 #endif // !defined(FML_OS_MACOSX)
863 pipelines_->texture_downsample_gles.CreateDefault(*context_,
864 options_trianglestrip);
865 }
866 #endif // IMPELLER_ENABLE_OPENGLES
867
868 is_valid_ = true;
869 InitializeCommonlyUsedShadersIfNeeded();
870 }
871
872 ContentContext::~ContentContext() = default;
873
874 bool ContentContext::IsValid() const {
875 return is_valid_;
876 }
877
878 std::shared_ptr<Texture> ContentContext::GetEmptyTexture() const {
879 return empty_texture_;
880 }
881
882 fml::StatusOr<RenderTarget> ContentContext::MakeSubpass(
883 std::string_view label,
884 ISize texture_size,
885 const std::shared_ptr<CommandBuffer>& command_buffer,
886 const SubpassCallback& subpass_callback,
887 bool msaa_enabled,
888 bool depth_stencil_enabled,
889 int32_t mip_count) const {
890 const std::shared_ptr<Context>& context = GetContext();
891 RenderTarget subpass_target;
892
893 std::optional<RenderTarget::AttachmentConfig> depth_stencil_config =
894 depth_stencil_enabled ? RenderTarget::kDefaultStencilAttachmentConfig
895 : std::optional<RenderTarget::AttachmentConfig>();
896
897 if (context->GetCapabilities()->SupportsOffscreenMSAA() && msaa_enabled) {
898 subpass_target = GetRenderTargetCache()->CreateOffscreenMSAA(
899 /*context=*/*context,
900 /*size=*/texture_size,
901 /*mip_count=*/mip_count,
902 /*label=*/label,
903 /*color_attachment_config=*/
904 RenderTarget::kDefaultColorAttachmentConfigMSAA,
905 /*stencil_attachment_config=*/depth_stencil_config,
906 /*existing_color_msaa_texture=*/nullptr,
907 /*existing_color_resolve_texture=*/nullptr,
908 /*existing_depth_stencil_texture=*/nullptr,
909 /*target_pixel_format=*/std::nullopt);
910 } else {
911 subpass_target = GetRenderTargetCache()->CreateOffscreen(
912 *context, texture_size,
913 /*mip_count=*/mip_count, label,
914 RenderTarget::kDefaultColorAttachmentConfig, depth_stencil_config);
915 }
916 return MakeSubpass(label, subpass_target, command_buffer, subpass_callback);
917 }
918
919 fml::StatusOr<RenderTarget> ContentContext::MakeSubpass(
920 std::string_view label,
921 const RenderTarget& subpass_target,
922 const std::shared_ptr<CommandBuffer>& command_buffer,
923 const SubpassCallback& subpass_callback) const {
924 const std::shared_ptr<Context>& context = GetContext();
925
926 auto subpass_texture = subpass_target.GetRenderTargetTexture();
927 if (!subpass_texture) {
928 return fml::Status(fml::StatusCode::kUnknown, "");
929 }
930
931 auto sub_renderpass = command_buffer->CreateRenderPass(subpass_target);
932 if (!sub_renderpass) {
933 return fml::Status(fml::StatusCode::kUnknown, "");
934 }
935 sub_renderpass->SetLabel(label);
936
937 if (!subpass_callback(*this, *sub_renderpass)) {
938 return fml::Status(fml::StatusCode::kUnknown, "");
939 }
940
941 if (!sub_renderpass->EncodeCommands()) {
942 return fml::Status(fml::StatusCode::kUnknown, "");
943 }
944
945 const std::shared_ptr<Texture>& target_texture =
946 subpass_target.GetRenderTargetTexture();
947 if (target_texture->GetMipCount() > 1) {
948 fml::Status mipmap_status =
949 AddMipmapGeneration(command_buffer, context, target_texture);
950 if (!mipmap_status.ok()) {
951 return mipmap_status;
952 }
953 }
954
955 return subpass_target;
956 }
957
958 Tessellator& ContentContext::GetTessellator() const {
959 return *tessellator_;
960 }
961
962 std::shared_ptr<Context> ContentContext::GetContext() const {
963 return context_;
964 }
965
966 const Capabilities& ContentContext::GetDeviceCapabilities() const {
967 return *context_->GetCapabilities();
968 }
969
970 PipelineRef ContentContext::GetCachedRuntimeEffectPipeline(
971 const std::string& unique_entrypoint_name,
972 const ContentContextOptions& options,
973 const std::function<std::shared_ptr<Pipeline<PipelineDescriptor>>()>&
974 create_callback) const {
975 RuntimeEffectPipelineKey key{unique_entrypoint_name, options};
976 auto it = runtime_effect_pipelines_.find(key);
977 if (it == runtime_effect_pipelines_.end()) {
978 it = runtime_effect_pipelines_.insert(it, {key, create_callback()});
979 }
980 return raw_ptr(it->second);
981 }
982
983 void ContentContext::ClearCachedRuntimeEffectPipeline(
984 const std::string& unique_entrypoint_name) const {
985 #ifdef IMPELLER_DEBUG
986 // destroying in-use pipleines is a validation error.
987 const auto& idle_waiter = GetContext()->GetIdleWaiter();
988 if (idle_waiter) {
989 idle_waiter->WaitIdle();
990 }
991 #endif // IMPELLER_DEBUG
992 for (auto it = runtime_effect_pipelines_.begin();
993 it != runtime_effect_pipelines_.end();) {
994 if (it->first.unique_entrypoint_name == unique_entrypoint_name) {
995 it = runtime_effect_pipelines_.erase(it);
996 } else {
997 it++;
998 }
999 }
1000 }
1001
1002 void ContentContext::ResetTransientsBuffers() {
1003 data_host_buffer_->Reset();
1004
1005 // We should only reset the indexes host buffer if it is actually different
1006 // from the data host buffer. Otherwise we'll end up resetting the same host
1007 // buffer twice.
1008 if (data_host_buffer_ != indexes_host_buffer_) {
1009 indexes_host_buffer_->Reset();
1010 }
1011 }
1012
1013 void ContentContext::InitializeCommonlyUsedShadersIfNeeded() const {
1014 if (GetContext()->GetFlags().lazy_shader_mode) {
1015 return;
1016 }
1017 GetContext()->InitializeCommonlyUsedShadersIfNeeded();
1018 }
1019
1020 PipelineRef ContentContext::GetFastGradientPipeline(
1021 ContentContextOptions opts) const {
1022 return GetPipeline(this, pipelines_->fast_gradient, opts);
1023 }
1024
1025 PipelineRef ContentContext::GetLinearGradientFillPipeline(
1026 ContentContextOptions opts) const {
1027 return GetPipeline(this, pipelines_->linear_gradient_fill, opts);
1028 }
1029
1030 PipelineRef ContentContext::GetLinearGradientUniformFillPipeline(
1031 ContentContextOptions opts) const {
1032 return GetPipeline(this, pipelines_->linear_gradient_uniform_fill, opts);
1033 }
1034
1035 PipelineRef ContentContext::GetRadialGradientUniformFillPipeline(
1036 ContentContextOptions opts) const {
1037 return GetPipeline(this, pipelines_->radial_gradient_uniform_fill, opts);
1038 }
1039
1040 PipelineRef ContentContext::GetSweepGradientUniformFillPipeline(
1041 ContentContextOptions opts) const {
1042 return GetPipeline(this, pipelines_->sweep_gradient_uniform_fill, opts);
1043 }
1044
1045 PipelineRef ContentContext::GetLinearGradientSSBOFillPipeline(
1046 ContentContextOptions opts) const {
1047 FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
1048 return GetPipeline(this, pipelines_->linear_gradient_ssbo_fill, opts);
1049 }
1050
1051 PipelineRef ContentContext::GetRadialGradientSSBOFillPipeline(
1052 ContentContextOptions opts) const {
1053 FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
1054 return GetPipeline(this, pipelines_->radial_gradient_ssbo_fill, opts);
1055 }
1056
1057 PipelineRef ContentContext::GetConicalGradientUniformFillPipeline(
1058 ContentContextOptions opts,
1059 ConicalKind kind) const {
1060 switch (kind) {
1061 case ConicalKind::kConical:
1062 return GetPipeline(this, pipelines_->conical_gradient_uniform_fill, opts);
1063 case ConicalKind::kRadial:
1064 return GetPipeline(this, pipelines_->conical_gradient_uniform_fill_radial,
1065 opts);
1066 case ConicalKind::kStrip:
1067 return GetPipeline(this, pipelines_->conical_gradient_uniform_fill_strip,
1068 opts);
1069 case ConicalKind::kStripAndRadial:
1070 return GetPipeline(
1071 this, pipelines_->conical_gradient_uniform_fill_strip_and_radial,
1072 opts);
1073 }
1074 }
1075
1076 PipelineRef ContentContext::GetConicalGradientSSBOFillPipeline(
1077 ContentContextOptions opts,
1078 ConicalKind kind) const {
1079 FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
1080 switch (kind) {
1081 case ConicalKind::kConical:
1082 return GetPipeline(this, pipelines_->conical_gradient_ssbo_fill, opts);
1083 case ConicalKind::kRadial:
1084 return GetPipeline(this, pipelines_->conical_gradient_ssbo_fill_radial,
1085 opts);
1086 case ConicalKind::kStrip:
1087 return GetPipeline(this, pipelines_->conical_gradient_ssbo_fill_strip,
1088 opts);
1089 case ConicalKind::kStripAndRadial:
1090 return GetPipeline(
1091 this, pipelines_->conical_gradient_ssbo_fill_strip_and_radial, opts);
1092 }
1093 }
1094
1095 PipelineRef ContentContext::GetSweepGradientSSBOFillPipeline(
1096 ContentContextOptions opts) const {
1097 FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
1098 return GetPipeline(this, pipelines_->sweep_gradient_ssbo_fill, opts);
1099 }
1100
1101 PipelineRef ContentContext::GetRadialGradientFillPipeline(
1102 ContentContextOptions opts) const {
1103 return GetPipeline(this, pipelines_->radial_gradient_fill, opts);
1104 }
1105
1106 PipelineRef ContentContext::GetConicalGradientFillPipeline(
1107 ContentContextOptions opts,
1108 ConicalKind kind) const {
1109 switch (kind) {
1110 case ConicalKind::kConical:
1111 return GetPipeline(this, pipelines_->conical_gradient_fill, opts);
1112 case ConicalKind::kRadial:
1113 return GetPipeline(this, pipelines_->conical_gradient_fill_radial, opts);
1114 case ConicalKind::kStrip:
1115 return GetPipeline(this, pipelines_->conical_gradient_fill_strip, opts);
1116 case ConicalKind::kStripAndRadial:
1117 return GetPipeline(
1118 this, pipelines_->conical_gradient_fill_strip_and_radial, opts);
1119 }
1120 }
1121
1122 PipelineRef ContentContext::GetRRectBlurPipeline(
1123 ContentContextOptions opts) const {
1124 return GetPipeline(this, pipelines_->rrect_blur, opts);
1125 }
1126
1127 PipelineRef ContentContext::GetRSuperellipseBlurPipeline(
1128 ContentContextOptions opts) const {
1129 return GetPipeline(this, pipelines_->rsuperellipse_blur, opts);
1130 }
1131
1132 PipelineRef ContentContext::GetSweepGradientFillPipeline(
1133 ContentContextOptions opts) const {
1134 return GetPipeline(this, pipelines_->sweep_gradient_fill, opts);
1135 }
1136
1137 PipelineRef ContentContext::GetSolidFillPipeline(
1138 ContentContextOptions opts) const {
1139 return GetPipeline(this, pipelines_->solid_fill, opts);
1140 }
1141
1142 PipelineRef ContentContext::GetTexturePipeline(
1143 ContentContextOptions opts) const {
1144 return GetPipeline(this, pipelines_->texture, opts);
1145 }
1146
1147 PipelineRef ContentContext::GetTextureStrictSrcPipeline(
1148 ContentContextOptions opts) const {
1149 return GetPipeline(this, pipelines_->texture_strict_src, opts);
1150 }
1151
1152 PipelineRef ContentContext::GetTiledTexturePipeline(
1153 ContentContextOptions opts) const {
1154 return GetPipeline(this, pipelines_->tiled_texture, opts);
1155 }
1156
1157 PipelineRef ContentContext::GetGaussianBlurPipeline(
1158 ContentContextOptions opts) const {
1159 return GetPipeline(this, pipelines_->gaussian_blur, opts);
1160 }
1161
1162 PipelineRef ContentContext::GetBorderMaskBlurPipeline(
1163 ContentContextOptions opts) const {
1164 return GetPipeline(this, pipelines_->border_mask_blur, opts);
1165 }
1166
1167 PipelineRef ContentContext::GetMorphologyFilterPipeline(
1168 ContentContextOptions opts) const {
1169 return GetPipeline(this, pipelines_->morphology_filter, opts);
1170 }
1171
1172 PipelineRef ContentContext::GetColorMatrixColorFilterPipeline(
1173 ContentContextOptions opts) const {
1174 return GetPipeline(this, pipelines_->color_matrix_color_filter, opts);
1175 }
1176
1177 PipelineRef ContentContext::GetLinearToSrgbFilterPipeline(
1178 ContentContextOptions opts) const {
1179 return GetPipeline(this, pipelines_->linear_to_srgb_filter, opts);
1180 }
1181
1182 PipelineRef ContentContext::GetSrgbToLinearFilterPipeline(
1183 ContentContextOptions opts) const {
1184 return GetPipeline(this, pipelines_->srgb_to_linear_filter, opts);
1185 }
1186
1187 PipelineRef ContentContext::GetClipPipeline(ContentContextOptions opts) const {
1188 return GetPipeline(this, pipelines_->clip, opts);
1189 }
1190
1191 PipelineRef ContentContext::GetGlyphAtlasPipeline(
1192 ContentContextOptions opts) const {
1193 return GetPipeline(this, pipelines_->glyph_atlas, opts);
1194 }
1195
1196 PipelineRef ContentContext::GetYUVToRGBFilterPipeline(
1197 ContentContextOptions opts) const {
1198 return GetPipeline(this, pipelines_->yuv_to_rgb_filter, opts);
1199 }
1200
1201 PipelineRef ContentContext::GetPorterDuffPipeline(
1202 BlendMode mode,
1203 ContentContextOptions opts) const {
1204 switch (mode) {
1205 case BlendMode::kClear:
1206 return GetClearBlendPipeline(opts);
1207 case BlendMode::kSrc:
1208 return GetSourceBlendPipeline(opts);
1209 case BlendMode::kDst:
1210 return GetDestinationBlendPipeline(opts);
1211 case BlendMode::kSrcOver:
1212 return GetSourceOverBlendPipeline(opts);
1213 case BlendMode::kDstOver:
1214 return GetDestinationOverBlendPipeline(opts);
1215 case BlendMode::kSrcIn:
1216 return GetSourceInBlendPipeline(opts);
1217 case BlendMode::kDstIn:
1218 return GetDestinationInBlendPipeline(opts);
1219 case BlendMode::kSrcOut:
1220 return GetSourceOutBlendPipeline(opts);
1221 case BlendMode::kDstOut:
1222 return GetDestinationOutBlendPipeline(opts);
1223 case BlendMode::kSrcATop:
1224 return GetSourceATopBlendPipeline(opts);
1225 case BlendMode::kDstATop:
1226 return GetDestinationATopBlendPipeline(opts);
1227 case BlendMode::kXor:
1228 return GetXorBlendPipeline(opts);
1229 case BlendMode::kPlus:
1230 return GetPlusBlendPipeline(opts);
1231 case BlendMode::kModulate:
1232 return GetModulateBlendPipeline(opts);
1233 case BlendMode::kScreen:
1234 return GetScreenBlendPipeline(opts);
1235 case BlendMode::kOverlay:
1236 case BlendMode::kDarken:
1237 case BlendMode::kLighten:
1238 case BlendMode::kColorDodge:
1239 case BlendMode::kColorBurn:
1240 case BlendMode::kHardLight:
1241 case BlendMode::kSoftLight:
1242 case BlendMode::kDifference:
1243 case BlendMode::kExclusion:
1244 case BlendMode::kMultiply:
1245 case BlendMode::kHue:
1246 case BlendMode::kSaturation:
1247 case BlendMode::kColor:
1248 case BlendMode::kLuminosity:
1249 VALIDATION_LOG << "Invalid porter duff blend mode "
1250 << BlendModeToString(mode);
1251 return GetClearBlendPipeline(opts);
1252 break;
1253 }
1254 }
1255
1256 PipelineRef ContentContext::GetClearBlendPipeline(
1257 ContentContextOptions opts) const {
1258 return GetPipeline(this, pipelines_->clear_blend, opts);
1259 }
1260
1261 PipelineRef ContentContext::GetSourceBlendPipeline(
1262 ContentContextOptions opts) const {
1263 return GetPipeline(this, pipelines_->source_blend, opts);
1264 }
1265
1266 PipelineRef ContentContext::GetDestinationBlendPipeline(
1267 ContentContextOptions opts) const {
1268 return GetPipeline(this, pipelines_->destination_blend, opts);
1269 }
1270
1271 PipelineRef ContentContext::GetSourceOverBlendPipeline(
1272 ContentContextOptions opts) const {
1273 return GetPipeline(this, pipelines_->source_over_blend, opts);
1274 }
1275
1276 PipelineRef ContentContext::GetDestinationOverBlendPipeline(
1277 ContentContextOptions opts) const {
1278 return GetPipeline(this, pipelines_->destination_over_blend, opts);
1279 }
1280
1281 PipelineRef ContentContext::GetSourceInBlendPipeline(
1282 ContentContextOptions opts) const {
1283 return GetPipeline(this, pipelines_->source_in_blend, opts);
1284 }
1285
1286 PipelineRef ContentContext::GetDestinationInBlendPipeline(
1287 ContentContextOptions opts) const {
1288 return GetPipeline(this, pipelines_->destination_in_blend, opts);
1289 }
1290
1291 PipelineRef ContentContext::GetSourceOutBlendPipeline(
1292 ContentContextOptions opts) const {
1293 return GetPipeline(this, pipelines_->source_out_blend, opts);
1294 }
1295
1296 PipelineRef ContentContext::GetDestinationOutBlendPipeline(
1297 ContentContextOptions opts) const {
1298 return GetPipeline(this, pipelines_->destination_out_blend, opts);
1299 }
1300
1301 PipelineRef ContentContext::GetSourceATopBlendPipeline(
1302 ContentContextOptions opts) const {
1303 return GetPipeline(this, pipelines_->source_a_top_blend, opts);
1304 }
1305
1306 PipelineRef ContentContext::GetDestinationATopBlendPipeline(
1307 ContentContextOptions opts) const {
1308 return GetPipeline(this, pipelines_->destination_a_top_blend, opts);
1309 }
1310
1311 PipelineRef ContentContext::GetXorBlendPipeline(
1312 ContentContextOptions opts) const {
1313 return GetPipeline(this, pipelines_->xor_blend, opts);
1314 }
1315
1316 PipelineRef ContentContext::GetPlusBlendPipeline(
1317 ContentContextOptions opts) const {
1318 return GetPipeline(this, pipelines_->plus_blend, opts);
1319 }
1320
1321 PipelineRef ContentContext::GetModulateBlendPipeline(
1322 ContentContextOptions opts) const {
1323 return GetPipeline(this, pipelines_->modulate_blend, opts);
1324 }
1325
1326 PipelineRef ContentContext::GetScreenBlendPipeline(
1327 ContentContextOptions opts) const {
1328 return GetPipeline(this, pipelines_->screen_blend, opts);
1329 }
1330
1331 PipelineRef ContentContext::GetBlendColorPipeline(
1332 ContentContextOptions opts) const {
1333 return GetPipeline(this, pipelines_->blend_color, opts);
1334 }
1335
1336 PipelineRef ContentContext::GetBlendColorBurnPipeline(
1337 ContentContextOptions opts) const {
1338 return GetPipeline(this, pipelines_->blend_colorburn, opts);
1339 }
1340
1341 PipelineRef ContentContext::GetBlendColorDodgePipeline(
1342 ContentContextOptions opts) const {
1343 return GetPipeline(this, pipelines_->blend_colordodge, opts);
1344 }
1345
1346 PipelineRef ContentContext::GetBlendDarkenPipeline(
1347 ContentContextOptions opts) const {
1348 return GetPipeline(this, pipelines_->blend_darken, opts);
1349 }
1350
1351 PipelineRef ContentContext::GetBlendDifferencePipeline(
1352 ContentContextOptions opts) const {
1353 return GetPipeline(this, pipelines_->blend_difference, opts);
1354 }
1355
1356 PipelineRef ContentContext::GetBlendExclusionPipeline(
1357 ContentContextOptions opts) const {
1358 return GetPipeline(this, pipelines_->blend_exclusion, opts);
1359 }
1360
1361 PipelineRef ContentContext::GetBlendHardLightPipeline(
1362 ContentContextOptions opts) const {
1363 return GetPipeline(this, pipelines_->blend_hardlight, opts);
1364 }
1365
1366 PipelineRef ContentContext::GetBlendHuePipeline(
1367 ContentContextOptions opts) const {
1368 return GetPipeline(this, pipelines_->blend_hue, opts);
1369 }
1370
1371 PipelineRef ContentContext::GetBlendLightenPipeline(
1372 ContentContextOptions opts) const {
1373 return GetPipeline(this, pipelines_->blend_lighten, opts);
1374 }
1375
1376 PipelineRef ContentContext::GetBlendLuminosityPipeline(
1377 ContentContextOptions opts) const {
1378 return GetPipeline(this, pipelines_->blend_luminosity, opts);
1379 }
1380
1381 PipelineRef ContentContext::GetBlendMultiplyPipeline(
1382 ContentContextOptions opts) const {
1383 return GetPipeline(this, pipelines_->blend_multiply, opts);
1384 }
1385
1386 PipelineRef ContentContext::GetBlendOverlayPipeline(
1387 ContentContextOptions opts) const {
1388 return GetPipeline(this, pipelines_->blend_overlay, opts);
1389 }
1390
1391 PipelineRef ContentContext::GetBlendSaturationPipeline(
1392 ContentContextOptions opts) const {
1393 return GetPipeline(this, pipelines_->blend_saturation, opts);
1394 }
1395
1396 PipelineRef ContentContext::GetBlendScreenPipeline(
1397 ContentContextOptions opts) const {
1398 return GetPipeline(this, pipelines_->blend_screen, opts);
1399 }
1400
1401 PipelineRef ContentContext::GetBlendSoftLightPipeline(
1402 ContentContextOptions opts) const {
1403 return GetPipeline(this, pipelines_->blend_softlight, opts);
1404 }
1405
1406 PipelineRef ContentContext::GetDownsamplePipeline(
1407 ContentContextOptions opts) const {
1408 return GetPipeline(this, pipelines_->texture_downsample, opts);
1409 }
1410
1411 PipelineRef ContentContext::GetFramebufferBlendColorPipeline(
1412 ContentContextOptions opts) const {
1413 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1414 return GetPipeline(this, pipelines_->framebuffer_blend_color, opts);
1415 }
1416
1417 PipelineRef ContentContext::GetFramebufferBlendColorBurnPipeline(
1418 ContentContextOptions opts) const {
1419 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1420 return GetPipeline(this, pipelines_->framebuffer_blend_colorburn, opts);
1421 }
1422
1423 PipelineRef ContentContext::GetFramebufferBlendColorDodgePipeline(
1424 ContentContextOptions opts) const {
1425 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1426 return GetPipeline(this, pipelines_->framebuffer_blend_colordodge, opts);
1427 }
1428
1429 PipelineRef ContentContext::GetFramebufferBlendDarkenPipeline(
1430 ContentContextOptions opts) const {
1431 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1432 return GetPipeline(this, pipelines_->framebuffer_blend_darken, opts);
1433 }
1434
1435 PipelineRef ContentContext::GetFramebufferBlendDifferencePipeline(
1436 ContentContextOptions opts) const {
1437 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1438 return GetPipeline(this, pipelines_->framebuffer_blend_difference, opts);
1439 }
1440
1441 PipelineRef ContentContext::GetFramebufferBlendExclusionPipeline(
1442 ContentContextOptions opts) const {
1443 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1444 return GetPipeline(this, pipelines_->framebuffer_blend_exclusion, opts);
1445 }
1446
1447 PipelineRef ContentContext::GetFramebufferBlendHardLightPipeline(
1448 ContentContextOptions opts) const {
1449 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1450 return GetPipeline(this, pipelines_->framebuffer_blend_hardlight, opts);
1451 }
1452
1453 PipelineRef ContentContext::GetFramebufferBlendHuePipeline(
1454 ContentContextOptions opts) const {
1455 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1456 return GetPipeline(this, pipelines_->framebuffer_blend_hue, opts);
1457 }
1458
1459 PipelineRef ContentContext::GetFramebufferBlendLightenPipeline(
1460 ContentContextOptions opts) const {
1461 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1462 return GetPipeline(this, pipelines_->framebuffer_blend_lighten, opts);
1463 }
1464
1465 PipelineRef ContentContext::GetFramebufferBlendLuminosityPipeline(
1466 ContentContextOptions opts) const {
1467 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1468 return GetPipeline(this, pipelines_->framebuffer_blend_luminosity, opts);
1469 }
1470
1471 PipelineRef ContentContext::GetFramebufferBlendMultiplyPipeline(
1472 ContentContextOptions opts) const {
1473 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1474 return GetPipeline(this, pipelines_->framebuffer_blend_multiply, opts);
1475 }
1476
1477 PipelineRef ContentContext::GetFramebufferBlendOverlayPipeline(
1478 ContentContextOptions opts) const {
1479 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1480 return GetPipeline(this, pipelines_->framebuffer_blend_overlay, opts);
1481 }
1482
1483 PipelineRef ContentContext::GetFramebufferBlendSaturationPipeline(
1484 ContentContextOptions opts) const {
1485 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1486 return GetPipeline(this, pipelines_->framebuffer_blend_saturation, opts);
1487 }
1488
1489 PipelineRef ContentContext::GetFramebufferBlendScreenPipeline(
1490 ContentContextOptions opts) const {
1491 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1492 return GetPipeline(this, pipelines_->framebuffer_blend_screen, opts);
1493 }
1494
1495 PipelineRef ContentContext::GetFramebufferBlendSoftLightPipeline(
1496 ContentContextOptions opts) const {
1497 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1498 return GetPipeline(this, pipelines_->framebuffer_blend_softlight, opts);
1499 }
1500
1501 PipelineRef ContentContext::GetDrawVerticesUberPipeline(
1502 BlendMode blend_mode,
1503 ContentContextOptions opts) const {
1504 if (blend_mode <= BlendMode::kHardLight) {
1505 return GetPipeline(this, pipelines_->vertices_uber_1_, opts);
1506 } else {
1507 return GetPipeline(this, pipelines_->vertices_uber_2_, opts);
1508 }
1509 }
1510
1511 PipelineRef ContentContext::GetCirclePipeline(
1512 ContentContextOptions opts) const {
1513 return GetPipeline(this, pipelines_->circle, opts);
1514 }
1515
1516 PipelineRef ContentContext::GetLinePipeline(ContentContextOptions opts) const {
1517 return GetPipeline(this, pipelines_->line, opts);
1518 }
1519
1520 #ifdef IMPELLER_ENABLE_OPENGLES
1521 PipelineRef ContentContext::GetDownsampleTextureGlesPipeline(
1522 ContentContextOptions opts) const {
1523 return GetPipeline(this, pipelines_->texture_downsample_gles, opts);
1524 }
1525
1526 PipelineRef ContentContext::GetTiledTextureExternalPipeline(
1527 ContentContextOptions opts) const {
1528 FML_DCHECK(GetContext()->GetBackendType() == Context::BackendType::kOpenGLES);
1529 return GetPipeline(this, pipelines_->tiled_texture_external, opts);
1530 }
1531
1532 PipelineRef ContentContext::GetTiledTextureUvExternalPipeline(
1533 ContentContextOptions opts) const {
1534 FML_DCHECK(GetContext()->GetBackendType() == Context::BackendType::kOpenGLES);
1535 return GetPipeline(this, pipelines_->tiled_texture_uv_external, opts);
1536 }
1537 #endif // IMPELLER_ENABLE_OPENGLES
1538
1539 } // namespace impeller
buffer_view
BufferView buffer_view
Definition: blit_command_gles.cc:154
impeller::Capabilities
Definition: capabilities.h:14
impeller::ContentContext::GetBlendLuminosityPipeline
PipelineRef GetBlendLuminosityPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1376
impeller::ContentContext::~ContentContext
~ContentContext()
impeller::ContentContext::GetTiledTexturePipeline
PipelineRef GetTiledTexturePipeline(ContentContextOptions opts) const
Definition: content_context.cc:1152
impeller::ContentContext::GetFramebufferBlendColorPipeline
PipelineRef GetFramebufferBlendColorPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1411
impeller::ContentContext::GetDownsamplePipeline
PipelineRef GetDownsamplePipeline(ContentContextOptions opts) const
Definition: content_context.cc:1406
impeller::ContentContext::GetSourceInBlendPipeline
PipelineRef GetSourceInBlendPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1281
impeller::ContentContext::ClearCachedRuntimeEffectPipeline
void ClearCachedRuntimeEffectPipeline(const std::string &unique_entrypoint_name) const
Definition: content_context.cc:983
impeller::ContentContext::GetLinearGradientFillPipeline
PipelineRef GetLinearGradientFillPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1025
impeller::ContentContext::GetFramebufferBlendOverlayPipeline
PipelineRef GetFramebufferBlendOverlayPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1477
impeller::ContentContext::GetBlendColorDodgePipeline
PipelineRef GetBlendColorDodgePipeline(ContentContextOptions opts) const
Definition: content_context.cc:1341
impeller::ContentContext::GetFramebufferBlendColorBurnPipeline
PipelineRef GetFramebufferBlendColorBurnPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1417
impeller::ContentContext::GetPorterDuffPipeline
PipelineRef GetPorterDuffPipeline(BlendMode mode, ContentContextOptions opts) const
Definition: content_context.cc:1201
impeller::ContentContext::GetEmptyTexture
std::shared_ptr< Texture > GetEmptyTexture() const
Definition: content_context.cc:878
impeller::ContentContext::GetSourceOutBlendPipeline
PipelineRef GetSourceOutBlendPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1291
impeller::ContentContext::GetScreenBlendPipeline
PipelineRef GetScreenBlendPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1326
impeller::ContentContext::GetBlendColorPipeline
PipelineRef GetBlendColorPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1331
impeller::ContentContext::GetLinePipeline
PipelineRef GetLinePipeline(ContentContextOptions opts) const
Definition: content_context.cc:1516
impeller::ContentContext::GetFramebufferBlendLuminosityPipeline
PipelineRef GetFramebufferBlendLuminosityPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1465
impeller::ContentContext::GetPlusBlendPipeline
PipelineRef GetPlusBlendPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1316
impeller::ContentContext::GetFastGradientPipeline
PipelineRef GetFastGradientPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1020
impeller::ContentContext::ContentContext
ContentContext(std::shared_ptr< Context > context, std::shared_ptr< TypographerContext > typographer_context, std::shared_ptr< RenderTargetAllocator > render_target_allocator=nullptr)
Definition: content_context.cc:547
impeller::ContentContext::ResetTransientsBuffers
void ResetTransientsBuffers()
Resets the transients buffers held onto by the content context.
Definition: content_context.cc:1002
impeller::ContentContext::GetSolidFillPipeline
PipelineRef GetSolidFillPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1137
impeller::ContentContext::MakeSubpass
fml::StatusOr< RenderTarget > MakeSubpass(std::string_view label, ISize texture_size, const std::shared_ptr< CommandBuffer > &command_buffer, const SubpassCallback &subpass_callback, bool msaa_enabled=true, bool depth_stencil_enabled=false, int32_t mip_count=1) const
Creates a new texture of size texture_size and calls subpass_callback with a RenderPass for drawing t...
Definition: content_context.cc:882
impeller::ContentContext::GetDeviceCapabilities
const Capabilities & GetDeviceCapabilities() const
Definition: content_context.cc:966
impeller::ContentContext::GetModulateBlendPipeline
PipelineRef GetModulateBlendPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1321
impeller::ContentContext::GetFramebufferBlendHardLightPipeline
PipelineRef GetFramebufferBlendHardLightPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1447
impeller::ContentContext::GetFramebufferBlendColorDodgePipeline
PipelineRef GetFramebufferBlendColorDodgePipeline(ContentContextOptions opts) const
Definition: content_context.cc:1423
impeller::ContentContext::GetSweepGradientUniformFillPipeline
PipelineRef GetSweepGradientUniformFillPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1040
impeller::ContentContext::GetBlendSoftLightPipeline
PipelineRef GetBlendSoftLightPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1401
impeller::ContentContext::GetDestinationATopBlendPipeline
PipelineRef GetDestinationATopBlendPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1306
impeller::ContentContext::GetTextureStrictSrcPipeline
PipelineRef GetTextureStrictSrcPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1147
impeller::ContentContext::GetCachedRuntimeEffectPipeline
PipelineRef GetCachedRuntimeEffectPipeline(const std::string &unique_entrypoint_name, const ContentContextOptions &options, const std::function< std::shared_ptr< Pipeline< PipelineDescriptor >>()> &create_callback) const
Definition: content_context.cc:970
impeller::ContentContext::GetRadialGradientSSBOFillPipeline
PipelineRef GetRadialGradientSSBOFillPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1051
impeller::ContentContext::GetBlendColorBurnPipeline
PipelineRef GetBlendColorBurnPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1336
impeller::ContentContext::GetSweepGradientSSBOFillPipeline
PipelineRef GetSweepGradientSSBOFillPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1095
impeller::ContentContext::GetLinearGradientUniformFillPipeline
PipelineRef GetLinearGradientUniformFillPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1030
impeller::ContentContext::GetFramebufferBlendScreenPipeline
PipelineRef GetFramebufferBlendScreenPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1489
impeller::ContentContext::GetLinearGradientSSBOFillPipeline
PipelineRef GetLinearGradientSSBOFillPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1045
impeller::ContentContext::GetRadialGradientFillPipeline
PipelineRef GetRadialGradientFillPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1101
impeller::ContentContext::GetTexturePipeline
PipelineRef GetTexturePipeline(ContentContextOptions opts) const
Definition: content_context.cc:1142
impeller::ContentContext::GetBlendHardLightPipeline
PipelineRef GetBlendHardLightPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1361
impeller::ContentContext::GetClearBlendPipeline
PipelineRef GetClearBlendPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1256
impeller::ContentContext::GetCirclePipeline
PipelineRef GetCirclePipeline(ContentContextOptions opts) const
Definition: content_context.cc:1511
impeller::ContentContext::GetConicalGradientUniformFillPipeline
PipelineRef GetConicalGradientUniformFillPipeline(ContentContextOptions opts, ConicalKind kind) const
Definition: content_context.cc:1057
impeller::ContentContext::GetRadialGradientUniformFillPipeline
PipelineRef GetRadialGradientUniformFillPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1035
impeller::ContentContext::GetSweepGradientFillPipeline
PipelineRef GetSweepGradientFillPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1132
impeller::ContentContext::GetFramebufferBlendExclusionPipeline
PipelineRef GetFramebufferBlendExclusionPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1441
impeller::ContentContext::GetFramebufferBlendDarkenPipeline
PipelineRef GetFramebufferBlendDarkenPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1429
impeller::ContentContext::GetBlendSaturationPipeline
PipelineRef GetBlendSaturationPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1391
impeller::ContentContext::GetFramebufferBlendSoftLightPipeline
PipelineRef GetFramebufferBlendSoftLightPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1495
impeller::ContentContext::GetFramebufferBlendLightenPipeline
PipelineRef GetFramebufferBlendLightenPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1459
impeller::ContentContext::GetMorphologyFilterPipeline
PipelineRef GetMorphologyFilterPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1167
impeller::ContentContext::GetFramebufferBlendSaturationPipeline
PipelineRef GetFramebufferBlendSaturationPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1483
impeller::ContentContext::GetBlendDifferencePipeline
PipelineRef GetBlendDifferencePipeline(ContentContextOptions opts) const
Definition: content_context.cc:1351
impeller::ContentContext::GetGaussianBlurPipeline
PipelineRef GetGaussianBlurPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1157
impeller::ContentContext::GetBlendHuePipeline
PipelineRef GetBlendHuePipeline(ContentContextOptions opts) const
Definition: content_context.cc:1366
impeller::ContentContext::GetSrgbToLinearFilterPipeline
PipelineRef GetSrgbToLinearFilterPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1182
impeller::ContentContext::GetDestinationOutBlendPipeline
PipelineRef GetDestinationOutBlendPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1296
impeller::ContentContext::GetYUVToRGBFilterPipeline
PipelineRef GetYUVToRGBFilterPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1196
impeller::ContentContext::GetFramebufferBlendDifferencePipeline
PipelineRef GetFramebufferBlendDifferencePipeline(ContentContextOptions opts) const
Definition: content_context.cc:1435
impeller::ContentContext::GetFramebufferBlendHuePipeline
PipelineRef GetFramebufferBlendHuePipeline(ContentContextOptions opts) const
Definition: content_context.cc:1453
impeller::ContentContext::GetSourceATopBlendPipeline
PipelineRef GetSourceATopBlendPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1301
impeller::ContentContext::GetTransientsDataBuffer
HostBuffer & GetTransientsDataBuffer() const
Retrieve the current host buffer for transient storage of other non-index data.
Definition: content_context.h:311
impeller::ContentContext::GetXorBlendPipeline
PipelineRef GetXorBlendPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1311
impeller::ContentContext::GetGlyphAtlasPipeline
PipelineRef GetGlyphAtlasPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1191
impeller::ContentContext::GetClipPipeline
PipelineRef GetClipPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1187
impeller::ContentContext::GetRenderTargetCache
const std::shared_ptr< RenderTargetAllocator > & GetRenderTargetCache() const
Definition: content_context.h:270
impeller::ContentContext::IsValid
bool IsValid() const
Definition: content_context.cc:874
impeller::ContentContext::GetRRectBlurPipeline
PipelineRef GetRRectBlurPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1122
impeller::ContentContext::GetBlendScreenPipeline
PipelineRef GetBlendScreenPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1396
impeller::ContentContext::SubpassCallback
std::function< bool(const ContentContext &, RenderPass &)> SubpassCallback
Definition: content_context.h:246
impeller::ContentContext::GetBlendDarkenPipeline
PipelineRef GetBlendDarkenPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1346
impeller::ContentContext::GetSourceBlendPipeline
PipelineRef GetSourceBlendPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1261
impeller::ContentContext::GetLinearToSrgbFilterPipeline
PipelineRef GetLinearToSrgbFilterPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1177
impeller::ContentContext::GetBlendOverlayPipeline
PipelineRef GetBlendOverlayPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1386
impeller::ContentContext::GetDestinationBlendPipeline
PipelineRef GetDestinationBlendPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1266
impeller::ContentContext::GetDestinationOverBlendPipeline
PipelineRef GetDestinationOverBlendPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1276
impeller::ContentContext::GetFramebufferBlendMultiplyPipeline
PipelineRef GetFramebufferBlendMultiplyPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1471
impeller::ContentContext::GetConicalGradientSSBOFillPipeline
PipelineRef GetConicalGradientSSBOFillPipeline(ContentContextOptions opts, ConicalKind kind) const
Definition: content_context.cc:1076
impeller::ContentContext::GetTessellator
Tessellator & GetTessellator() const
Definition: content_context.cc:958
impeller::ContentContext::GetBlendLightenPipeline
PipelineRef GetBlendLightenPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1371
impeller::ContentContext::GetBlendMultiplyPipeline
PipelineRef GetBlendMultiplyPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1381
impeller::ContentContext::GetSourceOverBlendPipeline
PipelineRef GetSourceOverBlendPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1271
impeller::ContentContext::GetBlendExclusionPipeline
PipelineRef GetBlendExclusionPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1356
impeller::ContentContext::GetColorMatrixColorFilterPipeline
PipelineRef GetColorMatrixColorFilterPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1172
impeller::ContentContext::GetConicalGradientFillPipeline
PipelineRef GetConicalGradientFillPipeline(ContentContextOptions opts, ConicalKind kind) const
Definition: content_context.cc:1106
impeller::ContentContext::GetContext
std::shared_ptr< Context > GetContext() const
Definition: content_context.cc:962
impeller::ContentContext::GetDestinationInBlendPipeline
PipelineRef GetDestinationInBlendPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1286
impeller::ContentContext::GetRSuperellipseBlurPipeline
PipelineRef GetRSuperellipseBlurPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1127
impeller::ContentContext::GetBorderMaskBlurPipeline
PipelineRef GetBorderMaskBlurPipeline(ContentContextOptions opts) const
Definition: content_context.cc:1162
impeller::ContentContext::GetDrawVerticesUberPipeline
PipelineRef GetDrawVerticesUberPipeline(BlendMode blend_mode, ContentContextOptions opts) const
Definition: content_context.cc:1501
impeller::Context
To do anything rendering related with Impeller, you need a context.
Definition: context.h:65
impeller::Context::GetCapabilities
virtual const std::shared_ptr< const Capabilities > & GetCapabilities() const =0
Get the capabilities of Impeller context. All optionally supported feature of the platform,...
impeller::Context::BackendType::kOpenGLES
@ kOpenGLES
impeller::Entity::kLastPipelineBlendMode
static constexpr BlendMode kLastPipelineBlendMode
Definition: entity.h:28
impeller::HostBuffer
Definition: host_buffer.h:26
impeller::HostBuffer::Emplace
BufferView Emplace(const BufferType &buffer, size_t alignment=0)
Emplace non-uniform data (like contiguous vertices) onto the host buffer.
Definition: host_buffer.h:92
impeller::HostBuffer::Create
static std::shared_ptr< HostBuffer > Create(const std::shared_ptr< Allocator > &allocator, const std::shared_ptr< const IdleWaiter > &idle_waiter, size_t minimum_uniform_alignment)
Definition: host_buffer.cc:21
impeller::LazyGlyphAtlas
Definition: lazy_glyph_atlas.h:16
impeller::PipelineDescriptor
Definition: pipeline_descriptor.h:24
impeller::PipelineDescriptor::SetDepthStencilAttachmentDescriptor
PipelineDescriptor & SetDepthStencilAttachmentDescriptor(std::optional< DepthAttachmentDescriptor > desc)
Definition: pipeline_descriptor.cc:151
impeller::PipelineDescriptor::ClearStencilAttachments
void ClearStencilAttachments()
Definition: pipeline_descriptor.cc:170
impeller::PipelineDescriptor::SetPolygonMode
void SetPolygonMode(PolygonMode mode)
Definition: pipeline_descriptor.cc:276
impeller::PipelineDescriptor::GetDepthStencilAttachmentDescriptor
std::optional< DepthAttachmentDescriptor > GetDepthStencilAttachmentDescriptor() const
Definition: pipeline_descriptor.cc:207
impeller::PipelineDescriptor::SetStencilAttachmentDescriptors
PipelineDescriptor & SetStencilAttachmentDescriptors(std::optional< StencilAttachmentDescriptor > front_and_back)
Definition: pipeline_descriptor.cc:157
impeller::PipelineDescriptor::GetColorAttachmentDescriptor
const ColorAttachmentDescriptor * GetColorAttachmentDescriptor(size_t index) const
Definition: pipeline_descriptor.cc:124
impeller::PipelineDescriptor::SetColorAttachmentDescriptor
PipelineDescriptor & SetColorAttachmentDescriptor(size_t index, ColorAttachmentDescriptor desc)
Definition: pipeline_descriptor.cc:110
impeller::PipelineDescriptor::SetSampleCount
PipelineDescriptor & SetSampleCount(SampleCount samples)
Definition: pipeline_descriptor.cc:76
impeller::PipelineDescriptor::SetPrimitiveType
void SetPrimitiveType(PrimitiveType type)
Definition: pipeline_descriptor.cc:268
impeller::PipelineDescriptor::ClearDepthAttachment
void ClearDepthAttachment()
Definition: pipeline_descriptor.cc:176
impeller::PipelineDescriptor::GetFrontStencilAttachmentDescriptor
std::optional< StencilAttachmentDescriptor > GetFrontStencilAttachmentDescriptor() const
Definition: pipeline_descriptor.cc:202
impeller::Pipeline< PipelineDescriptor >
impeller::RenderTargetCache
An implementation of the [RenderTargetAllocator] that caches all allocated texture data for one frame...
Definition: render_target_cache.h:18
impeller::RenderTarget
Definition: render_target.h:38
impeller::RenderTarget::GetRenderTargetTexture
std::shared_ptr< Texture > GetRenderTargetTexture() const
Definition: render_target.cc:176
impeller::RenderTarget::kDefaultColorAttachmentConfig
static constexpr AttachmentConfig kDefaultColorAttachmentConfig
Definition: render_target.h:55
impeller::RenderTarget::kDefaultColorAttachmentConfigMSAA
static constexpr AttachmentConfigMSAA kDefaultColorAttachmentConfigMSAA
Definition: render_target.h:61
impeller::RenderTarget::kDefaultStencilAttachmentConfig
static constexpr AttachmentConfig kDefaultStencilAttachmentConfig
Definition: render_target.h:68
impeller::Tessellator
A utility that generates triangles of the specified fill type given a polyline. This happens on the C...
Definition: tessellator.h:37
impeller::TextShadowCache
A cache for blurred text that re-uses these across frames.
Definition: text_shadow_cache.h:31
impeller::raw_ptr< Pipeline< PipelineDescriptor > >
command_buffer.h
desc_
std::optional< PipelineDescriptor > desc_
Definition: content_context.cc:77
pipelines_
std::vector< std::pair< uint64_t, std::unique_ptr< GenericRenderPipelineHandle > > > pipelines_
Definition: content_context.cc:80
default_options_
std::optional< ContentContextOptions > default_options_
Definition: content_context.cc:78
content_context.h
formats.h
x
int32_t x
Definition: dl_golden_unittests.cc:458
entity.h
framebuffer_blend_contents.h
impeller::interop::Create
ScopedObject< Object > Create(CtorArgs &&... args)
Definition: object.h:161
impeller
Definition: allocation.cc:12
impeller::BlendFactor::kDestinationColor
@ kDestinationColor
impeller::BlendFactor::kOne
@ kOne
impeller::BlendFactor::kSourceColor
@ kSourceColor
impeller::BlendFactor::kZero
@ kZero
impeller::BlendFactor::kDestinationAlpha
@ kDestinationAlpha
impeller::BlendFactor::kSourceAlpha
@ kSourceAlpha
impeller::BlendFactor::kOneMinusDestinationAlpha
@ kOneMinusDestinationAlpha
impeller::BlendFactor::kOneMinusSourceAlpha
@ kOneMinusSourceAlpha
impeller::PrimitiveType::kTriangleStrip
@ kTriangleStrip
impeller::Scalar
float Scalar
Definition: scalar.h:19
impeller::ConicalKind
ConicalKind
Definition: content_context.h:128
impeller::kStripAndRadial
@ kStripAndRadial
Definition: content_context.h:132
impeller::kStrip
@ kStrip
Definition: content_context.h:131
impeller::kConical
@ kConical
Definition: content_context.h:129
impeller::kRadial
@ kRadial
Definition: content_context.h:130
impeller::CreateDefaultPipeline
static std::unique_ptr< PipelineT > CreateDefaultPipeline(const Context &context)
Definition: content_context.cc:531
impeller::StorageMode::kDevicePrivate
@ kDevicePrivate
impeller::PipelineRef
raw_ptr< Pipeline< PipelineDescriptor > > PipelineRef
A raw ptr to a pipeline object.
Definition: pipeline.h:88
impeller::BlendModeToString
const char * BlendModeToString(BlendMode blend_mode)
Definition: color.cc:47
impeller::PixelFormat::kA8UNormInt
@ kA8UNormInt
impeller::PixelFormat::kR8G8B8A8UNormInt
@ kR8G8B8A8UNormInt
impeller::CompareFunction::kEqual
@ kEqual
Comparison test passes if new_value == current_value.
impeller::CompareFunction::kAlways
@ kAlways
Comparison test passes always passes.
impeller::CompareFunction::kLess
@ kLess
Comparison test passes if new_value < current_value.
impeller::CompareFunction::kNotEqual
@ kNotEqual
Comparison test passes if new_value != current_value.
impeller::AddMipmapGeneration
fml::Status AddMipmapGeneration(const std::shared_ptr< CommandBuffer > &command_buffer, const std::shared_ptr< Context > &context, const std::shared_ptr< Texture > &texture)
Adds a blit command to the render pass.
Definition: texture_util.cc:37
impeller::StencilOperation::kDecrementWrap
@ kDecrementWrap
Decrement the current stencil value by 1. If at zero, set to maximum.
impeller::StencilOperation::kSetToReferenceValue
@ kSetToReferenceValue
Reset the stencil value to the reference value.
impeller::StencilOperation::kIncrementClamp
@ kIncrementClamp
Increment the current stencil value by 1. Clamp it to the maximum.
impeller::StencilOperation::kIncrementWrap
@ kIncrementWrap
Increment the current stencil value by 1. If at maximum, set to zero.
impeller::StencilOperation::kKeep
@ kKeep
Don't modify the current stencil value.
impeller::BlendMode
BlendMode
Definition: color.h:58
impeller::BlendMode::kSrcOut
@ kSrcOut
impeller::BlendMode::kExclusion
@ kExclusion
impeller::BlendMode::kSaturation
@ kSaturation
impeller::BlendMode::kColorBurn
@ kColorBurn
impeller::BlendMode::kPlus
@ kPlus
impeller::BlendMode::kLighten
@ kLighten
impeller::BlendMode::kHue
@ kHue
impeller::BlendMode::kDst
@ kDst
impeller::BlendMode::kDstIn
@ kDstIn
impeller::BlendMode::kModulate
@ kModulate
impeller::BlendMode::kMultiply
@ kMultiply
impeller::BlendMode::kColorDodge
@ kColorDodge
impeller::BlendMode::kScreen
@ kScreen
impeller::BlendMode::kSrcOver
@ kSrcOver
impeller::BlendMode::kXor
@ kXor
impeller::BlendMode::kSrc
@ kSrc
impeller::BlendMode::kLuminosity
@ kLuminosity
impeller::BlendMode::kSoftLight
@ kSoftLight
impeller::BlendMode::kDifference
@ kDifference
impeller::BlendMode::kOverlay
@ kOverlay
impeller::BlendMode::kSrcATop
@ kSrcATop
impeller::BlendMode::kDstATop
@ kDstATop
impeller::BlendMode::kDstOver
@ kDstOver
impeller::BlendMode::kColor
@ kColor
impeller::BlendMode::kHardLight
@ kHardLight
impeller::BlendMode::kDstOut
@ kDstOut
impeller::BlendMode::kDarken
@ kDarken
impeller::BlendMode::kSrcIn
@ kSrcIn
impeller::BlendMode::kClear
@ kClear
impeller::GetPorterDuffSpecConstants
std::array< std::vector< Scalar >, 15 > GetPorterDuffSpecConstants(bool supports_decal)
Definition: content_context.cc:508
impeller::PolygonMode::kFill
@ kFill
impeller::ColorWriteMaskBits::kAll
@ kAll
impeller::ColorWriteMaskBits::kNone
@ kNone
impeller::BlendOperation::kAdd
@ kAdd
impeller::BlendOperation::kReverseSubtract
@ kReverseSubtract
impeller::SampleCount::kCount4
@ kCount4
impeller::SampleCount::kCount1
@ kCount1
impeller::BlendSelectValues::kExclusion
@ kExclusion
impeller::BlendSelectValues::kSaturation
@ kSaturation
impeller::BlendSelectValues::kColorBurn
@ kColorBurn
impeller::BlendSelectValues::kLighten
@ kLighten
impeller::BlendSelectValues::kHue
@ kHue
impeller::BlendSelectValues::kMultiply
@ kMultiply
impeller::BlendSelectValues::kColorDodge
@ kColorDodge
impeller::BlendSelectValues::kScreen
@ kScreen
impeller::BlendSelectValues::kLuminosity
@ kLuminosity
impeller::BlendSelectValues::kSoftLight
@ kSoftLight
impeller::BlendSelectValues::kDifference
@ kDifference
impeller::BlendSelectValues::kOverlay
@ kOverlay
impeller::BlendSelectValues::kColor
@ kColor
impeller::BlendSelectValues::kHardLight
@ kHardLight
impeller::BlendSelectValues::kDarken
@ kDarken
std
Definition: comparable.h:95
pipeline.h
pipeline_descriptor.h
pipeline_library.h
pipelines.h
render_target.h
render_target_cache.h
impeller::BufferView
Definition: buffer_view.h:19
impeller::ColorAttachmentDescriptor
Describe the color attachment that will be used with this pipeline.
Definition: formats.h:522
impeller::ColorAttachmentDescriptor::blending_enabled
bool blending_enabled
Definition: formats.h:524
impeller::ColorAttachmentDescriptor::color_blend_op
BlendOperation color_blend_op
Definition: formats.h:527
impeller::ColorAttachmentDescriptor::format
PixelFormat format
Definition: formats.h:523
impeller::ColorAttachmentDescriptor::dst_color_blend_factor
BlendFactor dst_color_blend_factor
Definition: formats.h:528
impeller::ColorAttachmentDescriptor::write_mask
ColorWriteMask write_mask
Definition: formats.h:534
impeller::ColorAttachmentDescriptor::src_alpha_blend_factor
BlendFactor src_alpha_blend_factor
Definition: formats.h:530
impeller::ColorAttachmentDescriptor::alpha_blend_op
BlendOperation alpha_blend_op
Definition: formats.h:531
impeller::ColorAttachmentDescriptor::src_color_blend_factor
BlendFactor src_color_blend_factor
Definition: formats.h:526
impeller::ColorAttachmentDescriptor::dst_alpha_blend_factor
BlendFactor dst_alpha_blend_factor
Definition: formats.h:532
impeller::Color::ToR8G8B8A8
std::array< uint8_t, 4 > ToR8G8B8A8() const
Convert to R8G8B8A8 representation.
Definition: color.h:246
impeller::Color::BlackTransparent
static constexpr Color BlackTransparent()
Definition: color.h:270
impeller::ContentContext::Pipelines
Definition: content_context.cc:215
impeller::ContentContext::Pipelines::solid_fill
Variants< SolidFillPipeline > solid_fill
Definition: content_context.cc:292
impeller::ContentContext::Pipelines::destination_blend
Variants< PorterDuffBlendPipeline > destination_blend
Definition: content_context.cc:274
impeller::ContentContext::Pipelines::sweep_gradient_ssbo_fill
Variants< SweepGradientSSBOFillPipeline > sweep_gradient_ssbo_fill
Definition: content_context.cc:295
impeller::ContentContext::Pipelines::blend_screen
Variants< BlendScreenPipeline > blend_screen
Definition: content_context.cc:230
impeller::ContentContext::Pipelines::modulate_blend
Variants< PorterDuffBlendPipeline > modulate_blend
Definition: content_context.cc:278
impeller::ContentContext::Pipelines::framebuffer_blend_overlay
Variants< FramebufferBlendOverlayPipeline > framebuffer_blend_overlay
Definition: content_context.cc:260
impeller::ContentContext::Pipelines::blend_saturation
Variants< BlendSaturationPipeline > blend_saturation
Definition: content_context.cc:229
impeller::ContentContext::Pipelines::tiled_texture
Variants< TiledTexturePipeline > tiled_texture
Definition: content_context.cc:300
impeller::ContentContext::Pipelines::destination_in_blend
Variants< PorterDuffBlendPipeline > destination_in_blend
Definition: content_context.cc:275
impeller::ContentContext::Pipelines::blend_softlight
Variants< BlendSoftLightPipeline > blend_softlight
Definition: content_context.cc:231
impeller::ContentContext::Pipelines::blend_colordodge
Variants< BlendColorDodgePipeline > blend_colordodge
Definition: content_context.cc:218
impeller::ContentContext::Pipelines::blend_multiply
Variants< BlendMultiplyPipeline > blend_multiply
Definition: content_context.cc:227
impeller::ContentContext::Pipelines::blend_color
Variants< BlendColorPipeline > blend_color
Definition: content_context.cc:219
impeller::ContentContext::Pipelines::blend_difference
Variants< BlendDifferencePipeline > blend_difference
Definition: content_context.cc:221
impeller::ContentContext::Pipelines::blend_overlay
Variants< BlendOverlayPipeline > blend_overlay
Definition: content_context.cc:228
impeller::ContentContext::Pipelines::conical_gradient_fill_strip
Variants< ConicalGradientFillStripPipeline > conical_gradient_fill_strip
Definition: content_context.cc:238
impeller::ContentContext::Pipelines::framebuffer_blend_exclusion
Variants< FramebufferBlendExclusionPipeline > framebuffer_blend_exclusion
Definition: content_context.cc:254
impeller::ContentContext::Pipelines::morphology_filter
Variants< MorphologyFilterPipeline > morphology_filter
Definition: content_context.cc:271
impeller::ContentContext::Pipelines::screen_blend
Variants< PorterDuffBlendPipeline > screen_blend
Definition: content_context.cc:280
impeller::ContentContext::Pipelines::framebuffer_blend_saturation
Variants< FramebufferBlendSaturationPipeline > framebuffer_blend_saturation
Definition: content_context.cc:261
impeller::ContentContext::Pipelines::source_over_blend
Variants< PorterDuffBlendPipeline > source_over_blend
Definition: content_context.cc:285
impeller::ContentContext::Pipelines::linear_gradient_fill
Variants< LinearGradientFillPipeline > linear_gradient_fill
Definition: content_context.cc:267
impeller::ContentContext::Pipelines::plus_blend
Variants< PorterDuffBlendPipeline > plus_blend
Definition: content_context.cc:279
impeller::ContentContext::Pipelines::vertices_uber_2_
Variants< VerticesUber2Shader > vertices_uber_2_
Definition: content_context.cc:302
impeller::ContentContext::Pipelines::framebuffer_blend_hardlight
Variants< FramebufferBlendHardLightPipeline > framebuffer_blend_hardlight
Definition: content_context.cc:255
impeller::ContentContext::Pipelines::radial_gradient_ssbo_fill
Variants< RadialGradientSSBOFillPipeline > radial_gradient_ssbo_fill
Definition: content_context.cc:288
impeller::ContentContext::Pipelines::line
Variants< LinePipeline > line
Definition: content_context.cc:266
impeller::ContentContext::Pipelines::clear_blend
Variants< PorterDuffBlendPipeline > clear_blend
Definition: content_context.cc:272
impeller::ContentContext::Pipelines::conical_gradient_uniform_fill
Variants< ConicalGradientUniformFillConicalPipeline > conical_gradient_uniform_fill
Definition: content_context.cc:244
impeller::ContentContext::Pipelines::framebuffer_blend_multiply
Variants< FramebufferBlendMultiplyPipeline > framebuffer_blend_multiply
Definition: content_context.cc:259
impeller::ContentContext::Pipelines::conical_gradient_ssbo_fill
Variants< ConicalGradientSSBOFillPipeline > conical_gradient_ssbo_fill
Definition: content_context.cc:240
impeller::ContentContext::Pipelines::texture_downsample
Variants< TextureDownsamplePipeline > texture_downsample
Definition: content_context.cc:297
impeller::ContentContext::Pipelines::framebuffer_blend_luminosity
Variants< FramebufferBlendLuminosityPipeline > framebuffer_blend_luminosity
Definition: content_context.cc:258
impeller::ContentContext::Pipelines::framebuffer_blend_softlight
Variants< FramebufferBlendSoftLightPipeline > framebuffer_blend_softlight
Definition: content_context.cc:263
impeller::ContentContext::Pipelines::sweep_gradient_uniform_fill
Variants< SweepGradientUniformFillPipeline > sweep_gradient_uniform_fill
Definition: content_context.cc:296
impeller::ContentContext::Pipelines::blend_colorburn
Variants< BlendColorBurnPipeline > blend_colorburn
Definition: content_context.cc:217
impeller::ContentContext::Pipelines::conical_gradient_uniform_fill_strip_and_radial
Variants< ConicalGradientUniformFillStripRadialPipeline > conical_gradient_uniform_fill_strip_and_radial
Definition: content_context.cc:247
impeller::ContentContext::Pipelines::source_in_blend
Variants< PorterDuffBlendPipeline > source_in_blend
Definition: content_context.cc:283
impeller::ContentContext::Pipelines::conical_gradient_fill
Variants< ConicalGradientFillConicalPipeline > conical_gradient_fill
Definition: content_context.cc:236
impeller::ContentContext::Pipelines::circle
Variants< CirclePipeline > circle
Definition: content_context.cc:233
impeller::ContentContext::Pipelines::sweep_gradient_fill
Variants< SweepGradientFillPipeline > sweep_gradient_fill
Definition: content_context.cc:294
impeller::ContentContext::Pipelines::framebuffer_blend_lighten
Variants< FramebufferBlendLightenPipeline > framebuffer_blend_lighten
Definition: content_context.cc:257
impeller::ContentContext::Pipelines::source_a_top_blend
Variants< PorterDuffBlendPipeline > source_a_top_blend
Definition: content_context.cc:281
impeller::ContentContext::Pipelines::destination_a_top_blend
Variants< PorterDuffBlendPipeline > destination_a_top_blend
Definition: content_context.cc:273
impeller::ContentContext::Pipelines::radial_gradient_uniform_fill
Variants< RadialGradientUniformFillPipeline > radial_gradient_uniform_fill
Definition: content_context.cc:289
impeller::ContentContext::Pipelines::blend_lighten
Variants< BlendLightenPipeline > blend_lighten
Definition: content_context.cc:225
impeller::ContentContext::Pipelines::linear_gradient_uniform_fill
Variants< LinearGradientUniformFillPipeline > linear_gradient_uniform_fill
Definition: content_context.cc:269
impeller::ContentContext::Pipelines::framebuffer_blend_colorburn
Variants< FramebufferBlendColorBurnPipeline > framebuffer_blend_colorburn
Definition: content_context.cc:249
impeller::ContentContext::Pipelines::conical_gradient_fill_radial
Variants< ConicalGradientFillRadialPipeline > conical_gradient_fill_radial
Definition: content_context.cc:237
impeller::ContentContext::Pipelines::clip
Variants< ClipPipeline > clip
Definition: content_context.cc:234
impeller::ContentContext::Pipelines::destination_over_blend
Variants< PorterDuffBlendPipeline > destination_over_blend
Definition: content_context.cc:277
impeller::ContentContext::Pipelines::blend_exclusion
Variants< BlendExclusionPipeline > blend_exclusion
Definition: content_context.cc:222
impeller::ContentContext::Pipelines::rsuperellipse_blur
Variants< RSuperellipseBlurPipeline > rsuperellipse_blur
Definition: content_context.cc:291
impeller::ContentContext::Pipelines::srgb_to_linear_filter
Variants< SrgbToLinearFilterPipeline > srgb_to_linear_filter
Definition: content_context.cc:293
impeller::ContentContext::Pipelines::color_matrix_color_filter
Variants< ColorMatrixColorFilterPipeline > color_matrix_color_filter
Definition: content_context.cc:235
impeller::ContentContext::Pipelines::linear_to_srgb_filter
Variants< LinearToSrgbFilterPipeline > linear_to_srgb_filter
Definition: content_context.cc:270
impeller::ContentContext::Pipelines::conical_gradient_uniform_fill_radial
Variants< ConicalGradientUniformFillRadialPipeline > conical_gradient_uniform_fill_radial
Definition: content_context.cc:245
impeller::ContentContext::Pipelines::conical_gradient_ssbo_fill_strip
Variants< ConicalGradientSSBOFillPipeline > conical_gradient_ssbo_fill_strip
Definition: content_context.cc:243
impeller::ContentContext::Pipelines::rrect_blur
Variants< RRectBlurPipeline > rrect_blur
Definition: content_context.cc:290
impeller::ContentContext::Pipelines::blend_darken
Variants< BlendDarkenPipeline > blend_darken
Definition: content_context.cc:220
impeller::ContentContext::Pipelines::texture
Variants< TexturePipeline > texture
Definition: content_context.cc:298
impeller::ContentContext::Pipelines::source_out_blend
Variants< PorterDuffBlendPipeline > source_out_blend
Definition: content_context.cc:284
impeller::ContentContext::Pipelines::framebuffer_blend_hue
Variants< FramebufferBlendHuePipeline > framebuffer_blend_hue
Definition: content_context.cc:256
impeller::ContentContext::Pipelines::texture_strict_src
Variants< TextureStrictSrcPipeline > texture_strict_src
Definition: content_context.cc:299
impeller::ContentContext::Pipelines::framebuffer_blend_color
Variants< FramebufferBlendColorPipeline > framebuffer_blend_color
Definition: content_context.cc:251
impeller::ContentContext::Pipelines::blend_hue
Variants< BlendHuePipeline > blend_hue
Definition: content_context.cc:224
impeller::ContentContext::Pipelines::framebuffer_blend_darken
Variants< FramebufferBlendDarkenPipeline > framebuffer_blend_darken
Definition: content_context.cc:252
impeller::ContentContext::Pipelines::fast_gradient
Variants< FastGradientPipeline > fast_gradient
Definition: content_context.cc:248
impeller::ContentContext::Pipelines::conical_gradient_uniform_fill_strip
Variants< ConicalGradientUniformFillStripPipeline > conical_gradient_uniform_fill_strip
Definition: content_context.cc:246
impeller::ContentContext::Pipelines::xor_blend
Variants< PorterDuffBlendPipeline > xor_blend
Definition: content_context.cc:286
impeller::ContentContext::Pipelines::gaussian_blur
Variants< GaussianBlurPipeline > gaussian_blur
Definition: content_context.cc:264
impeller::ContentContext::Pipelines::linear_gradient_ssbo_fill
Variants< LinearGradientSSBOFillPipeline > linear_gradient_ssbo_fill
Definition: content_context.cc:268
impeller::ContentContext::Pipelines::conical_gradient_ssbo_fill_strip_and_radial
Variants< ConicalGradientSSBOFillPipeline > conical_gradient_ssbo_fill_strip_and_radial
Definition: content_context.cc:242
impeller::ContentContext::Pipelines::glyph_atlas
Variants< GlyphAtlasPipeline > glyph_atlas
Definition: content_context.cc:265
impeller::ContentContext::Pipelines::source_blend
Variants< PorterDuffBlendPipeline > source_blend
Definition: content_context.cc:282
impeller::ContentContext::Pipelines::blend_luminosity
Variants< BlendLuminosityPipeline > blend_luminosity
Definition: content_context.cc:226
impeller::ContentContext::Pipelines::border_mask_blur
Variants< BorderMaskBlurPipeline > border_mask_blur
Definition: content_context.cc:232
impeller::ContentContext::Pipelines::framebuffer_blend_screen
Variants< FramebufferBlendScreenPipeline > framebuffer_blend_screen
Definition: content_context.cc:262
impeller::ContentContext::Pipelines::framebuffer_blend_difference
Variants< FramebufferBlendDifferencePipeline > framebuffer_blend_difference
Definition: content_context.cc:253
impeller::ContentContext::Pipelines::yuv_to_rgb_filter
Variants< YUVToRGBFilterPipeline > yuv_to_rgb_filter
Definition: content_context.cc:303
impeller::ContentContext::Pipelines::radial_gradient_fill
Variants< RadialGradientFillPipeline > radial_gradient_fill
Definition: content_context.cc:287
impeller::ContentContext::Pipelines::conical_gradient_ssbo_fill_radial
Variants< ConicalGradientSSBOFillPipeline > conical_gradient_ssbo_fill_radial
Definition: content_context.cc:241
impeller::ContentContext::Pipelines::conical_gradient_fill_strip_and_radial
Variants< ConicalGradientFillStripRadialPipeline > conical_gradient_fill_strip_and_radial
Definition: content_context.cc:239
impeller::ContentContext::Pipelines::blend_hardlight
Variants< BlendHardLightPipeline > blend_hardlight
Definition: content_context.cc:223
impeller::ContentContext::Pipelines::framebuffer_blend_colordodge
Variants< FramebufferBlendColorDodgePipeline > framebuffer_blend_colordodge
Definition: content_context.cc:250
impeller::ContentContext::Pipelines::destination_out_blend
Variants< PorterDuffBlendPipeline > destination_out_blend
Definition: content_context.cc:276
impeller::ContentContext::Pipelines::vertices_uber_1_
Variants< VerticesUber1Shader > vertices_uber_1_
Definition: content_context.cc:301
impeller::ContentContextOptions
Definition: content_context.h:40
impeller::ContentContextOptions::primitive_type
PrimitiveType primitive_type
Definition: content_context.h:97
impeller::ContentContextOptions::has_depth_stencil_attachments
bool has_depth_stencil_attachments
Definition: content_context.h:99
impeller::ContentContextOptions::stencil_mode
StencilMode stencil_mode
Definition: content_context.h:96
impeller::ContentContextOptions::depth_write_enabled
bool depth_write_enabled
Definition: content_context.h:100
impeller::ContentContextOptions::ApplyToPipelineDescriptor
void ApplyToPipelineDescriptor(PipelineDescriptor &desc) const
Definition: content_context.cc:313
impeller::ContentContextOptions::blend_mode
BlendMode blend_mode
Definition: content_context.h:94
impeller::ContentContextOptions::color_attachment_pixel_format
PixelFormat color_attachment_pixel_format
Definition: content_context.h:98
impeller::ContentContextOptions::StencilMode::kOverdrawPreventionRestore
@ kOverdrawPreventionRestore
impeller::ContentContextOptions::StencilMode::kStencilEvenOddFill
@ kStencilEvenOddFill
impeller::ContentContextOptions::StencilMode::kOverdrawPreventionIncrement
@ kOverdrawPreventionIncrement
impeller::ContentContextOptions::StencilMode::kCoverCompareInverted
@ kCoverCompareInverted
impeller::ContentContextOptions::StencilMode::kStencilNonZeroFill
@ kStencilNonZeroFill
impeller::ContentContextOptions::StencilMode::kIgnore
@ kIgnore
impeller::ContentContextOptions::StencilMode::kCoverCompare
@ kCoverCompare
impeller::ContentContextOptions::sample_count
SampleCount sample_count
Definition: content_context.h:93
impeller::ContentContextOptions::is_for_rrect_blur_clear
bool is_for_rrect_blur_clear
Definition: content_context.h:101
impeller::ContentContextOptions::depth_compare
CompareFunction depth_compare
Definition: content_context.h:95
impeller::DepthAttachmentDescriptor
Definition: formats.h:594
impeller::DepthAttachmentDescriptor::depth_compare
CompareFunction depth_compare
Definition: formats.h:598
impeller::DepthAttachmentDescriptor::depth_write_enabled
bool depth_write_enabled
Definition: formats.h:602
impeller::PipelineBuilder::MakeDefaultPipelineDescriptor
static std::optional< PipelineDescriptor > MakeDefaultPipelineDescriptor(const Context &context, const std::vector< Scalar > &constants={})
Create a default pipeline descriptor using the combination reflected shader information....
Definition: pipeline_builder.h:50
impeller::StencilAttachmentDescriptor
Definition: formats.h:614
impeller::StencilAttachmentDescriptor::stencil_failure
StencilOperation stencil_failure
Definition: formats.h:624
impeller::StencilAttachmentDescriptor::stencil_compare
CompareFunction stencil_compare
Definition: formats.h:620
impeller::StencilAttachmentDescriptor::depth_stencil_pass
StencilOperation depth_stencil_pass
Definition: formats.h:633
impeller::TSize
Definition: size.h:25
impeller::TextureDescriptor
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
Definition: texture_descriptor.h:38
impeller::TextureDescriptor::size
ISize size
Definition: texture_descriptor.h:42
impeller::TextureDescriptor::storage_mode
StorageMode storage_mode
Definition: texture_descriptor.h:39
impeller::TextureDescriptor::format
PixelFormat format
Definition: texture_descriptor.h:41
tessellator.h
text_shadow_cache.h
texture_descriptor.h
data
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:69
texture_util.h
typographer_context.h
validation.h
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91