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/logging.h"
14 #include "flutter/fml/status_or.h"
16 #include "impeller/core/formats.h"
25 
26 #include "impeller/entity/border_mask_blur.frag.h"
27 #include "impeller/entity/clip.frag.h"
28 #include "impeller/entity/clip.vert.h"
29 #include "impeller/entity/color_matrix_color_filter.frag.h"
30 #include "impeller/entity/conical_gradient_fill.frag.h"
31 #include "impeller/entity/fast_gradient.frag.h"
32 #include "impeller/entity/fast_gradient.vert.h"
33 #include "impeller/entity/filter_position.vert.h"
34 #include "impeller/entity/filter_position_uv.vert.h"
35 #include "impeller/entity/gaussian.frag.h"
36 #include "impeller/entity/glyph_atlas.frag.h"
37 #include "impeller/entity/glyph_atlas.vert.h"
38 #include "impeller/entity/gradient_fill.vert.h"
39 #include "impeller/entity/linear_gradient_fill.frag.h"
40 #include "impeller/entity/linear_to_srgb_filter.frag.h"
41 #include "impeller/entity/morphology_filter.frag.h"
42 #include "impeller/entity/porter_duff_blend.frag.h"
43 #include "impeller/entity/porter_duff_blend.vert.h"
44 #include "impeller/entity/radial_gradient_fill.frag.h"
45 #include "impeller/entity/rrect_blur.frag.h"
46 #include "impeller/entity/rrect_blur.vert.h"
47 #include "impeller/entity/solid_fill.frag.h"
48 #include "impeller/entity/solid_fill.vert.h"
49 #include "impeller/entity/srgb_to_linear_filter.frag.h"
50 #include "impeller/entity/sweep_gradient_fill.frag.h"
51 #include "impeller/entity/texture_downsample.frag.h"
52 #include "impeller/entity/texture_fill.frag.h"
53 #include "impeller/entity/texture_fill.vert.h"
54 #include "impeller/entity/texture_fill_strict_src.frag.h"
55 #include "impeller/entity/texture_uv_fill.vert.h"
56 #include "impeller/entity/tiled_texture_fill.frag.h"
57 #include "impeller/entity/yuv_to_rgb_filter.frag.h"
58 
59 #include "impeller/entity/conical_gradient_ssbo_fill.frag.h"
60 #include "impeller/entity/linear_gradient_ssbo_fill.frag.h"
61 #include "impeller/entity/radial_gradient_ssbo_fill.frag.h"
62 #include "impeller/entity/sweep_gradient_ssbo_fill.frag.h"
63 
64 #include "impeller/entity/advanced_blend.frag.h"
65 #include "impeller/entity/advanced_blend.vert.h"
66 
67 #include "impeller/entity/framebuffer_blend.frag.h"
68 #include "impeller/entity/framebuffer_blend.vert.h"
69 
70 #include "impeller/entity/vertices_uber.frag.h"
71 
72 #ifdef IMPELLER_ENABLE_OPENGLES
73 #include "impeller/entity/tiled_texture_fill_external.frag.h"
74 #endif // IMPELLER_ENABLE_OPENGLES
75 
76 namespace impeller {
77 
81  RenderPipelineHandle<GradientFillVertexShader,
82  LinearGradientFillFragmentShader>;
83 using SolidFillPipeline =
86  RenderPipelineHandle<GradientFillVertexShader,
87  RadialGradientFillFragmentShader>;
89  RenderPipelineHandle<GradientFillVertexShader,
90  ConicalGradientFillFragmentShader>;
92  RenderPipelineHandle<GradientFillVertexShader,
93  SweepGradientFillFragmentShader>;
95  RenderPipelineHandle<GradientFillVertexShader,
96  LinearGradientSsboFillFragmentShader>;
98  RenderPipelineHandle<GradientFillVertexShader,
99  ConicalGradientSsboFillFragmentShader>;
101  RenderPipelineHandle<GradientFillVertexShader,
102  RadialGradientSsboFillFragmentShader>;
104  RenderPipelineHandle<GradientFillVertexShader,
105  SweepGradientSsboFillFragmentShader>;
106 using RRectBlurPipeline =
108 using TexturePipeline =
111  RenderPipelineHandle<TextureFillVertexShader,
112  TextureDownsampleFragmentShader>;
114  RenderPipelineHandle<TextureFillVertexShader,
115  TextureFillStrictSrcFragmentShader>;
116 using TiledTexturePipeline =
117  RenderPipelineHandle<TextureUvFillVertexShader,
118  TiledTextureFillFragmentShader>;
119 using GaussianBlurPipeline =
122  RenderPipelineHandle<FilterPositionUvVertexShader,
123  BorderMaskBlurFragmentShader>;
125  RenderPipelineHandle<FilterPositionUvVertexShader,
126  MorphologyFilterFragmentShader>;
128  RenderPipelineHandle<FilterPositionVertexShader,
129  ColorMatrixColorFilterFragmentShader>;
131  RenderPipelineHandle<FilterPositionVertexShader,
132  LinearToSrgbFilterFragmentShader>;
134  RenderPipelineHandle<FilterPositionVertexShader,
135  SrgbToLinearFilterFragmentShader>;
137  RenderPipelineHandle<FilterPositionVertexShader,
138  YuvToRgbFilterFragmentShader>;
139 
140 using GlyphAtlasPipeline =
142 
144  RenderPipelineHandle<PorterDuffBlendVertexShader,
145  PorterDuffBlendFragmentShader>;
147 
148 // Advanced blends
149 using BlendColorPipeline = RenderPipelineHandle<AdvancedBlendVertexShader,
150  AdvancedBlendFragmentShader>;
152  RenderPipelineHandle<AdvancedBlendVertexShader,
153  AdvancedBlendFragmentShader>;
155  RenderPipelineHandle<AdvancedBlendVertexShader,
156  AdvancedBlendFragmentShader>;
157 using BlendDarkenPipeline = RenderPipelineHandle<AdvancedBlendVertexShader,
158  AdvancedBlendFragmentShader>;
160  RenderPipelineHandle<AdvancedBlendVertexShader,
161  AdvancedBlendFragmentShader>;
163  RenderPipelineHandle<AdvancedBlendVertexShader,
164  AdvancedBlendFragmentShader>;
166  RenderPipelineHandle<AdvancedBlendVertexShader,
167  AdvancedBlendFragmentShader>;
168 using BlendHuePipeline = RenderPipelineHandle<AdvancedBlendVertexShader,
169  AdvancedBlendFragmentShader>;
170 using BlendLightenPipeline = RenderPipelineHandle<AdvancedBlendVertexShader,
171  AdvancedBlendFragmentShader>;
173  RenderPipelineHandle<AdvancedBlendVertexShader,
174  AdvancedBlendFragmentShader>;
175 using BlendMultiplyPipeline = RenderPipelineHandle<AdvancedBlendVertexShader,
176  AdvancedBlendFragmentShader>;
177 using BlendOverlayPipeline = RenderPipelineHandle<AdvancedBlendVertexShader,
178  AdvancedBlendFragmentShader>;
180  RenderPipelineHandle<AdvancedBlendVertexShader,
181  AdvancedBlendFragmentShader>;
182 using BlendScreenPipeline = RenderPipelineHandle<AdvancedBlendVertexShader,
183  AdvancedBlendFragmentShader>;
185  RenderPipelineHandle<AdvancedBlendVertexShader,
186  AdvancedBlendFragmentShader>;
187 // Framebuffer Advanced Blends
189  RenderPipelineHandle<FramebufferBlendVertexShader,
190  FramebufferBlendFragmentShader>;
192  RenderPipelineHandle<FramebufferBlendVertexShader,
193  FramebufferBlendFragmentShader>;
195  RenderPipelineHandle<FramebufferBlendVertexShader,
196  FramebufferBlendFragmentShader>;
198  RenderPipelineHandle<FramebufferBlendVertexShader,
199  FramebufferBlendFragmentShader>;
201  RenderPipelineHandle<FramebufferBlendVertexShader,
202  FramebufferBlendFragmentShader>;
204  RenderPipelineHandle<FramebufferBlendVertexShader,
205  FramebufferBlendFragmentShader>;
207  RenderPipelineHandle<FramebufferBlendVertexShader,
208  FramebufferBlendFragmentShader>;
210  RenderPipelineHandle<FramebufferBlendVertexShader,
211  FramebufferBlendFragmentShader>;
213  RenderPipelineHandle<FramebufferBlendVertexShader,
214  FramebufferBlendFragmentShader>;
216  RenderPipelineHandle<FramebufferBlendVertexShader,
217  FramebufferBlendFragmentShader>;
219  RenderPipelineHandle<FramebufferBlendVertexShader,
220  FramebufferBlendFragmentShader>;
222  RenderPipelineHandle<FramebufferBlendVertexShader,
223  FramebufferBlendFragmentShader>;
225  RenderPipelineHandle<FramebufferBlendVertexShader,
226  FramebufferBlendFragmentShader>;
228  RenderPipelineHandle<FramebufferBlendVertexShader,
229  FramebufferBlendFragmentShader>;
231  RenderPipelineHandle<FramebufferBlendVertexShader,
232  FramebufferBlendFragmentShader>;
233 
234 /// Draw Vertices/Atlas Uber Shader
235 using VerticesUberShader = RenderPipelineHandle<PorterDuffBlendVertexShader,
236  VerticesUberFragmentShader>;
237 
238 #ifdef IMPELLER_ENABLE_OPENGLES
239 using TiledTextureExternalPipeline =
240  RenderPipelineHandle<TextureFillVertexShader,
241  TiledTextureFillExternalFragmentShader>;
242 #endif // IMPELLER_ENABLE_OPENGLES
243 
244 /// Pipeline state configuration.
245 ///
246 /// Each unique combination of these options requires a different pipeline state
247 /// object to be built. This struct is used as a key for the per-pipeline
248 /// variant cache.
249 ///
250 /// When adding fields to this key, reliant features should take care to limit
251 /// the combinatorical explosion of variations. A sufficiently complicated
252 /// Flutter application may easily require building hundreds of PSOs in total,
253 /// but they shouldn't require e.g. 10s of thousands.
255  enum class StencilMode : uint8_t {
256  /// Turn the stencil test off. Used when drawing without stencil-then-cover
257  /// or overdraw prevention.
258  kIgnore,
259 
260  // Operations used for stencil-then-cover.
261 
262  /// Draw the stencil for the NonZero fill path rule.
263  ///
264  /// The stencil ref should always be 0 on commands using this mode.
266  /// Draw the stencil for the EvenOdd fill path rule.
267  ///
268  /// The stencil ref should always be 0 on commands using this mode.
270  /// Used for draw calls which fill in the stenciled area. Intended to be
271  /// used after `kStencilNonZeroFill` or `kStencilEvenOddFill` is used to set
272  /// up the stencil buffer. Also cleans up the stencil buffer by resetting
273  /// everything to zero.
274  ///
275  /// The stencil ref should always be 0 on commands using this mode.
277  /// The opposite of `kCoverCompare`. Used for draw calls which fill in the
278  /// non-stenciled area (intersection clips). Intended to be used after
279  /// `kStencilNonZeroFill` or `kStencilEvenOddFill` is used to set up the
280  /// stencil buffer. Also cleans up the stencil buffer by resetting
281  /// everything to zero.
282  ///
283  /// The stencil ref should always be 0 on commands using this mode.
285 
286  // Operations used for the "overdraw prevention" mechanism. This is used for
287  // drawing strokes.
288 
289  /// For each fragment, increment the stencil value if it's currently zero.
290  /// Discard fragments when the value is non-zero. This prevents
291  /// self-overlapping strokes from drawing over themselves.
292  ///
293  /// Note that this is done for rendering correctness, not performance. If a
294  /// stroke is drawn with a backdrop-reliant blend and self-intersects, then
295  /// the intersected geometry will render incorrectly when overdrawn because
296  /// we don't adjust the geometry prevent self-intersection.
297  ///
298  /// The stencil ref should always be 0 on commands using this mode.
300  /// Reset the stencil to a new maximum value specified by the ref (currently
301  /// always 0).
302  ///
303  /// The stencil ref should always be 0 on commands using this mode.
305  };
306 
314  bool depth_write_enabled = false;
315  bool wireframe = false;
317 
318  struct Hash {
319  constexpr uint64_t operator()(const ContentContextOptions& o) const {
320  static_assert(sizeof(o.sample_count) == 1);
321  static_assert(sizeof(o.blend_mode) == 1);
322  static_assert(sizeof(o.sample_count) == 1);
323  static_assert(sizeof(o.depth_compare) == 1);
324  static_assert(sizeof(o.stencil_mode) == 1);
325  static_assert(sizeof(o.primitive_type) == 1);
326  static_assert(sizeof(o.color_attachment_pixel_format) == 1);
327 
328  return (o.is_for_rrect_blur_clear ? 1llu : 0llu) << 0 |
329  (o.wireframe ? 1llu : 0llu) << 1 |
330  (o.has_depth_stencil_attachments ? 1llu : 0llu) << 2 |
331  (o.depth_write_enabled ? 1llu : 0llu) << 3 |
332  // enums
333  static_cast<uint64_t>(o.color_attachment_pixel_format) << 8 |
334  static_cast<uint64_t>(o.primitive_type) << 16 |
335  static_cast<uint64_t>(o.stencil_mode) << 24 |
336  static_cast<uint64_t>(o.depth_compare) << 32 |
337  static_cast<uint64_t>(o.blend_mode) << 40 |
338  static_cast<uint64_t>(o.sample_count) << 48;
339  }
340  };
341 
342  struct Equal {
343  constexpr bool operator()(const ContentContextOptions& lhs,
344  const ContentContextOptions& rhs) const {
345  return lhs.sample_count == rhs.sample_count &&
346  lhs.blend_mode == rhs.blend_mode &&
348  lhs.depth_compare == rhs.depth_compare &&
349  lhs.stencil_mode == rhs.stencil_mode &&
350  lhs.primitive_type == rhs.primitive_type &&
355  lhs.wireframe == rhs.wireframe &&
357  }
358  };
359 
361 };
362 
363 class Tessellator;
364 class RenderTargetCache;
365 
367  public:
368  explicit ContentContext(
369  std::shared_ptr<Context> context,
370  std::shared_ptr<TypographerContext> typographer_context,
371  std::shared_ptr<RenderTargetAllocator> render_target_allocator = nullptr);
372 
373  ~ContentContext();
374 
375  bool IsValid() const;
376 
377  std::shared_ptr<Tessellator> GetTessellator() const;
378 
379  std::shared_ptr<Pipeline<PipelineDescriptor>> GetFastGradientPipeline(
380  ContentContextOptions opts) const {
381  return GetPipeline(fast_gradient_pipelines_, opts);
382  }
383 
384  std::shared_ptr<Pipeline<PipelineDescriptor>> GetLinearGradientFillPipeline(
385  ContentContextOptions opts) const {
386  return GetPipeline(linear_gradient_fill_pipelines_, opts);
387  }
388 
389  std::shared_ptr<Pipeline<PipelineDescriptor>>
391  FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
392  return GetPipeline(linear_gradient_ssbo_fill_pipelines_, opts);
393  }
394 
395  std::shared_ptr<Pipeline<PipelineDescriptor>>
397  FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
398  return GetPipeline(radial_gradient_ssbo_fill_pipelines_, opts);
399  }
400 
401  std::shared_ptr<Pipeline<PipelineDescriptor>>
403  FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
404  return GetPipeline(conical_gradient_ssbo_fill_pipelines_, opts);
405  }
406 
407  std::shared_ptr<Pipeline<PipelineDescriptor>>
409  FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
410  return GetPipeline(sweep_gradient_ssbo_fill_pipelines_, opts);
411  }
412 
413  std::shared_ptr<Pipeline<PipelineDescriptor>> GetRadialGradientFillPipeline(
414  ContentContextOptions opts) const {
415  return GetPipeline(radial_gradient_fill_pipelines_, opts);
416  }
417 
418  std::shared_ptr<Pipeline<PipelineDescriptor>> GetConicalGradientFillPipeline(
419  ContentContextOptions opts) const {
420  return GetPipeline(conical_gradient_fill_pipelines_, opts);
421  }
422 
423  std::shared_ptr<Pipeline<PipelineDescriptor>> GetRRectBlurPipeline(
424  ContentContextOptions opts) const {
425  return GetPipeline(rrect_blur_pipelines_, opts);
426  }
427 
428  std::shared_ptr<Pipeline<PipelineDescriptor>> GetSweepGradientFillPipeline(
429  ContentContextOptions opts) const {
430  return GetPipeline(sweep_gradient_fill_pipelines_, opts);
431  }
432 
433  std::shared_ptr<Pipeline<PipelineDescriptor>> GetSolidFillPipeline(
434  ContentContextOptions opts) const {
435  return GetPipeline(solid_fill_pipelines_, opts);
436  }
437 
438  std::shared_ptr<Pipeline<PipelineDescriptor>> GetTexturePipeline(
439  ContentContextOptions opts) const {
440  return GetPipeline(texture_pipelines_, opts);
441  }
442 
443  std::shared_ptr<Pipeline<PipelineDescriptor>> GetTextureStrictSrcPipeline(
444  ContentContextOptions opts) const {
445  return GetPipeline(texture_strict_src_pipelines_, opts);
446  }
447 
448 #ifdef IMPELLER_ENABLE_OPENGLES
449  std::shared_ptr<Pipeline<PipelineDescriptor>> GetTiledTextureExternalPipeline(
450  ContentContextOptions opts) const {
451  FML_DCHECK(GetContext()->GetBackendType() ==
453  return GetPipeline(tiled_texture_external_pipelines_, opts);
454  }
455 #endif // IMPELLER_ENABLE_OPENGLES
456 
457  std::shared_ptr<Pipeline<PipelineDescriptor>> GetTiledTexturePipeline(
458  ContentContextOptions opts) const {
459  return GetPipeline(tiled_texture_pipelines_, opts);
460  }
461 
462  std::shared_ptr<Pipeline<PipelineDescriptor>> GetGaussianBlurPipeline(
463  ContentContextOptions opts) const {
464  return GetPipeline(gaussian_blur_pipelines_, opts);
465  }
466 
467  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBorderMaskBlurPipeline(
468  ContentContextOptions opts) const {
469  return GetPipeline(border_mask_blur_pipelines_, opts);
470  }
471 
472  std::shared_ptr<Pipeline<PipelineDescriptor>> GetMorphologyFilterPipeline(
473  ContentContextOptions opts) const {
474  return GetPipeline(morphology_filter_pipelines_, opts);
475  }
476 
477  std::shared_ptr<Pipeline<PipelineDescriptor>>
479  return GetPipeline(color_matrix_color_filter_pipelines_, opts);
480  }
481 
482  std::shared_ptr<Pipeline<PipelineDescriptor>> GetLinearToSrgbFilterPipeline(
483  ContentContextOptions opts) const {
484  return GetPipeline(linear_to_srgb_filter_pipelines_, opts);
485  }
486 
487  std::shared_ptr<Pipeline<PipelineDescriptor>> GetSrgbToLinearFilterPipeline(
488  ContentContextOptions opts) const {
489  return GetPipeline(srgb_to_linear_filter_pipelines_, opts);
490  }
491 
492  std::shared_ptr<Pipeline<PipelineDescriptor>> GetClipPipeline(
493  ContentContextOptions opts) const {
494  return GetPipeline(clip_pipelines_, opts);
495  }
496 
497  std::shared_ptr<Pipeline<PipelineDescriptor>> GetGlyphAtlasPipeline(
498  ContentContextOptions opts) const {
499  return GetPipeline(glyph_atlas_pipelines_, opts);
500  }
501 
502  std::shared_ptr<Pipeline<PipelineDescriptor>> GetYUVToRGBFilterPipeline(
503  ContentContextOptions opts) const {
504  return GetPipeline(yuv_to_rgb_filter_pipelines_, opts);
505  }
506 
507  std::shared_ptr<Pipeline<PipelineDescriptor>> GetPorterDuffBlendPipeline(
508  ContentContextOptions opts) const {
509  return GetPipeline(porter_duff_blend_pipelines_, opts);
510  }
511 
512  // Advanced blends.
513 
514  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendColorPipeline(
515  ContentContextOptions opts) const {
516  return GetPipeline(blend_color_pipelines_, opts);
517  }
518 
519  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendColorBurnPipeline(
520  ContentContextOptions opts) const {
521  return GetPipeline(blend_colorburn_pipelines_, opts);
522  }
523 
524  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendColorDodgePipeline(
525  ContentContextOptions opts) const {
526  return GetPipeline(blend_colordodge_pipelines_, opts);
527  }
528 
529  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendDarkenPipeline(
530  ContentContextOptions opts) const {
531  return GetPipeline(blend_darken_pipelines_, opts);
532  }
533 
534  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendDifferencePipeline(
535  ContentContextOptions opts) const {
536  return GetPipeline(blend_difference_pipelines_, opts);
537  }
538 
539  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendExclusionPipeline(
540  ContentContextOptions opts) const {
541  return GetPipeline(blend_exclusion_pipelines_, opts);
542  }
543 
544  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendHardLightPipeline(
545  ContentContextOptions opts) const {
546  return GetPipeline(blend_hardlight_pipelines_, opts);
547  }
548 
549  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendHuePipeline(
550  ContentContextOptions opts) const {
551  return GetPipeline(blend_hue_pipelines_, opts);
552  }
553 
554  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendLightenPipeline(
555  ContentContextOptions opts) const {
556  return GetPipeline(blend_lighten_pipelines_, opts);
557  }
558 
559  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendLuminosityPipeline(
560  ContentContextOptions opts) const {
561  return GetPipeline(blend_luminosity_pipelines_, opts);
562  }
563 
564  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendMultiplyPipeline(
565  ContentContextOptions opts) const {
566  return GetPipeline(blend_multiply_pipelines_, opts);
567  }
568 
569  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendOverlayPipeline(
570  ContentContextOptions opts) const {
571  return GetPipeline(blend_overlay_pipelines_, opts);
572  }
573 
574  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendSaturationPipeline(
575  ContentContextOptions opts) const {
576  return GetPipeline(blend_saturation_pipelines_, opts);
577  }
578 
579  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendScreenPipeline(
580  ContentContextOptions opts) const {
581  return GetPipeline(blend_screen_pipelines_, opts);
582  }
583 
584  std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendSoftLightPipeline(
585  ContentContextOptions opts) const {
586  return GetPipeline(blend_softlight_pipelines_, opts);
587  }
588 
589  std::shared_ptr<Pipeline<PipelineDescriptor>> GetDownsamplePipeline(
590  ContentContextOptions opts) const {
591  return GetPipeline(texture_downsample_pipelines_, opts);
592  }
593 
594  // Framebuffer Advanced Blends
595  std::shared_ptr<Pipeline<PipelineDescriptor>>
597  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
598  return GetPipeline(framebuffer_blend_color_pipelines_, opts);
599  }
600 
601  std::shared_ptr<Pipeline<PipelineDescriptor>>
603  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
604  return GetPipeline(framebuffer_blend_colorburn_pipelines_, opts);
605  }
606 
607  std::shared_ptr<Pipeline<PipelineDescriptor>>
609  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
610  return GetPipeline(framebuffer_blend_colordodge_pipelines_, opts);
611  }
612 
613  std::shared_ptr<Pipeline<PipelineDescriptor>>
615  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
616  return GetPipeline(framebuffer_blend_darken_pipelines_, opts);
617  }
618 
619  std::shared_ptr<Pipeline<PipelineDescriptor>>
621  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
622  return GetPipeline(framebuffer_blend_difference_pipelines_, opts);
623  }
624 
625  std::shared_ptr<Pipeline<PipelineDescriptor>>
627  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
628  return GetPipeline(framebuffer_blend_exclusion_pipelines_, opts);
629  }
630 
631  std::shared_ptr<Pipeline<PipelineDescriptor>>
633  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
634  return GetPipeline(framebuffer_blend_hardlight_pipelines_, opts);
635  }
636 
637  std::shared_ptr<Pipeline<PipelineDescriptor>> GetFramebufferBlendHuePipeline(
638  ContentContextOptions opts) const {
639  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
640  return GetPipeline(framebuffer_blend_hue_pipelines_, opts);
641  }
642 
643  std::shared_ptr<Pipeline<PipelineDescriptor>>
645  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
646  return GetPipeline(framebuffer_blend_lighten_pipelines_, opts);
647  }
648 
649  std::shared_ptr<Pipeline<PipelineDescriptor>>
651  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
652  return GetPipeline(framebuffer_blend_luminosity_pipelines_, opts);
653  }
654 
655  std::shared_ptr<Pipeline<PipelineDescriptor>>
657  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
658  return GetPipeline(framebuffer_blend_multiply_pipelines_, opts);
659  }
660 
661  std::shared_ptr<Pipeline<PipelineDescriptor>>
663  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
664  return GetPipeline(framebuffer_blend_overlay_pipelines_, opts);
665  }
666 
667  std::shared_ptr<Pipeline<PipelineDescriptor>>
669  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
670  return GetPipeline(framebuffer_blend_saturation_pipelines_, opts);
671  }
672 
673  std::shared_ptr<Pipeline<PipelineDescriptor>>
675  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
676  return GetPipeline(framebuffer_blend_screen_pipelines_, opts);
677  }
678 
679  std::shared_ptr<Pipeline<PipelineDescriptor>>
681  FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
682  return GetPipeline(framebuffer_blend_softlight_pipelines_, opts);
683  }
684 
685  std::shared_ptr<Pipeline<PipelineDescriptor>> GetDrawVerticesUberShader(
686  ContentContextOptions opts) const {
687  return GetPipeline(vertices_uber_shader_, opts);
688  }
689 
690  // An empty 1x1 texture for binding drawVertices/drawAtlas or other cases
691  // that don't always have a texture (due to blending).
692  std::shared_ptr<Texture> GetEmptyTexture() const;
693 
694  std::shared_ptr<Context> GetContext() const;
695 
696  const Capabilities& GetDeviceCapabilities() const;
697 
698  void SetWireframe(bool wireframe);
699 
700  using SubpassCallback =
701  std::function<bool(const ContentContext&, RenderPass&)>;
702 
703  /// @brief Creates a new texture of size `texture_size` and calls
704  /// `subpass_callback` with a `RenderPass` for drawing to the texture.
705  fml::StatusOr<RenderTarget> MakeSubpass(
706  std::string_view label,
707  ISize texture_size,
708  const std::shared_ptr<CommandBuffer>& command_buffer,
709  const SubpassCallback& subpass_callback,
710  bool msaa_enabled = true,
711  bool depth_stencil_enabled = false,
712  int32_t mip_count = 1) const;
713 
714  /// Makes a subpass that will render to `subpass_target`.
715  fml::StatusOr<RenderTarget> MakeSubpass(
716  std::string_view label,
717  const RenderTarget& subpass_target,
718  const std::shared_ptr<CommandBuffer>& command_buffer,
719  const SubpassCallback& subpass_callback) const;
720 
721  const std::shared_ptr<LazyGlyphAtlas>& GetLazyGlyphAtlas() const {
722  return lazy_glyph_atlas_;
723  }
724 
725  const std::shared_ptr<RenderTargetAllocator>& GetRenderTargetCache() const {
726  return render_target_cache_;
727  }
728 
729  /// RuntimeEffect pipelines must be obtained via this method to avoid
730  /// re-creating them every frame.
731  ///
732  /// The unique_entrypoint_name comes from RuntimeEffect::GetEntrypoint.
733  /// Impellerc generates a unique entrypoint name for runtime effect shaders
734  /// based on the input file name and shader stage.
735  ///
736  /// The create_callback is synchronously invoked exactly once if a cached
737  /// pipeline is not found.
738  std::shared_ptr<Pipeline<PipelineDescriptor>> GetCachedRuntimeEffectPipeline(
739  const std::string& unique_entrypoint_name,
740  const ContentContextOptions& options,
741  const std::function<std::shared_ptr<Pipeline<PipelineDescriptor>>()>&
742  create_callback) const;
743 
744  /// Used by hot reload/hot restart to clear a cached pipeline from
745  /// GetCachedRuntimeEffectPipeline.
747  const std::string& unique_entrypoint_name) const;
748 
749  /// @brief Retrieve the currnent host buffer for transient storage.
750  ///
751  /// This is only safe to use from the raster threads. Other threads should
752  /// allocate their own device buffers.
753  HostBuffer& GetTransientsBuffer() const { return *host_buffer_; }
754 
755  private:
756  std::shared_ptr<Context> context_;
757  std::shared_ptr<LazyGlyphAtlas> lazy_glyph_atlas_;
758 
759  /// Run backend specific additional setup and create common shader variants.
760  ///
761  /// This bootstrap is intended to improve the performance of several
762  /// first frame benchmarks that are tracked in the flutter device lab.
763  /// The workload includes initializing commonly used but not default
764  /// shader variants, as well as forcing driver initialization.
765  void InitializeCommonlyUsedShadersIfNeeded() const;
766 
767  struct RuntimeEffectPipelineKey {
768  std::string unique_entrypoint_name;
769  ContentContextOptions options;
770 
771  struct Hash {
772  std::size_t operator()(const RuntimeEffectPipelineKey& key) const {
773  return fml::HashCombine(key.unique_entrypoint_name,
774  ContentContextOptions::Hash{}(key.options));
775  }
776  };
777 
778  struct Equal {
779  constexpr bool operator()(const RuntimeEffectPipelineKey& lhs,
780  const RuntimeEffectPipelineKey& rhs) const {
781  return lhs.unique_entrypoint_name == rhs.unique_entrypoint_name &&
782  ContentContextOptions::Equal{}(lhs.options, rhs.options);
783  }
784  };
785  };
786 
787  mutable std::unordered_map<RuntimeEffectPipelineKey,
788  std::shared_ptr<Pipeline<PipelineDescriptor>>,
789  RuntimeEffectPipelineKey::Hash,
790  RuntimeEffectPipelineKey::Equal>
791  runtime_effect_pipelines_;
792 
793  /// Holds multiple Pipelines associated with the same PipelineHandle types.
794  ///
795  /// For example, it may have multiple
796  /// RenderPipelineHandle<SolidFillVertexShader, SolidFillFragmentShader>
797  /// instances for different blend modes. From them you can access the
798  /// Pipeline.
799  ///
800  /// See also:
801  /// - impeller::ContentContextOptions - options from which variants are
802  /// created.
803  /// - impeller::Pipeline::CreateVariant
804  /// - impeller::RenderPipelineHandle<> - The type of objects this typically
805  /// contains.
806  template <class PipelineHandleT>
807  class Variants {
808  public:
809  Variants() = default;
810 
811  void Set(const ContentContextOptions& options,
812  std::unique_ptr<PipelineHandleT> pipeline) {
813  pipelines_[options] = std::move(pipeline);
814  }
815 
816  void SetDefault(const ContentContextOptions& options,
817  std::unique_ptr<PipelineHandleT> pipeline) {
818  default_options_ = options;
819  Set(options, std::move(pipeline));
820  }
821 
822  void CreateDefault(const Context& context,
823  const ContentContextOptions& options,
824  const std::initializer_list<Scalar>& constants = {}) {
825  auto desc = PipelineHandleT::Builder::MakeDefaultPipelineDescriptor(
826  context, constants);
827  if (!desc.has_value()) {
828  VALIDATION_LOG << "Failed to create default pipeline.";
829  return;
830  }
831  options.ApplyToPipelineDescriptor(*desc);
832  SetDefault(options, std::make_unique<PipelineHandleT>(context, desc));
833  }
834 
835  PipelineHandleT* Get(const ContentContextOptions& options) const {
836  if (auto found = pipelines_.find(options); found != pipelines_.end()) {
837  return found->second.get();
838  }
839  return nullptr;
840  }
841 
842  PipelineHandleT* GetDefault() const {
843  if (!default_options_.has_value()) {
844  return nullptr;
845  }
846  return Get(default_options_.value());
847  }
848 
849  size_t GetPipelineCount() const { return pipelines_.size(); }
850 
851  private:
852  std::optional<ContentContextOptions> default_options_;
853  std::unordered_map<ContentContextOptions,
854  std::unique_ptr<PipelineHandleT>,
855  ContentContextOptions::Hash,
856  ContentContextOptions::Equal>
857  pipelines_;
858 
859  Variants(const Variants&) = delete;
860 
861  Variants& operator=(const Variants&) = delete;
862  };
863 
864  // These are mutable because while the prototypes are created eagerly, any
865  // variants requested from that are lazily created and cached in the variants
866  // map.
867 
868  mutable Variants<SolidFillPipeline> solid_fill_pipelines_;
869  mutable Variants<FastGradientPipeline> fast_gradient_pipelines_;
870  mutable Variants<LinearGradientFillPipeline> linear_gradient_fill_pipelines_;
871  mutable Variants<RadialGradientFillPipeline> radial_gradient_fill_pipelines_;
872  mutable Variants<ConicalGradientFillPipeline>
873  conical_gradient_fill_pipelines_;
874  mutable Variants<SweepGradientFillPipeline> sweep_gradient_fill_pipelines_;
875  mutable Variants<LinearGradientSSBOFillPipeline>
876  linear_gradient_ssbo_fill_pipelines_;
877  mutable Variants<RadialGradientSSBOFillPipeline>
878  radial_gradient_ssbo_fill_pipelines_;
879  mutable Variants<ConicalGradientSSBOFillPipeline>
880  conical_gradient_ssbo_fill_pipelines_;
881  mutable Variants<SweepGradientSSBOFillPipeline>
882  sweep_gradient_ssbo_fill_pipelines_;
883  mutable Variants<RRectBlurPipeline> rrect_blur_pipelines_;
884  mutable Variants<TexturePipeline> texture_pipelines_;
885  mutable Variants<TextureDownsamplePipeline> texture_downsample_pipelines_;
886  mutable Variants<TextureStrictSrcPipeline> texture_strict_src_pipelines_;
887 #ifdef IMPELLER_ENABLE_OPENGLES
888  mutable Variants<TiledTextureExternalPipeline>
889  tiled_texture_external_pipelines_;
890 #endif // IMPELLER_ENABLE_OPENGLES
891  mutable Variants<TiledTexturePipeline> tiled_texture_pipelines_;
892  mutable Variants<GaussianBlurPipeline> gaussian_blur_pipelines_;
893  mutable Variants<BorderMaskBlurPipeline> border_mask_blur_pipelines_;
894  mutable Variants<MorphologyFilterPipeline> morphology_filter_pipelines_;
895  mutable Variants<ColorMatrixColorFilterPipeline>
896  color_matrix_color_filter_pipelines_;
897  mutable Variants<LinearToSrgbFilterPipeline> linear_to_srgb_filter_pipelines_;
898  mutable Variants<SrgbToLinearFilterPipeline> srgb_to_linear_filter_pipelines_;
899  mutable Variants<ClipPipeline> clip_pipelines_;
900  mutable Variants<GlyphAtlasPipeline> glyph_atlas_pipelines_;
901  mutable Variants<YUVToRGBFilterPipeline> yuv_to_rgb_filter_pipelines_;
902  mutable Variants<PorterDuffBlendPipeline> porter_duff_blend_pipelines_;
903  // Advanced blends.
904  mutable Variants<BlendColorPipeline> blend_color_pipelines_;
905  mutable Variants<BlendColorBurnPipeline> blend_colorburn_pipelines_;
906  mutable Variants<BlendColorDodgePipeline> blend_colordodge_pipelines_;
907  mutable Variants<BlendDarkenPipeline> blend_darken_pipelines_;
908  mutable Variants<BlendDifferencePipeline> blend_difference_pipelines_;
909  mutable Variants<BlendExclusionPipeline> blend_exclusion_pipelines_;
910  mutable Variants<BlendHardLightPipeline> blend_hardlight_pipelines_;
911  mutable Variants<BlendHuePipeline> blend_hue_pipelines_;
912  mutable Variants<BlendLightenPipeline> blend_lighten_pipelines_;
913  mutable Variants<BlendLuminosityPipeline> blend_luminosity_pipelines_;
914  mutable Variants<BlendMultiplyPipeline> blend_multiply_pipelines_;
915  mutable Variants<BlendOverlayPipeline> blend_overlay_pipelines_;
916  mutable Variants<BlendSaturationPipeline> blend_saturation_pipelines_;
917  mutable Variants<BlendScreenPipeline> blend_screen_pipelines_;
918  mutable Variants<BlendSoftLightPipeline> blend_softlight_pipelines_;
919  // Framebuffer Advanced blends.
920  mutable Variants<FramebufferBlendColorPipeline>
921  framebuffer_blend_color_pipelines_;
922  mutable Variants<FramebufferBlendColorBurnPipeline>
923  framebuffer_blend_colorburn_pipelines_;
924  mutable Variants<FramebufferBlendColorDodgePipeline>
925  framebuffer_blend_colordodge_pipelines_;
926  mutable Variants<FramebufferBlendDarkenPipeline>
927  framebuffer_blend_darken_pipelines_;
928  mutable Variants<FramebufferBlendDifferencePipeline>
929  framebuffer_blend_difference_pipelines_;
930  mutable Variants<FramebufferBlendExclusionPipeline>
931  framebuffer_blend_exclusion_pipelines_;
932  mutable Variants<FramebufferBlendHardLightPipeline>
933  framebuffer_blend_hardlight_pipelines_;
934  mutable Variants<FramebufferBlendHuePipeline>
935  framebuffer_blend_hue_pipelines_;
936  mutable Variants<FramebufferBlendLightenPipeline>
937  framebuffer_blend_lighten_pipelines_;
938  mutable Variants<FramebufferBlendLuminosityPipeline>
939  framebuffer_blend_luminosity_pipelines_;
940  mutable Variants<FramebufferBlendMultiplyPipeline>
941  framebuffer_blend_multiply_pipelines_;
942  mutable Variants<FramebufferBlendOverlayPipeline>
943  framebuffer_blend_overlay_pipelines_;
944  mutable Variants<FramebufferBlendSaturationPipeline>
945  framebuffer_blend_saturation_pipelines_;
946  mutable Variants<FramebufferBlendScreenPipeline>
947  framebuffer_blend_screen_pipelines_;
948  mutable Variants<FramebufferBlendSoftLightPipeline>
949  framebuffer_blend_softlight_pipelines_;
950  mutable Variants<VerticesUberShader> vertices_uber_shader_;
951 
952  template <class TypedPipeline>
953  std::shared_ptr<Pipeline<PipelineDescriptor>> GetPipeline(
954  Variants<TypedPipeline>& container,
955  ContentContextOptions opts) const {
956  TypedPipeline* pipeline = CreateIfNeeded(container, opts);
957  if (!pipeline) {
958  return nullptr;
959  }
960  return pipeline->WaitAndGet();
961  }
962 
963  template <class RenderPipelineHandleT>
964  RenderPipelineHandleT* CreateIfNeeded(
965  Variants<RenderPipelineHandleT>& container,
966  ContentContextOptions opts) const {
967  if (!IsValid()) {
968  return nullptr;
969  }
970 
971  if (wireframe_) {
972  opts.wireframe = true;
973  }
974 
975  if (RenderPipelineHandleT* found = container.Get(opts)) {
976  return found;
977  }
978 
979  RenderPipelineHandleT* default_handle = container.GetDefault();
980 
981  // The default must always be initialized in the constructor.
982  FML_CHECK(default_handle != nullptr);
983 
984  std::shared_ptr<Pipeline<PipelineDescriptor>> pipeline =
985  default_handle->WaitAndGet();
986  if (!pipeline) {
987  return nullptr;
988  }
989 
990  auto variant_future = pipeline->CreateVariant(
991  /*async=*/false, [&opts, variants_count = container.GetPipelineCount()](
992  PipelineDescriptor& desc) {
993  opts.ApplyToPipelineDescriptor(desc);
994  desc.SetLabel(
995  SPrintF("%s V#%zu", desc.GetLabel().c_str(), variants_count));
996  });
997  std::unique_ptr<RenderPipelineHandleT> variant =
998  std::make_unique<RenderPipelineHandleT>(std::move(variant_future));
999  container.Set(opts, std::move(variant));
1000  return container.Get(opts);
1001  }
1002 
1003  bool is_valid_ = false;
1004  std::shared_ptr<Tessellator> tessellator_;
1005  std::shared_ptr<RenderTargetAllocator> render_target_cache_;
1006  std::shared_ptr<HostBuffer> host_buffer_;
1007  std::shared_ptr<Texture> empty_texture_;
1008  bool wireframe_ = false;
1009 
1010  ContentContext(const ContentContext&) = delete;
1011 
1012  ContentContext& operator=(const ContentContext&) = delete;
1013 };
1014 
1015 } // namespace impeller
1016 
1017 #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:438
impeller::Pipeline< PipelineDescriptor >
impeller::ContentContextOptions::StencilMode::kIgnore
@ kIgnore
impeller::ContentContext::GetTextureStrictSrcPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetTextureStrictSrcPipeline(ContentContextOptions opts) const
Definition: content_context.h:443
impeller::ContentContext::GetFramebufferBlendScreenPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendScreenPipeline(ContentContextOptions opts) const
Definition: content_context.h:674
impeller::ContentContext::ClearCachedRuntimeEffectPipeline
void ClearCachedRuntimeEffectPipeline(const std::string &unique_entrypoint_name) const
Definition: content_context.cc:576
lazy_glyph_atlas.h
host_buffer.h
pipeline.h
impeller::ContentContext::GetRadialGradientFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetRadialGradientFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:413
impeller::ContentContext::GetBorderMaskBlurPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBorderMaskBlurPipeline(ContentContextOptions opts) const
Definition: content_context.h:467
impeller::ContentContext::GetLinearGradientFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetLinearGradientFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:384
impeller::ContentContext::GetBlendColorDodgePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendColorDodgePipeline(ContentContextOptions opts) const
Definition: content_context.h:524
impeller::ContentContext::GetFramebufferBlendColorBurnPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendColorBurnPipeline(ContentContextOptions opts) const
Definition: content_context.h:602
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:241
impeller::ContentContext::GetFramebufferBlendLightenPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendLightenPipeline(ContentContextOptions opts) const
Definition: content_context.h:644
impeller::ContentContext::GetLazyGlyphAtlas
const std::shared_ptr< LazyGlyphAtlas > & GetLazyGlyphAtlas() const
Definition: content_context.h:721
impeller::ContentContext::RuntimeEffectPipelineKey::Equal
Definition: content_context.h:778
impeller::ContentContext::GetDownsamplePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetDownsamplePipeline(ContentContextOptions opts) const
Definition: content_context.h:589
impeller::ContentContext::GetBlendHuePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendHuePipeline(ContentContextOptions opts) const
Definition: content_context.h:549
impeller::ContentContext::GetFastGradientPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFastGradientPipeline(ContentContextOptions opts) const
Definition: content_context.h:379
impeller::ContentContext::GetGaussianBlurPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetGaussianBlurPipeline(ContentContextOptions opts) const
Definition: content_context.h:462
impeller::ContentContextOptions::StencilMode::kOverdrawPreventionIncrement
@ kOverdrawPreventionIncrement
impeller::ContentContext::GetFramebufferBlendExclusionPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendExclusionPipeline(ContentContextOptions opts) const
Definition: content_context.h:626
impeller::BlendMode
BlendMode
Definition: color.h:58
impeller::HostBuffer
Definition: host_buffer.h:28
impeller::ContentContext::GetBlendColorPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendColorPipeline(ContentContextOptions opts) const
Definition: content_context.h:514
impeller::ContentContext::GetMorphologyFilterPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetMorphologyFilterPipeline(ContentContextOptions opts) const
Definition: content_context.h:472
impeller::ContentContextOptions::Hash
Definition: content_context.h:318
impeller::ContentContext::GetFramebufferBlendColorDodgePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendColorDodgePipeline(ContentContextOptions opts) const
Definition: content_context.h:608
impeller::ContentContext::GetBlendDarkenPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendDarkenPipeline(ContentContextOptions opts) const
Definition: content_context.h:529
formats.h
impeller::ContentContextOptions::has_depth_stencil_attachments
bool has_depth_stencil_attachments
Definition: content_context.h:313
impeller::ContentContext::GetClipPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetClipPipeline(ContentContextOptions opts) const
Definition: content_context.h:492
impeller::ContentContext::GetTiledTexturePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetTiledTexturePipeline(ContentContextOptions opts) const
Definition: content_context.h:457
impeller::ContentContextOptions::blend_mode
BlendMode blend_mode
Definition: content_context.h:308
impeller::ContentContext::GetSweepGradientSSBOFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetSweepGradientSSBOFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:408
typographer_context.h
impeller::ContentContext::GetFramebufferBlendOverlayPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendOverlayPipeline(ContentContextOptions opts) const
Definition: content_context.h:662
impeller::ContentContextOptions::ApplyToPipelineDescriptor
void ApplyToPipelineDescriptor(PipelineDescriptor &desc) const
Definition: content_context.cc:28
impeller::ContentContext::GetSrgbToLinearFilterPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetSrgbToLinearFilterPipeline(ContentContextOptions opts) const
Definition: content_context.h:487
impeller::RenderPipelineHandle
Definition: pipeline.h:99
impeller::ContentContextOptions::StencilMode::kStencilEvenOddFill
@ kStencilEvenOddFill
impeller::ContentContext::GetLinearToSrgbFilterPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetLinearToSrgbFilterPipeline(ContentContextOptions opts) const
Definition: content_context.h:482
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:563
validation.h
impeller::ContentContext::GetBlendDifferencePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendDifferencePipeline(ContentContextOptions opts) const
Definition: content_context.h:534
impeller::ContentContext::GetEmptyTexture
std::shared_ptr< Texture > GetEmptyTexture() const
Definition: content_context.cc:474
impeller::ContentContext::GetConicalGradientFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetConicalGradientFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:418
impeller::ContentContextOptions::Hash::operator()
constexpr uint64_t operator()(const ContentContextOptions &o) const
Definition: content_context.h:319
impeller::ContentContextOptions::wireframe
bool wireframe
Definition: content_context.h:315
impeller::ContentContext::GetLinearGradientSSBOFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetLinearGradientSSBOFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:390
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:99
impeller::ContentContext::GetFramebufferBlendHuePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendHuePipeline(ContentContextOptions opts) const
Definition: content_context.h:637
impeller::ContentContextOptions::StencilMode
StencilMode
Definition: content_context.h:255
impeller::PrimitiveType::kTriangle
@ kTriangle
impeller::FastGradientPipeline
RenderPipelineHandle< FastGradientVertexShader, FastGradientFragmentShader > FastGradientPipeline
Definition: content_context.h:79
impeller::Capabilities
Definition: capabilities.h:14
impeller::TSize
Definition: size.h:19
impeller::CompareFunction
CompareFunction
Definition: formats.h:552
impeller::PrimitiveType
PrimitiveType
Decides how backend draws pixels based on input vertices.
Definition: formats.h:352
impeller::ContentContext::GetYUVToRGBFilterPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetYUVToRGBFilterPipeline(ContentContextOptions opts) const
Definition: content_context.h:502
impeller::ContentContext::GetFramebufferBlendDifferencePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendDifferencePipeline(ContentContextOptions opts) const
Definition: content_context.h:620
impeller::ContentContextOptions::color_attachment_pixel_format
PixelFormat color_attachment_pixel_format
Definition: content_context.h:312
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:539
impeller::ContentContext::RuntimeEffectPipelineKey::Hash
Definition: content_context.h:771
impeller::ContentContext::GetConicalGradientSSBOFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetConicalGradientSSBOFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:402
impeller::ContentContextOptions::Equal::operator()
constexpr bool operator()(const ContentContextOptions &lhs, const ContentContextOptions &rhs) const
Definition: content_context.h:343
impeller::ContentContext::GetContext
std::shared_ptr< Context > GetContext() const
Definition: content_context.cc:550
impeller::ContentContextOptions::StencilMode::kStencilNonZeroFill
@ kStencilNonZeroFill
impeller::ContentContext::GetBlendColorBurnPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendColorBurnPipeline(ContentContextOptions opts) const
Definition: content_context.h:519
impeller::ContentContext::GetBlendScreenPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendScreenPipeline(ContentContextOptions opts) const
Definition: content_context.h:579
impeller::ContentContext::GetFramebufferBlendSaturationPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendSaturationPipeline(ContentContextOptions opts) const
Definition: content_context.h:668
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:478
impeller::ContentContext::GetBlendSoftLightPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendSoftLightPipeline(ContentContextOptions opts) const
Definition: content_context.h:584
impeller::ContentContext::GetSolidFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetSolidFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:433
impeller::ContentContext::GetFramebufferBlendDarkenPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendDarkenPipeline(ContentContextOptions opts) const
Definition: content_context.h:614
capabilities.h
impeller::ContentContext::RuntimeEffectPipelineKey::Hash::operator()
std::size_t operator()(const RuntimeEffectPipelineKey &key) const
Definition: content_context.h:772
impeller::RenderTarget
Definition: render_target.h:38
impeller::ContentContext::GetDrawVerticesUberShader
std::shared_ptr< Pipeline< PipelineDescriptor > > GetDrawVerticesUberShader(ContentContextOptions opts) const
Definition: content_context.h:685
impeller::ContentContext::GetRRectBlurPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetRRectBlurPipeline(ContentContextOptions opts) const
Definition: content_context.h:423
impeller::ContentContextOptions::is_for_rrect_blur_clear
bool is_for_rrect_blur_clear
Definition: content_context.h:316
impeller::ContentContextOptions::stencil_mode
StencilMode stencil_mode
Definition: content_context.h:310
impeller::ContentContextOptions::depth_write_enabled
bool depth_write_enabled
Definition: content_context.h:314
impeller::CompareFunction::kAlways
@ kAlways
Comparison test passes always passes.
impeller::ContentContext::GetTessellator
std::shared_ptr< Tessellator > GetTessellator() const
Definition: content_context.cc:546
impeller::ContentContext::GetFramebufferBlendMultiplyPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendMultiplyPipeline(ContentContextOptions opts) const
Definition: content_context.h:656
impeller::ContentContext::GetFramebufferBlendSoftLightPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendSoftLightPipeline(ContentContextOptions opts) const
Definition: content_context.h:680
impeller::ContentContextOptions::primitive_type
PrimitiveType primitive_type
Definition: content_context.h:311
impeller::PixelFormat::kUnknown
@ kUnknown
impeller::ContentContext::GetSweepGradientFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetSweepGradientFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:428
impeller::ContentContext::SubpassCallback
std::function< bool(const ContentContext &, RenderPass &)> SubpassCallback
Definition: content_context.h:701
impeller::ContentContext::GetBlendLightenPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendLightenPipeline(ContentContextOptions opts) const
Definition: content_context.h:554
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:91
command_buffer.h
impeller::ContentContext::GetRenderTargetCache
const std::shared_ptr< RenderTargetAllocator > & GetRenderTargetCache() const
Definition: content_context.h:725
impeller::ContentContextOptions::depth_compare
CompareFunction depth_compare
Definition: content_context.h:309
impeller::ContentContext::GetDeviceCapabilities
const Capabilities & GetDeviceCapabilities() const
Definition: content_context.cc:554
impeller::ContentContext::GetFramebufferBlendColorPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendColorPipeline(ContentContextOptions opts) const
Definition: content_context.h:596
impeller::ContentContext::GetBlendMultiplyPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendMultiplyPipeline(ContentContextOptions opts) const
Definition: content_context.h:564
impeller::ContentContext::GetBlendLuminosityPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendLuminosityPipeline(ContentContextOptions opts) const
Definition: content_context.h:559
impeller::ContentContext::GetBlendOverlayPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendOverlayPipeline(ContentContextOptions opts) const
Definition: content_context.h:569
impeller::ContentContextOptions::sample_count
SampleCount sample_count
Definition: content_context.h:307
impeller::ContentContext::GetBlendSaturationPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendSaturationPipeline(ContentContextOptions opts) const
Definition: content_context.h:574
impeller::SampleCount
SampleCount
Definition: formats.h:295
impeller::ContentContext::GetRadialGradientSSBOFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetRadialGradientSSBOFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:396
impeller::ContentContext::SetWireframe
void SetWireframe(bool wireframe)
Definition: content_context.cc:558
impeller::SampleCount::kCount1
@ kCount1
impeller::ContentContextOptions::StencilMode::kOverdrawPreventionRestore
@ kOverdrawPreventionRestore
impeller::ContentContext::RuntimeEffectPipelineKey::Equal::operator()
constexpr bool operator()(const RuntimeEffectPipelineKey &lhs, const RuntimeEffectPipelineKey &rhs) const
Definition: content_context.h:779
impeller::ContentContextOptions::StencilMode::kCoverCompareInverted
@ kCoverCompareInverted
pipeline_descriptor.h
impeller::ContentContextOptions::StencilMode::kCoverCompare
@ kCoverCompare
render_target.h
impeller::ContentContext::GetGlyphAtlasPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetGlyphAtlasPipeline(ContentContextOptions opts) const
Definition: content_context.h:497
impeller::ContentContextOptions::Equal
Definition: content_context.h:342
impeller::ContentContextOptions
Definition: content_context.h:254
impeller::ContentContext::GetFramebufferBlendHardLightPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendHardLightPipeline(ContentContextOptions opts) const
Definition: content_context.h:632
impeller
Definition: allocation.cc:12
impeller::ContentContext::IsValid
bool IsValid() const
Definition: content_context.cc:470
impeller::ContentContext
Definition: content_context.h:366
impeller::ContentContext::GetFramebufferBlendLuminosityPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendLuminosityPipeline(ContentContextOptions opts) const
Definition: content_context.h:650
impeller::BlendMode::kSourceOver
@ kSourceOver
impeller::ContentContext::GetTransientsBuffer
HostBuffer & GetTransientsBuffer() const
Retrieve the currnent host buffer for transient storage.
Definition: content_context.h:753
impeller::ContentContext::GetPorterDuffBlendPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetPorterDuffBlendPipeline(ContentContextOptions opts) const
Definition: content_context.h:507
impeller::ContentContext::GetBlendHardLightPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendHardLightPipeline(ContentContextOptions opts) const
Definition: content_context.h:544
impeller::ContentContext::GetColorMatrixColorFilterPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetColorMatrixColorFilterPipeline(ContentContextOptions opts) const
Definition: content_context.h:478