From 8f21d275416f85d2c088cff416769abf461ae279 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Mon, 29 Apr 2024 07:24:21 -0700 Subject: [PATCH] [Impeller] fix GLES image upload. (flutter/engine#52430) TLDR: this was a load bearing closure. See https://ci.chromium.org/ui/p/flutter/builders/prod/Linux_pixel_7pro%20complex_layout_scroll_perf_impeller_gles__timeline_summary/1492/overview --- .../lib/ui/painting/image_decoder_impeller.cc | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/engine/src/flutter/lib/ui/painting/image_decoder_impeller.cc b/engine/src/flutter/lib/ui/painting/image_decoder_impeller.cc index 099d1a4fef..7532399699 100644 --- a/engine/src/flutter/lib/ui/painting/image_decoder_impeller.cc +++ b/engine/src/flutter/lib/ui/painting/image_decoder_impeller.cc @@ -490,17 +490,28 @@ void ImageDecoderImpeller::Decode(fml::RefPtr descriptor, sk_sp image; std::string decode_error; - if (context->GetCapabilities()->SupportsBufferToTextureBlits()) { - std::tie(image, decode_error) = UploadTextureToPrivate( - context, bitmap_result.device_buffer, bitmap_result.image_info, - bitmap_result.sk_bitmap, gpu_disabled_switch); - result(image, decode_error); + auto upload_texture_and_invoke_result = [result, context, bitmap_result, + gpu_disabled_switch]() { + sk_sp image; + std::string decode_error; + if (context->GetCapabilities()->SupportsBufferToTextureBlits()) { + std::tie(image, decode_error) = UploadTextureToPrivate( + context, bitmap_result.device_buffer, bitmap_result.image_info, + bitmap_result.sk_bitmap, gpu_disabled_switch); + result(image, decode_error); + } else { + std::tie(image, decode_error) = UploadTextureToStorage( + context, bitmap_result.sk_bitmap, gpu_disabled_switch, + impeller::StorageMode::kDevicePrivate, + /*create_mips=*/true); + result(image, decode_error); + } + }; + if (context->GetBackendType() == + impeller::Context::BackendType::kOpenGLES) { + io_runner->PostTask(upload_texture_and_invoke_result); } else { - std::tie(image, decode_error) = UploadTextureToStorage( - context, bitmap_result.sk_bitmap, gpu_disabled_switch, - impeller::StorageMode::kDevicePrivate, - /*create_mips=*/true); - result(image, decode_error); + upload_texture_and_invoke_result(); } }); }