@geastack/apple 0.2.22 → 0.2.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/apple",
3
- "version": "0.2.22",
3
+ "version": "0.2.23",
4
4
  "description": "Generated Apple SDK bindings plus the macOS, iOS and tvOS native build targets for Gea apps.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -546,6 +546,16 @@ static __weak AppDelegate *gGeaAppDelegate = nil;
546
546
 
547
547
  [self tick];
548
548
  [self startFrameTimer];
549
+ // GEA_MACOS_FULLSCREEN=1 starts fullscreen. With GEA_MACOS_VSYNC=0 this is
550
+ // the uncapped arm: a windowed CAMetalLayer gets drawables back only as the
551
+ // compositor runs, a fullscreen one presents directly.
552
+ if (const char *fullscreen = std::getenv("GEA_MACOS_FULLSCREEN"); fullscreen && std::strcmp(fullscreen, "1") == 0) {
553
+ self.window.collectionBehavior |= NSWindowCollectionBehaviorFullScreenPrimary;
554
+ NSWindow *window = self.window;
555
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC / 2), dispatch_get_main_queue(), ^{
556
+ if (!(window.styleMask & NSWindowStyleMaskFullScreen)) [window toggleFullScreen:nil];
557
+ });
558
+ }
549
559
  }
550
560
 
551
561
  - (void)startFrameTimer
@@ -555,7 +565,11 @@ static __weak AppDelegate *gGeaAppDelegate = nil;
555
565
  #endif
556
566
  if (self.frameTimer) return;
557
567
  const BOOL thermalrightTarget = gea::macos::thermalright::enabled();
558
- if (!thermalrightTarget) {
568
+ // GEA_MACOS_VSYNC=0 drops the display-link cadence for the fast timer, so a
569
+ // renderer presenting with swap interval 0 runs uncapped (benchmarking).
570
+ const char *vsync = std::getenv("GEA_MACOS_VSYNC");
571
+ const BOOL uncapped = vsync && std::strcmp(vsync, "0") == 0;
572
+ if (!thermalrightTarget && !uncapped) {
559
573
  if (@available(macOS 14.0, *)) {
560
574
  if (self.frameDisplayLink) return;
561
575
  // A timer cannot express the desired display refresh rate. The
@@ -581,7 +595,16 @@ static __weak AppDelegate *gGeaAppDelegate = nil;
581
595
  repeats:YES
582
596
  block:^(NSTimer *t) {
583
597
  (void)t;
584
- [weakSelf tick];
598
+ if (!uncapped) {
599
+ [weakSelf tick];
600
+ return;
601
+ }
602
+ // The run loop fires even a 1/960 s timer only ~120 times a second, so
603
+ // uncapped, each fire runs frames back to back for up to ~6 ms and then
604
+ // returns so input and window events are still serviced.
605
+ const auto burstEnd = std::chrono::steady_clock::now() + std::chrono::milliseconds(6);
606
+ do [weakSelf tick];
607
+ while (std::chrono::steady_clock::now() < burstEnd);
585
608
  }];
586
609
  self.frameTimer.tolerance = thermalrightTarget ? 0.001 : 0.0;
587
610
  [[NSRunLoop currentRunLoop] addTimer:self.frameTimer forMode:NSRunLoopCommonModes];