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:
2026-11-04 15:01:47 -08:00
parent 58eb640c4e
commit 5c4acf141b
19 changed files with 622 additions and 81 deletions
+14 -9
View File
@@ -52,6 +52,10 @@ public sealed class TextLayerEditorPreviewTests
var leftPanel = (LeftPanel)window.FindName("LeftPanel")!;
var editor = (TextBox)leftPanel.FindName("TextLayerEditor")!;
Assert.Equal("Text", editor.Text);
var firstBitmap = first.VideoImageSource;
var secondBitmap = second.VideoImageSource;
Assert.NotNull(firstBitmap);
Assert.NotNull(secondBitmap);
Assert.True(first.IsDraggable);
Assert.Equal(900, first.Width);
Assert.Equal(140, first.Height);
@@ -62,14 +66,16 @@ public sealed class TextLayerEditorPreviewTests
Assert.Equal("Updated headline\nSecond line", first.TextContent);
Assert.Equal("Leave this caption alone", second.TextContent);
Assert.NotSame(firstBitmap, first.VideoImageSource);
Assert.Same(secondBitmap, second.VideoImageSource);
var preview = (PreviewPane)window.FindName("PreviewPane")!;
var firstPreview = FindTextPreview(preview, first);
var secondPreview = FindTextPreview(preview, second);
var firstPreview = FindTextImage(preview, first);
var secondPreview = FindTextImage(preview, second);
Assert.NotNull(firstPreview);
Assert.NotNull(secondPreview);
Assert.Equal("Updated headline\nSecond line", firstPreview!.Text);
Assert.Equal("Leave this caption alone", secondPreview!.Text);
Assert.Same(first.VideoImageSource, firstPreview!.Source);
Assert.Same(second.VideoImageSource, secondPreview!.Source);
Assert.True(firstPreview.IsVisible);
Assert.True(secondPreview.IsVisible);
}
@@ -82,15 +88,14 @@ public sealed class TextLayerEditorPreviewTests
}
}
private static TextBlock? FindTextPreview(DependencyObject parent, Source source)
private static Image? FindTextImage(DependencyObject parent, Source source)
{
if (parent is TextBlock text && Equals(text.Tag, "TextLayerPreview")
&& ReferenceEquals(text.DataContext, source))
return text;
if (parent is Image image && ReferenceEquals(image.DataContext, source))
return image;
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
{
var result = FindTextPreview(VisualTreeHelper.GetChild(parent, i), source);
var result = FindTextImage(VisualTreeHelper.GetChild(parent, i), source);
if (result != null) return result;
}
return null;