Started using bgr10_xr for opaque surfaces. (flutter/engine#39727)
* Started using bgr10_xr for opaque surfaces. * bdero feedback
This commit is contained in:
@@ -87,9 +87,7 @@ static BOOL IsWideGamutSupported() {
|
||||
layer.colorspace = srgb;
|
||||
CFRelease(srgb);
|
||||
if (self.opaque) {
|
||||
// TODO(https://github.com/flutter/flutter/issues/120641): Switch to
|
||||
// MTLPixelFormatBGR10_XR to save memory.
|
||||
layer.pixelFormat = MTLPixelFormatBGRA10_XR;
|
||||
layer.pixelFormat = MTLPixelFormatBGR10_XR;
|
||||
} else {
|
||||
layer.pixelFormat = MTLPixelFormatBGRA10_XR;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,19 @@
|
||||
#include "flutter/impeller/renderer/context.h"
|
||||
#include "flutter/shell/gpu/gpu_surface_metal_impeller.h"
|
||||
|
||||
namespace {
|
||||
impeller::PixelFormat InferOffscreenLayerPixelFormat(impeller::PixelFormat pixel_format) {
|
||||
switch (pixel_format) {
|
||||
case impeller::PixelFormat::kB10G10R10XR:
|
||||
return impeller::PixelFormat::kB10G10R10A10XR;
|
||||
default:
|
||||
return pixel_format;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace impeller {
|
||||
namespace {
|
||||
|
||||
// This appears to be the only safe way to override the
|
||||
// GetColorAttachmentPixelFormat method. It is assumed in the Context that
|
||||
// there will be one pixel format for the whole app which is not true. So, it
|
||||
@@ -96,7 +106,8 @@ void IOSSurfaceMetalImpeller::UpdateStorageSizeIfNecessary() {
|
||||
// |IOSSurface|
|
||||
std::unique_ptr<Surface> IOSSurfaceMetalImpeller::CreateGPUSurface(GrDirectContext*) {
|
||||
auto context = std::make_shared<CustomColorAttachmentPixelFormatContext>(
|
||||
impeller_context_, FromMTLPixelFormat(layer_.get().pixelFormat));
|
||||
impeller_context_,
|
||||
InferOffscreenLayerPixelFormat(FromMTLPixelFormat(layer_.get().pixelFormat)));
|
||||
return std::make_unique<GPUSurfaceMetalImpeller>(this, //
|
||||
context //
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user