From b98bc7c3603c19227b58d27429f19b0e989603e0 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Fri, 21 Apr 2023 01:45:06 -0700 Subject: [PATCH] [Impeller] Always use BGRA10_XR for wide gamut (flutter/engine#41385) Fixes errors blitting offscreen textures to onscreen textures when wide gamut is enabled due to the mismatching formats. --- .../darwin/ios/framework/Source/FlutterView.mm | 6 +----- .../platform/darwin/ios/ios_surface_metal_impeller.mm | 11 +---------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm index c441883999..aa95fb8445 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm @@ -96,11 +96,7 @@ static BOOL IsWideGamutSupported() { CGColorSpaceRef srgb = CGColorSpaceCreateWithName(kCGColorSpaceExtendedSRGB); layer.colorspace = srgb; CFRelease(srgb); - if (self.opaque) { - layer.pixelFormat = MTLPixelFormatBGR10_XR; - } else { - layer.pixelFormat = MTLPixelFormatBGRA10_XR; - } + layer.pixelFormat = MTLPixelFormatBGRA10_XR; } } diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.mm b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.mm index b4a7436885..427b91e0fa 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.mm @@ -10,15 +10,6 @@ namespace flutter { -static impeller::PixelFormat InferOffscreenLayerPixelFormat(impeller::PixelFormat pixel_format) { - switch (pixel_format) { - case impeller::PixelFormat::kB10G10R10XR: - return impeller::PixelFormat::kB10G10R10A10XR; - default: - return pixel_format; - } -} - IOSSurfaceMetalImpeller::IOSSurfaceMetalImpeller(const fml::scoped_nsobject& layer, const std::shared_ptr& context) : IOSSurface(context), @@ -47,7 +38,7 @@ void IOSSurfaceMetalImpeller::UpdateStorageSizeIfNecessary() { // |IOSSurface| std::unique_ptr IOSSurfaceMetalImpeller::CreateGPUSurface(GrDirectContext*) { impeller_context_->UpdateOffscreenLayerPixelFormat( - InferOffscreenLayerPixelFormat(impeller::FromMTLPixelFormat(layer_.get().pixelFormat))); + impeller::FromMTLPixelFormat(layer_.get().pixelFormat)); return std::make_unique(this, // impeller_context_ // );