| 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"
15 #include "impeller/base/validation.h"
16 #include "impeller/core/formats.h"
17 #include "impeller/core/host_buffer.h"
18 #include "impeller/renderer/capabilities.h"
19 #include "impeller/renderer/command_buffer.h"
20 #include "impeller/renderer/pipeline.h"
21 #include "impeller/renderer/pipeline_descriptor.h"
22 #include "impeller/renderer/render_target.h"
23 #include "impeller/typographer/lazy_glyph_atlas.h"
24 #include "impeller/typographer/typographer_context.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_fill.frag.h"
52 #include "impeller/entity/texture_fill.vert.h"
53 #include "impeller/entity/texture_fill_strict_src.frag.h"
54 #include "impeller/entity/texture_uv_fill.vert.h"
55 #include "impeller/entity/tiled_texture_fill.frag.h"
56 #include "impeller/entity/yuv_to_rgb_filter.frag.h"
57
58 #include "impeller/entity/conical_gradient_ssbo_fill.frag.h"
59 #include "impeller/entity/linear_gradient_ssbo_fill.frag.h"
60 #include "impeller/entity/radial_gradient_ssbo_fill.frag.h"
61 #include "impeller/entity/sweep_gradient_ssbo_fill.frag.h"
62
63 #include "impeller/entity/advanced_blend.frag.h"
64 #include "impeller/entity/advanced_blend.vert.h"
65
66 #include "impeller/entity/framebuffer_blend.frag.h"
67 #include "impeller/entity/framebuffer_blend.vert.h"
68
69 #include "impeller/entity/vertices_uber.frag.h"
70
71 #ifdef IMPELLER_ENABLE_OPENGLES
72 #include "impeller/entity/tiled_texture_fill_external.frag.h"
73 #endif // IMPELLER_ENABLE_OPENGLES
74
75 #if IMPELLER_ENABLE_3D
76 #include "impeller/scene/scene_context.h" // nogncheck
77 #endif
78
79 namespace impeller {
80
81 using FastGradientPipeline =
82 RenderPipelineHandle<FastGradientVertexShader, FastGradientFragmentShader>;
83 using LinearGradientFillPipeline =
84 RenderPipelineHandle<GradientFillVertexShader,
85 LinearGradientFillFragmentShader>;
86 using SolidFillPipeline =
87 RenderPipelineHandle<SolidFillVertexShader, SolidFillFragmentShader>;
88 using RadialGradientFillPipeline =
89 RenderPipelineHandle<GradientFillVertexShader,
90 RadialGradientFillFragmentShader>;
91 using ConicalGradientFillPipeline =
92 RenderPipelineHandle<GradientFillVertexShader,
93 ConicalGradientFillFragmentShader>;
94 using SweepGradientFillPipeline =
95 RenderPipelineHandle<GradientFillVertexShader,
96 SweepGradientFillFragmentShader>;
97 using LinearGradientSSBOFillPipeline =
98 RenderPipelineHandle<GradientFillVertexShader,
99 LinearGradientSsboFillFragmentShader>;
100 using ConicalGradientSSBOFillPipeline =
101 RenderPipelineHandle<GradientFillVertexShader,
102 ConicalGradientSsboFillFragmentShader>;
103 using RadialGradientSSBOFillPipeline =
104 RenderPipelineHandle<GradientFillVertexShader,
105 RadialGradientSsboFillFragmentShader>;
106 using SweepGradientSSBOFillPipeline =
107 RenderPipelineHandle<GradientFillVertexShader,
108 SweepGradientSsboFillFragmentShader>;
109 using RRectBlurPipeline =
110 RenderPipelineHandle<RrectBlurVertexShader, RrectBlurFragmentShader>;
111 using TexturePipeline =
112 RenderPipelineHandle<TextureFillVertexShader, TextureFillFragmentShader>;
113 using TextureStrictSrcPipeline =
114 RenderPipelineHandle<TextureFillVertexShader,
115 TextureFillStrictSrcFragmentShader>;
116 using TiledTexturePipeline =
117 RenderPipelineHandle<TextureUvFillVertexShader,
118 TiledTextureFillFragmentShader>;
119 using GaussianBlurPipeline =
120 RenderPipelineHandle<FilterPositionUvVertexShader, GaussianFragmentShader>;
121 using BorderMaskBlurPipeline =
122 RenderPipelineHandle<FilterPositionUvVertexShader,
123 BorderMaskBlurFragmentShader>;
124 using MorphologyFilterPipeline =
125 RenderPipelineHandle<FilterPositionUvVertexShader,
126 MorphologyFilterFragmentShader>;
127 using ColorMatrixColorFilterPipeline =
128 RenderPipelineHandle<FilterPositionVertexShader,
129 ColorMatrixColorFilterFragmentShader>;
130 using LinearToSrgbFilterPipeline =
131 RenderPipelineHandle<FilterPositionVertexShader,
132 LinearToSrgbFilterFragmentShader>;
133 using SrgbToLinearFilterPipeline =
134 RenderPipelineHandle<FilterPositionVertexShader,
135 SrgbToLinearFilterFragmentShader>;
136 using YUVToRGBFilterPipeline =
137 RenderPipelineHandle<FilterPositionVertexShader,
138 YuvToRgbFilterFragmentShader>;
139
140 using GlyphAtlasPipeline =
141 RenderPipelineHandle<GlyphAtlasVertexShader, GlyphAtlasFragmentShader>;
142
143 using PorterDuffBlendPipeline =
144 RenderPipelineHandle<PorterDuffBlendVertexShader,
145 PorterDuffBlendFragmentShader>;
146 using ClipPipeline = RenderPipelineHandle<ClipVertexShader, ClipFragmentShader>;
147
148 // Advanced blends
149 using BlendColorPipeline = RenderPipelineHandle<AdvancedBlendVertexShader,
150 AdvancedBlendFragmentShader>;
151 using BlendColorBurnPipeline =
152 RenderPipelineHandle<AdvancedBlendVertexShader,
153 AdvancedBlendFragmentShader>;
154 using BlendColorDodgePipeline =
155 RenderPipelineHandle<AdvancedBlendVertexShader,
156 AdvancedBlendFragmentShader>;
157 using BlendDarkenPipeline = RenderPipelineHandle<AdvancedBlendVertexShader,
158 AdvancedBlendFragmentShader>;
159 using BlendDifferencePipeline =
160 RenderPipelineHandle<AdvancedBlendVertexShader,
161 AdvancedBlendFragmentShader>;
162 using BlendExclusionPipeline =
163 RenderPipelineHandle<AdvancedBlendVertexShader,
164 AdvancedBlendFragmentShader>;
165 using BlendHardLightPipeline =
166 RenderPipelineHandle<AdvancedBlendVertexShader,
167 AdvancedBlendFragmentShader>;
168 using BlendHuePipeline = RenderPipelineHandle<AdvancedBlendVertexShader,
169 AdvancedBlendFragmentShader>;
170 using BlendLightenPipeline = RenderPipelineHandle<AdvancedBlendVertexShader,
171 AdvancedBlendFragmentShader>;
172 using BlendLuminosityPipeline =
173 RenderPipelineHandle<AdvancedBlendVertexShader,
174 AdvancedBlendFragmentShader>;
175 using BlendMultiplyPipeline = RenderPipelineHandle<AdvancedBlendVertexShader,
176 AdvancedBlendFragmentShader>;
177 using BlendOverlayPipeline = RenderPipelineHandle<AdvancedBlendVertexShader,
178 AdvancedBlendFragmentShader>;
179 using BlendSaturationPipeline =
180 RenderPipelineHandle<AdvancedBlendVertexShader,
181 AdvancedBlendFragmentShader>;
182 using BlendScreenPipeline = RenderPipelineHandle<AdvancedBlendVertexShader,
183 AdvancedBlendFragmentShader>;
184 using BlendSoftLightPipeline =
185 RenderPipelineHandle<AdvancedBlendVertexShader,
186 AdvancedBlendFragmentShader>;
187 // Framebuffer Advanced Blends
188 using FramebufferBlendColorPipeline =
189 RenderPipelineHandle<FramebufferBlendVertexShader,
190 FramebufferBlendFragmentShader>;
191 using FramebufferBlendColorBurnPipeline =
192 RenderPipelineHandle<FramebufferBlendVertexShader,
193 FramebufferBlendFragmentShader>;
194 using FramebufferBlendColorDodgePipeline =
195 RenderPipelineHandle<FramebufferBlendVertexShader,
196 FramebufferBlendFragmentShader>;
197 using FramebufferBlendDarkenPipeline =
198 RenderPipelineHandle<FramebufferBlendVertexShader,
199 FramebufferBlendFragmentShader>;
200 using FramebufferBlendDifferencePipeline =
201 RenderPipelineHandle<FramebufferBlendVertexShader,
202 FramebufferBlendFragmentShader>;
203 using FramebufferBlendExclusionPipeline =
204 RenderPipelineHandle<FramebufferBlendVertexShader,
205 FramebufferBlendFragmentShader>;
206 using FramebufferBlendHardLightPipeline =
207 RenderPipelineHandle<FramebufferBlendVertexShader,
208 FramebufferBlendFragmentShader>;
209 using FramebufferBlendHuePipeline =
210 RenderPipelineHandle<FramebufferBlendVertexShader,
211 FramebufferBlendFragmentShader>;
212 using FramebufferBlendLightenPipeline =
213 RenderPipelineHandle<FramebufferBlendVertexShader,
214 FramebufferBlendFragmentShader>;
215 using FramebufferBlendLuminosityPipeline =
216 RenderPipelineHandle<FramebufferBlendVertexShader,
217 FramebufferBlendFragmentShader>;
218 using FramebufferBlendMultiplyPipeline =
219 RenderPipelineHandle<FramebufferBlendVertexShader,
220 FramebufferBlendFragmentShader>;
221 using FramebufferBlendOverlayPipeline =
222 RenderPipelineHandle<FramebufferBlendVertexShader,
223 FramebufferBlendFragmentShader>;
224 using FramebufferBlendSaturationPipeline =
225 RenderPipelineHandle<FramebufferBlendVertexShader,
226 FramebufferBlendFragmentShader>;
227 using FramebufferBlendScreenPipeline =
228 RenderPipelineHandle<FramebufferBlendVertexShader,
229 FramebufferBlendFragmentShader>;
230 using FramebufferBlendSoftLightPipeline =
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<TextureUvFillVertexShader,
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.
254 struct ContentContextOptions {
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.
265 kStencilNonZeroFill,
266 /// Draw the stencil for the EvenOdd fill path rule.
267 ///
268 /// The stencil ref should always be 0 on commands using this mode.
269 kStencilEvenOddFill,
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.
276 kCoverCompare,
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.
284 kCoverCompareInverted,
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.
299 kOverdrawPreventionIncrement,
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.
304 kOverdrawPreventionRestore,
305 };
306
307 SampleCount sample_count = SampleCount::kCount1;
308 BlendMode blend_mode = BlendMode::kSourceOver;
309 CompareFunction depth_compare = CompareFunction::kAlways;
310 StencilMode stencil_mode = ContentContextOptions::StencilMode::kIgnore;
311 PrimitiveType primitive_type = PrimitiveType::kTriangle;
312 PixelFormat color_attachment_pixel_format = PixelFormat::kUnknown;
313 bool has_depth_stencil_attachments = true;
314 bool depth_write_enabled = false;
315 bool wireframe = false;
316 bool is_for_rrect_blur_clear = 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 &&
347 lhs.depth_write_enabled == rhs.depth_write_enabled &&
348 lhs.depth_compare == rhs.depth_compare &&
349 lhs.stencil_mode == rhs.stencil_mode &&
350 lhs.primitive_type == rhs.primitive_type &&
351 lhs.color_attachment_pixel_format ==
352 rhs.color_attachment_pixel_format &&
353 lhs.has_depth_stencil_attachments ==
354 rhs.has_depth_stencil_attachments &&
355 lhs.wireframe == rhs.wireframe &&
356 lhs.is_for_rrect_blur_clear == rhs.is_for_rrect_blur_clear;
357 }
358 };
359
360 void ApplyToPipelineDescriptor(PipelineDescriptor& desc) const;
361 };
362
363 class Tessellator;
364 class RenderTargetCache;
365
366 class ContentContext {
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 #if IMPELLER_ENABLE_3D
378 std::shared_ptr<scene::SceneContext> GetSceneContext() const;
379 #endif // IMPELLER_ENABLE_3D
380
381 std::shared_ptr<Tessellator> GetTessellator() const;
382
383 std::shared_ptr<Pipeline<PipelineDescriptor>> GetFastGradientPipeline(
384 ContentContextOptions opts) const {
385 return GetPipeline(fast_gradient_pipelines_, opts);
386 }
387
388 std::shared_ptr<Pipeline<PipelineDescriptor>> GetLinearGradientFillPipeline(
389 ContentContextOptions opts) const {
390 return GetPipeline(linear_gradient_fill_pipelines_, opts);
391 }
392
393 std::shared_ptr<Pipeline<PipelineDescriptor>>
394 GetLinearGradientSSBOFillPipeline(ContentContextOptions opts) const {
395 FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
396 return GetPipeline(linear_gradient_ssbo_fill_pipelines_, opts);
397 }
398
399 std::shared_ptr<Pipeline<PipelineDescriptor>>
400 GetRadialGradientSSBOFillPipeline(ContentContextOptions opts) const {
401 FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
402 return GetPipeline(radial_gradient_ssbo_fill_pipelines_, opts);
403 }
404
405 std::shared_ptr<Pipeline<PipelineDescriptor>>
406 GetConicalGradientSSBOFillPipeline(ContentContextOptions opts) const {
407 FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
408 return GetPipeline(conical_gradient_ssbo_fill_pipelines_, opts);
409 }
410
411 std::shared_ptr<Pipeline<PipelineDescriptor>>
412 GetSweepGradientSSBOFillPipeline(ContentContextOptions opts) const {
413 FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
414 return GetPipeline(sweep_gradient_ssbo_fill_pipelines_, opts);
415 }
416
417 std::shared_ptr<Pipeline<PipelineDescriptor>> GetRadialGradientFillPipeline(
418 ContentContextOptions opts) const {
419 return GetPipeline(radial_gradient_fill_pipelines_, opts);
420 }
421
422 std::shared_ptr<Pipeline<PipelineDescriptor>> GetConicalGradientFillPipeline(
423 ContentContextOptions opts) const {
424 return GetPipeline(conical_gradient_fill_pipelines_, opts);
425 }
426
427 std::shared_ptr<Pipeline<PipelineDescriptor>> GetRRectBlurPipeline(
428 ContentContextOptions opts) const {
429 return GetPipeline(rrect_blur_pipelines_, opts);
430 }
431
432 std::shared_ptr<Pipeline<PipelineDescriptor>> GetSweepGradientFillPipeline(
433 ContentContextOptions opts) const {
434 return GetPipeline(sweep_gradient_fill_pipelines_, opts);
435 }
436
437 std::shared_ptr<Pipeline<PipelineDescriptor>> GetSolidFillPipeline(
438 ContentContextOptions opts) const {
439 return GetPipeline(solid_fill_pipelines_, opts);
440 }
441
442 std::shared_ptr<Pipeline<PipelineDescriptor>> GetTexturePipeline(
443 ContentContextOptions opts) const {
444 return GetPipeline(texture_pipelines_, opts);
445 }
446
447 std::shared_ptr<Pipeline<PipelineDescriptor>> GetTextureStrictSrcPipeline(
448 ContentContextOptions opts) const {
449 return GetPipeline(texture_strict_src_pipelines_, opts);
450 }
451
452 #ifdef IMPELLER_ENABLE_OPENGLES
453 std::shared_ptr<Pipeline<PipelineDescriptor>> GetTiledTextureExternalPipeline(
454 ContentContextOptions opts) const {
455 FML_DCHECK(GetContext()->GetBackendType() ==
456 Context::BackendType::kOpenGLES);
457 return GetPipeline(tiled_texture_external_pipelines_, opts);
458 }
459 #endif // IMPELLER_ENABLE_OPENGLES
460
461 std::shared_ptr<Pipeline<PipelineDescriptor>> GetTiledTexturePipeline(
462 ContentContextOptions opts) const {
463 return GetPipeline(tiled_texture_pipelines_, opts);
464 }
465
466 std::shared_ptr<Pipeline<PipelineDescriptor>> GetGaussianBlurPipeline(
467 ContentContextOptions opts) const {
468 return GetPipeline(gaussian_blur_pipelines_, opts);
469 }
470
471 std::shared_ptr<Pipeline<PipelineDescriptor>> GetBorderMaskBlurPipeline(
472 ContentContextOptions opts) const {
473 return GetPipeline(border_mask_blur_pipelines_, opts);
474 }
475
476 std::shared_ptr<Pipeline<PipelineDescriptor>> GetMorphologyFilterPipeline(
477 ContentContextOptions opts) const {
478 return GetPipeline(morphology_filter_pipelines_, opts);
479 }
480
481 std::shared_ptr<Pipeline<PipelineDescriptor>>
482 GetColorMatrixColorFilterPipeline(ContentContextOptions opts) const {
483 return GetPipeline(color_matrix_color_filter_pipelines_, opts);
484 }
485
486 std::shared_ptr<Pipeline<PipelineDescriptor>> GetLinearToSrgbFilterPipeline(
487 ContentContextOptions opts) const {
488 return GetPipeline(linear_to_srgb_filter_pipelines_, opts);
489 }
490
491 std::shared_ptr<Pipeline<PipelineDescriptor>> GetSrgbToLinearFilterPipeline(
492 ContentContextOptions opts) const {
493 return GetPipeline(srgb_to_linear_filter_pipelines_, opts);
494 }
495
496 std::shared_ptr<Pipeline<PipelineDescriptor>> GetClipPipeline(
497 ContentContextOptions opts) const {
498 return GetPipeline(clip_pipelines_, opts);
499 }
500
501 std::shared_ptr<Pipeline<PipelineDescriptor>> GetGlyphAtlasPipeline(
502 ContentContextOptions opts) const {
503 return GetPipeline(glyph_atlas_pipelines_, opts);
504 }
505
506 std::shared_ptr<Pipeline<PipelineDescriptor>> GetYUVToRGBFilterPipeline(
507 ContentContextOptions opts) const {
508 return GetPipeline(yuv_to_rgb_filter_pipelines_, opts);
509 }
510
511 std::shared_ptr<Pipeline<PipelineDescriptor>> GetPorterDuffBlendPipeline(
512 ContentContextOptions opts) const {
513 return GetPipeline(porter_duff_blend_pipelines_, opts);
514 }
515
516 // Advanced blends.
517
518 std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendColorPipeline(
519 ContentContextOptions opts) const {
520 return GetPipeline(blend_color_pipelines_, opts);
521 }
522
523 std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendColorBurnPipeline(
524 ContentContextOptions opts) const {
525 return GetPipeline(blend_colorburn_pipelines_, opts);
526 }
527
528 std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendColorDodgePipeline(
529 ContentContextOptions opts) const {
530 return GetPipeline(blend_colordodge_pipelines_, opts);
531 }
532
533 std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendDarkenPipeline(
534 ContentContextOptions opts) const {
535 return GetPipeline(blend_darken_pipelines_, opts);
536 }
537
538 std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendDifferencePipeline(
539 ContentContextOptions opts) const {
540 return GetPipeline(blend_difference_pipelines_, opts);
541 }
542
543 std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendExclusionPipeline(
544 ContentContextOptions opts) const {
545 return GetPipeline(blend_exclusion_pipelines_, opts);
546 }
547
548 std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendHardLightPipeline(
549 ContentContextOptions opts) const {
550 return GetPipeline(blend_hardlight_pipelines_, opts);
551 }
552
553 std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendHuePipeline(
554 ContentContextOptions opts) const {
555 return GetPipeline(blend_hue_pipelines_, opts);
556 }
557
558 std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendLightenPipeline(
559 ContentContextOptions opts) const {
560 return GetPipeline(blend_lighten_pipelines_, opts);
561 }
562
563 std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendLuminosityPipeline(
564 ContentContextOptions opts) const {
565 return GetPipeline(blend_luminosity_pipelines_, opts);
566 }
567
568 std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendMultiplyPipeline(
569 ContentContextOptions opts) const {
570 return GetPipeline(blend_multiply_pipelines_, opts);
571 }
572
573 std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendOverlayPipeline(
574 ContentContextOptions opts) const {
575 return GetPipeline(blend_overlay_pipelines_, opts);
576 }
577
578 std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendSaturationPipeline(
579 ContentContextOptions opts) const {
580 return GetPipeline(blend_saturation_pipelines_, opts);
581 }
582
583 std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendScreenPipeline(
584 ContentContextOptions opts) const {
585 return GetPipeline(blend_screen_pipelines_, opts);
586 }
587
588 std::shared_ptr<Pipeline<PipelineDescriptor>> GetBlendSoftLightPipeline(
589 ContentContextOptions opts) const {
590 return GetPipeline(blend_softlight_pipelines_, opts);
591 }
592
593 // Framebuffer Advanced Blends
594 std::shared_ptr<Pipeline<PipelineDescriptor>>
595 GetFramebufferBlendColorPipeline(ContentContextOptions opts) const {
596 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
597 return GetPipeline(framebuffer_blend_color_pipelines_, opts);
598 }
599
600 std::shared_ptr<Pipeline<PipelineDescriptor>>
601 GetFramebufferBlendColorBurnPipeline(ContentContextOptions opts) const {
602 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
603 return GetPipeline(framebuffer_blend_colorburn_pipelines_, opts);
604 }
605
606 std::shared_ptr<Pipeline<PipelineDescriptor>>
607 GetFramebufferBlendColorDodgePipeline(ContentContextOptions opts) const {
608 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
609 return GetPipeline(framebuffer_blend_colordodge_pipelines_, opts);
610 }
611
612 std::shared_ptr<Pipeline<PipelineDescriptor>>
613 GetFramebufferBlendDarkenPipeline(ContentContextOptions opts) const {
614 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
615 return GetPipeline(framebuffer_blend_darken_pipelines_, opts);
616 }
617
618 std::shared_ptr<Pipeline<PipelineDescriptor>>
619 GetFramebufferBlendDifferencePipeline(ContentContextOptions opts) const {
620 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
621 return GetPipeline(framebuffer_blend_difference_pipelines_, opts);
622 }
623
624 std::shared_ptr<Pipeline<PipelineDescriptor>>
625 GetFramebufferBlendExclusionPipeline(ContentContextOptions opts) const {
626 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
627 return GetPipeline(framebuffer_blend_exclusion_pipelines_, opts);
628 }
629
630 std::shared_ptr<Pipeline<PipelineDescriptor>>
631 GetFramebufferBlendHardLightPipeline(ContentContextOptions opts) const {
632 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
633 return GetPipeline(framebuffer_blend_hardlight_pipelines_, opts);
634 }
635
636 std::shared_ptr<Pipeline<PipelineDescriptor>> GetFramebufferBlendHuePipeline(
637 ContentContextOptions opts) const {
638 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
639 return GetPipeline(framebuffer_blend_hue_pipelines_, opts);
640 }
641
642 std::shared_ptr<Pipeline<PipelineDescriptor>>
643 GetFramebufferBlendLightenPipeline(ContentContextOptions opts) const {
644 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
645 return GetPipeline(framebuffer_blend_lighten_pipelines_, opts);
646 }
647
648 std::shared_ptr<Pipeline<PipelineDescriptor>>
649 GetFramebufferBlendLuminosityPipeline(ContentContextOptions opts) const {
650 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
651 return GetPipeline(framebuffer_blend_luminosity_pipelines_, opts);
652 }
653
654 std::shared_ptr<Pipeline<PipelineDescriptor>>
655 GetFramebufferBlendMultiplyPipeline(ContentContextOptions opts) const {
656 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
657 return GetPipeline(framebuffer_blend_multiply_pipelines_, opts);
658 }
659
660 std::shared_ptr<Pipeline<PipelineDescriptor>>
661 GetFramebufferBlendOverlayPipeline(ContentContextOptions opts) const {
662 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
663 return GetPipeline(framebuffer_blend_overlay_pipelines_, opts);
664 }
665
666 std::shared_ptr<Pipeline<PipelineDescriptor>>
667 GetFramebufferBlendSaturationPipeline(ContentContextOptions opts) const {
668 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
669 return GetPipeline(framebuffer_blend_saturation_pipelines_, opts);
670 }
671
672 std::shared_ptr<Pipeline<PipelineDescriptor>>
673 GetFramebufferBlendScreenPipeline(ContentContextOptions opts) const {
674 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
675 return GetPipeline(framebuffer_blend_screen_pipelines_, opts);
676 }
677
678 std::shared_ptr<Pipeline<PipelineDescriptor>>
679 GetFramebufferBlendSoftLightPipeline(ContentContextOptions opts) const {
680 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
681 return GetPipeline(framebuffer_blend_softlight_pipelines_, opts);
682 }
683
684 std::shared_ptr<Pipeline<PipelineDescriptor>> GetDrawVerticesUberShader(
685 ContentContextOptions opts) const {
686 return GetPipeline(vertices_uber_shader_, opts);
687 }
688
689 // An empty 1x1 texture for binding drawVertices/drawAtlas or other cases
690 // that don't always have a texture (due to blending).
691 std::shared_ptr<Texture> GetEmptyTexture() const;
692
693 std::shared_ptr<Context> GetContext() const;
694
695 const Capabilities& GetDeviceCapabilities() const;
696
697 void SetWireframe(bool wireframe);
698
699 using SubpassCallback =
700 std::function<bool(const ContentContext&, RenderPass&)>;
701
702 /// @brief Creates a new texture of size `texture_size` and calls
703 /// `subpass_callback` with a `RenderPass` for drawing to the texture.
704 fml::StatusOr<RenderTarget> MakeSubpass(
705 std::string_view label,
706 ISize texture_size,
707 const std::shared_ptr<CommandBuffer>& command_buffer,
708 const SubpassCallback& subpass_callback,
709 bool msaa_enabled = true,
710 bool depth_stencil_enabled = false,
711 int32_t mip_count = 1) const;
712
713 /// Makes a subpass that will render to `subpass_target`.
714 fml::StatusOr<RenderTarget> MakeSubpass(
715 std::string_view label,
716 const RenderTarget& subpass_target,
717 const std::shared_ptr<CommandBuffer>& command_buffer,
718 const SubpassCallback& subpass_callback) const;
719
720 const std::shared_ptr<LazyGlyphAtlas>& GetLazyGlyphAtlas() const {
721 return lazy_glyph_atlas_;
722 }
723
724 const std::shared_ptr<RenderTargetAllocator>& GetRenderTargetCache() const {
725 return render_target_cache_;
726 }
727
728 /// RuntimeEffect pipelines must be obtained via this method to avoid
729 /// re-creating them every frame.
730 ///
731 /// The unique_entrypoint_name comes from RuntimeEffect::GetEntrypoint.
732 /// Impellerc generates a unique entrypoint name for runtime effect shaders
733 /// based on the input file name and shader stage.
734 ///
735 /// The create_callback is synchronously invoked exactly once if a cached
736 /// pipeline is not found.
737 std::shared_ptr<Pipeline<PipelineDescriptor>> GetCachedRuntimeEffectPipeline(
738 const std::string& unique_entrypoint_name,
739 const ContentContextOptions& options,
740 const std::function<std::shared_ptr<Pipeline<PipelineDescriptor>>()>&
741 create_callback) const;
742
743 /// Used by hot reload/hot restart to clear a cached pipeline from
744 /// GetCachedRuntimeEffectPipeline.
745 void ClearCachedRuntimeEffectPipeline(
746 const std::string& unique_entrypoint_name) const;
747
748 /// @brief Retrieve the currnent host buffer for transient storage.
749 ///
750 /// This is only safe to use from the raster threads. Other threads should
751 /// allocate their own device buffers.
752 HostBuffer& GetTransientsBuffer() const { return *host_buffer_; }
753
754 private:
755 std::shared_ptr<Context> context_;
756 std::shared_ptr<LazyGlyphAtlas> lazy_glyph_atlas_;
757
758 /// Run backend specific additional setup and create common shader variants.
759 ///
760 /// This bootstrap is intended to improve the performance of several
761 /// first frame benchmarks that are tracked in the flutter device lab.
762 /// The workload includes initializing commonly used but not default
763 /// shader variants, as well as forcing driver initialization.
764 void InitializeCommonlyUsedShadersIfNeeded() const;
765
766 struct RuntimeEffectPipelineKey {
767 std::string unique_entrypoint_name;
768 ContentContextOptions options;
769
770 struct Hash {
771 std::size_t operator()(const RuntimeEffectPipelineKey& key) const {
772 return fml::HashCombine(key.unique_entrypoint_name,
773 ContentContextOptions::Hash{}(key.options));
774 }
775 };
776
777 struct Equal {
778 constexpr bool operator()(const RuntimeEffectPipelineKey& lhs,
779 const RuntimeEffectPipelineKey& rhs) const {
780 return lhs.unique_entrypoint_name == rhs.unique_entrypoint_name &&
781 ContentContextOptions::Equal{}(lhs.options, rhs.options);
782 }
783 };
784 };
785
786 mutable std::unordered_map<RuntimeEffectPipelineKey,
787 std::shared_ptr<Pipeline<PipelineDescriptor>>,
788 RuntimeEffectPipelineKey::Hash,
789 RuntimeEffectPipelineKey::Equal>
790 runtime_effect_pipelines_;
791
792 /// Holds multiple Pipelines associated with the same PipelineHandle types.
793 ///
794 /// For example, it may have multiple
795 /// RenderPipelineHandle<SolidFillVertexShader, SolidFillFragmentShader>
796 /// instances for different blend modes. From them you can access the
797 /// Pipeline.
798 ///
799 /// See also:
800 /// - impeller::ContentContextOptions - options from which variants are
801 /// created.
802 /// - impeller::Pipeline::CreateVariant
803 /// - impeller::RenderPipelineHandle<> - The type of objects this typically
804 /// contains.
805 template <class PipelineHandleT>
806 class Variants {
807 public:
808 Variants() = default;
809
810 void Set(const ContentContextOptions& options,
811 std::unique_ptr<PipelineHandleT> pipeline) {
812 pipelines_[options] = std::move(pipeline);
813 }
814
815 void SetDefault(const ContentContextOptions& options,
816 std::unique_ptr<PipelineHandleT> pipeline) {
817 default_options_ = options;
818 Set(options, std::move(pipeline));
819 }
820
821 void CreateDefault(const Context& context,
822 const ContentContextOptions& options,
823 const std::initializer_list<Scalar>& constants = {}) {
824 auto desc = PipelineHandleT::Builder::MakeDefaultPipelineDescriptor(
825 context, constants);
826 if (!desc.has_value()) {
827 VALIDATION_LOG << "Failed to create default pipeline.";
828 return;
829 }
830 options.ApplyToPipelineDescriptor(*desc);
831 SetDefault(options, std::make_unique<PipelineHandleT>(context, desc));
832 }
833
834 PipelineHandleT* Get(const ContentContextOptions& options) const {
835 if (auto found = pipelines_.find(options); found != pipelines_.end()) {
836 return found->second.get();
837 }
838 return nullptr;
839 }
840
841 PipelineHandleT* GetDefault() const {
842 if (!default_options_.has_value()) {
843 return nullptr;
844 }
845 return Get(default_options_.value());
846 }
847
848 size_t GetPipelineCount() const { return pipelines_.size(); }
849
850 private:
851 std::optional<ContentContextOptions> default_options_;
852 std::unordered_map<ContentContextOptions,
853 std::unique_ptr<PipelineHandleT>,
854 ContentContextOptions::Hash,
855 ContentContextOptions::Equal>
856 pipelines_;
857
858 Variants(const Variants&) = delete;
859
860 Variants& operator=(const Variants&) = delete;
861 };
862
863 // These are mutable because while the prototypes are created eagerly, any
864 // variants requested from that are lazily created and cached in the variants
865 // map.
866
867 mutable Variants<SolidFillPipeline> solid_fill_pipelines_;
868 mutable Variants<FastGradientPipeline> fast_gradient_pipelines_;
869 mutable Variants<LinearGradientFillPipeline> linear_gradient_fill_pipelines_;
870 mutable Variants<RadialGradientFillPipeline> radial_gradient_fill_pipelines_;
871 mutable Variants<ConicalGradientFillPipeline>
872 conical_gradient_fill_pipelines_;
873 mutable Variants<SweepGradientFillPipeline> sweep_gradient_fill_pipelines_;
874 mutable Variants<LinearGradientSSBOFillPipeline>
875 linear_gradient_ssbo_fill_pipelines_;
876 mutable Variants<RadialGradientSSBOFillPipeline>
877 radial_gradient_ssbo_fill_pipelines_;
878 mutable Variants<ConicalGradientSSBOFillPipeline>
879 conical_gradient_ssbo_fill_pipelines_;
880 mutable Variants<SweepGradientSSBOFillPipeline>
881 sweep_gradient_ssbo_fill_pipelines_;
882 mutable Variants<RRectBlurPipeline> rrect_blur_pipelines_;
883 mutable Variants<TexturePipeline> texture_pipelines_;
884 mutable Variants<TextureStrictSrcPipeline> texture_strict_src_pipelines_;
885 #ifdef IMPELLER_ENABLE_OPENGLES
886 mutable Variants<TiledTextureExternalPipeline>
887 tiled_texture_external_pipelines_;
888 #endif // IMPELLER_ENABLE_OPENGLES
889 mutable Variants<TiledTexturePipeline> tiled_texture_pipelines_;
890 mutable Variants<GaussianBlurPipeline> gaussian_blur_pipelines_;
891 mutable Variants<BorderMaskBlurPipeline> border_mask_blur_pipelines_;
892 mutable Variants<MorphologyFilterPipeline> morphology_filter_pipelines_;
893 mutable Variants<ColorMatrixColorFilterPipeline>
894 color_matrix_color_filter_pipelines_;
895 mutable Variants<LinearToSrgbFilterPipeline> linear_to_srgb_filter_pipelines_;
896 mutable Variants<SrgbToLinearFilterPipeline> srgb_to_linear_filter_pipelines_;
897 mutable Variants<ClipPipeline> clip_pipelines_;
898 mutable Variants<GlyphAtlasPipeline> glyph_atlas_pipelines_;
899 mutable Variants<YUVToRGBFilterPipeline> yuv_to_rgb_filter_pipelines_;
900 mutable Variants<PorterDuffBlendPipeline> porter_duff_blend_pipelines_;
901 // Advanced blends.
902 mutable Variants<BlendColorPipeline> blend_color_pipelines_;
903 mutable Variants<BlendColorBurnPipeline> blend_colorburn_pipelines_;
904 mutable Variants<BlendColorDodgePipeline> blend_colordodge_pipelines_;
905 mutable Variants<BlendDarkenPipeline> blend_darken_pipelines_;
906 mutable Variants<BlendDifferencePipeline> blend_difference_pipelines_;
907 mutable Variants<BlendExclusionPipeline> blend_exclusion_pipelines_;
908 mutable Variants<BlendHardLightPipeline> blend_hardlight_pipelines_;
909 mutable Variants<BlendHuePipeline> blend_hue_pipelines_;
910 mutable Variants<BlendLightenPipeline> blend_lighten_pipelines_;
911 mutable Variants<BlendLuminosityPipeline> blend_luminosity_pipelines_;
912 mutable Variants<BlendMultiplyPipeline> blend_multiply_pipelines_;
913 mutable Variants<BlendOverlayPipeline> blend_overlay_pipelines_;
914 mutable Variants<BlendSaturationPipeline> blend_saturation_pipelines_;
915 mutable Variants<BlendScreenPipeline> blend_screen_pipelines_;
916 mutable Variants<BlendSoftLightPipeline> blend_softlight_pipelines_;
917 // Framebuffer Advanced blends.
918 mutable Variants<FramebufferBlendColorPipeline>
919 framebuffer_blend_color_pipelines_;
920 mutable Variants<FramebufferBlendColorBurnPipeline>
921 framebuffer_blend_colorburn_pipelines_;
922 mutable Variants<FramebufferBlendColorDodgePipeline>
923 framebuffer_blend_colordodge_pipelines_;
924 mutable Variants<FramebufferBlendDarkenPipeline>
925 framebuffer_blend_darken_pipelines_;
926 mutable Variants<FramebufferBlendDifferencePipeline>
927 framebuffer_blend_difference_pipelines_;
928 mutable Variants<FramebufferBlendExclusionPipeline>
929 framebuffer_blend_exclusion_pipelines_;
930 mutable Variants<FramebufferBlendHardLightPipeline>
931 framebuffer_blend_hardlight_pipelines_;
932 mutable Variants<FramebufferBlendHuePipeline>
933 framebuffer_blend_hue_pipelines_;
934 mutable Variants<FramebufferBlendLightenPipeline>
935 framebuffer_blend_lighten_pipelines_;
936 mutable Variants<FramebufferBlendLuminosityPipeline>
937 framebuffer_blend_luminosity_pipelines_;
938 mutable Variants<FramebufferBlendMultiplyPipeline>
939 framebuffer_blend_multiply_pipelines_;
940 mutable Variants<FramebufferBlendOverlayPipeline>
941 framebuffer_blend_overlay_pipelines_;
942 mutable Variants<FramebufferBlendSaturationPipeline>
943 framebuffer_blend_saturation_pipelines_;
944 mutable Variants<FramebufferBlendScreenPipeline>
945 framebuffer_blend_screen_pipelines_;
946 mutable Variants<FramebufferBlendSoftLightPipeline>
947 framebuffer_blend_softlight_pipelines_;
948 mutable Variants<VerticesUberShader> vertices_uber_shader_;
949
950 template <class TypedPipeline>
951 std::shared_ptr<Pipeline<PipelineDescriptor>> GetPipeline(
952 Variants<TypedPipeline>& container,
953 ContentContextOptions opts) const {
954 TypedPipeline* pipeline = CreateIfNeeded(container, opts);
955 if (!pipeline) {
956 return nullptr;
957 }
958 return pipeline->WaitAndGet();
959 }
960
961 template <class RenderPipelineHandleT>
962 RenderPipelineHandleT* CreateIfNeeded(
963 Variants<RenderPipelineHandleT>& container,
964 ContentContextOptions opts) const {
965 if (!IsValid()) {
966 return nullptr;
967 }
968
969 if (wireframe_) {
970 opts.wireframe = true;
971 }
972
973 if (RenderPipelineHandleT* found = container.Get(opts)) {
974 return found;
975 }
976
977 RenderPipelineHandleT* default_handle = container.GetDefault();
978
979 // The default must always be initialized in the constructor.
980 FML_CHECK(default_handle != nullptr);
981
982 std::shared_ptr<Pipeline<PipelineDescriptor>> pipeline =
983 default_handle->WaitAndGet();
984 if (!pipeline) {
985 return nullptr;
986 }
987
988 auto variant_future = pipeline->CreateVariant(
989 /*async=*/false, [&opts, variants_count = container.GetPipelineCount()](
990 PipelineDescriptor& desc) {
991 opts.ApplyToPipelineDescriptor(desc);
992 desc.SetLabel(
993 SPrintF("%s V#%zu", desc.GetLabel().c_str(), variants_count));
994 });
995 std::unique_ptr<RenderPipelineHandleT> variant =
996 std::make_unique<RenderPipelineHandleT>(std::move(variant_future));
997 container.Set(opts, std::move(variant));
998 return container.Get(opts);
999 }
1000
1001 bool is_valid_ = false;
1002 std::shared_ptr<Tessellator> tessellator_;
1003 #if IMPELLER_ENABLE_3D
1004 std::shared_ptr<scene::SceneContext> scene_context_;
1005 #endif // IMPELLER_ENABLE_3D
1006 std::shared_ptr<RenderTargetAllocator> render_target_cache_;
1007 std::shared_ptr<HostBuffer> host_buffer_;
1008 std::shared_ptr<Texture> empty_texture_;
1009 bool wireframe_ = false;
1010
1011 ContentContext(const ContentContext&) = delete;
1012
1013 ContentContext& operator=(const ContentContext&) = delete;
1014 };
1015
1016 } // namespace impeller
1017
1018 #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:442
impeller::Pipeline< PipelineDescriptor >
impeller::ContentContextOptions::StencilMode::kIgnore
@ kIgnore
impeller::ContentContext::GetTextureStrictSrcPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetTextureStrictSrcPipeline(ContentContextOptions opts) const
Definition: content_context.h:447
impeller::ContentContext::GetFramebufferBlendScreenPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendScreenPipeline(ContentContextOptions opts) const
Definition: content_context.h:673
impeller::ContentContext::ClearCachedRuntimeEffectPipeline
void ClearCachedRuntimeEffectPipeline(const std::string &unique_entrypoint_name) const
Definition: content_context.cc:579
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:417
impeller::ContentContext::GetBorderMaskBlurPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBorderMaskBlurPipeline(ContentContextOptions opts) const
Definition: content_context.h:471
impeller::ContentContext::GetLinearGradientFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetLinearGradientFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:388
scene_context.h
impeller::ContentContext::GetBlendColorDodgePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendColorDodgePipeline(ContentContextOptions opts) const
Definition: content_context.h:528
impeller::ContentContext::GetFramebufferBlendColorBurnPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendColorBurnPipeline(ContentContextOptions opts) const
Definition: content_context.h:601
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:643
impeller::ContentContext::GetLazyGlyphAtlas
const std::shared_ptr< LazyGlyphAtlas > & GetLazyGlyphAtlas() const
Definition: content_context.h:720
impeller::ContentContext::RuntimeEffectPipelineKey::Equal
Definition: content_context.h:777
impeller::ContentContext::GetBlendHuePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendHuePipeline(ContentContextOptions opts) const
Definition: content_context.h:553
impeller::ContentContext::GetFastGradientPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFastGradientPipeline(ContentContextOptions opts) const
Definition: content_context.h:383
impeller::ContentContext::GetGaussianBlurPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetGaussianBlurPipeline(ContentContextOptions opts) const
Definition: content_context.h:466
impeller::ContentContextOptions::StencilMode::kOverdrawPreventionIncrement
@ kOverdrawPreventionIncrement
impeller::ContentContext::GetFramebufferBlendExclusionPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendExclusionPipeline(ContentContextOptions opts) const
Definition: content_context.h:625
impeller::BlendMode
BlendMode
Definition: color.h:59
impeller::HostBuffer
Definition: host_buffer.h:28
impeller::ContentContext::GetBlendColorPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendColorPipeline(ContentContextOptions opts) const
Definition: content_context.h:518
impeller::ContentContext::GetMorphologyFilterPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetMorphologyFilterPipeline(ContentContextOptions opts) const
Definition: content_context.h:476
formats.h
impeller::ContentContextOptions::Hash
Definition: content_context.h:318
impeller::ContentContext::GetFramebufferBlendColorDodgePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendColorDodgePipeline(ContentContextOptions opts) const
Definition: content_context.h:607
impeller::ContentContext::GetBlendDarkenPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendDarkenPipeline(ContentContextOptions opts) const
Definition: content_context.h:533
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:496
impeller::ContentContext::GetTiledTexturePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetTiledTexturePipeline(ContentContextOptions opts) const
Definition: content_context.h:461
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:412
typographer_context.h
impeller::ContentContext::GetFramebufferBlendOverlayPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendOverlayPipeline(ContentContextOptions opts) const
Definition: content_context.h:661
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:491
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:486
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:566
validation.h
impeller::ContentContext::GetBlendDifferencePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendDifferencePipeline(ContentContextOptions opts) const
Definition: content_context.h:538
impeller::ContentContext::GetEmptyTexture
std::shared_ptr< Texture > GetEmptyTexture() const
Definition: content_context.cc:471
impeller::ContentContext::GetConicalGradientFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetConicalGradientFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:422
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:394
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:636
impeller::ContentContextOptions::StencilMode
StencilMode
Definition: content_context.h:255
impeller::PrimitiveType::kTriangle
@ kTriangle
impeller::FastGradientPipeline
RenderPipelineHandle< FastGradientVertexShader, FastGradientFragmentShader > FastGradientPipeline
Definition: content_context.h:82
impeller::Capabilities
Definition: capabilities.h:14
impeller::TSize
Definition: size.h:19
impeller::CompareFunction
CompareFunction
Definition: formats.h:546
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:506
impeller::ContentContext::GetFramebufferBlendDifferencePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendDifferencePipeline(ContentContextOptions opts) const
Definition: content_context.h:619
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:543
impeller::ContentContext::RuntimeEffectPipelineKey::Hash
Definition: content_context.h:770
impeller::ContentContext::GetConicalGradientSSBOFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetConicalGradientSSBOFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:406
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:553
impeller::ContentContextOptions::StencilMode::kStencilNonZeroFill
@ kStencilNonZeroFill
impeller::ContentContext::GetBlendColorBurnPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendColorBurnPipeline(ContentContextOptions opts) const
Definition: content_context.h:523
impeller::ContentContext::GetBlendScreenPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendScreenPipeline(ContentContextOptions opts) const
Definition: content_context.h:583
impeller::ContentContext::GetFramebufferBlendSaturationPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendSaturationPipeline(ContentContextOptions opts) const
Definition: content_context.h:667
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:475
impeller::ContentContext::GetBlendSoftLightPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendSoftLightPipeline(ContentContextOptions opts) const
Definition: content_context.h:588
impeller::ContentContext::GetSolidFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetSolidFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:437
impeller::ContentContext::GetFramebufferBlendDarkenPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendDarkenPipeline(ContentContextOptions opts) const
Definition: content_context.h:613
capabilities.h
impeller::ContentContext::RuntimeEffectPipelineKey::Hash::operator()
std::size_t operator()(const RuntimeEffectPipelineKey &key) const
Definition: content_context.h:771
impeller::RenderTarget
Definition: render_target.h:38
impeller::ContentContext::GetDrawVerticesUberShader
std::shared_ptr< Pipeline< PipelineDescriptor > > GetDrawVerticesUberShader(ContentContextOptions opts) const
Definition: content_context.h:684
impeller::ContentContext::GetRRectBlurPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetRRectBlurPipeline(ContentContextOptions opts) const
Definition: content_context.h:427
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:549
impeller::ContentContext::GetFramebufferBlendMultiplyPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendMultiplyPipeline(ContentContextOptions opts) const
Definition: content_context.h:655
impeller::ContentContext::GetFramebufferBlendSoftLightPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendSoftLightPipeline(ContentContextOptions opts) const
Definition: content_context.h:679
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:432
impeller::ContentContext::SubpassCallback
std::function< bool(const ContentContext &, RenderPass &)> SubpassCallback
Definition: content_context.h:700
impeller::ContentContext::GetBlendLightenPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendLightenPipeline(ContentContextOptions opts) const
Definition: content_context.h:558
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:724
impeller::ContentContextOptions::depth_compare
CompareFunction depth_compare
Definition: content_context.h:309
impeller::ContentContext::GetDeviceCapabilities
const Capabilities & GetDeviceCapabilities() const
Definition: content_context.cc:557
impeller::ContentContext::GetFramebufferBlendColorPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendColorPipeline(ContentContextOptions opts) const
Definition: content_context.h:595
impeller::ContentContext::GetBlendMultiplyPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendMultiplyPipeline(ContentContextOptions opts) const
Definition: content_context.h:568
impeller::ContentContext::GetBlendLuminosityPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendLuminosityPipeline(ContentContextOptions opts) const
Definition: content_context.h:563
impeller::ContentContext::GetBlendOverlayPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendOverlayPipeline(ContentContextOptions opts) const
Definition: content_context.h:573
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:578
impeller::SampleCount
SampleCount
Definition: formats.h:295
impeller::ContentContext::GetRadialGradientSSBOFillPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetRadialGradientSSBOFillPipeline(ContentContextOptions opts) const
Definition: content_context.h:400
impeller::ContentContext::SetWireframe
void SetWireframe(bool wireframe)
Definition: content_context.cc:561
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:778
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:501
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:631
impeller
Definition: aiks_blend_unittests.cc:18
impeller::ContentContext::IsValid
bool IsValid() const
Definition: content_context.cc:467
impeller::ContentContext
Definition: content_context.h:366
impeller::ContentContext::GetFramebufferBlendLuminosityPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetFramebufferBlendLuminosityPipeline(ContentContextOptions opts) const
Definition: content_context.h:649
impeller::BlendMode::kSourceOver
@ kSourceOver
impeller::ContentContext::GetTransientsBuffer
HostBuffer & GetTransientsBuffer() const
Retrieve the currnent host buffer for transient storage.
Definition: content_context.h:752
impeller::ContentContext::GetPorterDuffBlendPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetPorterDuffBlendPipeline(ContentContextOptions opts) const
Definition: content_context.h:511
impeller::ContentContext::GetBlendHardLightPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetBlendHardLightPipeline(ContentContextOptions opts) const
Definition: content_context.h:548
impeller::ContentContext::GetColorMatrixColorFilterPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetColorMatrixColorFilterPipeline(ContentContextOptions opts) const
Definition: content_context.h:482