feat(text): composite shared text rasters in output
Raster static text on UI-thread changes and reuse the same transparent BGRA frame in preview and all compositor paths. Cache text frame identity in the frame-pump signature and invalidate static bakes on edits. Follow OBS text-source conventions: https://obsproject.com/kb/text-sources
This commit is contained in:
@@ -540,6 +540,36 @@ public class FramePumpTests
|
||||
await pump.StopAsync();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task FullRenderCache_TextOverlayFrameChange_Recomposites()
|
||||
{
|
||||
var scene = new Scene { Name = "Text cache" };
|
||||
scene.Elements.Add(new Source
|
||||
{
|
||||
Type = SourceType.TextOverlay,
|
||||
Width = 64,
|
||||
Height = 48,
|
||||
});
|
||||
var current = SceneCompositorTests.Solid(64, 48, 255, 0, 0);
|
||||
var encoder = new FakeEncoder();
|
||||
using var pump = NewPump(encoder, scene: () => scene, resolve: _ => current);
|
||||
|
||||
await pump.StartAsync();
|
||||
var deadline = DateTime.UtcNow.AddSeconds(5);
|
||||
while (DateTime.UtcNow < deadline && (encoder.Frames.Count < 6 || pump.CacheHits < 4))
|
||||
await Task.Delay(10);
|
||||
Assert.Equal(1, pump.CacheRenders);
|
||||
|
||||
current = SceneCompositorTests.Solid(64, 48, 0, 0, 255);
|
||||
deadline = DateTime.UtcNow.AddSeconds(5);
|
||||
while (DateTime.UtcNow < deadline && pump.CacheRenders < 2)
|
||||
await Task.Delay(10);
|
||||
|
||||
Assert.True(pump.CacheRenders >= 2, "the changed text raster did not invalidate the full-render cache");
|
||||
AssertColor(encoder.Frames[^1], 8, 8, 0, 0, 255);
|
||||
await pump.StopAsync();
|
||||
}
|
||||
|
||||
/// <summary>One integration test for the take-8 off-UI fix: the pump loop must NOT
|
||||
/// run on the starting thread's SynchronizationContext (StartAsync fires from a UI
|
||||
/// command handler; the old loop inherited it, so every frame competed with the
|
||||
|
||||
Reference in New Issue
Block a user