From 7e57890718356743f89d2611b877cd1d6007d398 Mon Sep 17 00:00:00 2001 From: gaaclarke <30870216+gaaclarke@users.noreply.github.com> Date: Tue, 25 Mar 2025 14:09:57 -0700 Subject: [PATCH] Refactored `content_context.h` to move logic out of the header (#165833) Improvements: - Includes for generated shader headers removed from content_context.h - `Variants` moved to .cc - `CreateIfNeeded` moved to .cc - `GetPipeline` moved to .cc - `Variants` are no longer `mutable` - Shader static_assert linker checks are moved to .cc ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --- .../ci/licenses_golden/licenses_flutter | 2 + .../display_list/dl_vertices_geometry.cc | 1 + engine/src/flutter/impeller/entity/BUILD.gn | 1 + .../impeller/entity/contents/clip_contents.cc | 1 + .../entity/contents/color_source_contents.h | 1 + .../entity/contents/content_context.cc | 668 ++++++++++++------ .../entity/contents/content_context.h | 412 +---------- .../impeller/entity/contents/pipelines.h | 166 +++++ .../impeller/entity/contents/text_contents.h | 1 + .../impeller/entity/geometry/geometry.cc | 1 + .../entity/geometry/geometry_unittests.cc | 1 + .../impeller/entity/geometry/line_geometry.cc | 1 + .../entity/geometry/stroke_path_geometry.cc | 1 + .../src/flutter/impeller/renderer/pipeline.h | 5 - 14 files changed, 648 insertions(+), 614 deletions(-) create mode 100644 engine/src/flutter/impeller/entity/contents/pipelines.h diff --git a/engine/src/flutter/ci/licenses_golden/licenses_flutter b/engine/src/flutter/ci/licenses_golden/licenses_flutter index 279ff9ab07..82256f6c5b 100644 --- a/engine/src/flutter/ci/licenses_golden/licenses_flutter +++ b/engine/src/flutter/ci/licenses_golden/licenses_flutter @@ -51235,6 +51235,7 @@ ORIGIN: ../../../flutter/impeller/entity/contents/line_contents.cc + ../../../fl ORIGIN: ../../../flutter/impeller/entity/contents/line_contents.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/entity/contents/linear_gradient_contents.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/entity/contents/linear_gradient_contents.h + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/impeller/entity/contents/pipelines.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/entity/contents/radial_gradient_contents.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/entity/contents/radial_gradient_contents.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/impeller/entity/contents/runtime_effect_contents.cc + ../../../flutter/LICENSE @@ -54212,6 +54213,7 @@ FILE: ../../../flutter/impeller/entity/contents/line_contents.cc FILE: ../../../flutter/impeller/entity/contents/line_contents.h FILE: ../../../flutter/impeller/entity/contents/linear_gradient_contents.cc FILE: ../../../flutter/impeller/entity/contents/linear_gradient_contents.h +FILE: ../../../flutter/impeller/entity/contents/pipelines.h FILE: ../../../flutter/impeller/entity/contents/radial_gradient_contents.cc FILE: ../../../flutter/impeller/entity/contents/radial_gradient_contents.h FILE: ../../../flutter/impeller/entity/contents/runtime_effect_contents.cc diff --git a/engine/src/flutter/impeller/display_list/dl_vertices_geometry.cc b/engine/src/flutter/impeller/display_list/dl_vertices_geometry.cc index 4fa86ac207..3307c9c6c0 100644 --- a/engine/src/flutter/impeller/display_list/dl_vertices_geometry.cc +++ b/engine/src/flutter/impeller/display_list/dl_vertices_geometry.cc @@ -7,6 +7,7 @@ #include "display_list/dl_vertices.h" #include "impeller/core/formats.h" #include "impeller/display_list/skia_conversions.h" +#include "impeller/entity/contents/pipelines.h" #include "impeller/geometry/point.h" namespace impeller { diff --git a/engine/src/flutter/impeller/entity/BUILD.gn b/engine/src/flutter/impeller/entity/BUILD.gn index 688cf7a9c2..551b0e4fdf 100644 --- a/engine/src/flutter/impeller/entity/BUILD.gn +++ b/engine/src/flutter/impeller/entity/BUILD.gn @@ -165,6 +165,7 @@ impeller_component("entity") { "contents/line_contents.h", "contents/linear_gradient_contents.cc", "contents/linear_gradient_contents.h", + "contents/pipelines.h", "contents/radial_gradient_contents.cc", "contents/radial_gradient_contents.h", "contents/runtime_effect_contents.cc", diff --git a/engine/src/flutter/impeller/entity/contents/clip_contents.cc b/engine/src/flutter/impeller/entity/contents/clip_contents.cc index 7c456572be..c778bec336 100644 --- a/engine/src/flutter/impeller/entity/contents/clip_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/clip_contents.cc @@ -10,6 +10,7 @@ #include "impeller/core/vertex_buffer.h" #include "impeller/entity/contents/clip_contents.h" #include "impeller/entity/contents/content_context.h" +#include "impeller/entity/contents/pipelines.h" #include "impeller/entity/entity.h" #include "impeller/renderer/render_pass.h" #include "impeller/renderer/vertex_buffer_builder.h" diff --git a/engine/src/flutter/impeller/entity/contents/color_source_contents.h b/engine/src/flutter/impeller/entity/contents/color_source_contents.h index 6d58ab07ab..d43b291a05 100644 --- a/engine/src/flutter/impeller/entity/contents/color_source_contents.h +++ b/engine/src/flutter/impeller/entity/contents/color_source_contents.h @@ -9,6 +9,7 @@ #include "impeller/entity/contents/clip_contents.h" #include "impeller/entity/contents/content_context.h" #include "impeller/entity/contents/contents.h" +#include "impeller/entity/contents/pipelines.h" #include "impeller/entity/geometry/geometry.h" #include "impeller/entity/geometry/rect_geometry.h" #include "impeller/geometry/matrix.h" diff --git a/engine/src/flutter/impeller/entity/contents/content_context.cc b/engine/src/flutter/impeller/entity/contents/content_context.cc index 41383a7384..d1310a18a9 100644 --- a/engine/src/flutter/impeller/entity/contents/content_context.cc +++ b/engine/src/flutter/impeller/entity/contents/content_context.cc @@ -12,6 +12,7 @@ #include "impeller/core/formats.h" #include "impeller/core/texture_descriptor.h" #include "impeller/entity/contents/framebuffer_blend_contents.h" +#include "impeller/entity/contents/pipelines.h" #include "impeller/entity/entity.h" #include "impeller/entity/render_target_cache.h" #include "impeller/renderer/command_buffer.h" @@ -24,6 +25,264 @@ namespace impeller { +namespace { + +/// Holds multiple Pipelines associated with the same PipelineHandle types. +/// +/// For example, it may have multiple +/// RenderPipelineHandle +/// instances for different blend modes. From them you can access the +/// Pipeline. +/// +/// See also: +/// - impeller::ContentContextOptions - options from which variants are +/// created. +/// - impeller::Pipeline::CreateVariant +/// - impeller::RenderPipelineHandle<> - The type of objects this typically +/// contains. +template +class Variants { + static_assert( + ShaderStageCompatibilityChecker< + typename PipelineHandleT::VertexShader, + typename PipelineHandleT::FragmentShader>::Check(), + "The output slots for the fragment shader don't have matches in the " + "vertex shader's output slots. This will result in a linker error."); + + public: + Variants() = default; + + void Set(const ContentContextOptions& options, + std::unique_ptr pipeline) { + uint64_t p_key = options.ToKey(); + for (const auto& [key, pipeline] : pipelines_) { + if (key == p_key) { + return; + } + } + pipelines_.push_back(std::make_pair(p_key, std::move(pipeline))); + } + + void SetDefault(const ContentContextOptions& options, + std::unique_ptr pipeline) { + default_options_ = options; + if (pipeline) { + Set(options, std::move(pipeline)); + } + } + + void SetDefaultDescriptor(std::optional desc) { + desc_ = std::move(desc); + } + + void CreateDefault(const Context& context, + const ContentContextOptions& options, + const std::vector& constants = {}) { + auto desc = PipelineHandleT::Builder::MakeDefaultPipelineDescriptor( + context, constants); + if (!desc.has_value()) { + VALIDATION_LOG << "Failed to create default pipeline."; + return; + } + options.ApplyToPipelineDescriptor(*desc); + desc_ = desc; + if (context.GetFlags().lazy_shader_mode) { + SetDefault(options, nullptr); + } else { + SetDefault(options, std::make_unique(context, desc_, + /*async=*/true)); + } + } + + PipelineHandleT* Get(const ContentContextOptions& options) const { + uint64_t p_key = options.ToKey(); + for (const auto& [key, pipeline] : pipelines_) { + if (key == p_key) { + return pipeline.get(); + } + } + return nullptr; + } + + bool IsDefault(const ContentContextOptions& opts) { + return default_options_.has_value() && + opts.ToKey() == default_options_.value().ToKey(); + } + + PipelineHandleT* GetDefault(const Context& context) { + if (!default_options_.has_value()) { + return nullptr; + } + PipelineHandleT* result = Get(default_options_.value()); + if (result != nullptr) { + return result; + } + SetDefault(default_options_.value(), std::make_unique( + context, desc_, /*async=*/false)); + return Get(default_options_.value()); + } + + size_t GetPipelineCount() const { return pipelines_.size(); } + + private: + std::optional desc_; + std::optional default_options_; + std::vector>> pipelines_; + + Variants(const Variants&) = delete; + + Variants& operator=(const Variants&) = delete; +}; + +template +RenderPipelineHandleT* CreateIfNeeded( + const ContentContext* context, + Variants& container, + ContentContextOptions opts) { + if (!context->IsValid()) { + return nullptr; + } + + if (RenderPipelineHandleT* found = container.Get(opts)) { + return found; + } + + RenderPipelineHandleT* default_handle = + container.GetDefault(*context->GetContext()); + if (container.IsDefault(opts)) { + return default_handle; + } + + // The default must always be initialized in the constructor. + FML_CHECK(default_handle != nullptr); + + const std::shared_ptr>& pipeline = + default_handle->WaitAndGet(); + if (!pipeline) { + return nullptr; + } + + auto variant_future = pipeline->CreateVariant( + /*async=*/false, [&opts, variants_count = container.GetPipelineCount()]( + PipelineDescriptor& desc) { + opts.ApplyToPipelineDescriptor(desc); + desc.SetLabel( + SPrintF("%s V#%zu", desc.GetLabel().data(), variants_count)); + }); + std::unique_ptr variant = + std::make_unique(std::move(variant_future)); + container.Set(opts, std::move(variant)); + return container.Get(opts); +} + +template +PipelineRef GetPipeline(const ContentContext* context, + Variants& container, + ContentContextOptions opts) { + TypedPipeline* pipeline = CreateIfNeeded(context, container, opts); + if (!pipeline) { + return raw_ptr>(); + } + return raw_ptr(pipeline->WaitAndGet()); +} + +} // namespace + +struct ContentContext::Pipelines { + // clang-format off + Variants blend_colorburn; + Variants blend_colordodge; + Variants blend_color; + Variants blend_darken; + Variants blend_difference; + Variants blend_exclusion; + Variants blend_hardlight; + Variants blend_hue; + Variants blend_lighten; + Variants blend_luminosity; + Variants blend_multiply; + Variants blend_overlay; + Variants blend_saturation; + Variants blend_screen; + Variants blend_softlight; + Variants border_mask_blur; + Variants clip; + Variants color_matrix_color_filter; + Variants conical_gradient_fill; + Variants conical_gradient_fill_radial; + Variants conical_gradient_fill_strip; + Variants conical_gradient_fill_strip_and_radial; + Variants conical_gradient_ssbo_fill; + Variants conical_gradient_ssbo_fill_radial; + Variants conical_gradient_ssbo_fill_strip_and_radial; + Variants conical_gradient_ssbo_fill_strip; + Variants conical_gradient_uniform_fill; + Variants conical_gradient_uniform_fill_radial; + Variants conical_gradient_uniform_fill_strip; + Variants conical_gradient_uniform_fill_strip_and_radial; + Variants fast_gradient; + Variants framebuffer_blend_colorburn; + Variants framebuffer_blend_colordodge; + Variants framebuffer_blend_color; + Variants framebuffer_blend_darken; + Variants framebuffer_blend_difference; + Variants framebuffer_blend_exclusion; + Variants framebuffer_blend_hardlight; + Variants framebuffer_blend_hue; + Variants framebuffer_blend_lighten; + Variants framebuffer_blend_luminosity; + Variants framebuffer_blend_multiply; + Variants framebuffer_blend_overlay; + Variants framebuffer_blend_saturation; + Variants framebuffer_blend_screen; + Variants framebuffer_blend_softlight; + Variants gaussian_blur; + Variants glyph_atlas; + Variants line; + Variants linear_gradient_fill; + Variants linear_gradient_ssbo_fill; + Variants linear_gradient_uniform_fill; + Variants linear_to_srgb_filter; + Variants morphology_filter; + Variants clear_blend; + Variants destination_a_top_blend; + Variants destination_blend; + Variants destination_in_blend; + Variants destination_out_blend; + Variants destination_over_blend; + Variants modulate_blend; + Variants plus_blend; + Variants screen_blend; + Variants source_a_top_blend; + Variants source_blend; + Variants source_in_blend; + Variants source_out_blend; + Variants source_over_blend; + Variants xor_blend; + Variants radial_gradient_fill; + Variants radial_gradient_ssbo_fill; + Variants radial_gradient_uniform_fill; + Variants rrect_blur; + Variants solid_fill; + Variants srgb_to_linear_filter; + Variants sweep_gradient_fill; + Variants sweep_gradient_ssbo_fill; + Variants sweep_gradient_uniform_fill; + Variants texture_downsample; + Variants texture; + Variants texture_strict_src; + Variants tiled_texture; + Variants vertices_uber_shader_; + Variants yuv_to_rgb_filter; + +#ifdef IMPELLER_ENABLE_OPENGLES + Variants tiled_texture_external; + Variants texture_downsample_gles; + Variants tiled_texture_uv_external; +#endif // IMPELLER_ENABLE_OPENGLES + // clang-format on +}; + void ContentContextOptions::ApplyToPipelineDescriptor( PipelineDescriptor& desc) const { auto pipeline_blend = blend_mode; @@ -265,6 +524,7 @@ ContentContext::ContentContext( : context_(std::move(context)), lazy_glyph_atlas_( std::make_shared(std::move(typographer_context))), + pipelines_(new Pipelines()), tessellator_(std::make_shared()), render_target_cache_(render_target_allocator == nullptr ? std::make_shared( @@ -321,49 +581,52 @@ ContentContext::ContentContext( // rendered without the pipelines being ready. Put pipelines that are more // likely to be used first. { - glyph_atlas_pipelines_.CreateDefault( + pipelines_->glyph_atlas.CreateDefault( *context_, options, {static_cast( GetContext()->GetCapabilities()->GetDefaultGlyphAtlasFormat() == PixelFormat::kA8UNormInt)}); - solid_fill_pipelines_.CreateDefault(*context_, options); - texture_pipelines_.CreateDefault(*context_, options); - fast_gradient_pipelines_.CreateDefault(*context_, options); - line_pipelines_.CreateDefault(*context_, options); + pipelines_->solid_fill.CreateDefault(*context_, options); + pipelines_->texture.CreateDefault(*context_, options); + pipelines_->fast_gradient.CreateDefault(*context_, options); + pipelines_->line.CreateDefault(*context_, options); if (context_->GetCapabilities()->SupportsSSBO()) { - linear_gradient_ssbo_fill_pipelines_.CreateDefault(*context_, options); - radial_gradient_ssbo_fill_pipelines_.CreateDefault(*context_, options); - conical_gradient_ssbo_fill_pipelines_.CreateDefault(*context_, options, - {3.0}); - conical_gradient_ssbo_fill_radial_pipelines_.CreateDefault( + pipelines_->linear_gradient_ssbo_fill.CreateDefault(*context_, options); + pipelines_->radial_gradient_ssbo_fill.CreateDefault(*context_, options); + pipelines_->conical_gradient_ssbo_fill.CreateDefault(*context_, options, + {3.0}); + pipelines_->conical_gradient_ssbo_fill_radial.CreateDefault( *context_, options, {1.0}); - conical_gradient_ssbo_fill_strip_pipelines_.CreateDefault(*context_, - options, {2.0}); - conical_gradient_ssbo_fill_strip_and_radial_pipelines_.CreateDefault( + pipelines_->conical_gradient_ssbo_fill_strip.CreateDefault( + *context_, options, {2.0}); + pipelines_->conical_gradient_ssbo_fill_strip_and_radial.CreateDefault( *context_, options, {0.0}); - sweep_gradient_ssbo_fill_pipelines_.CreateDefault(*context_, options); + pipelines_->sweep_gradient_ssbo_fill.CreateDefault(*context_, options); } else { - linear_gradient_uniform_fill_pipelines_.CreateDefault(*context_, options); - radial_gradient_uniform_fill_pipelines_.CreateDefault(*context_, options); - conical_gradient_uniform_fill_pipelines_.CreateDefault(*context_, + pipelines_->linear_gradient_uniform_fill.CreateDefault(*context_, options); - conical_gradient_uniform_fill_radial_pipelines_.CreateDefault(*context_, + pipelines_->radial_gradient_uniform_fill.CreateDefault(*context_, + options); + pipelines_->conical_gradient_uniform_fill.CreateDefault(*context_, + options); + pipelines_->conical_gradient_uniform_fill_radial.CreateDefault(*context_, + options); + pipelines_->conical_gradient_uniform_fill_strip.CreateDefault(*context_, options); - conical_gradient_uniform_fill_strip_pipelines_.CreateDefault(*context_, - options); - conical_gradient_uniform_fill_strip_and_radial_pipelines_.CreateDefault( + pipelines_->conical_gradient_uniform_fill_strip_and_radial.CreateDefault( *context_, options); - sweep_gradient_uniform_fill_pipelines_.CreateDefault(*context_, options); + pipelines_->sweep_gradient_uniform_fill.CreateDefault(*context_, options); - linear_gradient_fill_pipelines_.CreateDefault(*context_, options); - radial_gradient_fill_pipelines_.CreateDefault(*context_, options); - conical_gradient_fill_pipelines_.CreateDefault(*context_, options); - conical_gradient_fill_radial_pipelines_.CreateDefault(*context_, options); - conical_gradient_fill_strip_pipelines_.CreateDefault(*context_, options); - conical_gradient_fill_strip_and_radial_pipelines_.CreateDefault(*context_, - options); - sweep_gradient_fill_pipelines_.CreateDefault(*context_, options); + pipelines_->linear_gradient_fill.CreateDefault(*context_, options); + pipelines_->radial_gradient_fill.CreateDefault(*context_, options); + pipelines_->conical_gradient_fill.CreateDefault(*context_, options); + pipelines_->conical_gradient_fill_radial.CreateDefault(*context_, + options); + pipelines_->conical_gradient_fill_strip.CreateDefault(*context_, options); + pipelines_->conical_gradient_fill_strip_and_radial.CreateDefault( + *context_, options); + pipelines_->sweep_gradient_fill.CreateDefault(*context_, options); } /// Setup default clip pipeline. @@ -386,171 +649,173 @@ ContentContext::ContentContext( clip_pipeline_descriptor->SetColorAttachmentDescriptors( std::move(clip_color_attachments)); if (GetContext()->GetFlags().lazy_shader_mode) { - clip_pipelines_.SetDefaultDescriptor(clip_pipeline_descriptor); - clip_pipelines_.SetDefault(options, nullptr); + pipelines_->clip.SetDefaultDescriptor(clip_pipeline_descriptor); + pipelines_->clip.SetDefault(options, nullptr); } else { - clip_pipelines_.SetDefault( + pipelines_->clip.SetDefault( options, std::make_unique(*context_, clip_pipeline_descriptor)); } - texture_downsample_pipelines_.CreateDefault( + pipelines_->texture_downsample.CreateDefault( *context_, options_no_msaa_no_depth_stencil); - rrect_blur_pipelines_.CreateDefault(*context_, options_trianglestrip); - texture_strict_src_pipelines_.CreateDefault(*context_, options); - tiled_texture_pipelines_.CreateDefault(*context_, options, - {supports_decal}); - gaussian_blur_pipelines_.CreateDefault( + pipelines_->rrect_blur.CreateDefault(*context_, options_trianglestrip); + pipelines_->texture_strict_src.CreateDefault(*context_, options); + pipelines_->tiled_texture.CreateDefault(*context_, options, + {supports_decal}); + pipelines_->gaussian_blur.CreateDefault( *context_, options_no_msaa_no_depth_stencil, {supports_decal}); - border_mask_blur_pipelines_.CreateDefault(*context_, options_trianglestrip); - color_matrix_color_filter_pipelines_.CreateDefault(*context_, - options_trianglestrip); - vertices_uber_shader_.CreateDefault(*context_, options, {supports_decal}); + pipelines_->border_mask_blur.CreateDefault(*context_, + options_trianglestrip); + pipelines_->color_matrix_color_filter.CreateDefault(*context_, + options_trianglestrip); + pipelines_->vertices_uber_shader_.CreateDefault(*context_, options, + {supports_decal}); const std::array, 15> porter_duff_constants = GetPorterDuffSpecConstants(supports_decal); - clear_blend_pipelines_.CreateDefault(*context_, options_trianglestrip, - porter_duff_constants[0]); - source_blend_pipelines_.CreateDefault(*context_, options_trianglestrip, - porter_duff_constants[1]); - destination_blend_pipelines_.CreateDefault(*context_, options_trianglestrip, - porter_duff_constants[2]); - source_over_blend_pipelines_.CreateDefault(*context_, options_trianglestrip, - porter_duff_constants[3]); - destination_over_blend_pipelines_.CreateDefault( + pipelines_->clear_blend.CreateDefault(*context_, options_trianglestrip, + porter_duff_constants[0]); + pipelines_->source_blend.CreateDefault(*context_, options_trianglestrip, + porter_duff_constants[1]); + pipelines_->destination_blend.CreateDefault( + *context_, options_trianglestrip, porter_duff_constants[2]); + pipelines_->source_over_blend.CreateDefault( + *context_, options_trianglestrip, porter_duff_constants[3]); + pipelines_->destination_over_blend.CreateDefault( *context_, options_trianglestrip, porter_duff_constants[4]); - source_in_blend_pipelines_.CreateDefault(*context_, options_trianglestrip, - porter_duff_constants[5]); - destination_in_blend_pipelines_.CreateDefault( + pipelines_->source_in_blend.CreateDefault(*context_, options_trianglestrip, + porter_duff_constants[5]); + pipelines_->destination_in_blend.CreateDefault( *context_, options_trianglestrip, porter_duff_constants[6]); - source_out_blend_pipelines_.CreateDefault(*context_, options_trianglestrip, - porter_duff_constants[7]); - destination_out_blend_pipelines_.CreateDefault( + pipelines_->source_out_blend.CreateDefault(*context_, options_trianglestrip, + porter_duff_constants[7]); + pipelines_->destination_out_blend.CreateDefault( *context_, options_trianglestrip, porter_duff_constants[8]); - source_a_top_blend_pipelines_.CreateDefault( + pipelines_->source_a_top_blend.CreateDefault( *context_, options_trianglestrip, porter_duff_constants[9]); - destination_a_top_blend_pipelines_.CreateDefault( + pipelines_->destination_a_top_blend.CreateDefault( *context_, options_trianglestrip, porter_duff_constants[10]); - xor_blend_pipelines_.CreateDefault(*context_, options_trianglestrip, - porter_duff_constants[11]); - plus_blend_pipelines_.CreateDefault(*context_, options_trianglestrip, - porter_duff_constants[12]); - modulate_blend_pipelines_.CreateDefault(*context_, options_trianglestrip, - porter_duff_constants[13]); - screen_blend_pipelines_.CreateDefault(*context_, options_trianglestrip, - porter_duff_constants[14]); + pipelines_->xor_blend.CreateDefault(*context_, options_trianglestrip, + porter_duff_constants[11]); + pipelines_->plus_blend.CreateDefault(*context_, options_trianglestrip, + porter_duff_constants[12]); + pipelines_->modulate_blend.CreateDefault(*context_, options_trianglestrip, + porter_duff_constants[13]); + pipelines_->screen_blend.CreateDefault(*context_, options_trianglestrip, + porter_duff_constants[14]); } if (context_->GetCapabilities()->SupportsFramebufferFetch()) { - framebuffer_blend_color_pipelines_.CreateDefault( + pipelines_->framebuffer_blend_color.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kColor), supports_decal}); - framebuffer_blend_colorburn_pipelines_.CreateDefault( + pipelines_->framebuffer_blend_colorburn.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kColorBurn), supports_decal}); - framebuffer_blend_colordodge_pipelines_.CreateDefault( + pipelines_->framebuffer_blend_colordodge.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kColorDodge), supports_decal}); - framebuffer_blend_darken_pipelines_.CreateDefault( + pipelines_->framebuffer_blend_darken.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kDarken), supports_decal}); - framebuffer_blend_difference_pipelines_.CreateDefault( + pipelines_->framebuffer_blend_difference.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kDifference), supports_decal}); - framebuffer_blend_exclusion_pipelines_.CreateDefault( + pipelines_->framebuffer_blend_exclusion.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kExclusion), supports_decal}); - framebuffer_blend_hardlight_pipelines_.CreateDefault( + pipelines_->framebuffer_blend_hardlight.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kHardLight), supports_decal}); - framebuffer_blend_hue_pipelines_.CreateDefault( + pipelines_->framebuffer_blend_hue.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kHue), supports_decal}); - framebuffer_blend_lighten_pipelines_.CreateDefault( + pipelines_->framebuffer_blend_lighten.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kLighten), supports_decal}); - framebuffer_blend_luminosity_pipelines_.CreateDefault( + pipelines_->framebuffer_blend_luminosity.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kLuminosity), supports_decal}); - framebuffer_blend_multiply_pipelines_.CreateDefault( + pipelines_->framebuffer_blend_multiply.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kMultiply), supports_decal}); - framebuffer_blend_overlay_pipelines_.CreateDefault( + pipelines_->framebuffer_blend_overlay.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kOverlay), supports_decal}); - framebuffer_blend_saturation_pipelines_.CreateDefault( + pipelines_->framebuffer_blend_saturation.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kSaturation), supports_decal}); - framebuffer_blend_screen_pipelines_.CreateDefault( + pipelines_->framebuffer_blend_screen.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kScreen), supports_decal}); - framebuffer_blend_softlight_pipelines_.CreateDefault( + pipelines_->framebuffer_blend_softlight.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kSoftLight), supports_decal}); } else { - blend_color_pipelines_.CreateDefault( + pipelines_->blend_color.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kColor), supports_decal}); - blend_colorburn_pipelines_.CreateDefault( + pipelines_->blend_colorburn.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kColorBurn), supports_decal}); - blend_colordodge_pipelines_.CreateDefault( + pipelines_->blend_colordodge.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kColorDodge), supports_decal}); - blend_darken_pipelines_.CreateDefault( + pipelines_->blend_darken.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kDarken), supports_decal}); - blend_difference_pipelines_.CreateDefault( + pipelines_->blend_difference.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kDifference), supports_decal}); - blend_exclusion_pipelines_.CreateDefault( + pipelines_->blend_exclusion.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kExclusion), supports_decal}); - blend_hardlight_pipelines_.CreateDefault( + pipelines_->blend_hardlight.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kHardLight), supports_decal}); - blend_hue_pipelines_.CreateDefault( + pipelines_->blend_hue.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kHue), supports_decal}); - blend_lighten_pipelines_.CreateDefault( + pipelines_->blend_lighten.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kLighten), supports_decal}); - blend_luminosity_pipelines_.CreateDefault( + pipelines_->blend_luminosity.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kLuminosity), supports_decal}); - blend_multiply_pipelines_.CreateDefault( + pipelines_->blend_multiply.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kMultiply), supports_decal}); - blend_overlay_pipelines_.CreateDefault( + pipelines_->blend_overlay.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kOverlay), supports_decal}); - blend_saturation_pipelines_.CreateDefault( + pipelines_->blend_saturation.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kSaturation), supports_decal}); - blend_screen_pipelines_.CreateDefault( + pipelines_->blend_screen.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kScreen), supports_decal}); - blend_softlight_pipelines_.CreateDefault( + pipelines_->blend_softlight.CreateDefault( *context_, options_trianglestrip, {static_cast(BlendSelectValues::kSoftLight), supports_decal}); } - morphology_filter_pipelines_.CreateDefault(*context_, options_trianglestrip, - {supports_decal}); - linear_to_srgb_filter_pipelines_.CreateDefault(*context_, - options_trianglestrip); - srgb_to_linear_filter_pipelines_.CreateDefault(*context_, - options_trianglestrip); - yuv_to_rgb_filter_pipelines_.CreateDefault(*context_, options_trianglestrip); + pipelines_->morphology_filter.CreateDefault(*context_, options_trianglestrip, + {supports_decal}); + pipelines_->linear_to_srgb_filter.CreateDefault(*context_, + options_trianglestrip); + pipelines_->srgb_to_linear_filter.CreateDefault(*context_, + options_trianglestrip); + pipelines_->yuv_to_rgb_filter.CreateDefault(*context_, options_trianglestrip); #if defined(IMPELLER_ENABLE_OPENGLES) if (GetContext()->GetBackendType() == Context::BackendType::kOpenGLES) { #if !defined(FML_OS_MACOSX) // GLES only shader that is unsupported on macOS. - tiled_texture_external_pipelines_.CreateDefault(*context_, options); - tiled_texture_uv_external_pipelines_.CreateDefault(*context_, options); + pipelines_->tiled_texture_external.CreateDefault(*context_, options); + pipelines_->tiled_texture_uv_external.CreateDefault(*context_, options); #endif // !defined(FML_OS_MACOSX) - texture_downsample_gles_pipelines_.CreateDefault(*context_, - options_trianglestrip); + pipelines_->texture_downsample_gles.CreateDefault(*context_, + options_trianglestrip); } #endif // IMPELLER_ENABLE_OPENGLES @@ -686,39 +951,39 @@ void ContentContext::InitializeCommonlyUsedShadersIfNeeded() const { PipelineRef ContentContext::GetFastGradientPipeline( ContentContextOptions opts) const { - return GetPipeline(fast_gradient_pipelines_, opts); + return GetPipeline(this, pipelines_->fast_gradient, opts); } PipelineRef ContentContext::GetLinearGradientFillPipeline( ContentContextOptions opts) const { - return GetPipeline(linear_gradient_fill_pipelines_, opts); + return GetPipeline(this, pipelines_->linear_gradient_fill, opts); } PipelineRef ContentContext::GetLinearGradientUniformFillPipeline( ContentContextOptions opts) const { - return GetPipeline(linear_gradient_uniform_fill_pipelines_, opts); + return GetPipeline(this, pipelines_->linear_gradient_uniform_fill, opts); } PipelineRef ContentContext::GetRadialGradientUniformFillPipeline( ContentContextOptions opts) const { - return GetPipeline(radial_gradient_uniform_fill_pipelines_, opts); + return GetPipeline(this, pipelines_->radial_gradient_uniform_fill, opts); } PipelineRef ContentContext::GetSweepGradientUniformFillPipeline( ContentContextOptions opts) const { - return GetPipeline(sweep_gradient_uniform_fill_pipelines_, opts); + return GetPipeline(this, pipelines_->sweep_gradient_uniform_fill, opts); } PipelineRef ContentContext::GetLinearGradientSSBOFillPipeline( ContentContextOptions opts) const { FML_DCHECK(GetDeviceCapabilities().SupportsSSBO()); - return GetPipeline(linear_gradient_ssbo_fill_pipelines_, opts); + return GetPipeline(this, pipelines_->linear_gradient_ssbo_fill, opts); } PipelineRef ContentContext::GetRadialGradientSSBOFillPipeline( ContentContextOptions opts) const { FML_DCHECK(GetDeviceCapabilities().SupportsSSBO()); - return GetPipeline(radial_gradient_ssbo_fill_pipelines_, opts); + return GetPipeline(this, pipelines_->radial_gradient_ssbo_fill, opts); } PipelineRef ContentContext::GetConicalGradientUniformFillPipeline( @@ -726,14 +991,17 @@ PipelineRef ContentContext::GetConicalGradientUniformFillPipeline( ConicalKind kind) const { switch (kind) { case ConicalKind::kConical: - return GetPipeline(conical_gradient_uniform_fill_pipelines_, opts); + return GetPipeline(this, pipelines_->conical_gradient_uniform_fill, opts); case ConicalKind::kRadial: - return GetPipeline(conical_gradient_uniform_fill_radial_pipelines_, opts); + return GetPipeline(this, pipelines_->conical_gradient_uniform_fill_radial, + opts); case ConicalKind::kStrip: - return GetPipeline(conical_gradient_uniform_fill_strip_pipelines_, opts); + return GetPipeline(this, pipelines_->conical_gradient_uniform_fill_strip, + opts); case ConicalKind::kStripAndRadial: return GetPipeline( - conical_gradient_uniform_fill_strip_and_radial_pipelines_, opts); + this, pipelines_->conical_gradient_uniform_fill_strip_and_radial, + opts); } } @@ -743,26 +1011,28 @@ PipelineRef ContentContext::GetConicalGradientSSBOFillPipeline( FML_DCHECK(GetDeviceCapabilities().SupportsSSBO()); switch (kind) { case ConicalKind::kConical: - return GetPipeline(conical_gradient_ssbo_fill_pipelines_, opts); + return GetPipeline(this, pipelines_->conical_gradient_ssbo_fill, opts); case ConicalKind::kRadial: - return GetPipeline(conical_gradient_ssbo_fill_radial_pipelines_, opts); - case ConicalKind::kStrip: - return GetPipeline(conical_gradient_ssbo_fill_strip_pipelines_, opts); - case ConicalKind::kStripAndRadial: - return GetPipeline(conical_gradient_ssbo_fill_strip_and_radial_pipelines_, + return GetPipeline(this, pipelines_->conical_gradient_ssbo_fill_radial, opts); + case ConicalKind::kStrip: + return GetPipeline(this, pipelines_->conical_gradient_ssbo_fill_strip, + opts); + case ConicalKind::kStripAndRadial: + return GetPipeline( + this, pipelines_->conical_gradient_ssbo_fill_strip_and_radial, opts); } } PipelineRef ContentContext::GetSweepGradientSSBOFillPipeline( ContentContextOptions opts) const { FML_DCHECK(GetDeviceCapabilities().SupportsSSBO()); - return GetPipeline(sweep_gradient_ssbo_fill_pipelines_, opts); + return GetPipeline(this, pipelines_->sweep_gradient_ssbo_fill, opts); } PipelineRef ContentContext::GetRadialGradientFillPipeline( ContentContextOptions opts) const { - return GetPipeline(radial_gradient_fill_pipelines_, opts); + return GetPipeline(this, pipelines_->radial_gradient_fill, opts); } PipelineRef ContentContext::GetConicalGradientFillPipeline( @@ -770,89 +1040,89 @@ PipelineRef ContentContext::GetConicalGradientFillPipeline( ConicalKind kind) const { switch (kind) { case ConicalKind::kConical: - return GetPipeline(conical_gradient_fill_pipelines_, opts); + return GetPipeline(this, pipelines_->conical_gradient_fill, opts); case ConicalKind::kRadial: - return GetPipeline(conical_gradient_fill_radial_pipelines_, opts); + return GetPipeline(this, pipelines_->conical_gradient_fill_radial, opts); case ConicalKind::kStrip: - return GetPipeline(conical_gradient_fill_strip_pipelines_, opts); + return GetPipeline(this, pipelines_->conical_gradient_fill_strip, opts); case ConicalKind::kStripAndRadial: - return GetPipeline(conical_gradient_fill_strip_and_radial_pipelines_, - opts); + return GetPipeline( + this, pipelines_->conical_gradient_fill_strip_and_radial, opts); } } PipelineRef ContentContext::GetRRectBlurPipeline( ContentContextOptions opts) const { - return GetPipeline(rrect_blur_pipelines_, opts); + return GetPipeline(this, pipelines_->rrect_blur, opts); } PipelineRef ContentContext::GetSweepGradientFillPipeline( ContentContextOptions opts) const { - return GetPipeline(sweep_gradient_fill_pipelines_, opts); + return GetPipeline(this, pipelines_->sweep_gradient_fill, opts); } PipelineRef ContentContext::GetSolidFillPipeline( ContentContextOptions opts) const { - return GetPipeline(solid_fill_pipelines_, opts); + return GetPipeline(this, pipelines_->solid_fill, opts); } PipelineRef ContentContext::GetTexturePipeline( ContentContextOptions opts) const { - return GetPipeline(texture_pipelines_, opts); + return GetPipeline(this, pipelines_->texture, opts); } PipelineRef ContentContext::GetTextureStrictSrcPipeline( ContentContextOptions opts) const { - return GetPipeline(texture_strict_src_pipelines_, opts); + return GetPipeline(this, pipelines_->texture_strict_src, opts); } PipelineRef ContentContext::GetTiledTexturePipeline( ContentContextOptions opts) const { - return GetPipeline(tiled_texture_pipelines_, opts); + return GetPipeline(this, pipelines_->tiled_texture, opts); } PipelineRef ContentContext::GetGaussianBlurPipeline( ContentContextOptions opts) const { - return GetPipeline(gaussian_blur_pipelines_, opts); + return GetPipeline(this, pipelines_->gaussian_blur, opts); } PipelineRef ContentContext::GetBorderMaskBlurPipeline( ContentContextOptions opts) const { - return GetPipeline(border_mask_blur_pipelines_, opts); + return GetPipeline(this, pipelines_->border_mask_blur, opts); } PipelineRef ContentContext::GetMorphologyFilterPipeline( ContentContextOptions opts) const { - return GetPipeline(morphology_filter_pipelines_, opts); + return GetPipeline(this, pipelines_->morphology_filter, opts); } PipelineRef ContentContext::GetColorMatrixColorFilterPipeline( ContentContextOptions opts) const { - return GetPipeline(color_matrix_color_filter_pipelines_, opts); + return GetPipeline(this, pipelines_->color_matrix_color_filter, opts); } PipelineRef ContentContext::GetLinearToSrgbFilterPipeline( ContentContextOptions opts) const { - return GetPipeline(linear_to_srgb_filter_pipelines_, opts); + return GetPipeline(this, pipelines_->linear_to_srgb_filter, opts); } PipelineRef ContentContext::GetSrgbToLinearFilterPipeline( ContentContextOptions opts) const { - return GetPipeline(srgb_to_linear_filter_pipelines_, opts); + return GetPipeline(this, pipelines_->srgb_to_linear_filter, opts); } PipelineRef ContentContext::GetClipPipeline(ContentContextOptions opts) const { - return GetPipeline(clip_pipelines_, opts); + return GetPipeline(this, pipelines_->clip, opts); } PipelineRef ContentContext::GetGlyphAtlasPipeline( ContentContextOptions opts) const { - return GetPipeline(glyph_atlas_pipelines_, opts); + return GetPipeline(this, pipelines_->glyph_atlas, opts); } PipelineRef ContentContext::GetYUVToRGBFilterPipeline( ContentContextOptions opts) const { - return GetPipeline(yuv_to_rgb_filter_pipelines_, opts); + return GetPipeline(this, pipelines_->yuv_to_rgb_filter, opts); } PipelineRef ContentContext::GetPorterDuffPipeline( @@ -912,274 +1182,274 @@ PipelineRef ContentContext::GetPorterDuffPipeline( PipelineRef ContentContext::GetClearBlendPipeline( ContentContextOptions opts) const { - return GetPipeline(clear_blend_pipelines_, opts); + return GetPipeline(this, pipelines_->clear_blend, opts); } PipelineRef ContentContext::GetSourceBlendPipeline( ContentContextOptions opts) const { - return GetPipeline(source_blend_pipelines_, opts); + return GetPipeline(this, pipelines_->source_blend, opts); } PipelineRef ContentContext::GetDestinationBlendPipeline( ContentContextOptions opts) const { - return GetPipeline(destination_blend_pipelines_, opts); + return GetPipeline(this, pipelines_->destination_blend, opts); } PipelineRef ContentContext::GetSourceOverBlendPipeline( ContentContextOptions opts) const { - return GetPipeline(source_over_blend_pipelines_, opts); + return GetPipeline(this, pipelines_->source_over_blend, opts); } PipelineRef ContentContext::GetDestinationOverBlendPipeline( ContentContextOptions opts) const { - return GetPipeline(destination_over_blend_pipelines_, opts); + return GetPipeline(this, pipelines_->destination_over_blend, opts); } PipelineRef ContentContext::GetSourceInBlendPipeline( ContentContextOptions opts) const { - return GetPipeline(source_in_blend_pipelines_, opts); + return GetPipeline(this, pipelines_->source_in_blend, opts); } PipelineRef ContentContext::GetDestinationInBlendPipeline( ContentContextOptions opts) const { - return GetPipeline(destination_in_blend_pipelines_, opts); + return GetPipeline(this, pipelines_->destination_in_blend, opts); } PipelineRef ContentContext::GetSourceOutBlendPipeline( ContentContextOptions opts) const { - return GetPipeline(source_out_blend_pipelines_, opts); + return GetPipeline(this, pipelines_->source_out_blend, opts); } PipelineRef ContentContext::GetDestinationOutBlendPipeline( ContentContextOptions opts) const { - return GetPipeline(destination_out_blend_pipelines_, opts); + return GetPipeline(this, pipelines_->destination_out_blend, opts); } PipelineRef ContentContext::GetSourceATopBlendPipeline( ContentContextOptions opts) const { - return GetPipeline(source_a_top_blend_pipelines_, opts); + return GetPipeline(this, pipelines_->source_a_top_blend, opts); } PipelineRef ContentContext::GetDestinationATopBlendPipeline( ContentContextOptions opts) const { - return GetPipeline(destination_a_top_blend_pipelines_, opts); + return GetPipeline(this, pipelines_->destination_a_top_blend, opts); } PipelineRef ContentContext::GetXorBlendPipeline( ContentContextOptions opts) const { - return GetPipeline(xor_blend_pipelines_, opts); + return GetPipeline(this, pipelines_->xor_blend, opts); } PipelineRef ContentContext::GetPlusBlendPipeline( ContentContextOptions opts) const { - return GetPipeline(plus_blend_pipelines_, opts); + return GetPipeline(this, pipelines_->plus_blend, opts); } PipelineRef ContentContext::GetModulateBlendPipeline( ContentContextOptions opts) const { - return GetPipeline(modulate_blend_pipelines_, opts); + return GetPipeline(this, pipelines_->modulate_blend, opts); } PipelineRef ContentContext::GetScreenBlendPipeline( ContentContextOptions opts) const { - return GetPipeline(screen_blend_pipelines_, opts); + return GetPipeline(this, pipelines_->screen_blend, opts); } PipelineRef ContentContext::GetBlendColorPipeline( ContentContextOptions opts) const { - return GetPipeline(blend_color_pipelines_, opts); + return GetPipeline(this, pipelines_->blend_color, opts); } PipelineRef ContentContext::GetBlendColorBurnPipeline( ContentContextOptions opts) const { - return GetPipeline(blend_colorburn_pipelines_, opts); + return GetPipeline(this, pipelines_->blend_colorburn, opts); } PipelineRef ContentContext::GetBlendColorDodgePipeline( ContentContextOptions opts) const { - return GetPipeline(blend_colordodge_pipelines_, opts); + return GetPipeline(this, pipelines_->blend_colordodge, opts); } PipelineRef ContentContext::GetBlendDarkenPipeline( ContentContextOptions opts) const { - return GetPipeline(blend_darken_pipelines_, opts); + return GetPipeline(this, pipelines_->blend_darken, opts); } PipelineRef ContentContext::GetBlendDifferencePipeline( ContentContextOptions opts) const { - return GetPipeline(blend_difference_pipelines_, opts); + return GetPipeline(this, pipelines_->blend_difference, opts); } PipelineRef ContentContext::GetBlendExclusionPipeline( ContentContextOptions opts) const { - return GetPipeline(blend_exclusion_pipelines_, opts); + return GetPipeline(this, pipelines_->blend_exclusion, opts); } PipelineRef ContentContext::GetBlendHardLightPipeline( ContentContextOptions opts) const { - return GetPipeline(blend_hardlight_pipelines_, opts); + return GetPipeline(this, pipelines_->blend_hardlight, opts); } PipelineRef ContentContext::GetBlendHuePipeline( ContentContextOptions opts) const { - return GetPipeline(blend_hue_pipelines_, opts); + return GetPipeline(this, pipelines_->blend_hue, opts); } PipelineRef ContentContext::GetBlendLightenPipeline( ContentContextOptions opts) const { - return GetPipeline(blend_lighten_pipelines_, opts); + return GetPipeline(this, pipelines_->blend_lighten, opts); } PipelineRef ContentContext::GetBlendLuminosityPipeline( ContentContextOptions opts) const { - return GetPipeline(blend_luminosity_pipelines_, opts); + return GetPipeline(this, pipelines_->blend_luminosity, opts); } PipelineRef ContentContext::GetBlendMultiplyPipeline( ContentContextOptions opts) const { - return GetPipeline(blend_multiply_pipelines_, opts); + return GetPipeline(this, pipelines_->blend_multiply, opts); } PipelineRef ContentContext::GetBlendOverlayPipeline( ContentContextOptions opts) const { - return GetPipeline(blend_overlay_pipelines_, opts); + return GetPipeline(this, pipelines_->blend_overlay, opts); } PipelineRef ContentContext::GetBlendSaturationPipeline( ContentContextOptions opts) const { - return GetPipeline(blend_saturation_pipelines_, opts); + return GetPipeline(this, pipelines_->blend_saturation, opts); } PipelineRef ContentContext::GetBlendScreenPipeline( ContentContextOptions opts) const { - return GetPipeline(blend_screen_pipelines_, opts); + return GetPipeline(this, pipelines_->blend_screen, opts); } PipelineRef ContentContext::GetBlendSoftLightPipeline( ContentContextOptions opts) const { - return GetPipeline(blend_softlight_pipelines_, opts); + return GetPipeline(this, pipelines_->blend_softlight, opts); } PipelineRef ContentContext::GetDownsamplePipeline( ContentContextOptions opts) const { - return GetPipeline(texture_downsample_pipelines_, opts); + return GetPipeline(this, pipelines_->texture_downsample, opts); } PipelineRef ContentContext::GetFramebufferBlendColorPipeline( ContentContextOptions opts) const { FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch()); - return GetPipeline(framebuffer_blend_color_pipelines_, opts); + return GetPipeline(this, pipelines_->framebuffer_blend_color, opts); } PipelineRef ContentContext::GetFramebufferBlendColorBurnPipeline( ContentContextOptions opts) const { FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch()); - return GetPipeline(framebuffer_blend_colorburn_pipelines_, opts); + return GetPipeline(this, pipelines_->framebuffer_blend_colorburn, opts); } PipelineRef ContentContext::GetFramebufferBlendColorDodgePipeline( ContentContextOptions opts) const { FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch()); - return GetPipeline(framebuffer_blend_colordodge_pipelines_, opts); + return GetPipeline(this, pipelines_->framebuffer_blend_colordodge, opts); } PipelineRef ContentContext::GetFramebufferBlendDarkenPipeline( ContentContextOptions opts) const { FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch()); - return GetPipeline(framebuffer_blend_darken_pipelines_, opts); + return GetPipeline(this, pipelines_->framebuffer_blend_darken, opts); } PipelineRef ContentContext::GetFramebufferBlendDifferencePipeline( ContentContextOptions opts) const { FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch()); - return GetPipeline(framebuffer_blend_difference_pipelines_, opts); + return GetPipeline(this, pipelines_->framebuffer_blend_difference, opts); } PipelineRef ContentContext::GetFramebufferBlendExclusionPipeline( ContentContextOptions opts) const { FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch()); - return GetPipeline(framebuffer_blend_exclusion_pipelines_, opts); + return GetPipeline(this, pipelines_->framebuffer_blend_exclusion, opts); } PipelineRef ContentContext::GetFramebufferBlendHardLightPipeline( ContentContextOptions opts) const { FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch()); - return GetPipeline(framebuffer_blend_hardlight_pipelines_, opts); + return GetPipeline(this, pipelines_->framebuffer_blend_hardlight, opts); } PipelineRef ContentContext::GetFramebufferBlendHuePipeline( ContentContextOptions opts) const { FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch()); - return GetPipeline(framebuffer_blend_hue_pipelines_, opts); + return GetPipeline(this, pipelines_->framebuffer_blend_hue, opts); } PipelineRef ContentContext::GetFramebufferBlendLightenPipeline( ContentContextOptions opts) const { FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch()); - return GetPipeline(framebuffer_blend_lighten_pipelines_, opts); + return GetPipeline(this, pipelines_->framebuffer_blend_lighten, opts); } PipelineRef ContentContext::GetFramebufferBlendLuminosityPipeline( ContentContextOptions opts) const { FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch()); - return GetPipeline(framebuffer_blend_luminosity_pipelines_, opts); + return GetPipeline(this, pipelines_->framebuffer_blend_luminosity, opts); } PipelineRef ContentContext::GetFramebufferBlendMultiplyPipeline( ContentContextOptions opts) const { FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch()); - return GetPipeline(framebuffer_blend_multiply_pipelines_, opts); + return GetPipeline(this, pipelines_->framebuffer_blend_multiply, opts); } PipelineRef ContentContext::GetFramebufferBlendOverlayPipeline( ContentContextOptions opts) const { FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch()); - return GetPipeline(framebuffer_blend_overlay_pipelines_, opts); + return GetPipeline(this, pipelines_->framebuffer_blend_overlay, opts); } PipelineRef ContentContext::GetFramebufferBlendSaturationPipeline( ContentContextOptions opts) const { FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch()); - return GetPipeline(framebuffer_blend_saturation_pipelines_, opts); + return GetPipeline(this, pipelines_->framebuffer_blend_saturation, opts); } PipelineRef ContentContext::GetFramebufferBlendScreenPipeline( ContentContextOptions opts) const { FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch()); - return GetPipeline(framebuffer_blend_screen_pipelines_, opts); + return GetPipeline(this, pipelines_->framebuffer_blend_screen, opts); } PipelineRef ContentContext::GetFramebufferBlendSoftLightPipeline( ContentContextOptions opts) const { FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch()); - return GetPipeline(framebuffer_blend_softlight_pipelines_, opts); + return GetPipeline(this, pipelines_->framebuffer_blend_softlight, opts); } PipelineRef ContentContext::GetDrawVerticesUberShader( ContentContextOptions opts) const { - return GetPipeline(vertices_uber_shader_, opts); + return GetPipeline(this, pipelines_->vertices_uber_shader_, opts); } PipelineRef ContentContext::GetLinePipeline(ContentContextOptions opts) const { - return GetPipeline(line_pipelines_, opts); + return GetPipeline(this, pipelines_->line, opts); } #ifdef IMPELLER_ENABLE_OPENGLES PipelineRef ContentContext::GetDownsampleTextureGlesPipeline( ContentContextOptions opts) const { - return GetPipeline(texture_downsample_gles_pipelines_, opts); + return GetPipeline(this, pipelines_->texture_downsample_gles, opts); } PipelineRef ContentContext::GetTiledTextureExternalPipeline( ContentContextOptions opts) const { FML_DCHECK(GetContext()->GetBackendType() == Context::BackendType::kOpenGLES); - return GetPipeline(tiled_texture_external_pipelines_, opts); + return GetPipeline(this, pipelines_->tiled_texture_external, opts); } PipelineRef ContentContext::GetTiledTextureUvExternalPipeline( ContentContextOptions opts) const { FML_DCHECK(GetContext()->GetBackendType() == Context::BackendType::kOpenGLES); - return GetPipeline(tiled_texture_uv_external_pipelines_, opts); + return GetPipeline(this, pipelines_->tiled_texture_uv_external, opts); } #endif // IMPELLER_ENABLE_OPENGLES diff --git a/engine/src/flutter/impeller/entity/contents/content_context.h b/engine/src/flutter/impeller/entity/contents/content_context.h index f24ae29e89..5c91345bcd 100644 --- a/engine/src/flutter/impeller/entity/contents/content_context.h +++ b/engine/src/flutter/impeller/entity/contents/content_context.h @@ -25,166 +25,7 @@ #include "impeller/typographer/lazy_glyph_atlas.h" #include "impeller/typographer/typographer_context.h" -#include "impeller/entity/border_mask_blur.frag.h" -#include "impeller/entity/clip.frag.h" -#include "impeller/entity/clip.vert.h" -#include "impeller/entity/color_matrix_color_filter.frag.h" -#include "impeller/entity/conical_gradient_fill_conical.frag.h" -#include "impeller/entity/conical_gradient_fill_radial.frag.h" -#include "impeller/entity/conical_gradient_fill_strip.frag.h" -#include "impeller/entity/conical_gradient_fill_strip_radial.frag.h" -#include "impeller/entity/fast_gradient.frag.h" -#include "impeller/entity/fast_gradient.vert.h" -#include "impeller/entity/filter_position.vert.h" -#include "impeller/entity/filter_position_uv.vert.h" -#include "impeller/entity/gaussian.frag.h" -#include "impeller/entity/glyph_atlas.frag.h" -#include "impeller/entity/glyph_atlas.vert.h" -#include "impeller/entity/gradient_fill.vert.h" -#include "impeller/entity/line.frag.h" -#include "impeller/entity/line.vert.h" -#include "impeller/entity/linear_gradient_fill.frag.h" -#include "impeller/entity/linear_to_srgb_filter.frag.h" -#include "impeller/entity/morphology_filter.frag.h" -#include "impeller/entity/porter_duff_blend.frag.h" -#include "impeller/entity/porter_duff_blend.vert.h" -#include "impeller/entity/radial_gradient_fill.frag.h" -#include "impeller/entity/rrect_blur.frag.h" -#include "impeller/entity/rrect_blur.vert.h" -#include "impeller/entity/solid_fill.frag.h" -#include "impeller/entity/solid_fill.vert.h" -#include "impeller/entity/srgb_to_linear_filter.frag.h" -#include "impeller/entity/sweep_gradient_fill.frag.h" -#include "impeller/entity/texture_downsample.frag.h" -#include "impeller/entity/texture_fill.frag.h" -#include "impeller/entity/texture_fill.vert.h" -#include "impeller/entity/texture_fill_strict_src.frag.h" -#include "impeller/entity/texture_uv_fill.vert.h" -#include "impeller/entity/tiled_texture_fill.frag.h" -#include "impeller/entity/yuv_to_rgb_filter.frag.h" - -#include "impeller/entity/conical_gradient_uniform_fill_conical.frag.h" -#include "impeller/entity/conical_gradient_uniform_fill_radial.frag.h" -#include "impeller/entity/conical_gradient_uniform_fill_strip.frag.h" -#include "impeller/entity/conical_gradient_uniform_fill_strip_radial.frag.h" -#include "impeller/entity/linear_gradient_uniform_fill.frag.h" -#include "impeller/entity/radial_gradient_uniform_fill.frag.h" -#include "impeller/entity/sweep_gradient_uniform_fill.frag.h" - -#include "impeller/entity/conical_gradient_ssbo_fill.frag.h" -#include "impeller/entity/linear_gradient_ssbo_fill.frag.h" -#include "impeller/entity/radial_gradient_ssbo_fill.frag.h" -#include "impeller/entity/sweep_gradient_ssbo_fill.frag.h" - -#include "impeller/entity/advanced_blend.frag.h" -#include "impeller/entity/advanced_blend.vert.h" - -#include "impeller/entity/framebuffer_blend.frag.h" -#include "impeller/entity/framebuffer_blend.vert.h" - -#include "impeller/entity/vertices_uber.frag.h" - -#ifdef IMPELLER_ENABLE_OPENGLES -#include "impeller/entity/texture_downsample_gles.frag.h" -#include "impeller/entity/tiled_texture_fill_external.frag.h" -#endif // IMPELLER_ENABLE_OPENGLES - namespace impeller { - -template -using GradientPipelineHandle = - RenderPipelineHandle; - -using AdvancedBlendPipelineHandle = - RenderPipelineHandle; - -using FramebufferBlendPipelineHandle = - RenderPipelineHandle; - -// clang-format off -using BlendColorBurnPipeline = AdvancedBlendPipelineHandle; -using BlendColorDodgePipeline = AdvancedBlendPipelineHandle; -using BlendColorPipeline = AdvancedBlendPipelineHandle; -using BlendDarkenPipeline = AdvancedBlendPipelineHandle; -using BlendDifferencePipeline = AdvancedBlendPipelineHandle; -using BlendExclusionPipeline = AdvancedBlendPipelineHandle; -using BlendHardLightPipeline = AdvancedBlendPipelineHandle; -using BlendHuePipeline = AdvancedBlendPipelineHandle; -using BlendLightenPipeline = AdvancedBlendPipelineHandle; -using BlendLuminosityPipeline = AdvancedBlendPipelineHandle; -using BlendMultiplyPipeline = AdvancedBlendPipelineHandle; -using BlendOverlayPipeline = AdvancedBlendPipelineHandle; -using BlendSaturationPipeline = AdvancedBlendPipelineHandle; -using BlendScreenPipeline = AdvancedBlendPipelineHandle; -using BlendSoftLightPipeline = AdvancedBlendPipelineHandle; -using BorderMaskBlurPipeline = RenderPipelineHandle; -using ClipPipeline = RenderPipelineHandle; -using ColorMatrixColorFilterPipeline = RenderPipelineHandle; -using ConicalGradientFillConicalPipeline = GradientPipelineHandle; -using ConicalGradientFillRadialPipeline = GradientPipelineHandle; -using ConicalGradientFillStripPipeline = GradientPipelineHandle; -using ConicalGradientFillStripRadialPipeline = GradientPipelineHandle; -using ConicalGradientSSBOFillPipeline = GradientPipelineHandle; -using ConicalGradientUniformFillConicalPipeline = GradientPipelineHandle; -using ConicalGradientUniformFillRadialPipeline = GradientPipelineHandle; -using ConicalGradientUniformFillStripPipeline = GradientPipelineHandle; -using ConicalGradientUniformFillStripRadialPipeline = GradientPipelineHandle; -using FastGradientPipeline = RenderPipelineHandle; -using FramebufferBlendColorBurnPipeline = FramebufferBlendPipelineHandle; -using FramebufferBlendColorDodgePipeline = FramebufferBlendPipelineHandle; -using FramebufferBlendColorPipeline = FramebufferBlendPipelineHandle; -using FramebufferBlendDarkenPipeline = FramebufferBlendPipelineHandle; -using FramebufferBlendDifferencePipeline = FramebufferBlendPipelineHandle; -using FramebufferBlendExclusionPipeline = FramebufferBlendPipelineHandle; -using FramebufferBlendHardLightPipeline = FramebufferBlendPipelineHandle; -using FramebufferBlendHuePipeline = FramebufferBlendPipelineHandle; -using FramebufferBlendLightenPipeline = FramebufferBlendPipelineHandle; -using FramebufferBlendLuminosityPipeline = FramebufferBlendPipelineHandle; -using FramebufferBlendMultiplyPipeline = FramebufferBlendPipelineHandle; -using FramebufferBlendOverlayPipeline = FramebufferBlendPipelineHandle; -using FramebufferBlendSaturationPipeline = FramebufferBlendPipelineHandle; -using FramebufferBlendScreenPipeline = FramebufferBlendPipelineHandle; -using FramebufferBlendSoftLightPipeline = FramebufferBlendPipelineHandle; -using GaussianBlurPipeline = RenderPipelineHandle; -using GlyphAtlasPipeline = RenderPipelineHandle; -using LinePipeline = RenderPipelineHandle; -using LinearGradientFillPipeline = GradientPipelineHandle; -using LinearGradientSSBOFillPipeline = GradientPipelineHandle; -using LinearGradientUniformFillPipeline = GradientPipelineHandle; -using LinearToSrgbFilterPipeline = RenderPipelineHandle; -using MorphologyFilterPipeline = RenderPipelineHandle; -using PorterDuffBlendPipeline = RenderPipelineHandle; -using RadialGradientFillPipeline = GradientPipelineHandle; -using RadialGradientSSBOFillPipeline = GradientPipelineHandle; -using RadialGradientUniformFillPipeline = GradientPipelineHandle; -using RRectBlurPipeline = RenderPipelineHandle; -using SolidFillPipeline = RenderPipelineHandle; -using SrgbToLinearFilterPipeline = RenderPipelineHandle; -using SweepGradientFillPipeline = GradientPipelineHandle; -using SweepGradientSSBOFillPipeline = GradientPipelineHandle; -using SweepGradientUniformFillPipeline = GradientPipelineHandle; -using TextureDownsamplePipeline = RenderPipelineHandle; -using TexturePipeline = RenderPipelineHandle; -using TextureStrictSrcPipeline = RenderPipelineHandle; -using TiledTexturePipeline = RenderPipelineHandle; -using VerticesUberShader = RenderPipelineHandle; -using YUVToRGBFilterPipeline = RenderPipelineHandle; -// clang-format on - -#ifdef IMPELLER_ENABLE_OPENGLES -using TiledTextureExternalPipeline = - RenderPipelineHandle; -using TiledTextureUvExternalPipeline = - RenderPipelineHandle; -using TextureDownsampleGlesPipeline = - RenderPipelineHandle; -#endif // IMPELLER_ENABLE_OPENGLES - /// Pipeline state configuration. /// /// Each unique combination of these options requires a different pipeline state @@ -494,257 +335,8 @@ class ContentContext { RuntimeEffectPipelineKey::Equal> runtime_effect_pipelines_; - /// Holds multiple Pipelines associated with the same PipelineHandle types. - /// - /// For example, it may have multiple - /// RenderPipelineHandle - /// instances for different blend modes. From them you can access the - /// Pipeline. - /// - /// See also: - /// - impeller::ContentContextOptions - options from which variants are - /// created. - /// - impeller::Pipeline::CreateVariant - /// - impeller::RenderPipelineHandle<> - The type of objects this typically - /// contains. - template - class Variants { - public: - Variants() = default; - - void Set(const ContentContextOptions& options, - std::unique_ptr pipeline) { - uint64_t p_key = options.ToKey(); - for (const auto& [key, pipeline] : pipelines_) { - if (key == p_key) { - return; - } - } - pipelines_.push_back(std::make_pair(p_key, std::move(pipeline))); - } - - void SetDefault(const ContentContextOptions& options, - std::unique_ptr pipeline) { - default_options_ = options; - if (pipeline) { - Set(options, std::move(pipeline)); - } - } - - void SetDefaultDescriptor(std::optional desc) { - desc_ = std::move(desc); - } - - void CreateDefault(const Context& context, - const ContentContextOptions& options, - const std::vector& constants = {}) { - auto desc = PipelineHandleT::Builder::MakeDefaultPipelineDescriptor( - context, constants); - if (!desc.has_value()) { - VALIDATION_LOG << "Failed to create default pipeline."; - return; - } - options.ApplyToPipelineDescriptor(*desc); - desc_ = desc; - if (context.GetFlags().lazy_shader_mode) { - SetDefault(options, nullptr); - } else { - SetDefault(options, std::make_unique(context, desc_, - /*async=*/true)); - } - } - - PipelineHandleT* Get(const ContentContextOptions& options) const { - uint64_t p_key = options.ToKey(); - for (const auto& [key, pipeline] : pipelines_) { - if (key == p_key) { - return pipeline.get(); - } - } - return nullptr; - } - - bool IsDefault(const ContentContextOptions& opts) { - return default_options_.has_value() && - opts.ToKey() == default_options_.value().ToKey(); - } - - PipelineHandleT* GetDefault(const Context& context) { - if (!default_options_.has_value()) { - return nullptr; - } - PipelineHandleT* result = Get(default_options_.value()); - if (result != nullptr) { - return result; - } - SetDefault( - default_options_.value(), - std::make_unique(context, desc_, /*async=*/false)); - return Get(default_options_.value()); - } - - size_t GetPipelineCount() const { return pipelines_.size(); } - - private: - std::optional desc_; - std::optional default_options_; - std::vector>> - pipelines_; - - Variants(const Variants&) = delete; - - Variants& operator=(const Variants&) = delete; - }; - - // These are mutable because while the prototypes are created eagerly, any - // variants requested from that are lazily created and cached in the variants - // map. - - // clang-format off - mutable Variants blend_colorburn_pipelines_; - mutable Variants blend_colordodge_pipelines_; - mutable Variants blend_color_pipelines_; - mutable Variants blend_darken_pipelines_; - mutable Variants blend_difference_pipelines_; - mutable Variants blend_exclusion_pipelines_; - mutable Variants blend_hardlight_pipelines_; - mutable Variants blend_hue_pipelines_; - mutable Variants blend_lighten_pipelines_; - mutable Variants blend_luminosity_pipelines_; - mutable Variants blend_multiply_pipelines_; - mutable Variants blend_overlay_pipelines_; - mutable Variants blend_saturation_pipelines_; - mutable Variants blend_screen_pipelines_; - mutable Variants blend_softlight_pipelines_; - mutable Variants border_mask_blur_pipelines_; - mutable Variants clip_pipelines_; - mutable Variants color_matrix_color_filter_pipelines_; - mutable Variants conical_gradient_fill_pipelines_; - mutable Variants conical_gradient_fill_radial_pipelines_; - mutable Variants conical_gradient_fill_strip_pipelines_; - mutable Variants conical_gradient_fill_strip_and_radial_pipelines_; - mutable Variants conical_gradient_ssbo_fill_pipelines_; - mutable Variants conical_gradient_ssbo_fill_radial_pipelines_; - mutable Variants conical_gradient_ssbo_fill_strip_and_radial_pipelines_; - mutable Variants conical_gradient_ssbo_fill_strip_pipelines_; - mutable Variants conical_gradient_uniform_fill_pipelines_; - mutable Variants conical_gradient_uniform_fill_radial_pipelines_; - mutable Variants conical_gradient_uniform_fill_strip_pipelines_; - mutable Variants conical_gradient_uniform_fill_strip_and_radial_pipelines_; - mutable Variants fast_gradient_pipelines_; - mutable Variants framebuffer_blend_colorburn_pipelines_; - mutable Variants framebuffer_blend_colordodge_pipelines_; - mutable Variants framebuffer_blend_color_pipelines_; - mutable Variants framebuffer_blend_darken_pipelines_; - mutable Variants framebuffer_blend_difference_pipelines_; - mutable Variants framebuffer_blend_exclusion_pipelines_; - mutable Variants framebuffer_blend_hardlight_pipelines_; - mutable Variants framebuffer_blend_hue_pipelines_; - mutable Variants framebuffer_blend_lighten_pipelines_; - mutable Variants framebuffer_blend_luminosity_pipelines_; - mutable Variants framebuffer_blend_multiply_pipelines_; - mutable Variants framebuffer_blend_overlay_pipelines_; - mutable Variants framebuffer_blend_saturation_pipelines_; - mutable Variants framebuffer_blend_screen_pipelines_; - mutable Variants framebuffer_blend_softlight_pipelines_; - mutable Variants gaussian_blur_pipelines_; - mutable Variants glyph_atlas_pipelines_; - mutable Variants line_pipelines_; - mutable Variants linear_gradient_fill_pipelines_; - mutable Variants linear_gradient_ssbo_fill_pipelines_; - mutable Variants linear_gradient_uniform_fill_pipelines_; - mutable Variants linear_to_srgb_filter_pipelines_; - mutable Variants morphology_filter_pipelines_; - mutable Variants clear_blend_pipelines_; - mutable Variants destination_a_top_blend_pipelines_; - mutable Variants destination_blend_pipelines_; - mutable Variants destination_in_blend_pipelines_; - mutable Variants destination_out_blend_pipelines_; - mutable Variants destination_over_blend_pipelines_; - mutable Variants modulate_blend_pipelines_; - mutable Variants plus_blend_pipelines_; - mutable Variants screen_blend_pipelines_; - mutable Variants source_a_top_blend_pipelines_; - mutable Variants source_blend_pipelines_; - mutable Variants source_in_blend_pipelines_; - mutable Variants source_out_blend_pipelines_; - mutable Variants source_over_blend_pipelines_; - mutable Variants xor_blend_pipelines_; - mutable Variants radial_gradient_fill_pipelines_; - mutable Variants radial_gradient_ssbo_fill_pipelines_; - mutable Variants radial_gradient_uniform_fill_pipelines_; - mutable Variants rrect_blur_pipelines_; - mutable Variants solid_fill_pipelines_; - mutable Variants srgb_to_linear_filter_pipelines_; - mutable Variants sweep_gradient_fill_pipelines_; - mutable Variants sweep_gradient_ssbo_fill_pipelines_; - mutable Variants sweep_gradient_uniform_fill_pipelines_; - mutable Variants texture_downsample_pipelines_; - mutable Variants texture_pipelines_; - mutable Variants texture_strict_src_pipelines_; - mutable Variants tiled_texture_pipelines_; - mutable Variants vertices_uber_shader_; - mutable Variants yuv_to_rgb_filter_pipelines_; - -#ifdef IMPELLER_ENABLE_OPENGLES - mutable Variants tiled_texture_external_pipelines_; - mutable Variants texture_downsample_gles_pipelines_; - mutable Variants tiled_texture_uv_external_pipelines_; -#endif // IMPELLER_ENABLE_OPENGLES - // clang-format on - - template - PipelineRef GetPipeline(Variants& container, - ContentContextOptions opts) const { - TypedPipeline* pipeline = CreateIfNeeded(container, opts); - if (!pipeline) { - return raw_ptr>(); - } - return raw_ptr(pipeline->WaitAndGet()); - } - - template - RenderPipelineHandleT* CreateIfNeeded( - Variants& container, - ContentContextOptions opts) const { - if (!IsValid()) { - return nullptr; - } - - if (wireframe_) { - opts.wireframe = true; - } - - if (RenderPipelineHandleT* found = container.Get(opts)) { - return found; - } - - RenderPipelineHandleT* default_handle = container.GetDefault(*GetContext()); - if (container.IsDefault(opts)) { - return default_handle; - } - - // The default must always be initialized in the constructor. - FML_CHECK(default_handle != nullptr); - - const std::shared_ptr>& pipeline = - default_handle->WaitAndGet(); - if (!pipeline) { - return nullptr; - } - - auto variant_future = pipeline->CreateVariant( - /*async=*/false, [&opts, variants_count = container.GetPipelineCount()]( - PipelineDescriptor& desc) { - opts.ApplyToPipelineDescriptor(desc); - desc.SetLabel( - SPrintF("%s V#%zu", desc.GetLabel().data(), variants_count)); - }); - std::unique_ptr variant = - std::make_unique(std::move(variant_future)); - container.Set(opts, std::move(variant)); - return container.Get(opts); - } + struct Pipelines; + std::unique_ptr pipelines_; bool is_valid_ = false; std::shared_ptr tessellator_; diff --git a/engine/src/flutter/impeller/entity/contents/pipelines.h b/engine/src/flutter/impeller/entity/contents/pipelines.h new file mode 100644 index 0000000000..91ea4e15bc --- /dev/null +++ b/engine/src/flutter/impeller/entity/contents/pipelines.h @@ -0,0 +1,166 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef FLUTTER_IMPELLER_ENTITY_CONTENTS_PIPELINES_H_ +#define FLUTTER_IMPELLER_ENTITY_CONTENTS_PIPELINES_H_ + +#include "impeller/entity/advanced_blend.frag.h" +#include "impeller/entity/advanced_blend.vert.h" +#include "impeller/entity/border_mask_blur.frag.h" +#include "impeller/entity/clip.frag.h" +#include "impeller/entity/clip.vert.h" +#include "impeller/entity/color_matrix_color_filter.frag.h" +#include "impeller/entity/conical_gradient_fill_conical.frag.h" +#include "impeller/entity/conical_gradient_fill_radial.frag.h" +#include "impeller/entity/conical_gradient_fill_strip.frag.h" +#include "impeller/entity/conical_gradient_fill_strip_radial.frag.h" +#include "impeller/entity/conical_gradient_ssbo_fill.frag.h" +#include "impeller/entity/conical_gradient_uniform_fill_conical.frag.h" +#include "impeller/entity/conical_gradient_uniform_fill_radial.frag.h" +#include "impeller/entity/conical_gradient_uniform_fill_strip.frag.h" +#include "impeller/entity/conical_gradient_uniform_fill_strip_radial.frag.h" +#include "impeller/entity/fast_gradient.frag.h" +#include "impeller/entity/fast_gradient.vert.h" +#include "impeller/entity/filter_position.vert.h" +#include "impeller/entity/filter_position_uv.vert.h" +#include "impeller/entity/framebuffer_blend.frag.h" +#include "impeller/entity/framebuffer_blend.vert.h" +#include "impeller/entity/gaussian.frag.h" +#include "impeller/entity/glyph_atlas.frag.h" +#include "impeller/entity/glyph_atlas.vert.h" +#include "impeller/entity/gradient_fill.vert.h" +#include "impeller/entity/line.frag.h" +#include "impeller/entity/line.vert.h" +#include "impeller/entity/linear_gradient_fill.frag.h" +#include "impeller/entity/linear_gradient_ssbo_fill.frag.h" +#include "impeller/entity/linear_gradient_uniform_fill.frag.h" +#include "impeller/entity/linear_to_srgb_filter.frag.h" +#include "impeller/entity/morphology_filter.frag.h" +#include "impeller/entity/porter_duff_blend.frag.h" +#include "impeller/entity/porter_duff_blend.vert.h" +#include "impeller/entity/radial_gradient_fill.frag.h" +#include "impeller/entity/radial_gradient_ssbo_fill.frag.h" +#include "impeller/entity/radial_gradient_uniform_fill.frag.h" +#include "impeller/entity/rrect_blur.frag.h" +#include "impeller/entity/rrect_blur.vert.h" +#include "impeller/entity/solid_fill.frag.h" +#include "impeller/entity/solid_fill.vert.h" +#include "impeller/entity/srgb_to_linear_filter.frag.h" +#include "impeller/entity/sweep_gradient_fill.frag.h" +#include "impeller/entity/sweep_gradient_ssbo_fill.frag.h" +#include "impeller/entity/sweep_gradient_uniform_fill.frag.h" +#include "impeller/entity/texture_downsample.frag.h" +#include "impeller/entity/texture_fill.frag.h" +#include "impeller/entity/texture_fill.vert.h" +#include "impeller/entity/texture_fill_strict_src.frag.h" +#include "impeller/entity/texture_uv_fill.vert.h" +#include "impeller/entity/tiled_texture_fill.frag.h" +#include "impeller/entity/vertices_uber.frag.h" +#include "impeller/entity/yuv_to_rgb_filter.frag.h" +#include "impeller/renderer/pipeline.h" + +#ifdef IMPELLER_ENABLE_OPENGLES +#include "impeller/entity/texture_downsample_gles.frag.h" +#include "impeller/entity/tiled_texture_fill_external.frag.h" +#endif // IMPELLER_ENABLE_OPENGLES + +// TODO(gaaclarke): These should be split up into different files. +namespace impeller { + +template +using GradientPipelineHandle = + RenderPipelineHandle; + +using AdvancedBlendPipelineHandle = + RenderPipelineHandle; + +using FramebufferBlendPipelineHandle = + RenderPipelineHandle; + +// clang-format off +using BlendColorBurnPipeline = AdvancedBlendPipelineHandle; +using BlendColorDodgePipeline = AdvancedBlendPipelineHandle; +using BlendColorPipeline = AdvancedBlendPipelineHandle; +using BlendDarkenPipeline = AdvancedBlendPipelineHandle; +using BlendDifferencePipeline = AdvancedBlendPipelineHandle; +using BlendExclusionPipeline = AdvancedBlendPipelineHandle; +using BlendHardLightPipeline = AdvancedBlendPipelineHandle; +using BlendHuePipeline = AdvancedBlendPipelineHandle; +using BlendLightenPipeline = AdvancedBlendPipelineHandle; +using BlendLuminosityPipeline = AdvancedBlendPipelineHandle; +using BlendMultiplyPipeline = AdvancedBlendPipelineHandle; +using BlendOverlayPipeline = AdvancedBlendPipelineHandle; +using BlendSaturationPipeline = AdvancedBlendPipelineHandle; +using BlendScreenPipeline = AdvancedBlendPipelineHandle; +using BlendSoftLightPipeline = AdvancedBlendPipelineHandle; +using BorderMaskBlurPipeline = RenderPipelineHandle; +using ClipPipeline = RenderPipelineHandle; +using ColorMatrixColorFilterPipeline = RenderPipelineHandle; +using ConicalGradientFillConicalPipeline = GradientPipelineHandle; +using ConicalGradientFillRadialPipeline = GradientPipelineHandle; +using ConicalGradientFillStripPipeline = GradientPipelineHandle; +using ConicalGradientFillStripRadialPipeline = GradientPipelineHandle; +using ConicalGradientSSBOFillPipeline = GradientPipelineHandle; +using ConicalGradientUniformFillConicalPipeline = GradientPipelineHandle; +using ConicalGradientUniformFillRadialPipeline = GradientPipelineHandle; +using ConicalGradientUniformFillStripPipeline = GradientPipelineHandle; +using ConicalGradientUniformFillStripRadialPipeline = GradientPipelineHandle; +using FastGradientPipeline = RenderPipelineHandle; +using FramebufferBlendColorBurnPipeline = FramebufferBlendPipelineHandle; +using FramebufferBlendColorDodgePipeline = FramebufferBlendPipelineHandle; +using FramebufferBlendColorPipeline = FramebufferBlendPipelineHandle; +using FramebufferBlendDarkenPipeline = FramebufferBlendPipelineHandle; +using FramebufferBlendDifferencePipeline = FramebufferBlendPipelineHandle; +using FramebufferBlendExclusionPipeline = FramebufferBlendPipelineHandle; +using FramebufferBlendHardLightPipeline = FramebufferBlendPipelineHandle; +using FramebufferBlendHuePipeline = FramebufferBlendPipelineHandle; +using FramebufferBlendLightenPipeline = FramebufferBlendPipelineHandle; +using FramebufferBlendLuminosityPipeline = FramebufferBlendPipelineHandle; +using FramebufferBlendMultiplyPipeline = FramebufferBlendPipelineHandle; +using FramebufferBlendOverlayPipeline = FramebufferBlendPipelineHandle; +using FramebufferBlendSaturationPipeline = FramebufferBlendPipelineHandle; +using FramebufferBlendScreenPipeline = FramebufferBlendPipelineHandle; +using FramebufferBlendSoftLightPipeline = FramebufferBlendPipelineHandle; +using GaussianBlurPipeline = RenderPipelineHandle; +using GlyphAtlasPipeline = RenderPipelineHandle; +using LinePipeline = RenderPipelineHandle; +using LinearGradientFillPipeline = GradientPipelineHandle; +using LinearGradientSSBOFillPipeline = GradientPipelineHandle; +using LinearGradientUniformFillPipeline = GradientPipelineHandle; +using LinearToSrgbFilterPipeline = RenderPipelineHandle; +using MorphologyFilterPipeline = RenderPipelineHandle; +using PorterDuffBlendPipeline = RenderPipelineHandle; +using RadialGradientFillPipeline = GradientPipelineHandle; +using RadialGradientSSBOFillPipeline = GradientPipelineHandle; +using RadialGradientUniformFillPipeline = GradientPipelineHandle; +using RRectBlurPipeline = RenderPipelineHandle; +using SolidFillPipeline = RenderPipelineHandle; +using SrgbToLinearFilterPipeline = RenderPipelineHandle; +using SweepGradientFillPipeline = GradientPipelineHandle; +using SweepGradientSSBOFillPipeline = GradientPipelineHandle; +using SweepGradientUniformFillPipeline = GradientPipelineHandle; +using TextureDownsamplePipeline = RenderPipelineHandle; +using TexturePipeline = RenderPipelineHandle; +using TextureStrictSrcPipeline = RenderPipelineHandle; +using TiledTexturePipeline = RenderPipelineHandle; +using VerticesUberShader = RenderPipelineHandle; +using YUVToRGBFilterPipeline = RenderPipelineHandle; +// clang-format on + +#ifdef IMPELLER_ENABLE_OPENGLES +using TiledTextureExternalPipeline = + RenderPipelineHandle; +using TiledTextureUvExternalPipeline = + RenderPipelineHandle; +using TextureDownsampleGlesPipeline = + RenderPipelineHandle; +#endif // IMPELLER_ENABLE_OPENGLES +} // namespace impeller + +#endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_PIPELINES_H_ diff --git a/engine/src/flutter/impeller/entity/contents/text_contents.h b/engine/src/flutter/impeller/entity/contents/text_contents.h index 6e5861f371..58f202d5f0 100644 --- a/engine/src/flutter/impeller/entity/contents/text_contents.h +++ b/engine/src/flutter/impeller/entity/contents/text_contents.h @@ -9,6 +9,7 @@ #include "impeller/entity/contents/content_context.h" #include "impeller/entity/contents/contents.h" +#include "impeller/entity/contents/pipelines.h" #include "impeller/geometry/color.h" #include "impeller/typographer/font_glyph_pair.h" #include "impeller/typographer/text_frame.h" diff --git a/engine/src/flutter/impeller/entity/geometry/geometry.cc b/engine/src/flutter/impeller/entity/geometry/geometry.cc index b259f1820b..ca0c4bfb07 100644 --- a/engine/src/flutter/impeller/entity/geometry/geometry.cc +++ b/engine/src/flutter/impeller/entity/geometry/geometry.cc @@ -8,6 +8,7 @@ #include #include "impeller/entity/contents/content_context.h" +#include "impeller/entity/contents/pipelines.h" #include "impeller/entity/geometry/circle_geometry.h" #include "impeller/entity/geometry/cover_geometry.h" #include "impeller/entity/geometry/ellipse_geometry.h" diff --git a/engine/src/flutter/impeller/entity/geometry/geometry_unittests.cc b/engine/src/flutter/impeller/entity/geometry/geometry_unittests.cc index 8889ab141f..9d2bc907c7 100644 --- a/engine/src/flutter/impeller/entity/geometry/geometry_unittests.cc +++ b/engine/src/flutter/impeller/entity/geometry/geometry_unittests.cc @@ -6,6 +6,7 @@ #include "flutter/testing/testing.h" #include "gtest/gtest.h" #include "impeller/entity/contents/content_context.h" +#include "impeller/entity/contents/pipelines.h" #include "impeller/entity/geometry/geometry.h" #include "impeller/entity/geometry/stroke_path_geometry.h" #include "impeller/geometry/constants.h" diff --git a/engine/src/flutter/impeller/entity/geometry/line_geometry.cc b/engine/src/flutter/impeller/entity/geometry/line_geometry.cc index 4a58578535..d4a38375d6 100644 --- a/engine/src/flutter/impeller/entity/geometry/line_geometry.cc +++ b/engine/src/flutter/impeller/entity/geometry/line_geometry.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "impeller/entity/geometry/line_geometry.h" +#include "impeller/entity/contents/pipelines.h" #include "impeller/entity/geometry/geometry.h" namespace impeller { diff --git a/engine/src/flutter/impeller/entity/geometry/stroke_path_geometry.cc b/engine/src/flutter/impeller/entity/geometry/stroke_path_geometry.cc index a4fc27edba..4a56e13000 100644 --- a/engine/src/flutter/impeller/entity/geometry/stroke_path_geometry.cc +++ b/engine/src/flutter/impeller/entity/geometry/stroke_path_geometry.cc @@ -7,6 +7,7 @@ #include "impeller/core/buffer_view.h" #include "impeller/core/formats.h" #include "impeller/core/host_buffer.h" +#include "impeller/entity/contents/pipelines.h" #include "impeller/entity/geometry/geometry.h" #include "impeller/geometry/constants.h" #include "impeller/geometry/path_builder.h" diff --git a/engine/src/flutter/impeller/renderer/pipeline.h b/engine/src/flutter/impeller/renderer/pipeline.h index edaf7821d8..0bb5c7c475 100644 --- a/engine/src/flutter/impeller/renderer/pipeline.h +++ b/engine/src/flutter/impeller/renderer/pipeline.h @@ -115,11 +115,6 @@ PipelineFuture CreatePipelineFuture( /// RenderPipelineHandles. template class RenderPipelineHandle { - static_assert( - ShaderStageCompatibilityChecker::Check(), - "The output slots for the fragment shader don't have matches in the " - "vertex shader's output slots. This will result in a linker error."); - public: using VertexShader = VertexShader_; using FragmentShader = FragmentShader_;