Flutter Impeller
content_context.h
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 #ifndef FLUTTER_IMPELLER_ENTITY_CONTENTS_CONTENT_CONTEXT_H_
6 #define FLUTTER_IMPELLER_ENTITY_CONTENTS_CONTENT_CONTEXT_H_
7 
8 #include <initializer_list>
9 #include <memory>
10 #include <optional>
11 #include <unordered_map>
12 
13 #include "flutter/fml/build_config.h"
14 #include "flutter/fml/logging.h"
15 #include "flutter/fml/status_or.h"
17 #include "impeller/core/formats.h"
19 #include "impeller/entity/entity.h"
26 
27 #ifdef IMPELLER_DEBUG
28 #include "impeller/entity/checkerboard.frag.h"
29 #include "impeller/entity/checkerboard.vert.h"
30 #endif // IMPELLER_DEBUG
31 
32 #include "impeller/entity/blend.frag.h"
33 #include "impeller/entity/blend.vert.h"
34 #include "impeller/entity/border_mask_blur.frag.h"
35 #include "impeller/entity/border_mask_blur.vert.h"
36 #include "impeller/entity/clip.frag.h"
37 #include "impeller/entity/clip.vert.h"
38 #include "impeller/entity/color_matrix_color_filter.frag.h"
39 #include "impeller/entity/color_matrix_color_filter.vert.h"
40 #include "impeller/entity/conical_gradient_fill.frag.h"
41 #include "impeller/entity/glyph_atlas.frag.h"
42 #include "impeller/entity/glyph_atlas.vert.h"
43 #include "impeller/entity/glyph_atlas_color.frag.h"
44 #include "impeller/entity/gradient_fill.vert.h"
45 #include "impeller/entity/linear_gradient_fill.frag.h"
46 #include "impeller/entity/linear_to_srgb_filter.frag.h"
47 #include "impeller/entity/linear_to_srgb_filter.vert.h"
48 #include "impeller/entity/morphology_filter.frag.h"
49 #include "impeller/entity/morphology_filter.vert.h"
50 #include "impeller/entity/points.comp.h"
51 #include "impeller/entity/porter_duff_blend.frag.h"
52 #include "impeller/entity/porter_duff_blend.vert.h"
53 #include "impeller/entity/radial_gradient_fill.frag.h"
54 #include "impeller/entity/rrect_blur.frag.h"
55 #include "impeller/entity/rrect_blur.vert.h"
56 #include "impeller/entity/solid_fill.frag.h"
57 #include "impeller/entity/solid_fill.vert.h"
58 #include "impeller/entity/srgb_to_linear_filter.frag.h"
59 #include "impeller/entity/srgb_to_linear_filter.vert.h"
60 #include "impeller/entity/sweep_gradient_fill.frag.h"
61 #include "impeller/entity/texture_fill.frag.h"
62 #include "impeller/entity/texture_fill.vert.h"
63 #include "impeller/entity/texture_fill_strict_src.frag.h"
64 #include "impeller/entity/tiled_texture_fill.frag.h"
65 #include "impeller/entity/uv.comp.h"
66 #include "impeller/entity/vertices.frag.h"
67 #include "impeller/entity/yuv_to_rgb_filter.frag.h"
68 #include "impeller/entity/yuv_to_rgb_filter.vert.h"
69 
70 #include "impeller/entity/gaussian_blur.vert.h"
71 #include "impeller/entity/gaussian_blur_noalpha_decal.frag.h"
72 #include "impeller/entity/gaussian_blur_noalpha_nodecal.frag.h"
73 #include "impeller/entity/kernel_decal.frag.h"
74 #include "impeller/entity/kernel_nodecal.frag.h"
75 
76 #include "impeller/entity/position_color.vert.h"
77 
79 
80 #include "impeller/entity/conical_gradient_ssbo_fill.frag.h"
81 #include "impeller/entity/linear_gradient_ssbo_fill.frag.h"
82 #include "impeller/entity/radial_gradient_ssbo_fill.frag.h"
83 #include "impeller/entity/sweep_gradient_ssbo_fill.frag.h"
84 
85 #include "impeller/entity/advanced_blend.frag.h"
86 #include "impeller/entity/advanced_blend.vert.h"
87 
88 #include "impeller/entity/framebuffer_blend.frag.h"
89 #include "impeller/entity/framebuffer_blend.vert.h"
90 
91 #ifdef IMPELLER_ENABLE_OPENGLES
92 #include "impeller/entity/texture_fill_external.frag.h"
93 #include "impeller/entity/tiled_texture_fill_external.frag.h"
94 #endif // IMPELLER_ENABLE_OPENGLES
95 
96 #if IMPELLER_ENABLE_3D
97 #include "impeller/scene/scene_context.h" // nogncheck
98 #endif
99 
100 namespace impeller {
101 
102 #ifdef IMPELLER_DEBUG
103 using CheckerboardPipeline =
104  RenderPipelineT<CheckerboardVertexShader, CheckerboardFragmentShader>;
105 #endif // IMPELLER_DEBUG
106 
109 using SolidFillPipeline =
114  RenderPipelineT<GradientFillVertexShader,
115  ConicalGradientFillFragmentShader>;
119  RenderPipelineT<GradientFillVertexShader,
120  LinearGradientSsboFillFragmentShader>;
122  RenderPipelineT<GradientFillVertexShader,
123  ConicalGradientSsboFillFragmentShader>;
125  RenderPipelineT<GradientFillVertexShader,
126  RadialGradientSsboFillFragmentShader>;
128  RenderPipelineT<GradientFillVertexShader,
129  SweepGradientSsboFillFragmentShader>;
130 using RRectBlurPipeline =
133 using TexturePipeline =
136  RenderPipelineT<TextureFillVertexShader,
137  TextureFillStrictSrcFragmentShader>;
138 using PositionUVPipeline =
140 using TiledTexturePipeline =
144  GaussianBlurNoalphaDecalFragmentShader>;
145 using GaussianBlurPipeline =
147  GaussianBlurNoalphaNodecalFragmentShader>;
148 using KernelDecalPipeline =
150 using KernelPipeline =
155  RenderPipelineT<MorphologyFilterVertexShader,
156  MorphologyFilterFragmentShader>;
158  RenderPipelineT<ColorMatrixColorFilterVertexShader,
159  ColorMatrixColorFilterFragmentShader>;
161  RenderPipelineT<LinearToSrgbFilterVertexShader,
162  LinearToSrgbFilterFragmentShader>;
164  RenderPipelineT<SrgbToLinearFilterVertexShader,
165  SrgbToLinearFilterFragmentShader>;
166 using GlyphAtlasPipeline =
172 // Instead of requiring new shaders for clips, the solid fill stages are used
173 // to redirect writing to the stencil instead of color attachments.
175 
176 using GeometryColorPipeline =
180 
181 // Advanced blends
182 using BlendColorPipeline =
188 using BlendDarkenPipeline =
196 using BlendHuePipeline =
198 using BlendLightenPipeline =
202 using BlendMultiplyPipeline =
204 using BlendOverlayPipeline =
208 using BlendScreenPipeline =
212 // Framebuffer Advanced Blends
214  RenderPipelineT<FramebufferBlendVertexShader,
215  FramebufferBlendFragmentShader>;
217  RenderPipelineT<FramebufferBlendVertexShader,
218  FramebufferBlendFragmentShader>;
220  RenderPipelineT<FramebufferBlendVertexShader,
221  FramebufferBlendFragmentShader>;
223  RenderPipelineT<FramebufferBlendVertexShader,
224  FramebufferBlendFragmentShader>;
226  RenderPipelineT<FramebufferBlendVertexShader,
227  FramebufferBlendFragmentShader>;
229  RenderPipelineT<FramebufferBlendVertexShader,
230  FramebufferBlendFragmentShader>;
232  RenderPipelineT<FramebufferBlendVertexShader,
233  FramebufferBlendFragmentShader>;
235  RenderPipelineT<FramebufferBlendVertexShader,
236  FramebufferBlendFragmentShader>;
238  RenderPipelineT<FramebufferBlendVertexShader,
239  FramebufferBlendFragmentShader>;
241  RenderPipelineT<FramebufferBlendVertexShader,
242  FramebufferBlendFragmentShader>;
244  RenderPipelineT<FramebufferBlendVertexShader,
245  FramebufferBlendFragmentShader>;
247  RenderPipelineT<FramebufferBlendVertexShader,
248  FramebufferBlendFragmentShader>;
250  RenderPipelineT<FramebufferBlendVertexShader,
251  FramebufferBlendFragmentShader>;
253  RenderPipelineT<FramebufferBlendVertexShader,
254  FramebufferBlendFragmentShader>;
256  RenderPipelineT<FramebufferBlendVertexShader,
257  FramebufferBlendFragmentShader>;
258 
259 /// Geometry Pipelines
262 
263 #ifdef IMPELLER_ENABLE_OPENGLES
264 using TextureExternalPipeline =
266 
267 using TiledTextureExternalPipeline =
268  RenderPipelineT<TextureFillVertexShader,
269  TiledTextureFillExternalFragmentShader>;
270 #endif // IMPELLER_ENABLE_OPENGLES
271 
272 // A struct used to isolate command buffer storage from the content
273 // context options to preserve const-ness.
275  std::vector<std::shared_ptr<CommandBuffer>> command_buffers;
276 };
277 
278 /// Pipeline state configuration.
279 ///
280 /// Each unique combination of these options requires a different pipeline state
281 /// object to be built. This struct is used as a key for the per-pipeline
282 /// variant cache.
283 ///
284 /// When adding fields to this key, reliant features should take care to limit
285 /// the combinatorical explosion of variations. A sufficiently complicated
286 /// Flutter application may easily require building hundreds of PSOs in total,
287 /// but they shouldn't require e.g. 10s of thousands.
289  enum class StencilMode : uint8_t {
290  /// Turn the stencil test off. Used when drawing without stencil-then-cover.
291  kIgnore,
292 
293  // Operations used for stencil-then-cover
294 
295  /// Draw the stencil for the NonZero fill path rule.
296  ///
297  /// The stencil ref should always be 0 on commands using this mode.
299  /// Draw the stencil for the EvenOdd fill path rule.
300  ///
301  /// The stencil ref should always be 0 on commands using this mode.
303  /// Used for draw calls which fill in the stenciled area. Intended to be
304  /// used after `kStencilNonZeroFill` or `kStencilEvenOddFill` is used to set
305  /// up the stencil buffer. Also cleans up the stencil buffer by resetting
306  /// everything to zero.
307  ///
308  /// The stencil ref should always be 0 on commands using this mode.
310  /// The opposite of `kCoverCompare`. Used for draw calls which fill in the
311  /// non-stenciled area (intersection clips). Intended to be used after
312  /// `kStencilNonZeroFill` or `kStencilEvenOddFill` is used to set up the
313  /// stencil buffer. Also cleans up the stencil buffer by resetting
314  /// everything to zero.
315  ///
316  /// The stencil ref should always be 0 on commands using this mode.
318 
319  // Operations to control the legacy clip implementation, which forms a
320  // heightmap on the stencil buffer.
321 
322  /// Slice the clip heightmap to a new maximum height.
324  /// Increment the stencil heightmap.
326  /// Decrement the stencil heightmap (used for difference clipping only).
328  /// Used for applying clips to all non-clip draw calls.
330  };
331 
340  bool depth_write_enabled = false;
341  bool wireframe = false;
343 
344  struct Hash {
345  constexpr uint64_t operator()(const ContentContextOptions& o) const {
346  static_assert(sizeof(o.sample_count) == 1);
347  static_assert(sizeof(o.blend_mode) == 1);
348  static_assert(sizeof(o.sample_count) == 1);
349  static_assert(sizeof(o.depth_compare) == 1);
350  static_assert(sizeof(o.stencil_mode) == 1);
351  static_assert(sizeof(o.primitive_type) == 1);
352  static_assert(sizeof(o.color_attachment_pixel_format) == 1);
353 
354  return (o.is_for_rrect_blur_clear ? 1llu : 0llu) << 0 |
355  (o.wireframe ? 1llu : 0llu) << 1 |
356  (o.has_depth_stencil_attachments ? 1llu : 0llu) << 2 |
357  (o.depth_write_enabled ? 1llu : 0llu) << 3 |
358  // enums
359  static_cast<uint64_t>(o.color_attachment_pixel_format) << 8 |
360  static_cast<uint64_t>(o.primitive_type) << 16 |
361  static_cast<uint64_t>(o.stencil_mode) << 24 |
362  static_cast<uint64_t>(o.depth_compare) << 32 |
363  static_cast<uint64_t>(o.blend_mode) << 40 |
364  static_cast<uint64_t>(o.sample_count) << 48;
365  }
366  };
367 
368  struct Equal {
369  constexpr bool operator()(const ContentContextOptions& lhs,
370  const ContentContextOptions& rhs) const {
371  return lhs.sample_count == rhs.sample_count &&
372  lhs.blend_mode == rhs.blend_mode &&
374  lhs.depth_compare == rhs.depth_compare &&
375  lhs.stencil_mode == rhs.stencil_mode &&
376  lhs.primitive_type == rhs.primitive_type &&
381  lhs.wireframe == rhs.wireframe &&
383  }
384  };
385 
387 };
388 
389 class Tessellator;
390 class RenderTargetCache;
391 
393  public:
394  explicit ContentContext(
395  std::shared_ptr<Context> context,
396  std::shared_ptr<TypographerContext> typographer_context,
397  std::shared_ptr<RenderTargetAllocator> render_target_allocator = nullptr);
398 
399  ~ContentContext();
400 
401  bool IsValid() const;
402 
403  /// This setting does two things:
404  /// 1. Enables clipping with the depth buffer, freeing up the stencil buffer.
405  /// See also: https://github.com/flutter/flutter/issues/138460
406  /// 2. Switches the generic tessellation fallback to use stencil-then-cover.
407  /// See also: https://github.com/flutter/flutter/issues/123671
408  ///
409  // TODO(bdero): Remove this setting once StC is fully de-risked
410  // https://github.com/flutter/flutter/issues/123671
411  static constexpr bool kEnableStencilThenCover = true;
412 
413 #if IMPELLER_ENABLE_3D
414  std::shared_ptr<scene::SceneContext> GetSceneContext() const;
415 #endif // IMPELLER_ENABLE_3D
416 
417  std::shared_ptr<Tessellator> GetTessellator() const;
418 
419 #ifdef IMPELLER_DEBUG
420  std::shared_ptr<Pipeline<PipelineDescriptor>> GetCheckerboardPipeline(
421  ContentContextOptions opts) const {
422  return GetPipeline(checkerboard_pipelines_, opts);
423  }
424 #endif // IMPELLER_DEBUG
425 
426  std::shared_ptr<Pipeline<PipelineDescriptor>> GetLinearGradientFillPipeline(
427  ContentContextOptions opts) const {
428  return GetPipeline(linear_gradient_fill_pipelines_, opts);
429  }
430 
431  std::shared_ptr<Pipeline<PipelineDescriptor>>
433  FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
434  return GetPipeline(linear_gradient_ssbo_fill_pipelines_, opts);
435  }
436 
437  std::shared_ptr<Pipeline<PipelineDescriptor>>
439  FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
440  return GetPipeline(radial_gradient_ssbo_fill_pipelines_, opts);
441  }
442 
443  std::shared_ptr<Pipeline<PipelineDescriptor>>
445  FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
446  return GetPipeline(conical_gradient_ssbo_fill_pipelines_, opts);
447  }
448 
449  std::shared_ptr<Pipeline<PipelineDescriptor>>
451  FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
452  return GetPipeline(sweep_gradient_ssbo_fill_pipelines_, opts);
453  }
454 
455  std::shared_ptr<Pipeline<PipelineDescriptor>> GetRadialGradientFillPipeline(
456  ContentContextOptions opts) const {
457  return GetPipeline(radial_gradient_fill_pipelines_, opts);
458  }
459 
460  std::shared_ptr<Pipeline<PipelineDescriptor>> GetConicalGradientFillPipeline(
461  ContentContextOptions opts) const {
462  return GetPipeline(conical_gradient_fill_pipelines_, opts);
463  }
464 
465  std::shared_ptr<Pipeline<PipelineDescriptor>> GetRRectBlurPipeline(
466  ContentContextOptions opts) const {
467  return GetPipeline(rrect_blur_pipelines_, opts);
468  }
469 
470  std::shared_ptr<Pipeline<PipelineDescriptor>> GetSweepGradientFillPipeline(
471  ContentContextOptions opts) const {
472  return GetPipeline(sweep_gradient_fill_pipelines_, opts);
473  }
474 
475  std::shared_ptr<Pipeline<PipelineDescriptor>> GetSolidFillPipeline(
476  ContentContextOptions opts) const {
477  return GetPipeline(solid_fill_pipelines_, opts);
478  }
479 
480  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendPipeline(
481  ContentContextOptions opts) const {
482  return GetPipeline(texture_blend_pipelines_, opts);
483  }
484 
485  std::shared_ptr<Pipeline<PipelineDescriptor>> GetTexturePipeline(
486  ContentContextOptions opts) const {
487  return GetPipeline(texture_pipelines_, opts);
488  }
489 
490  std::shared_ptr<Pipeline<PipelineDescriptor>> GetTextureStrictSrcPipeline(
491  ContentContextOptions opts) const {
492  return GetPipeline(texture_strict_src_pipelines_, opts);
493  }
494 
495 #ifdef IMPELLER_ENABLE_OPENGLES
496  std::shared_ptr<Pipeline<PipelineDescriptor>> GetTextureExternalPipeline(
497  ContentContextOptions opts) const {
498  FML_DCHECK(GetContext()->GetBackendType() ==
500  return GetPipeline(texture_external_pipelines_, opts);
501  }
502 
503  std::shared_ptr<Pipeline<PipelineDescriptor>> GetTiledTextureExternalPipeline(
504  ContentContextOptions opts) const {
505  FML_DCHECK(GetContext()->GetBackendType() ==
507  return GetPipeline(tiled_texture_external_pipelines_, opts);
508  }
509 #endif // IMPELLER_ENABLE_OPENGLES
510 
511  std::shared_ptr<Pipeline<PipelineDescriptor>> GetPositionUVPipeline(
512  ContentContextOptions opts) const {
513  return GetPipeline(position_uv_pipelines_, opts);
514  }
515 
516  std::shared_ptr<Pipeline<PipelineDescriptor>> GetTiledTexturePipeline(
517  ContentContextOptions opts) const {
518  return GetPipeline(tiled_texture_pipelines_, opts);
519  }
520 
521  std::shared_ptr<Pipeline<PipelineDescriptor>> GetGaussianBlurDecalPipeline(
522  ContentContextOptions opts) const {
523  return GetPipeline(gaussian_blur_noalpha_decal_pipelines_, opts);
524  }
525 
526  std::shared_ptr<Pipeline<PipelineDescriptor>> GetGaussianBlurPipeline(
527  ContentContextOptions opts) const {
528  return GetPipeline(gaussian_blur_noalpha_nodecal_pipelines_, opts);
529  }
530 
531  std::shared_ptr<Pipeline<PipelineDescriptor>> GetKernelDecalPipeline(
532  ContentContextOptions opts) const {
533  return GetPipeline(kernel_decal_pipelines_, opts);
534  }
535 
536  std::shared_ptr<Pipeline<PipelineDescriptor>> GetKernelPipeline(
537  ContentContextOptions opts) const {
538  return GetPipeline(kernel_nodecal_pipelines_, opts);
539  }
540 
541  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBorderMaskBlurPipeline(
542  ContentContextOptions opts) const {
543  return GetPipeline(border_mask_blur_pipelines_, opts);
544  }
545 
546  std::shared_ptr<Pipeline<PipelineDescriptor>> GetMorphologyFilterPipeline(
547  ContentContextOptions opts) const {
548  return GetPipeline(morphology_filter_pipelines_, opts);
549  }
550 
551  std::shared_ptr<Pipeline<PipelineDescriptor>>
553  return GetPipeline(color_matrix_color_filter_pipelines_, opts);
554  }
555 
556  std::shared_ptr<Pipeline<PipelineDescriptor>> GetLinearToSrgbFilterPipeline(
557  ContentContextOptions opts) const {
558  return GetPipeline(linear_to_srgb_filter_pipelines_, opts);
559  }
560 
561  std::shared_ptr<Pipeline<PipelineDescriptor>> GetSrgbToLinearFilterPipeline(
562  ContentContextOptions opts) const {
563  return GetPipeline(srgb_to_linear_filter_pipelines_, opts);
564  }
565 
566  std::shared_ptr<Pipeline<PipelineDescriptor>> GetClipPipeline(
567  ContentContextOptions opts) const {
568  return GetPipeline(clip_pipelines_, opts);
569  }
570 
571  std::shared_ptr<Pipeline<PipelineDescriptor>> GetGlyphAtlasPipeline(
572  ContentContextOptions opts) const {
573  return GetPipeline(glyph_atlas_pipelines_, opts);
574  }
575 
576  std::shared_ptr<Pipeline<PipelineDescriptor>> GetGlyphAtlasColorPipeline(
577  ContentContextOptions opts) const {
578  return GetPipeline(glyph_atlas_color_pipelines_, opts);
579  }
580 
581  std::shared_ptr<Pipeline<PipelineDescriptor>> GetGeometryColorPipeline(
582  ContentContextOptions opts) const {
583  return GetPipeline(geometry_color_pipelines_, opts);
584  }
585 
586  std::shared_ptr<Pipeline<PipelineDescriptor>> GetYUVToRGBFilterPipeline(
587  ContentContextOptions opts) const {
588  return GetPipeline(yuv_to_rgb_filter_pipelines_, opts);
589  }
590 
591  std::shared_ptr<Pipeline<PipelineDescriptor>> GetPorterDuffBlendPipeline(
592  ContentContextOptions opts) const {
593  return GetPipeline(porter_duff_blend_pipelines_, opts);
594  }
595 
596  // Advanced blends.
597 
598  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendColorPipeline(
599  ContentContextOptions opts) const {
600  return GetPipeline(blend_color_pipelines_, opts);
601  }
602 
603  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendColorBurnPipeline(
604  ContentContextOptions opts) const {
605  return GetPipeline(blend_colorburn_pipelines_, opts);
606  }
607 
608  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendColorDodgePipeline(
609  ContentContextOptions opts) const {
610  return GetPipeline(blend_colordodge_pipelines_, opts);
611  }
612 
613  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendDarkenPipeline(
614  ContentContextOptions opts) const {
615  return GetPipeline(blend_darken_pipelines_, opts);
616  }
617 
618  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendDifferencePipeline(
619  ContentContextOptions opts) const {
620  return GetPipeline(blend_difference_pipelines_, opts);
621  }
622 
623  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendExclusionPipeline(
624  ContentContextOptions opts) const {
625  return GetPipeline(blend_exclusion_pipelines_, opts);
626  }
627 
628  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendHardLightPipeline(
629  ContentContextOptions opts) const {
630  return GetPipeline(blend_hardlight_pipelines_, opts);
631  }
632 
633  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendHuePipeline(
634  ContentContextOptions opts) const {
635  return GetPipeline(blend_hue_pipelines_, opts);
636  }
637 
638  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendLightenPipeline(
639  ContentContextOptions opts) const {
640  return GetPipeline(blend_lighten_pipelines_, opts);
641  }
642 
643  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendLuminosityPipeline(
644  ContentContextOptions opts) const {
645  return GetPipeline(blend_luminosity_pipelines_, opts);
646  }
647 
648  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendMultiplyPipeline(
649  ContentContextOptions opts) const {
650  return GetPipeline(blend_multiply_pipelines_, opts);
651  }
652 
653  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendOverlayPipeline(
654  ContentContextOptions opts) const {
655  return GetPipeline(blend_overlay_pipelines_, opts);
656  }
657 
658  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendSaturationPipeline(
659  ContentContextOptions opts) const {
660  return GetPipeline(blend_saturation_pipelines_, opts);
661  }
662 
663  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendScreenPipeline(
664  ContentContextOptions opts) const {
665  return GetPipeline(blend_screen_pipelines_, opts);
666  }
667 
668  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendSoftLightPipeline(
669  ContentContextOptions opts) const {
670  return GetPipeline(blend_softlight_pipelines_, opts);
671  }
672 
673  // Framebuffer Advanced Blends
674  std::shared_ptr<Pipeline<PipelineDescriptor>>
676  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
677  return GetPipeline(framebuffer_blend_color_pipelines_, opts);
678  }
679 
680  std::shared_ptr<Pipeline<PipelineDescriptor>>
682  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
683  return GetPipeline(framebuffer_blend_colorburn_pipelines_, opts);
684  }
685 
686  std::shared_ptr<Pipeline<PipelineDescriptor>>
688  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
689  return GetPipeline(framebuffer_blend_colordodge_pipelines_, opts);
690  }
691 
692  std::shared_ptr<Pipeline<PipelineDescriptor>>
694  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
695  return GetPipeline(framebuffer_blend_darken_pipelines_, opts);
696  }
697 
698  std::shared_ptr<Pipeline<PipelineDescriptor>>
700  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
701  return GetPipeline(framebuffer_blend_difference_pipelines_, opts);
702  }
703 
704  std::shared_ptr<Pipeline<PipelineDescriptor>>
706  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
707  return GetPipeline(framebuffer_blend_exclusion_pipelines_, opts);
708  }
709 
710  std::shared_ptr<Pipeline<PipelineDescriptor>>
712  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
713  return GetPipeline(framebuffer_blend_hardlight_pipelines_, opts);
714  }
715 
716  std::shared_ptr<Pipeline<PipelineDescriptor>> GetFramebufferBlendHuePipeline(
717  ContentContextOptions opts) const {
718  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
719  return GetPipeline(framebuffer_blend_hue_pipelines_, opts);
720  }
721 
722  std::shared_ptr<Pipeline<PipelineDescriptor>>
724  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
725  return GetPipeline(framebuffer_blend_lighten_pipelines_, opts);
726  }
727 
728  std::shared_ptr<Pipeline<PipelineDescriptor>>
730  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
731  return GetPipeline(framebuffer_blend_luminosity_pipelines_, opts);
732  }
733 
734  std::shared_ptr<Pipeline<PipelineDescriptor>>
736  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
737  return GetPipeline(framebuffer_blend_multiply_pipelines_, opts);
738  }
739 
740  std::shared_ptr<Pipeline<PipelineDescriptor>>
742  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
743  return GetPipeline(framebuffer_blend_overlay_pipelines_, opts);
744  }
745 
746  std::shared_ptr<Pipeline<PipelineDescriptor>>
748  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
749  return GetPipeline(framebuffer_blend_saturation_pipelines_, opts);
750  }
751 
752  std::shared_ptr<Pipeline<PipelineDescriptor>>
754  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
755  return GetPipeline(framebuffer_blend_screen_pipelines_, opts);
756  }
757 
758  std::shared_ptr<Pipeline<PipelineDescriptor>>
760  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
761  return GetPipeline(framebuffer_blend_softlight_pipelines_, opts);
762  }
763 
764  std::shared_ptr<Pipeline<ComputePipelineDescriptor>> GetPointComputePipeline()
765  const {
766  FML_DCHECK(GetDeviceCapabilities().SupportsCompute());
767  return point_field_compute_pipelines_;
768  }
769 
770  std::shared_ptr<Pipeline<ComputePipelineDescriptor>> GetUvComputePipeline()
771  const {
772  FML_DCHECK(GetDeviceCapabilities().SupportsCompute());
773  return uv_compute_pipelines_;
774  }
775 
776  std::shared_ptr<Context> GetContext() const;
777 
778  const Capabilities& GetDeviceCapabilities() const;
779 
780  void SetWireframe(bool wireframe);
781 
782  using SubpassCallback =
783  std::function<bool(const ContentContext&, RenderPass&)>;
784 
785  /// @brief Creates a new texture of size `texture_size` and calls
786  /// `subpass_callback` with a `RenderPass` for drawing to the texture.
787  fml::StatusOr<RenderTarget> MakeSubpass(
788  const std::string& label,
789  ISize texture_size,
790  const SubpassCallback& subpass_callback,
791  bool msaa_enabled = true,
792  bool depth_stencil_enabled = false,
793  int32_t mip_count = 1) const;
794 
795  /// Makes a subpass that will render to `subpass_target`.
796  fml::StatusOr<RenderTarget> MakeSubpass(
797  const std::string& label,
798  const RenderTarget& subpass_target,
799  const SubpassCallback& subpass_callback) const;
800 
801  const std::shared_ptr<LazyGlyphAtlas>& GetLazyGlyphAtlas() const {
802  return lazy_glyph_atlas_;
803  }
804 
805  const std::shared_ptr<RenderTargetAllocator>& GetRenderTargetCache() const {
806  return render_target_cache_;
807  }
808 
809  /// RuntimeEffect pipelines must be obtained via this method to avoid
810  /// re-creating them every frame.
811  ///
812  /// The unique_entrypoint_name comes from RuntimeEffect::GetEntrypoint.
813  /// Impellerc generates a unique entrypoint name for runtime effect shaders
814  /// based on the input file name and shader stage.
815  ///
816  /// The create_callback is synchronously invoked exactly once if a cached
817  /// pipeline is not found.
818  std::shared_ptr<Pipeline<PipelineDescriptor>> GetCachedRuntimeEffectPipeline(
819  const std::string& unique_entrypoint_name,
820  const ContentContextOptions& options,
821  const std::function<std::shared_ptr<Pipeline<PipelineDescriptor>>()>&
822  create_callback) const;
823 
824  /// Used by hot reload/hot restart to clear a cached pipeline from
825  /// GetCachedRuntimeEffectPipeline.
827  const std::string& unique_entrypoint_name) const;
828 
829  /// @brief Retrieve the currnent host buffer for transient storage.
830  ///
831  /// This is only safe to use from the raster threads. Other threads should
832  /// allocate their own device buffers.
833  HostBuffer& GetTransientsBuffer() const { return *host_buffer_; }
834 
835  private:
836  std::shared_ptr<Context> context_;
837  std::shared_ptr<LazyGlyphAtlas> lazy_glyph_atlas_;
838 
839  /// Run backend specific additional setup and create common shader variants.
840  ///
841  /// This bootstrap is intended to improve the performance of several
842  /// first frame benchmarks that are tracked in the flutter device lab.
843  /// The workload includes initializing commonly used but not default
844  /// shader variants, as well as forcing driver initialization.
845  void InitializeCommonlyUsedShadersIfNeeded() const;
846 
847  struct RuntimeEffectPipelineKey {
848  std::string unique_entrypoint_name;
849  ContentContextOptions options;
850 
851  struct Hash {
852  std::size_t operator()(const RuntimeEffectPipelineKey& key) const {
853  return fml::HashCombine(key.unique_entrypoint_name,
854  ContentContextOptions::Hash{}(key.options));
855  }
856  };
857 
858  struct Equal {
859  constexpr bool operator()(const RuntimeEffectPipelineKey& lhs,
860  const RuntimeEffectPipelineKey& rhs) const {
861  return lhs.unique_entrypoint_name == rhs.unique_entrypoint_name &&
862  ContentContextOptions::Equal{}(lhs.options, rhs.options);
863  }
864  };
865  };
866 
867  mutable std::unordered_map<RuntimeEffectPipelineKey,
868  std::shared_ptr<Pipeline<PipelineDescriptor>>,
869  RuntimeEffectPipelineKey::Hash,
870  RuntimeEffectPipelineKey::Equal>
871  runtime_effect_pipelines_;
872 
873  template <class PipelineT>
874  class Variants {
875  public:
876  Variants() = default;
877 
878  void Set(const ContentContextOptions& options,
879  std::unique_ptr<PipelineT> pipeline) {
880  pipelines_[options] = std::move(pipeline);
881  }
882 
883  void SetDefault(const ContentContextOptions& options,
884  std::unique_ptr<PipelineT> pipeline) {
885  default_options_ = options;
886  Set(options, std::move(pipeline));
887  }
888 
889  void CreateDefault(const Context& context,
890  const ContentContextOptions& options,
891  const std::initializer_list<Scalar>& constants = {}) {
892  auto desc =
893  PipelineT::Builder::MakeDefaultPipelineDescriptor(context, constants);
894  if (!desc.has_value()) {
895  VALIDATION_LOG << "Failed to create default pipeline.";
896  return;
897  }
898  options.ApplyToPipelineDescriptor(*desc);
899  SetDefault(options, std::make_unique<PipelineT>(context, desc));
900  }
901 
902  PipelineT* Get(const ContentContextOptions& options) const {
903  if (auto found = pipelines_.find(options); found != pipelines_.end()) {
904  return found->second.get();
905  }
906  return nullptr;
907  }
908 
909  PipelineT* GetDefault() const {
910  if (!default_options_.has_value()) {
911  return nullptr;
912  }
913  return Get(default_options_.value());
914  }
915 
916  size_t GetPipelineCount() const { return pipelines_.size(); }
917 
918  private:
919  std::optional<ContentContextOptions> default_options_;
920  std::unordered_map<ContentContextOptions,
921  std::unique_ptr<PipelineT>,
922  ContentContextOptions::Hash,
923  ContentContextOptions::Equal>
924  pipelines_;
925 
926  Variants(const Variants&) = delete;
927 
928  Variants& operator=(const Variants&) = delete;
929  };
930 
931  // These are mutable because while the prototypes are created eagerly, any
932  // variants requested from that are lazily created and cached in the variants
933  // map.
934 
935 #ifdef IMPELLER_DEBUG
936  mutable Variants<CheckerboardPipeline> checkerboard_pipelines_;
937 #endif // IMPELLER_DEBUG
938 
939  mutable Variants<SolidFillPipeline> solid_fill_pipelines_;
940  mutable Variants<LinearGradientFillPipeline> linear_gradient_fill_pipelines_;
941  mutable Variants<RadialGradientFillPipeline> radial_gradient_fill_pipelines_;
942  mutable Variants<ConicalGradientFillPipeline>
943  conical_gradient_fill_pipelines_;
944  mutable Variants<SweepGradientFillPipeline> sweep_gradient_fill_pipelines_;
945  mutable Variants<LinearGradientSSBOFillPipeline>
946  linear_gradient_ssbo_fill_pipelines_;
947  mutable Variants<RadialGradientSSBOFillPipeline>
948  radial_gradient_ssbo_fill_pipelines_;
949  mutable Variants<ConicalGradientSSBOFillPipeline>
950  conical_gradient_ssbo_fill_pipelines_;
951  mutable Variants<SweepGradientSSBOFillPipeline>
952  sweep_gradient_ssbo_fill_pipelines_;
953  mutable Variants<RRectBlurPipeline> rrect_blur_pipelines_;
954  mutable Variants<BlendPipeline> texture_blend_pipelines_;
955  mutable Variants<TexturePipeline> texture_pipelines_;
956  mutable Variants<TextureStrictSrcPipeline> texture_strict_src_pipelines_;
957 #ifdef IMPELLER_ENABLE_OPENGLES
958  mutable Variants<TextureExternalPipeline> texture_external_pipelines_;
959  mutable Variants<TiledTextureExternalPipeline>
960  tiled_texture_external_pipelines_;
961 #endif // IMPELLER_ENABLE_OPENGLES
962  mutable Variants<PositionUVPipeline> position_uv_pipelines_;
963  mutable Variants<TiledTexturePipeline> tiled_texture_pipelines_;
964  mutable Variants<GaussianBlurDecalPipeline>
965  gaussian_blur_noalpha_decal_pipelines_;
966  mutable Variants<GaussianBlurPipeline>
967  gaussian_blur_noalpha_nodecal_pipelines_;
968  mutable Variants<KernelDecalPipeline> kernel_decal_pipelines_;
969  mutable Variants<KernelPipeline> kernel_nodecal_pipelines_;
970  mutable Variants<BorderMaskBlurPipeline> border_mask_blur_pipelines_;
971  mutable Variants<MorphologyFilterPipeline> morphology_filter_pipelines_;
972  mutable Variants<ColorMatrixColorFilterPipeline>
973  color_matrix_color_filter_pipelines_;
974  mutable Variants<LinearToSrgbFilterPipeline> linear_to_srgb_filter_pipelines_;
975  mutable Variants<SrgbToLinearFilterPipeline> srgb_to_linear_filter_pipelines_;
976  mutable Variants<ClipPipeline> clip_pipelines_;
977  mutable Variants<GlyphAtlasPipeline> glyph_atlas_pipelines_;
978  mutable Variants<GlyphAtlasColorPipeline> glyph_atlas_color_pipelines_;
979  mutable Variants<GeometryColorPipeline> geometry_color_pipelines_;
980  mutable Variants<YUVToRGBFilterPipeline> yuv_to_rgb_filter_pipelines_;
981  mutable Variants<PorterDuffBlendPipeline> porter_duff_blend_pipelines_;
982  // Advanced blends.
983  mutable Variants<BlendColorPipeline> blend_color_pipelines_;
984  mutable Variants<BlendColorBurnPipeline> blend_colorburn_pipelines_;
985  mutable Variants<BlendColorDodgePipeline> blend_colordodge_pipelines_;
986  mutable Variants<BlendDarkenPipeline> blend_darken_pipelines_;
987  mutable Variants<BlendDifferencePipeline> blend_difference_pipelines_;
988  mutable Variants<BlendExclusionPipeline> blend_exclusion_pipelines_;
989  mutable Variants<BlendHardLightPipeline> blend_hardlight_pipelines_;
990  mutable Variants<BlendHuePipeline> blend_hue_pipelines_;
991  mutable Variants<BlendLightenPipeline> blend_lighten_pipelines_;
992  mutable Variants<BlendLuminosityPipeline> blend_luminosity_pipelines_;
993  mutable Variants<BlendMultiplyPipeline> blend_multiply_pipelines_;
994  mutable Variants<BlendOverlayPipeline> blend_overlay_pipelines_;
995  mutable Variants<BlendSaturationPipeline> blend_saturation_pipelines_;
996  mutable Variants<BlendScreenPipeline> blend_screen_pipelines_;
997  mutable Variants<BlendSoftLightPipeline> blend_softlight_pipelines_;
998  // Framebuffer Advanced blends.
999  mutable Variants<FramebufferBlendColorPipeline>
1000  framebuffer_blend_color_pipelines_;
1001  mutable Variants<FramebufferBlendColorBurnPipeline>
1002  framebuffer_blend_colorburn_pipelines_;
1003  mutable Variants<FramebufferBlendColorDodgePipeline>
1004  framebuffer_blend_colordodge_pipelines_;
1005  mutable Variants<FramebufferBlendDarkenPipeline>
1006  framebuffer_blend_darken_pipelines_;
1007  mutable Variants<FramebufferBlendDifferencePipeline>
1008  framebuffer_blend_difference_pipelines_;
1009  mutable Variants<FramebufferBlendExclusionPipeline>
1010  framebuffer_blend_exclusion_pipelines_;
1011  mutable Variants<FramebufferBlendHardLightPipeline>
1012  framebuffer_blend_hardlight_pipelines_;
1013  mutable Variants<FramebufferBlendHuePipeline>
1014  framebuffer_blend_hue_pipelines_;
1015  mutable Variants<FramebufferBlendLightenPipeline>
1016  framebuffer_blend_lighten_pipelines_;
1017  mutable Variants<FramebufferBlendLuminosityPipeline>
1018  framebuffer_blend_luminosity_pipelines_;
1019  mutable Variants<FramebufferBlendMultiplyPipeline>
1020  framebuffer_blend_multiply_pipelines_;
1021  mutable Variants<FramebufferBlendOverlayPipeline>
1022  framebuffer_blend_overlay_pipelines_;
1023  mutable Variants<FramebufferBlendSaturationPipeline>
1024  framebuffer_blend_saturation_pipelines_;
1025  mutable Variants<FramebufferBlendScreenPipeline>
1026  framebuffer_blend_screen_pipelines_;
1027  mutable Variants<FramebufferBlendSoftLightPipeline>
1028  framebuffer_blend_softlight_pipelines_;
1029  mutable std::shared_ptr<Pipeline<ComputePipelineDescriptor>>
1030  point_field_compute_pipelines_;
1031  mutable std::shared_ptr<Pipeline<ComputePipelineDescriptor>>
1032  uv_compute_pipelines_;
1033 
1034  template <class TypedPipeline>
1035  std::shared_ptr<Pipeline<PipelineDescriptor>> GetPipeline(
1036  Variants<TypedPipeline>& container,
1037  ContentContextOptions opts) const {
1038  TypedPipeline* pipeline = CreateIfNeeded(container, opts);
1039  if (!pipeline) {
1040  return nullptr;
1041  }
1042  return pipeline->WaitAndGet();
1043  }
1044 
1045  template <class TypedPipeline>
1046  TypedPipeline* CreateIfNeeded(Variants<TypedPipeline>& container,
1047  ContentContextOptions opts) const {
1048  if (!IsValid()) {
1049  return nullptr;
1050  }
1051 
1052  if (wireframe_) {
1053  opts.wireframe = true;
1054  }
1055 
1056  if (TypedPipeline* found = container.Get(opts)) {
1057  return found;
1058  }
1059 
1060  TypedPipeline* prototype = container.GetDefault();
1061 
1062  // The prototype must always be initialized in the constructor.
1063  FML_CHECK(prototype != nullptr);
1064 
1065  std::shared_ptr<Pipeline<PipelineDescriptor>> pipeline =
1066  prototype->WaitAndGet();
1067  if (!pipeline) {
1068  return nullptr;
1069  }
1070 
1071  auto variant_future = pipeline->CreateVariant(
1072  [&opts, variants_count =
1073  container.GetPipelineCount()](PipelineDescriptor& desc) {
1074  opts.ApplyToPipelineDescriptor(desc);
1075  desc.SetLabel(
1076  SPrintF("%s V#%zu", desc.GetLabel().c_str(), variants_count));
1077  });
1078  std::unique_ptr<TypedPipeline> variant =
1079  std::make_unique<TypedPipeline>(std::move(variant_future));
1080  container.Set(opts, std::move(variant));
1081  return container.Get(opts);
1082  }
1083 
1084  bool is_valid_ = false;
1085  std::shared_ptr<Tessellator> tessellator_;
1086 #if IMPELLER_ENABLE_3D
1087  std::shared_ptr<scene::SceneContext> scene_context_;
1088 #endif // IMPELLER_ENABLE_3D
1089  std::shared_ptr<RenderTargetAllocator> render_target_cache_;
1090  std::shared_ptr<HostBuffer> host_buffer_;
1091  std::unique_ptr<PendingCommandBuffers> pending_command_buffers_;
1092  bool wireframe_ = false;
1093 
1094  ContentContext(const ContentContext&) = delete;
1095 
1096  ContentContext& operator=(const ContentContext&) = delete;
1097 };
1098 
1099 } // namespace impeller
1100 
1101 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_CONTENT_CONTEXT_H_
impeller::PipelineDescriptor
Definition: pipeline_descriptor.h:24
impeller::ContentContext::GetTexturePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetTexturePipeline(ContentContextOptions opts) const
Definition: content_context.h:485
impeller::Pipeline< PipelineDescriptor >
impeller::ContentContextOptions::StencilMode::kIgnore
@ kIgnore
Turn the stencil test off. Used when drawing without stencil-then-cover.
impeller::ContentContext::GetTextureStrictSrcPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetTextureStrictSrcPipeline(ContentContextOptions opts) const
Definition: content_context.h:490
impeller::LinearGradientFillPipeline
RenderPipelineT< GradientFillVertexShader, LinearGradientFillFragmentShader > LinearGradientFillPipeline
Definition: content_context.h:108
impeller::ContentContext::GetFramebufferBlendScreenPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendScreenPipeline(ContentContextOptions opts) const
Definition: content_context.h:753
impeller::ContentContext::ClearCachedRuntimeEffectPipeline
void ClearCachedRuntimeEffectPipeline(const std::string &unique_entrypoint_name) const
Definition: content_context.cc:590
impeller::ContentContext::GetKernelDecalPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetKernelDecalPipeline(ContentContextOptions opts) const
Definition: content_context.h:531
host_buffer.h
pipeline.h
impeller::ContentContext::GetRadialGradientFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetRadialGradientFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:455
impeller::ContentContext::GetBorderMaskBlurPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBorderMaskBlurPipeline(ContentContextOptions opts) const
Definition: content_context.h:541
impeller::ContentContext::GetGlyphAtlasColorPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetGlyphAtlasColorPipeline(ContentContextOptions opts) const
Definition: content_context.h:576
impeller::ContentContext::GetLinearGradientFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetLinearGradientFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:426
scene_context.h
impeller::ContentContext::GetBlendPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendPipeline(ContentContextOptions opts) const
Definition: content_context.h:480
impeller::ContentContext::GetBlendColorDodgePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendColorDodgePipeline(ContentContextOptions opts) const
Definition: content_context.h:608
impeller::ContentContext::GetFramebufferBlendColorBurnPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendColorBurnPipeline(ContentContextOptions opts) const
Definition: content_context.h:681
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:248
impeller::ContentContext::GetFramebufferBlendLightenPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendLightenPipeline(ContentContextOptions opts) const
Definition: content_context.h:723
impeller::ContentContext::GetLazyGlyphAtlas
const std::shared_ptr< LazyGlyphAtlas > & GetLazyGlyphAtlas() const
Definition: content_context.h:801
impeller::ContentContext::RuntimeEffectPipelineKey::Equal
Definition: content_context.h:858
impeller::ContentContext::GetBlendHuePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendHuePipeline(ContentContextOptions opts) const
Definition: content_context.h:633
entity.h
impeller::ContentContext::GetPointComputePipeline
std::shared_ptr< Pipeline< ComputePipelineDescriptor > > GetPointComputePipeline() const
Definition: content_context.h:764
impeller::ContentContext::GetGaussianBlurPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetGaussianBlurPipeline(ContentContextOptions opts) const
Definition: content_context.h:526
impeller::ContentContext::GetFramebufferBlendExclusionPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendExclusionPipeline(ContentContextOptions opts) const
Definition: content_context.h:705
impeller::BlendMode
BlendMode
Definition: color.h:59
impeller::ContentContextOptions::StencilMode::kLegacyClipCompare
@ kLegacyClipCompare
Used for applying clips to all non-clip draw calls.
impeller::HostBuffer
Definition: host_buffer.h:28
impeller::ContentContext::GetBlendColorPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendColorPipeline(ContentContextOptions opts) const
Definition: content_context.h:598
impeller::ContentContext::GetMorphologyFilterPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetMorphologyFilterPipeline(ContentContextOptions opts) const
Definition: content_context.h:546
formats.h
impeller::ContentContextOptions::Hash
Definition: content_context.h:344
impeller::ContentContext::GetGaussianBlurDecalPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetGaussianBlurDecalPipeline(ContentContextOptions opts) const
Definition: content_context.h:521
impeller::ContentContext::GetFramebufferBlendColorDodgePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendColorDodgePipeline(ContentContextOptions opts) const
Definition: content_context.h:687
impeller::ContentContext::GetBlendDarkenPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendDarkenPipeline(ContentContextOptions opts) const
Definition: content_context.h:613
impeller::ContentContextOptions::has_depth_stencil_attachments
bool has_depth_stencil_attachments
Definition: content_context.h:339
impeller::ContentContext::GetClipPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetClipPipeline(ContentContextOptions opts) const
Definition: content_context.h:566
impeller::ContentContext::GetTiledTexturePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetTiledTexturePipeline(ContentContextOptions opts) const
Definition: content_context.h:516
impeller::ContentContextOptions::blend_mode
BlendMode blend_mode
Definition: content_context.h:333
impeller::ContentContext::GetSweepGradientSSBOFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetSweepGradientSSBOFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:450
impeller::PendingCommandBuffers::command_buffers
std::vector< std::shared_ptr< CommandBuffer > > command_buffers
Definition: content_context.h:275
typographer_context.h
impeller::ContentContext::GetFramebufferBlendOverlayPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendOverlayPipeline(ContentContextOptions opts) const
Definition: content_context.h:741
impeller::ContentContextOptions::ApplyToPipelineDescriptor
void ApplyToPipelineDescriptor(PipelineDescriptor &desc) const
Definition: content_context.cc:27
impeller::ContentContext::GetSrgbToLinearFilterPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetSrgbToLinearFilterPipeline(ContentContextOptions opts) const
Definition: content_context.h:561
impeller::ContentContextOptions::StencilMode::kStencilEvenOddFill
@ kStencilEvenOddFill
impeller::ContentContext::GetKernelPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetKernelPipeline(ContentContextOptions opts) const
Definition: content_context.h:536
impeller::ContentContext::GetLinearToSrgbFilterPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetLinearToSrgbFilterPipeline(ContentContextOptions opts) const
Definition: content_context.h:556
impeller::ContentContext::GetCachedRuntimeEffectPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > 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:577
validation.h
impeller::ContentContext::GetBlendDifferencePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendDifferencePipeline(ContentContextOptions opts) const
Definition: content_context.h:618
impeller::ContentContextOptions::StencilMode::kLegacyClipDecrement
@ kLegacyClipDecrement
Decrement the stencil heightmap (used for difference clipping only).
impeller::ContentContext::GetConicalGradientFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetConicalGradientFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:460
impeller::ContentContextOptions::Hash::operator()
constexpr uint64_t operator()(const ContentContextOptions &o) const
Definition: content_context.h:345
impeller::ContentContextOptions::wireframe
bool wireframe
Definition: content_context.h:341
impeller::ContentContext::GetLinearGradientSSBOFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetLinearGradientSSBOFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:432
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:100
impeller::ContentContext::kEnableStencilThenCover
static constexpr bool kEnableStencilThenCover
Definition: content_context.h:411
impeller::ContentContext::GetUvComputePipeline
std::shared_ptr< Pipeline< ComputePipelineDescriptor > > GetUvComputePipeline() const
Definition: content_context.h:770
impeller::ContentContext::GetFramebufferBlendHuePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendHuePipeline(ContentContextOptions opts) const
Definition: content_context.h:716
impeller::ContentContextOptions::StencilMode
StencilMode
Definition: content_context.h:289
impeller::PrimitiveType::kTriangle
@ kTriangle
impeller::Capabilities
Definition: capabilities.h:15
impeller::TSize< int64_t >
impeller::CompareFunction
CompareFunction
Definition: formats.h:534
impeller::PrimitiveType
PrimitiveType
Decides how backend draws pixels based on input vertices.
Definition: formats.h:353
impeller::ContentContext::GetYUVToRGBFilterPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetYUVToRGBFilterPipeline(ContentContextOptions opts) const
Definition: content_context.h:586
impeller::ContentContext::GetFramebufferBlendDifferencePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendDifferencePipeline(ContentContextOptions opts) const
Definition: content_context.h:699
impeller::ContentContextOptions::StencilMode::kLegacyClipIncrement
@ kLegacyClipIncrement
Increment the stencil heightmap.
impeller::ContentContextOptions::color_attachment_pixel_format
PixelFormat color_attachment_pixel_format
Definition: content_context.h:338
impeller::ContentContext::~ContentContext
~ContentContext()
impeller::Context::BackendType::kOpenGLES
@ kOpenGLES
impeller::ContentContext::GetBlendExclusionPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendExclusionPipeline(ContentContextOptions opts) const
Definition: content_context.h:623
impeller::ContentContext::RuntimeEffectPipelineKey::Hash
Definition: content_context.h:851
impeller::ContentContext::GetConicalGradientSSBOFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetConicalGradientSSBOFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:444
impeller::ContentContext::MakeSubpass
fml::StatusOr< RenderTarget > MakeSubpass(const std::string &label, ISize texture_size, 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:478
impeller::ContentContextOptions::Equal::operator()
constexpr bool operator()(const ContentContextOptions &lhs, const ContentContextOptions &rhs) const
Definition: content_context.h:369
impeller::ContentContext::GetContext
std::shared_ptr< Context > GetContext() const
Definition: content_context.cc:564
impeller::ContentContextOptions::StencilMode::kStencilNonZeroFill
@ kStencilNonZeroFill
impeller::ContentContext::GetBlendColorBurnPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendColorBurnPipeline(ContentContextOptions opts) const
Definition: content_context.h:603
impeller::ContentContext::GetBlendScreenPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendScreenPipeline(ContentContextOptions opts) const
Definition: content_context.h:663
impeller::ContentContext::GetFramebufferBlendSaturationPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendSaturationPipeline(ContentContextOptions opts) const
Definition: content_context.h:747
impeller::PendingCommandBuffers
Definition: content_context.h:274
impeller::ContentContext::GetBlendSoftLightPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendSoftLightPipeline(ContentContextOptions opts) const
Definition: content_context.h:668
impeller::ContentContext::GetSolidFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetSolidFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:475
impeller::ContentContext::GetFramebufferBlendDarkenPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendDarkenPipeline(ContentContextOptions opts) const
Definition: content_context.h:693
capabilities.h
impeller::ContentContext::RuntimeEffectPipelineKey::Hash::operator()
std::size_t operator()(const RuntimeEffectPipelineKey &key) const
Definition: content_context.h:852
impeller::RenderTarget
Definition: render_target.h:38
impeller::ContentContext::GetRRectBlurPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetRRectBlurPipeline(ContentContextOptions opts) const
Definition: content_context.h:465
impeller::ContentContextOptions::is_for_rrect_blur_clear
bool is_for_rrect_blur_clear
Definition: content_context.h:342
impeller::ContentContextOptions::stencil_mode
StencilMode stencil_mode
Definition: content_context.h:335
impeller::ContentContextOptions::depth_write_enabled
bool depth_write_enabled
Definition: content_context.h:340
impeller::CompareFunction::kAlways
@ kAlways
Comparison test passes always passes.
impeller::ContentContext::GetTessellator
std::shared_ptr< Tessellator > GetTessellator() const
Definition: content_context.cc:560
impeller::ContentContext::GetFramebufferBlendMultiplyPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendMultiplyPipeline(ContentContextOptions opts) const
Definition: content_context.h:735
impeller::ContentContext::GetFramebufferBlendSoftLightPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendSoftLightPipeline(ContentContextOptions opts) const
Definition: content_context.h:759
impeller::ContentContextOptions::primitive_type
PrimitiveType primitive_type
Definition: content_context.h:337
impeller::PixelFormat::kUnknown
@ kUnknown
impeller::ContentContext::GetSweepGradientFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetSweepGradientFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:470
impeller::ContentContext::SubpassCallback
std::function< bool(const ContentContext &, RenderPass &)> SubpassCallback
Definition: content_context.h:783
impeller::ContentContext::GetBlendLightenPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendLightenPipeline(ContentContextOptions opts) const
Definition: content_context.h:638
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:33
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:73
command_buffer.h
impeller::ContentContext::GetRenderTargetCache
const std::shared_ptr< RenderTargetAllocator > & GetRenderTargetCache() const
Definition: content_context.h:805
impeller::ContentContextOptions::depth_compare
CompareFunction depth_compare
Definition: content_context.h:334
impeller::ContentContext::GetDeviceCapabilities
const Capabilities & GetDeviceCapabilities() const
Definition: content_context.cc:568
impeller::ContentContext::GetFramebufferBlendColorPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendColorPipeline(ContentContextOptions opts) const
Definition: content_context.h:675
impeller::ContentContext::GetBlendMultiplyPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendMultiplyPipeline(ContentContextOptions opts) const
Definition: content_context.h:648
impeller::ContentContext::GetBlendLuminosityPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendLuminosityPipeline(ContentContextOptions opts) const
Definition: content_context.h:643
impeller::ContentContext::GetBlendOverlayPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendOverlayPipeline(ContentContextOptions opts) const
Definition: content_context.h:653
impeller::ContentContextOptions::sample_count
SampleCount sample_count
Definition: content_context.h:332
impeller::ContentContext::GetBlendSaturationPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendSaturationPipeline(ContentContextOptions opts) const
Definition: content_context.h:658
impeller::SampleCount
SampleCount
Definition: formats.h:296
impeller::ContentContext::GetRadialGradientSSBOFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetRadialGradientSSBOFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:438
impeller::RenderPipelineT
Definition: pipeline.h:91
impeller::ContentContext::SetWireframe
void SetWireframe(bool wireframe)
Definition: content_context.cc:572
impeller::SampleCount::kCount1
@ kCount1
impeller::ContentContext::RuntimeEffectPipelineKey::Equal::operator()
constexpr bool operator()(const RuntimeEffectPipelineKey &lhs, const RuntimeEffectPipelineKey &rhs) const
Definition: content_context.h:859
impeller::ContentContextOptions::StencilMode::kCoverCompareInverted
@ kCoverCompareInverted
pipeline_descriptor.h
glyph_atlas.h
impeller::ContentContextOptions::StencilMode::kCoverCompare
@ kCoverCompare
render_target.h
impeller::ContentContext::GetPositionUVPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetPositionUVPipeline(ContentContextOptions opts) const
Definition: content_context.h:511
impeller::ContentContext::GetGlyphAtlasPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetGlyphAtlasPipeline(ContentContextOptions opts) const
Definition: content_context.h:571
impeller::ContentContextOptions::Equal
Definition: content_context.h:368
impeller::ContentContextOptions
Definition: content_context.h:288
impeller::ContentContextOptions::StencilMode::kLegacyClipRestore
@ kLegacyClipRestore
Slice the clip heightmap to a new maximum height.
impeller::ContentContext::GetFramebufferBlendHardLightPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendHardLightPipeline(ContentContextOptions opts) const
Definition: content_context.h:711
impeller
Definition: aiks_blur_unittests.cc:20
impeller::ContentContext::IsValid
bool IsValid() const
Definition: content_context.cc:474
impeller::ContentContext
Definition: content_context.h:392
impeller::ContentContext::GetFramebufferBlendLuminosityPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendLuminosityPipeline(ContentContextOptions opts) const
Definition: content_context.h:729
impeller::ContentContext::GetGeometryColorPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetGeometryColorPipeline(ContentContextOptions opts) const
Definition: content_context.h:581
impeller::BlendMode::kSourceOver
@ kSourceOver
impeller::ContentContext::GetTransientsBuffer
HostBuffer & GetTransientsBuffer() const
Retrieve the currnent host buffer for transient storage.
Definition: content_context.h:833
impeller::ContentContext::GetPorterDuffBlendPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetPorterDuffBlendPipeline(ContentContextOptions opts) const
Definition: content_context.h:591
impeller::ComputePipelineBuilder
An optional (but highly recommended) utility for creating pipelines from reflected shader information...
Definition: compute_pipeline_builder.h:25
impeller::ContentContext::GetBlendHardLightPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendHardLightPipeline(ContentContextOptions opts) const
Definition: content_context.h:628
impeller::GaussianBlurVertexShader
KernelPipeline::VertexShader GaussianBlurVertexShader
Definition: gaussian_blur_filter_contents.cc:22
impeller::ContentContext::GetColorMatrixColorFilterPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetColorMatrixColorFilterPipeline(ContentContextOptions opts) const
Definition: content_context.h:552