Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions shell/platform/darwin/ios/framework/Source/FlutterView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ - (void)layoutSubviews {
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;
}
Expand Down
14 changes: 12 additions & 2 deletions shell/platform/darwin/ios/ios_surface_metal_impeller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,19 @@
#include "flutter/impeller/renderer/context.h"
#include "flutter/shell/gpu/gpu_surface_metal_impeller.h"

namespace impeller {
namespace {
impeller::PixelFormat InferContextPixelFormat(impeller::PixelFormat pixel_format) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: InferOffscreenLayerPixelFormat?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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
Expand Down Expand Up @@ -96,7 +106,7 @@ PixelFormat GetColorAttachmentPixelFormat() const override {
// |IOSSurface|
std::unique_ptr<Surface> IOSSurfaceMetalImpeller::CreateGPUSurface(GrDirectContext*) {
auto context = std::make_shared<CustomColorAttachmentPixelFormatContext>(
impeller_context_, FromMTLPixelFormat(layer_.get().pixelFormat));
impeller_context_, InferContextPixelFormat(FromMTLPixelFormat(layer_.get().pixelFormat)));
return std::make_unique<GPUSurfaceMetalImpeller>(this, //
context //
);
Expand Down