This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
shell/platform/darwin/macos/framework/Source Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222 */
2323@interface FlutterView : NSView
2424
25+ @property (weak , nonatomic ) NSColor * __nullable backgroundColor;
26+
2527/* *
2628 * Initialize a FlutterView that will be rendered to using Metal rendering apis.
2729 */
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ - (instancetype)initWithMTLDevice:(id<MTLDevice>)device
2828 self = [super initWithFrame: NSZeroRect ];
2929 if (self) {
3030 [self setWantsLayer: YES ];
31+ [self paintContainingLayerBackgroundColor ];
3132 [self setLayerContentsRedrawPolicy: NSViewLayerContentsRedrawDuringViewResize];
3233 _reshapeListener = reshapeListener;
3334 _resizableBackingStoreProvider =
@@ -51,6 +52,7 @@ - (instancetype)initWithFrame:(NSRect)frame
5152 self = [super initWithFrame: frame];
5253 if (self) {
5354 [self setWantsLayer: YES ];
55+ [self paintContainingLayerBackgroundColor ];
5456 _reshapeListener = reshapeListener;
5557 _resizableBackingStoreProvider =
5658 [[FlutterOpenGLResizableBackingStoreProvider alloc ] initWithMainContext: mainContext
@@ -84,6 +86,17 @@ - (void)reshaped {
8486 }];
8587}
8688
89+ - (NSColor *)backgroundColor {
90+ return _backgroundColor ? _backgroundColor : [NSColor blackColor ];
91+ }
92+
93+ - (void )paintContainingLayerBackgroundColor {
94+ if (self) {
95+ [self setWantsLayer: YES ];
96+ self.layer .backgroundColor = self.backgroundColor .CGColor ;
97+ }
98+ }
99+
87100#pragma mark - NSView overrides
88101
89102- (void )setFrameSize : (NSSize )newSize {
You can’t perform that action at this time.
0 commit comments