mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-08 12:35:01 +00:00
Fix tests (#2065)
This commit is contained in:
1 parent
61b5301f1a
commit
961b23fd2d
3 files changed
+14
-11
No files matched your search
@@ -466,11 +466,15 @@ public final class FrameManager {
|
||||
|
||||
private volatile boolean acquireThreadReported;
|
||||
|
||||
static boolean acquireAffinityViolated(Thread self, Thread window) {
|
||||
return window != null && window != self;
|
||||
}
|
||||
|
||||
private void checkAcquireOnWindowThread() {
|
||||
if (acquireThreadReported) return;
|
||||
final Thread self = Thread.currentThread();
|
||||
final Thread window = device.getWindowThread();
|
||||
if (window == null || window == self) return;
|
||||
if (!acquireAffinityViolated(self, window)) return;
|
||||
acquireThreadReported = true;
|
||||
|
||||
final String message = "Swapchain acquired on '" + self.getName() + "', window created on '" + window.getName() + "'";
|
||||
|
||||
+5
-1
@@ -33,10 +33,14 @@ public final class SplashDispatcher {
|
||||
return (long) w << 32 | (h & 0xffffffffL);
|
||||
}
|
||||
|
||||
static boolean intervalElapsed(long now, long lastBlitNanos, boolean force) {
|
||||
return force || now - lastBlitNanos >= MIN_INTERVAL_NS;
|
||||
}
|
||||
|
||||
public static void tryDispatch(SDLGPURenderBackend backend, OffscreenTarget target, boolean force) {
|
||||
if (!frameReady || target == null) return;
|
||||
final long now = System.nanoTime();
|
||||
if (!force && now - lastBlitNanos < MIN_INTERVAL_NS) return;
|
||||
if (!intervalElapsed(now, lastBlitNanos, force)) return;
|
||||
lastBlitNanos = now;
|
||||
frameReady = false;
|
||||
backend.dispatchSplashBlit(target);
|
||||
|
||||
+4
-9
@@ -12,22 +12,17 @@ class AcquireAffinityTest {
|
||||
|
||||
@Test
|
||||
void acquiringOnTheWindowThreadIsTheOnlyAcceptedCase() {
|
||||
assertFalse(FrameManager.acquireAffinityViolated(WINDOW, WINDOW, 0));
|
||||
assertFalse(FrameManager.acquireAffinityViolated(WINDOW, WINDOW));
|
||||
}
|
||||
|
||||
@Test
|
||||
void acquiringOnAnyOtherThreadViolatesTheSdlContract() {
|
||||
assertTrue(FrameManager.acquireAffinityViolated(OTHER, WINDOW, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aLaterAcquireFromASecondThreadViolatesEvenWhenTheFirstWasCorrect() {
|
||||
assertTrue(FrameManager.acquireAffinityViolated(WINDOW, WINDOW, 1),
|
||||
"drift after a correct first acquire must still be caught");
|
||||
assertTrue(FrameManager.acquireAffinityViolated(OTHER, WINDOW));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anUnknownWindowThreadCannotBeJudged() {
|
||||
assertFalse(FrameManager.acquireAffinityViolated(OTHER, null, 3));
|
||||
assertFalse(FrameManager.acquireAffinityViolated(OTHER, null),
|
||||
"the check runs before the window is claimed; judging a null window would throw at startup");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user