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