Merge pull request #81339 from bruvzg/macos_fix_mvk_live_resize

[macOS] Fix live resize with the latest MoltenVK version.
This commit is contained in:
Yuri Sizov 2023-09-06 14:49:30 +02:00
commit 07176632a6
2 changed files with 10 additions and 1 deletions

View File

@ -47,9 +47,11 @@
@interface GodotContentLayerDelegate : NSObject <CALayerDelegate> {
DisplayServer::WindowID window_id;
bool need_redraw;
}
- (void)setWindowID:(DisplayServer::WindowID)wid;
- (void)setNeedRedraw:(bool)redraw;
@end

View File

@ -40,6 +40,7 @@
- (id)init {
self = [super init];
window_id = DisplayServer::INVALID_WINDOW_ID;
need_redraw = false;
return self;
}
@ -47,13 +48,18 @@
window_id = wid;
}
- (void)setNeedRedraw:(bool)redraw {
need_redraw = redraw;
}
- (void)displayLayer:(CALayer *)layer {
DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
if (OS::get_singleton()->get_main_loop() && ds->get_is_resizing()) {
if (OS::get_singleton()->get_main_loop() && ds->get_is_resizing() && need_redraw) {
Main::force_redraw();
if (!Main::is_iterating()) { // Avoid cyclic loop.
Main::iteration();
}
need_redraw = false;
}
}
@ -93,6 +99,7 @@
}
[super setFrameSize:newSize];
[layer_delegate setNeedRedraw:true];
[self.layer setNeedsDisplay]; // Force "drawRect" call.
}