@@ -16,11 +16,12 @@ + (double)displayRefreshRate;
1616@class FlutterTexture;
1717@class FlutterDrawable;
1818
19- extern CFTimeInterval display_link_target ;
19+ static MTLPixelFormat _defaultPixelFormat = MTLPixelFormatBGRA8Unorm ;
2020
2121@interface FlutterMetalLayer () {
2222 id <MTLDevice > _preferredDevice;
2323 CGSize _drawableSize;
24+ MTLPixelFormat _pixelFormat;
2425
2526 NSUInteger _nextDrawableId;
2627
@@ -149,7 +150,6 @@ @implementation FlutterMetalLayer
149150
150151@synthesize preferredDevice = _preferredDevice;
151152@synthesize device = _device;
152- @synthesize pixelFormat = _pixelFormat;
153153@synthesize framebufferOnly = _framebufferOnly;
154154@synthesize colorspace = _colorspace;
155155@synthesize wantsExtendedDynamicRangeContent = _wantsExtendedDynamicRangeContent;
@@ -158,7 +158,7 @@ - (instancetype)init {
158158 if (self = [super init ]) {
159159 _preferredDevice = MTLCreateSystemDefaultDevice ();
160160 self.device = self.preferredDevice ;
161- self. pixelFormat = MTLPixelFormatBGRA8Unorm ;
161+ _pixelFormat = _defaultPixelFormat ;
162162 _availableTextures = [[NSMutableSet alloc ] init ];
163163
164164 _displayLink = [CADisplayLink displayLinkWithTarget: self selector: @selector (onDisplayLink: )];
@@ -172,6 +172,18 @@ - (instancetype)init {
172172 return self;
173173}
174174
175+ - (MTLPixelFormat )pixelFormat {
176+ return _pixelFormat;
177+ }
178+
179+ - (void )setPixelFormat : (MTLPixelFormat )pixelFormat {
180+ _pixelFormat = pixelFormat;
181+
182+ // FlutterView updates pixel format on it's layer, but the overlay views
183+ // don't - they get correct pixel format right magically.
184+ _defaultPixelFormat = pixelFormat;
185+ }
186+
175187- (void )dealloc {
176188 [[NSNotificationCenter defaultCenter ] removeObserver: self ];
177189}
0 commit comments