11 #include "flutter/display_list/image/dl_image.h"
12 #include "fml/trace_event.h"
35 class GenericVariants {
37 void Set(
const ContentContextOptions& options,
38 std::unique_ptr<GenericRenderPipelineHandle>
pipeline) {
39 uint64_t p_key = options.ToKey();
48 void SetDefault(
const ContentContextOptions& options,
49 std::unique_ptr<GenericRenderPipelineHandle>
pipeline) {
56 GenericRenderPipelineHandle* Get(
const ContentContextOptions& options)
const {
57 uint64_t p_key = options.ToKey();
66 void SetDefaultDescriptor(std::optional<PipelineDescriptor> desc) {
67 desc_ = std::move(desc);
70 size_t GetPipelineCount()
const {
return pipelines_.size(); }
72 bool IsDefault(
const ContentContextOptions& opts) {
78 std::optional<PipelineDescriptor>
desc_;
80 std::vector<std::pair<uint64_t, std::unique_ptr<GenericRenderPipelineHandle>>>
97 template <
class PipelineHandleT>
98 class Variants :
public GenericVariants {
100 ShaderStageCompatibilityChecker<
101 typename PipelineHandleT::VertexShader,
102 typename PipelineHandleT::FragmentShader>::Check(),
103 "The output slots for the fragment shader don't have matches in the "
104 "vertex shader's output slots. This will result in a linker error.");
107 Variants() =
default;
109 void Set(
const ContentContextOptions& options,
110 std::unique_ptr<PipelineHandleT>
pipeline) {
111 GenericVariants::Set(options, std::move(
pipeline));
114 void SetDefault(
const ContentContextOptions& options,
115 std::unique_ptr<PipelineHandleT>
pipeline) {
116 GenericVariants::SetDefault(options, std::move(
pipeline));
119 void CreateDefault(
const Context&
context,
120 const ContentContextOptions& options,
121 const std::vector<Scalar>& constants = {}) {
122 std::optional<PipelineDescriptor> desc =
123 PipelineHandleT::Builder::MakeDefaultPipelineDescriptor(
context,
125 if (!desc.has_value()) {
129 context.GetPipelineLibrary()->LogPipelineCreation(*desc);
130 options.ApplyToPipelineDescriptor(*desc);
132 SetDefault(options, std::make_unique<PipelineHandleT>(
context,
desc_,
136 PipelineHandleT* Get(
const ContentContextOptions& options)
const {
137 return static_cast<PipelineHandleT*
>(GenericVariants::Get(options));
140 PipelineHandleT* GetDefault(
const Context&
context) {
145 if (result !=
nullptr) {
155 Variants(
const Variants&) =
delete;
157 Variants& operator=(
const Variants&) =
delete;
160 template <
class RenderPipelineHandleT>
161 RenderPipelineHandleT* CreateIfNeeded(
163 Variants<RenderPipelineHandleT>& container,
164 ContentContextOptions opts,
165 PipelineCompileQueue* compile_queue) {
170 if (RenderPipelineHandleT* found = container.Get(opts)) {
174 RenderPipelineHandleT* default_handle =
175 container.GetDefault(*
context->GetContext());
176 if (container.IsDefault(opts)) {
177 return default_handle;
181 FML_CHECK(default_handle !=
nullptr);
183 const std::shared_ptr<Pipeline<PipelineDescriptor>>&
pipeline =
184 default_handle->WaitAndGet(compile_queue);
189 auto variant_future =
pipeline->CreateVariant(
190 false, [&opts, variants_count = container.GetPipelineCount()](
191 PipelineDescriptor& desc) {
192 opts.ApplyToPipelineDescriptor(desc);
193 desc.SetLabel(std::format(
"{} V#{}", desc.GetLabel(), variants_count));
195 std::unique_ptr<RenderPipelineHandleT> variant =
196 std::make_unique<RenderPipelineHandleT>(std::move(variant_future));
197 container.Set(opts, std::move(variant));
198 return container.Get(opts);
201 template <
class TypedPipeline>
203 Variants<TypedPipeline>& container,
204 ContentContextOptions opts) {
206 context->GetContext()->GetPipelineLibrary()->GetPipelineCompileQueue();
208 CreateIfNeeded(
context, container, opts, compile_queue);
210 return raw_ptr<Pipeline<PipelineDescriptor>>();
212 return raw_ptr(
pipeline->WaitAndGet(compile_queue));
312 #if defined(IMPELLER_ENABLE_OPENGLES) && !defined(FML_OS_EMSCRIPTEN)
313 Variants<TiledTextureExternalPipeline> tiled_texture_external;
314 Variants<TiledTextureUvExternalPipeline> tiled_texture_uv_external;
317 #if defined(IMPELLER_ENABLE_OPENGLES)
318 Variants<TextureDownsampleGlesPipeline> texture_downsample_gles;
328 <<
" as a pipeline blend.";
340 switch (pipeline_blend) {
449 <<
"Depth attachment doesn't match expected pipeline state. "
450 "has_depth_stencil_attachments="
453 <<
"Stencil attachment doesn't match expected pipeline state. "
454 "has_depth_stencil_attachments="
456 if (maybe_stencil.has_value()) {
502 if (maybe_depth.has_value()) {
514 bool supports_decal) {
515 Scalar x = supports_decal ? 1 : 0;
528 {
x, 1, -1, 1, -1, 0},
535 template <
typename PipelineT>
538 auto desc = PipelineT::Builder::MakeDefaultPipelineDescriptor(
context);
539 if (!desc.has_value()) {
543 const auto default_color_format =
544 context.GetCapabilities()->GetDefaultColorFormat();
547 .color_attachment_pixel_format = default_color_format}
548 .ApplyToPipelineDescriptor(*desc);
549 return std::make_unique<PipelineT>(
context, desc);
553 std::shared_ptr<Context>
context,
554 std::shared_ptr<TypographerContext> typographer_context,
555 std::shared_ptr<RenderTargetAllocator> render_target_allocator)
561 context_->GetCapabilities()->Supports32BitPrimitiveIndices())),
562 render_target_cache_(render_target_allocator == nullptr
564 context_->GetResourceAllocator())
565 :
std::move(render_target_allocator)),
567 context_->GetResourceAllocator(),
568 context_->GetIdleWaiter(),
569 context_->GetCapabilities()->GetMinimumUniformAlignment())),
571 if (!context_ || !context_->IsValid()) {
579 indexes_host_buffer_ =
580 context_->GetCapabilities()->NeedsPartitionedHostBuffer()
582 context_->GetResourceAllocator(), context_->GetIdleWaiter(),
583 context_->GetCapabilities()->GetMinimumUniformAlignment())
590 empty_texture_ =
GetContext()->GetResourceAllocator()->CreateTexture(desc);
593 std::shared_ptr<CommandBuffer> cmd_buffer =
595 std::shared_ptr<BlitPass> blit_pass = cmd_buffer->CreateBlitPass();
598 blit_pass->AddCopy(buffer_view, empty_texture_);
600 if (!blit_pass->EncodeCommands() || !
GetContext()
602 ->Submit({std::move(cmd_buffer)})
610 .color_attachment_pixel_format =
611 context_->GetCapabilities()->GetDefaultColorFormat()};
615 .color_attachment_pixel_format =
616 context_->GetCapabilities()->GetDefaultColorFormat()};
620 .color_attachment_pixel_format =
621 context_->GetCapabilities()->GetDefaultColorFormat(),
622 .has_depth_stencil_attachments =
false};
623 const auto supports_decal =
static_cast<Scalar>(
624 context_->GetCapabilities()->SupportsDecalSamplerAddressMode());
633 GetContext()->GetCapabilities()->GetDefaultGlyphAtlasFormat() ==
635 pipelines_->solid_fill.CreateDefault(*context_, options);
636 pipelines_->texture.CreateDefault(*context_, options);
637 pipelines_->fast_gradient.CreateDefault(*context_, options);
638 pipelines_->line.CreateDefault(*context_, options);
639 pipelines_->circle.CreateDefault(*context_, options);
640 if (context_->GetFlags().use_sdfs ||
641 context_->GetFlags().antialiased_lines) {
642 pipelines_->uber_sdf.CreateDefault(*context_, options);
643 pipelines_->complex_rse.CreateDefault(*context_, options);
646 if (context_->GetCapabilities()->SupportsSSBO()) {
647 pipelines_->linear_gradient_ssbo_fill.CreateDefault(*context_, options);
648 pipelines_->radial_gradient_ssbo_fill.CreateDefault(*context_, options);
649 pipelines_->conical_gradient_ssbo_fill.CreateDefault(*context_, options,
651 pipelines_->conical_gradient_ssbo_fill_radial.CreateDefault(
652 *context_, options, {1.0});
653 pipelines_->conical_gradient_ssbo_fill_strip.CreateDefault(
654 *context_, options, {2.0});
655 pipelines_->conical_gradient_ssbo_fill_strip_and_radial.CreateDefault(
656 *context_, options, {0.0});
657 pipelines_->sweep_gradient_ssbo_fill.CreateDefault(*context_, options);
659 pipelines_->linear_gradient_uniform_fill.CreateDefault(*context_,
661 pipelines_->radial_gradient_uniform_fill.CreateDefault(*context_,
663 pipelines_->conical_gradient_uniform_fill.CreateDefault(*context_,
665 pipelines_->conical_gradient_uniform_fill_radial.CreateDefault(*context_,
667 pipelines_->conical_gradient_uniform_fill_strip.CreateDefault(*context_,
669 pipelines_->conical_gradient_uniform_fill_strip_and_radial.CreateDefault(
671 pipelines_->sweep_gradient_uniform_fill.CreateDefault(*context_, options);
673 pipelines_->linear_gradient_fill.CreateDefault(*context_, options);
674 pipelines_->radial_gradient_fill.CreateDefault(*context_, options);
675 pipelines_->conical_gradient_fill.CreateDefault(*context_, options);
676 pipelines_->conical_gradient_fill_radial.CreateDefault(*context_,
678 pipelines_->conical_gradient_fill_strip.CreateDefault(*context_, options);
679 pipelines_->conical_gradient_fill_strip_and_radial.CreateDefault(
681 pipelines_->sweep_gradient_fill.CreateDefault(*context_, options);
685 auto clip_pipeline_descriptor =
687 if (!clip_pipeline_descriptor.has_value()) {
692 .color_attachment_pixel_format =
693 context_->GetCapabilities()->GetDefaultColorFormat()}
694 .ApplyToPipelineDescriptor(*clip_pipeline_descriptor);
696 auto clip_color_attachments =
697 clip_pipeline_descriptor->GetColorAttachmentDescriptors();
698 for (
auto& color_attachment : clip_color_attachments) {
701 clip_pipeline_descriptor->SetColorAttachmentDescriptors(
702 std::move(clip_color_attachments));
705 std::make_unique<ClipPipeline>(*context_, clip_pipeline_descriptor));
707 *context_, options_no_msaa_no_depth_stencil);
708 pipelines_->texture_downsample_bounded.CreateDefault(
709 *context_, options_no_msaa_no_depth_stencil);
710 pipelines_->rrect_blur.CreateDefault(*context_, options_trianglestrip);
711 pipelines_->rsuperellipse_blur.CreateDefault(*context_,
712 options_trianglestrip);
713 pipelines_->texture_strict_src.CreateDefault(*context_, options);
714 pipelines_->tiled_texture.CreateDefault(*context_, options,
717 *context_, options_no_msaa_no_depth_stencil, {supports_decal});
718 pipelines_->border_mask_blur.CreateDefault(*context_,
719 options_trianglestrip);
720 pipelines_->color_matrix_color_filter.CreateDefault(*context_,
721 options_trianglestrip);
722 pipelines_->shadow_vertices_.CreateDefault(*context_, options);
723 pipelines_->vertices_uber_1_.CreateDefault(*context_, options,
725 pipelines_->vertices_uber_2_.CreateDefault(*context_, options,
728 const std::array<std::vector<Scalar>, 15> porter_duff_constants =
730 pipelines_->clear_blend.CreateDefault(*context_, options_trianglestrip,
731 porter_duff_constants[0]);
732 pipelines_->source_blend.CreateDefault(*context_, options_trianglestrip,
733 porter_duff_constants[1]);
735 *context_, options_trianglestrip, porter_duff_constants[2]);
737 *context_, options_trianglestrip, porter_duff_constants[3]);
738 pipelines_->destination_over_blend.CreateDefault(
739 *context_, options_trianglestrip, porter_duff_constants[4]);
740 pipelines_->source_in_blend.CreateDefault(*context_, options_trianglestrip,
741 porter_duff_constants[5]);
742 pipelines_->destination_in_blend.CreateDefault(
743 *context_, options_trianglestrip, porter_duff_constants[6]);
744 pipelines_->source_out_blend.CreateDefault(*context_, options_trianglestrip,
745 porter_duff_constants[7]);
746 pipelines_->destination_out_blend.CreateDefault(
747 *context_, options_trianglestrip, porter_duff_constants[8]);
749 *context_, options_trianglestrip, porter_duff_constants[9]);
750 pipelines_->destination_a_top_blend.CreateDefault(
751 *context_, options_trianglestrip, porter_duff_constants[10]);
752 pipelines_->xor_blend.CreateDefault(*context_, options_trianglestrip,
753 porter_duff_constants[11]);
754 pipelines_->plus_blend.CreateDefault(*context_, options_trianglestrip,
755 porter_duff_constants[12]);
756 pipelines_->modulate_blend.CreateDefault(*context_, options_trianglestrip,
757 porter_duff_constants[13]);
758 pipelines_->screen_blend.CreateDefault(*context_, options_trianglestrip,
759 porter_duff_constants[14]);
762 if (context_->GetCapabilities()->SupportsFramebufferFetch()) {
763 pipelines_->framebuffer_blend_color.CreateDefault(
764 *context_, options_trianglestrip,
766 pipelines_->framebuffer_blend_colorburn.CreateDefault(
767 *context_, options_trianglestrip,
769 pipelines_->framebuffer_blend_colordodge.CreateDefault(
770 *context_, options_trianglestrip,
772 pipelines_->framebuffer_blend_darken.CreateDefault(
773 *context_, options_trianglestrip,
775 pipelines_->framebuffer_blend_difference.CreateDefault(
776 *context_, options_trianglestrip,
778 pipelines_->framebuffer_blend_exclusion.CreateDefault(
779 *context_, options_trianglestrip,
781 pipelines_->framebuffer_blend_hardlight.CreateDefault(
782 *context_, options_trianglestrip,
784 pipelines_->framebuffer_blend_hue.CreateDefault(
785 *context_, options_trianglestrip,
787 pipelines_->framebuffer_blend_lighten.CreateDefault(
788 *context_, options_trianglestrip,
790 pipelines_->framebuffer_blend_luminosity.CreateDefault(
791 *context_, options_trianglestrip,
793 pipelines_->framebuffer_blend_multiply.CreateDefault(
794 *context_, options_trianglestrip,
796 pipelines_->framebuffer_blend_overlay.CreateDefault(
797 *context_, options_trianglestrip,
799 pipelines_->framebuffer_blend_saturation.CreateDefault(
800 *context_, options_trianglestrip,
802 pipelines_->framebuffer_blend_screen.CreateDefault(
803 *context_, options_trianglestrip,
805 pipelines_->framebuffer_blend_softlight.CreateDefault(
806 *context_, options_trianglestrip,
810 *context_, options_trianglestrip,
813 *context_, options_trianglestrip,
816 *context_, options_trianglestrip,
819 *context_, options_trianglestrip,
822 *context_, options_trianglestrip,
825 *context_, options_trianglestrip,
828 *context_, options_trianglestrip,
831 *context_, options_trianglestrip,
834 *context_, options_trianglestrip,
837 *context_, options_trianglestrip,
840 *context_, options_trianglestrip,
843 *context_, options_trianglestrip,
846 *context_, options_trianglestrip,
849 *context_, options_trianglestrip,
852 *context_, options_trianglestrip,
856 pipelines_->morphology_filter.CreateDefault(*context_, options_trianglestrip,
858 pipelines_->linear_to_srgb_filter.CreateDefault(*context_,
859 options_trianglestrip);
860 pipelines_->srgb_to_linear_filter.CreateDefault(*context_,
861 options_trianglestrip);
862 pipelines_->yuv_to_rgb_filter.CreateDefault(*context_, options_trianglestrip);
865 #if defined(IMPELLER_ENABLE_OPENGLES) && !defined(FML_OS_MACOSX) && \
866 !defined(FML_OS_EMSCRIPTEN)
868 pipelines_->tiled_texture_external.CreateDefault(*context_, options);
869 pipelines_->tiled_texture_uv_external.CreateDefault(*context_, options);
872 #if defined(IMPELLER_ENABLE_OPENGLES)
873 pipelines_->texture_downsample_gles.CreateDefault(*context_,
874 options_trianglestrip);
879 InitializeCommonlyUsedShadersIfNeeded();
889 return empty_texture_;
893 std::string_view label,
898 bool depth_stencil_enabled,
899 int32_t mip_count)
const {
903 std::optional<RenderTarget::AttachmentConfig> depth_stencil_config =
905 : std::optional<RenderTarget::AttachmentConfig>();
907 if (
context->GetCapabilities()->SupportsOffscreenMSAA() && msaa_enabled) {
915 depth_stencil_config,
930 std::string_view label,
937 if (!subpass_texture) {
938 return fml::Status(fml::StatusCode::kUnknown,
"");
941 auto sub_renderpass =
command_buffer->CreateRenderPass(subpass_target);
942 if (!sub_renderpass) {
943 return fml::Status(fml::StatusCode::kUnknown,
"");
945 sub_renderpass->SetLabel(label);
947 if (!subpass_callback(*
this, *sub_renderpass)) {
948 return fml::Status(fml::StatusCode::kUnknown,
"");
951 if (!sub_renderpass->EncodeCommands()) {
952 return fml::Status(fml::StatusCode::kUnknown,
"");
955 const std::shared_ptr<Texture>& target_texture =
957 if (target_texture->GetMipCount() > 1) {
958 fml::Status mipmap_status =
960 if (!mipmap_status.ok()) {
961 return mipmap_status;
965 return subpass_target;
969 return *tessellator_;
977 return *context_->GetCapabilities();
981 const std::string& unique_entrypoint_name,
984 create_callback)
const {
985 RuntimeEffectPipelineKey key{unique_entrypoint_name, options};
986 auto it = runtime_effect_pipelines_.find(key);
987 if (it == runtime_effect_pipelines_.end()) {
988 it = runtime_effect_pipelines_.insert(it, {key, create_callback()});
994 const std::string& unique_entrypoint_name)
const {
995 #ifdef IMPELLER_DEBUG
997 const auto& idle_waiter =
GetContext()->GetIdleWaiter();
999 idle_waiter->WaitIdle();
1002 for (
auto it = runtime_effect_pipelines_.begin();
1003 it != runtime_effect_pipelines_.end();) {
1004 if (it->first.unique_entrypoint_name == unique_entrypoint_name) {
1005 it = runtime_effect_pipelines_.erase(it);
1013 data_host_buffer_->Reset();
1018 if (data_host_buffer_ != indexes_host_buffer_) {
1019 indexes_host_buffer_->Reset();
1023 void ContentContext::InitializeCommonlyUsedShadersIfNeeded()
const {
1024 GetContext()->InitializeCommonlyUsedShadersIfNeeded();
1029 return GetPipeline(
this,
pipelines_->fast_gradient, opts);
1034 return GetPipeline(
this,
pipelines_->linear_gradient_fill, opts);
1039 return GetPipeline(
this,
pipelines_->linear_gradient_uniform_fill, opts);
1044 return GetPipeline(
this,
pipelines_->radial_gradient_uniform_fill, opts);
1049 return GetPipeline(
this,
pipelines_->sweep_gradient_uniform_fill, opts);
1055 return GetPipeline(
this,
pipelines_->linear_gradient_ssbo_fill, opts);
1061 return GetPipeline(
this,
pipelines_->radial_gradient_ssbo_fill, opts);
1069 return GetPipeline(
this,
pipelines_->conical_gradient_uniform_fill, opts);
1071 return GetPipeline(
this,
pipelines_->conical_gradient_uniform_fill_radial,
1074 return GetPipeline(
this,
pipelines_->conical_gradient_uniform_fill_strip,
1078 this,
pipelines_->conical_gradient_uniform_fill_strip_and_radial,
1089 return GetPipeline(
this,
pipelines_->conical_gradient_ssbo_fill, opts);
1091 return GetPipeline(
this,
pipelines_->conical_gradient_ssbo_fill_radial,
1094 return GetPipeline(
this,
pipelines_->conical_gradient_ssbo_fill_strip,
1098 this,
pipelines_->conical_gradient_ssbo_fill_strip_and_radial, opts);
1105 return GetPipeline(
this,
pipelines_->sweep_gradient_ssbo_fill, opts);
1110 return GetPipeline(
this,
pipelines_->radial_gradient_fill, opts);
1118 return GetPipeline(
this,
pipelines_->conical_gradient_fill, opts);
1120 return GetPipeline(
this,
pipelines_->conical_gradient_fill_radial, opts);
1122 return GetPipeline(
this,
pipelines_->conical_gradient_fill_strip, opts);
1125 this,
pipelines_->conical_gradient_fill_strip_and_radial, opts);
1131 return GetPipeline(
this,
pipelines_->rrect_blur, opts);
1136 return GetPipeline(
this,
pipelines_->rsuperellipse_blur, opts);
1141 return GetPipeline(
this,
pipelines_->sweep_gradient_fill, opts);
1146 return GetPipeline(
this,
pipelines_->solid_fill, opts);
1151 return GetPipeline(
this,
pipelines_->texture, opts);
1156 return GetPipeline(
this,
pipelines_->texture_strict_src, opts);
1161 return GetPipeline(
this,
pipelines_->tiled_texture, opts);
1166 return GetPipeline(
this,
pipelines_->gaussian_blur, opts);
1171 return GetPipeline(
this,
pipelines_->border_mask_blur, opts);
1176 return GetPipeline(
this,
pipelines_->morphology_filter, opts);
1181 return GetPipeline(
this,
pipelines_->color_matrix_color_filter, opts);
1186 return GetPipeline(
this,
pipelines_->linear_to_srgb_filter, opts);
1191 return GetPipeline(
this,
pipelines_->srgb_to_linear_filter, opts);
1195 return GetPipeline(
this,
pipelines_->clip, opts);
1200 return GetPipeline(
this,
pipelines_->glyph_atlas, opts);
1205 return GetPipeline(
this,
pipelines_->yuv_to_rgb_filter, opts);
1210 return GetPipeline(
this,
pipelines_->uber_sdf, opts);
1215 return GetPipeline(
this,
pipelines_->complex_rse, opts);
1275 return GetPipeline(
this,
pipelines_->clear_blend, opts);
1280 return GetPipeline(
this,
pipelines_->source_blend, opts);
1285 return GetPipeline(
this,
pipelines_->destination_blend, opts);
1290 return GetPipeline(
this,
pipelines_->source_over_blend, opts);
1295 return GetPipeline(
this,
pipelines_->destination_over_blend, opts);
1300 return GetPipeline(
this,
pipelines_->source_in_blend, opts);
1305 return GetPipeline(
this,
pipelines_->destination_in_blend, opts);
1310 return GetPipeline(
this,
pipelines_->source_out_blend, opts);
1315 return GetPipeline(
this,
pipelines_->destination_out_blend, opts);
1320 return GetPipeline(
this,
pipelines_->source_a_top_blend, opts);
1325 return GetPipeline(
this,
pipelines_->destination_a_top_blend, opts);
1330 return GetPipeline(
this,
pipelines_->xor_blend, opts);
1335 return GetPipeline(
this,
pipelines_->plus_blend, opts);
1340 return GetPipeline(
this,
pipelines_->modulate_blend, opts);
1345 return GetPipeline(
this,
pipelines_->screen_blend, opts);
1350 return GetPipeline(
this,
pipelines_->blend_color, opts);
1355 return GetPipeline(
this,
pipelines_->blend_colorburn, opts);
1360 return GetPipeline(
this,
pipelines_->blend_colordodge, opts);
1365 return GetPipeline(
this,
pipelines_->blend_darken, opts);
1370 return GetPipeline(
this,
pipelines_->blend_difference, opts);
1375 return GetPipeline(
this,
pipelines_->blend_exclusion, opts);
1380 return GetPipeline(
this,
pipelines_->blend_hardlight, opts);
1385 return GetPipeline(
this,
pipelines_->blend_hue, opts);
1390 return GetPipeline(
this,
pipelines_->blend_lighten, opts);
1395 return GetPipeline(
this,
pipelines_->blend_luminosity, opts);
1400 return GetPipeline(
this,
pipelines_->blend_multiply, opts);
1405 return GetPipeline(
this,
pipelines_->blend_overlay, opts);
1410 return GetPipeline(
this,
pipelines_->blend_saturation, opts);
1415 return GetPipeline(
this,
pipelines_->blend_screen, opts);
1420 return GetPipeline(
this,
pipelines_->blend_softlight, opts);
1425 return GetPipeline(
this,
pipelines_->texture_downsample, opts);
1430 return GetPipeline(
this,
pipelines_->texture_downsample_bounded, opts);
1436 return GetPipeline(
this,
pipelines_->framebuffer_blend_color, opts);
1442 return GetPipeline(
this,
pipelines_->framebuffer_blend_colorburn, opts);
1448 return GetPipeline(
this,
pipelines_->framebuffer_blend_colordodge, opts);
1454 return GetPipeline(
this,
pipelines_->framebuffer_blend_darken, opts);
1460 return GetPipeline(
this,
pipelines_->framebuffer_blend_difference, opts);
1466 return GetPipeline(
this,
pipelines_->framebuffer_blend_exclusion, opts);
1472 return GetPipeline(
this,
pipelines_->framebuffer_blend_hardlight, opts);
1478 return GetPipeline(
this,
pipelines_->framebuffer_blend_hue, opts);
1484 return GetPipeline(
this,
pipelines_->framebuffer_blend_lighten, opts);
1490 return GetPipeline(
this,
pipelines_->framebuffer_blend_luminosity, opts);
1496 return GetPipeline(
this,
pipelines_->framebuffer_blend_multiply, opts);
1502 return GetPipeline(
this,
pipelines_->framebuffer_blend_overlay, opts);
1508 return GetPipeline(
this,
pipelines_->framebuffer_blend_saturation, opts);
1514 return GetPipeline(
this,
pipelines_->framebuffer_blend_screen, opts);
1520 return GetPipeline(
this,
pipelines_->framebuffer_blend_softlight, opts);
1525 return GetPipeline(
this,
pipelines_->shadow_vertices_, opts);
1532 return GetPipeline(
this,
pipelines_->vertices_uber_1_, opts);
1534 return GetPipeline(
this,
pipelines_->vertices_uber_2_, opts);
1540 return GetPipeline(
this,
pipelines_->circle, opts);
1544 return GetPipeline(
this,
pipelines_->line, opts);
1547 #ifdef IMPELLER_ENABLE_OPENGLES
1549 #if !defined(FML_OS_EMSCRIPTEN)
1550 PipelineRef ContentContext::GetTiledTextureUvExternalPipeline(
1553 return GetPipeline(
this,
pipelines_->tiled_texture_uv_external, opts);
1556 PipelineRef ContentContext::GetTiledTextureExternalPipeline(
1557 ContentContextOptions opts)
const {
1559 return GetPipeline(
this,
pipelines_->tiled_texture_external, opts);
1563 PipelineRef ContentContext::GetDownsampleTextureGlesPipeline(
1564 ContentContextOptions opts)
const {
1565 return GetPipeline(
this,
pipelines_->texture_downsample_gles, opts);
1571 is_texture_caching_enabled_ = enabled;
1573 texture_cache_.clear();
1578 const flutter::DlImage* image)
const {
1582 if (is_texture_caching_enabled_) {
1583 auto it = texture_cache_.find(image);
1584 if (it != texture_cache_.end()) {
1592 const flutter::DlImage* image,
1593 const std::shared_ptr<Texture>& texture)
const {
1594 if (!image || !texture) {
1597 if (is_texture_caching_enabled_) {
1598 texture_cache_[image] = texture;
1603 texture_cache_.erase(image);
1607 texture_cache_.clear();
PipelineRef GetBlendLuminosityPipeline(ContentContextOptions opts) const
PipelineRef GetTiledTexturePipeline(ContentContextOptions opts) const
PipelineRef GetFramebufferBlendColorPipeline(ContentContextOptions opts) const
PipelineRef GetDownsamplePipeline(ContentContextOptions opts) const
PipelineRef GetSourceInBlendPipeline(ContentContextOptions opts) const
void ClearCachedRuntimeEffectPipeline(const std::string &unique_entrypoint_name) const
PipelineRef GetLinearGradientFillPipeline(ContentContextOptions opts) const
PipelineRef GetFramebufferBlendOverlayPipeline(ContentContextOptions opts) const
PipelineRef GetBlendColorDodgePipeline(ContentContextOptions opts) const
PipelineRef GetFramebufferBlendColorBurnPipeline(ContentContextOptions opts) const
PipelineRef GetPorterDuffPipeline(BlendMode mode, ContentContextOptions opts) const
std::shared_ptr< Texture > GetCachedTexture(const flutter::DlImage *image) const
Get a cached texture for the given image.
std::shared_ptr< Texture > GetEmptyTexture() const
PipelineRef GetSourceOutBlendPipeline(ContentContextOptions opts) const
PipelineRef GetScreenBlendPipeline(ContentContextOptions opts) const
PipelineRef GetBlendColorPipeline(ContentContextOptions opts) const
PipelineRef GetLinePipeline(ContentContextOptions opts) const
PipelineRef GetFramebufferBlendLuminosityPipeline(ContentContextOptions opts) const
PipelineRef GetDownsampleBoundedPipeline(ContentContextOptions opts) const
PipelineRef GetPlusBlendPipeline(ContentContextOptions opts) const
PipelineRef GetUberSDFPipeline(ContentContextOptions opts) const
PipelineRef GetFastGradientPipeline(ContentContextOptions opts) const
ContentContext(std::shared_ptr< Context > context, std::shared_ptr< TypographerContext > typographer_context, std::shared_ptr< RenderTargetAllocator > render_target_allocator=nullptr)
void ResetTransientsBuffers()
Resets the transients buffers held onto by the content context.
PipelineRef GetSolidFillPipeline(ContentContextOptions opts) const
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...
const Capabilities & GetDeviceCapabilities() const
PipelineRef GetModulateBlendPipeline(ContentContextOptions opts) const
PipelineRef GetFramebufferBlendHardLightPipeline(ContentContextOptions opts) const
PipelineRef GetFramebufferBlendColorDodgePipeline(ContentContextOptions opts) const
PipelineRef GetSweepGradientUniformFillPipeline(ContentContextOptions opts) const
PipelineRef GetBlendSoftLightPipeline(ContentContextOptions opts) const
PipelineRef GetDestinationATopBlendPipeline(ContentContextOptions opts) const
PipelineRef GetTextureStrictSrcPipeline(ContentContextOptions opts) const
PipelineRef GetDrawShadowVerticesPipeline(ContentContextOptions opts) const
PipelineRef GetCachedRuntimeEffectPipeline(const std::string &unique_entrypoint_name, const ContentContextOptions &options, const std::function< std::shared_ptr< Pipeline< PipelineDescriptor >>()> &create_callback) const
PipelineRef GetRadialGradientSSBOFillPipeline(ContentContextOptions opts) const
PipelineRef GetBlendColorBurnPipeline(ContentContextOptions opts) const
PipelineRef GetSweepGradientSSBOFillPipeline(ContentContextOptions opts) const
PipelineRef GetLinearGradientUniformFillPipeline(ContentContextOptions opts) const
PipelineRef GetFramebufferBlendScreenPipeline(ContentContextOptions opts) const
PipelineRef GetLinearGradientSSBOFillPipeline(ContentContextOptions opts) const
PipelineRef GetRadialGradientFillPipeline(ContentContextOptions opts) const
PipelineRef GetTexturePipeline(ContentContextOptions opts) const
PipelineRef GetBlendHardLightPipeline(ContentContextOptions opts) const
PipelineRef GetClearBlendPipeline(ContentContextOptions opts) const
PipelineRef GetCirclePipeline(ContentContextOptions opts) const
PipelineRef GetConicalGradientUniformFillPipeline(ContentContextOptions opts, ConicalKind kind) const
PipelineRef GetComplexRSEPipeline(ContentContextOptions opts) const
PipelineRef GetRadialGradientUniformFillPipeline(ContentContextOptions opts) const
PipelineRef GetSweepGradientFillPipeline(ContentContextOptions opts) const
PipelineRef GetFramebufferBlendExclusionPipeline(ContentContextOptions opts) const
PipelineRef GetFramebufferBlendDarkenPipeline(ContentContextOptions opts) const
PipelineRef GetBlendSaturationPipeline(ContentContextOptions opts) const
PipelineRef GetFramebufferBlendSoftLightPipeline(ContentContextOptions opts) const
PipelineRef GetFramebufferBlendLightenPipeline(ContentContextOptions opts) const
PipelineRef GetMorphologyFilterPipeline(ContentContextOptions opts) const
PipelineRef GetFramebufferBlendSaturationPipeline(ContentContextOptions opts) const
PipelineRef GetBlendDifferencePipeline(ContentContextOptions opts) const
PipelineRef GetGaussianBlurPipeline(ContentContextOptions opts) const
PipelineRef GetBlendHuePipeline(ContentContextOptions opts) const
PipelineRef GetSrgbToLinearFilterPipeline(ContentContextOptions opts) const
PipelineRef GetDestinationOutBlendPipeline(ContentContextOptions opts) const
PipelineRef GetYUVToRGBFilterPipeline(ContentContextOptions opts) const
PipelineRef GetFramebufferBlendDifferencePipeline(ContentContextOptions opts) const
PipelineRef GetFramebufferBlendHuePipeline(ContentContextOptions opts) const
PipelineRef GetSourceATopBlendPipeline(ContentContextOptions opts) const
HostBuffer & GetTransientsDataBuffer() const
Retrieve the current host buffer for transient storage of other non-index data.
PipelineRef GetXorBlendPipeline(ContentContextOptions opts) const
PipelineRef GetGlyphAtlasPipeline(ContentContextOptions opts) const
PipelineRef GetClipPipeline(ContentContextOptions opts) const
const std::shared_ptr< RenderTargetAllocator > & GetRenderTargetCache() const
PipelineRef GetRRectBlurPipeline(ContentContextOptions opts) const
PipelineRef GetBlendScreenPipeline(ContentContextOptions opts) const
std::function< bool(const ContentContext &, RenderPass &)> SubpassCallback
PipelineRef GetBlendDarkenPipeline(ContentContextOptions opts) const
PipelineRef GetSourceBlendPipeline(ContentContextOptions opts) const
PipelineRef GetLinearToSrgbFilterPipeline(ContentContextOptions opts) const
PipelineRef GetBlendOverlayPipeline(ContentContextOptions opts) const
PipelineRef GetDestinationBlendPipeline(ContentContextOptions opts) const
PipelineRef GetDestinationOverBlendPipeline(ContentContextOptions opts) const
PipelineRef GetFramebufferBlendMultiplyPipeline(ContentContextOptions opts) const
void SetTextureCachingEnabled(bool enabled)
Enable or disable texture caching.
PipelineRef GetConicalGradientSSBOFillPipeline(ContentContextOptions opts, ConicalKind kind) const
Tessellator & GetTessellator() const
void SetCachedTexture(const flutter::DlImage *image, const std::shared_ptr< Texture > &texture) const
Set a cached texture for the given image.
PipelineRef GetBlendLightenPipeline(ContentContextOptions opts) const
PipelineRef GetBlendMultiplyPipeline(ContentContextOptions opts) const
PipelineRef GetSourceOverBlendPipeline(ContentContextOptions opts) const
PipelineRef GetBlendExclusionPipeline(ContentContextOptions opts) const
PipelineRef GetColorMatrixColorFilterPipeline(ContentContextOptions opts) const
void RemoveCachedTexture(const flutter::DlImage *image) const
Remove a cached texture for the given image.
PipelineRef GetConicalGradientFillPipeline(ContentContextOptions opts, ConicalKind kind) const
std::shared_ptr< Context > GetContext() const
void ClearCachedTextures() const
Clear all cached textures.
PipelineRef GetDestinationInBlendPipeline(ContentContextOptions opts) const
PipelineRef GetRSuperellipseBlurPipeline(ContentContextOptions opts) const
PipelineRef GetBorderMaskBlurPipeline(ContentContextOptions opts) const
PipelineRef GetDrawVerticesUberPipeline(BlendMode blend_mode, ContentContextOptions opts) const
To do anything rendering related with Impeller, you need a context.
static constexpr BlendMode kLastPipelineBlendMode
BufferView Emplace(const BufferType &buffer, size_t alignment=0)
Emplace non-uniform data (like contiguous vertices) onto the host buffer.
static std::shared_ptr< HostBuffer > Create(const std::shared_ptr< Allocator > &allocator, const std::shared_ptr< const IdleWaiter > &idle_waiter, size_t minimum_uniform_alignment)
PipelineDescriptor & SetDepthStencilAttachmentDescriptor(std::optional< DepthAttachmentDescriptor > desc)
void ClearStencilAttachments()
void SetPolygonMode(PolygonMode mode)
std::optional< DepthAttachmentDescriptor > GetDepthStencilAttachmentDescriptor() const
PipelineDescriptor & SetStencilAttachmentDescriptors(std::optional< StencilAttachmentDescriptor > front_and_back)
const ColorAttachmentDescriptor * GetColorAttachmentDescriptor(size_t index) const
PipelineDescriptor & SetColorAttachmentDescriptor(size_t index, ColorAttachmentDescriptor desc)
PipelineDescriptor & SetSampleCount(SampleCount samples)
void SetPrimitiveType(PrimitiveType type)
void ClearDepthAttachment()
std::optional< StencilAttachmentDescriptor > GetFrontStencilAttachmentDescriptor() const
An implementation of the [RenderTargetAllocator] that caches all allocated texture data for at least ...
std::shared_ptr< Texture > GetRenderTargetTexture() const
static constexpr AttachmentConfig kDefaultColorAttachmentConfig
static constexpr AttachmentConfigMSAA kDefaultColorAttachmentConfigMSAA
static constexpr AttachmentConfig kDefaultStencilAttachmentConfig
A utility that generates triangles of the specified fill type given a polyline. This happens on the C...
A cache for blurred text that re-uses these across frames.
std::optional< PipelineDescriptor > desc_
std::vector< std::pair< uint64_t, std::unique_ptr< GenericRenderPipelineHandle > > > pipelines_
std::optional< ContentContextOptions > default_options_
ScopedObject< Object > Create(CtorArgs &&... args)
@ kOneMinusDestinationAlpha
static std::unique_ptr< PipelineT > CreateDefaultPipeline(const Context &context)
raw_ptr< Pipeline< PipelineDescriptor > > PipelineRef
A raw ptr to a pipeline object.
const char * BlendModeToString(BlendMode blend_mode)
@ kEqual
Comparison test passes if new_value == current_value.
@ kAlways
Comparison test passes always passes.
@ kNotEqual
Comparison test passes if new_value != current_value.
fml::Status AddMipmapGeneration(const std::shared_ptr< CommandBuffer > &command_buffer, const std::shared_ptr< Context > &context, const std::shared_ptr< Texture > &texture)
Adds a blit command to the render pass.
@ kDecrementWrap
Decrement the current stencil value by 1. If at zero, set to maximum.
@ kSetToReferenceValue
Reset the stencil value to the reference value.
@ kIncrementWrap
Increment the current stencil value by 1. If at maximum, set to zero.
@ kKeep
Don't modify the current stencil value.
std::array< std::vector< Scalar >, 15 > GetPorterDuffSpecConstants(bool supports_decal)
std::shared_ptr< ContextGLES > context
std::shared_ptr< PipelineGLES > pipeline
std::shared_ptr< CommandBuffer > command_buffer
Describe the color attachment that will be used with this pipeline.
BlendOperation color_blend_op
BlendFactor dst_color_blend_factor
ColorWriteMask write_mask
BlendFactor src_alpha_blend_factor
BlendOperation alpha_blend_op
BlendFactor src_color_blend_factor
BlendFactor dst_alpha_blend_factor
std::array< uint8_t, 4 > ToR8G8B8A8() const
Convert to R8G8B8A8 representation.
static constexpr Color BlackTransparent()
Variants< SolidFillPipeline > solid_fill
Variants< PorterDuffBlendPipeline > destination_blend
Variants< SweepGradientSSBOFillPipeline > sweep_gradient_ssbo_fill
Variants< BlendScreenPipeline > blend_screen
Variants< PorterDuffBlendPipeline > modulate_blend
Variants< FramebufferBlendOverlayPipeline > framebuffer_blend_overlay
Variants< BlendSaturationPipeline > blend_saturation
Variants< TiledTexturePipeline > tiled_texture
Variants< PorterDuffBlendPipeline > destination_in_blend
Variants< BlendSoftLightPipeline > blend_softlight
Variants< BlendColorDodgePipeline > blend_colordodge
Variants< BlendMultiplyPipeline > blend_multiply
Variants< BlendColorPipeline > blend_color
Variants< BlendDifferencePipeline > blend_difference
Variants< BlendOverlayPipeline > blend_overlay
Variants< ConicalGradientFillStripPipeline > conical_gradient_fill_strip
Variants< FramebufferBlendExclusionPipeline > framebuffer_blend_exclusion
Variants< MorphologyFilterPipeline > morphology_filter
Variants< PorterDuffBlendPipeline > screen_blend
Variants< FramebufferBlendSaturationPipeline > framebuffer_blend_saturation
Variants< PorterDuffBlendPipeline > source_over_blend
Variants< LinearGradientFillPipeline > linear_gradient_fill
Variants< PorterDuffBlendPipeline > plus_blend
Variants< VerticesUber2Shader > vertices_uber_2_
Variants< FramebufferBlendHardLightPipeline > framebuffer_blend_hardlight
Variants< RadialGradientSSBOFillPipeline > radial_gradient_ssbo_fill
Variants< LinePipeline > line
Variants< PorterDuffBlendPipeline > clear_blend
Variants< ConicalGradientUniformFillConicalPipeline > conical_gradient_uniform_fill
Variants< FramebufferBlendMultiplyPipeline > framebuffer_blend_multiply
Variants< ComplexRSEPipeline > complex_rse
Variants< ConicalGradientSSBOFillPipeline > conical_gradient_ssbo_fill
Variants< TextureDownsamplePipeline > texture_downsample
Variants< TextureDownsampleBoundedPipeline > texture_downsample_bounded
Variants< FramebufferBlendLuminosityPipeline > framebuffer_blend_luminosity
Variants< FramebufferBlendSoftLightPipeline > framebuffer_blend_softlight
Variants< SweepGradientUniformFillPipeline > sweep_gradient_uniform_fill
Variants< BlendColorBurnPipeline > blend_colorburn
Variants< ConicalGradientUniformFillStripRadialPipeline > conical_gradient_uniform_fill_strip_and_radial
Variants< PorterDuffBlendPipeline > source_in_blend
Variants< ConicalGradientFillConicalPipeline > conical_gradient_fill
Variants< ShadowVerticesShader > shadow_vertices_
Variants< CirclePipeline > circle
Variants< SweepGradientFillPipeline > sweep_gradient_fill
Variants< FramebufferBlendLightenPipeline > framebuffer_blend_lighten
Variants< PorterDuffBlendPipeline > source_a_top_blend
Variants< PorterDuffBlendPipeline > destination_a_top_blend
Variants< RadialGradientUniformFillPipeline > radial_gradient_uniform_fill
Variants< BlendLightenPipeline > blend_lighten
Variants< LinearGradientUniformFillPipeline > linear_gradient_uniform_fill
Variants< FramebufferBlendColorBurnPipeline > framebuffer_blend_colorburn
Variants< ConicalGradientFillRadialPipeline > conical_gradient_fill_radial
Variants< ClipPipeline > clip
Variants< PorterDuffBlendPipeline > destination_over_blend
Variants< BlendExclusionPipeline > blend_exclusion
Variants< RSuperellipseBlurPipeline > rsuperellipse_blur
Variants< SrgbToLinearFilterPipeline > srgb_to_linear_filter
Variants< UberSDFPipeline > uber_sdf
Variants< ColorMatrixColorFilterPipeline > color_matrix_color_filter
Variants< LinearToSrgbFilterPipeline > linear_to_srgb_filter
Variants< ConicalGradientUniformFillRadialPipeline > conical_gradient_uniform_fill_radial
Variants< ConicalGradientSSBOFillPipeline > conical_gradient_ssbo_fill_strip
Variants< RRectBlurPipeline > rrect_blur
Variants< BlendDarkenPipeline > blend_darken
Variants< TexturePipeline > texture
Variants< PorterDuffBlendPipeline > source_out_blend
Variants< FramebufferBlendHuePipeline > framebuffer_blend_hue
Variants< TextureStrictSrcPipeline > texture_strict_src
Variants< FramebufferBlendColorPipeline > framebuffer_blend_color
Variants< BlendHuePipeline > blend_hue
Variants< FramebufferBlendDarkenPipeline > framebuffer_blend_darken
Variants< FastGradientPipeline > fast_gradient
Variants< ConicalGradientUniformFillStripPipeline > conical_gradient_uniform_fill_strip
Variants< PorterDuffBlendPipeline > xor_blend
Variants< GaussianBlurPipeline > gaussian_blur
Variants< LinearGradientSSBOFillPipeline > linear_gradient_ssbo_fill
Variants< ConicalGradientSSBOFillPipeline > conical_gradient_ssbo_fill_strip_and_radial
Variants< GlyphAtlasPipeline > glyph_atlas
Variants< PorterDuffBlendPipeline > source_blend
Variants< BlendLuminosityPipeline > blend_luminosity
Variants< BorderMaskBlurPipeline > border_mask_blur
Variants< FramebufferBlendScreenPipeline > framebuffer_blend_screen
Variants< FramebufferBlendDifferencePipeline > framebuffer_blend_difference
Variants< YUVToRGBFilterPipeline > yuv_to_rgb_filter
Variants< RadialGradientFillPipeline > radial_gradient_fill
Variants< ConicalGradientSSBOFillPipeline > conical_gradient_ssbo_fill_radial
Variants< ConicalGradientFillStripRadialPipeline > conical_gradient_fill_strip_and_radial
Variants< BlendHardLightPipeline > blend_hardlight
Variants< FramebufferBlendColorDodgePipeline > framebuffer_blend_colordodge
Variants< PorterDuffBlendPipeline > destination_out_blend
Variants< VerticesUber1Shader > vertices_uber_1_
PrimitiveType primitive_type
bool has_depth_stencil_attachments
void ApplyToPipelineDescriptor(PipelineDescriptor &desc) const
PixelFormat color_attachment_pixel_format
@ kIgnore
Turn the stencil test off. Used when drawing without stencil-then-cover.
bool is_for_rrect_blur_clear
CompareFunction depth_compare
CompareFunction depth_compare
static std::optional< PipelineDescriptor > MakeDefaultPipelineDescriptor(const Context &context, const std::vector< Scalar > &constants={})
Create a default pipeline descriptor using the combination reflected shader information....
StencilOperation stencil_failure
CompareFunction stencil_compare
StencilOperation depth_stencil_pass
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...