Crossfade between palettes instead of flashing empty

Switching source kept nothing on screen until the new one drew. The old
frame now stays until the first new frame lands, then fades out over it
in 150 ms.

Model used: Claude Opus 5.5
This commit is contained in:
piexel committed 2026-10-25 20:06:30 +01:00
1 parent 806a33976a
commit 547c52540a
3 files changed
+183

No files matched your search

@@ -0,0 +1,62 @@
package art.arcane.iris.studio.map;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
public final class FrameCrossfadeTest {
private final FrameCrossfade crossfade = new FrameCrossfade(() -> {
});
@Test
public void heldFrameStaysFullyVisibleUntilTheNextFrameArrives() {
NoiseRenderCoordinator.Result frame = frame();
crossfade.hold(frame);
assertSame(frame, crossfade.outgoing());
assertEquals(1F, crossfade.outgoingOpacity(), 0F);
}
@Test
public void heldFrameFadesOnceTheNextFrameArrives() throws InterruptedException {
crossfade.hold(frame());
crossfade.reveal();
Thread.sleep(20L);
assertTrue(crossfade.outgoingOpacity() < 1F);
}
@Test
public void switchingAgainBeforeAnythingDrewKeepsTheFrameHeld() {
NoiseRenderCoordinator.Result frame = frame();
crossfade.hold(frame);
crossfade.hold(null);
assertSame(frame, crossfade.outgoing());
}
@Test
public void frameWithoutAHeldFrameHasNothingToFade() {
crossfade.reveal();
assertNull(crossfade.outgoing());
}
@Test
public void clearDropsTheHeldFrame() {
crossfade.hold(frame());
crossfade.clear();
assertNull(crossfade.outgoing());
}
private static NoiseRenderCoordinator.Result frame() {
return new NoiseRenderCoordinator.Result(null, null, 1D, 1L, 0D, 1D, 0.5D, 0L, 0L, 0L);
}
}