|
@@ -49,6 +49,28 @@
|
|
#include <os/log.h>
|
|
#include <os/log.h>
|
|
#include <sys/sysctl.h>
|
|
#include <sys/sysctl.h>
|
|
|
|
|
|
|
|
+void OS_MacOS::add_frame_delay(bool p_can_draw, bool p_wake_for_events) {
|
|
|
|
+ if (p_wake_for_events) {
|
|
|
|
+ uint64_t delay = get_frame_delay(p_can_draw);
|
|
|
|
+ if (delay == 0) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (wait_timer) {
|
|
|
|
+ CFRunLoopTimerInvalidate(wait_timer);
|
|
|
|
+ CFRelease(wait_timer);
|
|
|
|
+ }
|
|
|
|
+ wait_timer = CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + (double(delay) / 1000000.0), 0, 0, 0,
|
|
|
|
+ ^(CFRunLoopTimerRef timer) {
|
|
|
|
+ CFRunLoopTimerInvalidate(wait_timer);
|
|
|
|
+ CFRelease(wait_timer);
|
|
|
|
+ wait_timer = nil;
|
|
|
|
+ });
|
|
|
|
+ CFRunLoopAddTimer(CFRunLoopGetCurrent(), wait_timer, kCFRunLoopCommonModes);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ OS_Unix::add_frame_delay(p_can_draw, p_wake_for_events);
|
|
|
|
+}
|
|
|
|
+
|
|
void OS_MacOS::initialize() {
|
|
void OS_MacOS::initialize() {
|
|
crash_handler.initialize();
|
|
crash_handler.initialize();
|
|
|
|
|
|
@@ -995,8 +1017,9 @@ void OS_MacOS_NSApp::start_main() {
|
|
ERR_PRINT("NSException: " + String::utf8([exception reason].UTF8String));
|
|
ERR_PRINT("NSException: " + String::utf8([exception reason].UTF8String));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- CFRunLoopWakeUp(CFRunLoopGetCurrent()); // Prevent main loop from sleeping.
|
|
|
|
|
|
+ if (wait_timer == nil) {
|
|
|
|
+ CFRunLoopWakeUp(CFRunLoopGetCurrent()); // Prevent main loop from sleeping.
|
|
|
|
+ }
|
|
});
|
|
});
|
|
CFRunLoopAddObserver(CFRunLoopGetCurrent(), pre_wait_observer, kCFRunLoopCommonModes);
|
|
CFRunLoopAddObserver(CFRunLoopGetCurrent(), pre_wait_observer, kCFRunLoopCommonModes);
|
|
return;
|
|
return;
|