From 7e17315e74763e94d4127f387ec2276ff734eeed Mon Sep 17 00:00:00 2001 From: Aiden Date: Wed, 20 May 2026 14:47:45 +1000 Subject: [PATCH] Preview windows changes --- config/runtime-host.json | 2 +- src/README.md | 2 +- src/preview/PreviewConfig.h | 2 +- src/preview/PreviewWindowThread.cpp | 8 ++++++++ tests/RenderCadenceCompositorAppConfigProviderTests.cpp | 2 +- tests/RenderCadenceCompositorPreviewConfigTests.cpp | 1 + 6 files changed, 13 insertions(+), 4 deletions(-) diff --git a/config/runtime-host.json b/config/runtime-host.json index c143ed3..cde908e 100644 --- a/config/runtime-host.json +++ b/config/runtime-host.json @@ -11,6 +11,6 @@ "autoReload": true, "maxTemporalHistoryFrames": 12, "previewEnabled": true, - "previewFps": 30, + "previewFps": 59.94, "enableExternalKeying": true } diff --git a/src/README.md b/src/README.md index b23eb14..8f7af6c 100644 --- a/src/README.md +++ b/src/README.md @@ -208,7 +208,7 @@ Currently consumed fields: - `previewFps` - `enableExternalKeying` -When `previewEnabled` is true, the preview window runs on `PreviewWindowThread`. It paints BGRA8 system-memory frames with Win32/GDI after render readback has already completed, so it does not bind GL and does not consume frames from DeckLink output. +When `previewEnabled` is true, the preview window runs on `PreviewWindowThread`. It paints BGRA8 system-memory frames with Win32/GDI after render readback has already completed, so it does not bind GL and does not consume frames from DeckLink output. `previewFps` controls the preview repaint cadence; the default is 60 fps and `config/runtime-host.json` tracks the shipped 59.94 output cadence. The loaded config is treated as a read-only startup snapshot. Subsystems that need config should receive this snapshot or a narrowed config struct from app orchestration; they should not reload files independently. diff --git a/src/preview/PreviewConfig.h b/src/preview/PreviewConfig.h index fe45a8d..e62e862 100644 --- a/src/preview/PreviewConfig.h +++ b/src/preview/PreviewConfig.h @@ -4,7 +4,7 @@ namespace RenderCadenceCompositor { -constexpr double kDefaultPreviewFps = 30.0; +constexpr double kDefaultPreviewFps = 60.0; constexpr double kMinimumPreviewFps = 1.0; struct PreviewWindowConfig diff --git a/src/preview/PreviewWindowThread.cpp b/src/preview/PreviewWindowThread.cpp index 5542a6a..d543b01 100644 --- a/src/preview/PreviewWindowThread.cpp +++ b/src/preview/PreviewWindowThread.cpp @@ -210,6 +210,10 @@ void PreviewWindowThread::Paint(HWND window) frame.height > 0; if (canPaintFrame) { + const int previousStretchMode = SetStretchBltMode(dc, HALFTONE); + POINT previousBrushOrigin = {}; + SetBrushOrgEx(dc, 0, 0, &previousBrushOrigin); + BITMAPINFO bitmapInfo = {}; bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bitmapInfo.bmiHeader.biWidth = static_cast(frame.width); @@ -232,6 +236,10 @@ void PreviewWindowThread::Paint(HWND window) &bitmapInfo, DIB_RGB_COLORS, SRCCOPY); + + if (previousStretchMode != 0) + SetStretchBltMode(dc, previousStretchMode); + SetBrushOrgEx(dc, previousBrushOrigin.x, previousBrushOrigin.y, nullptr); } else { diff --git a/tests/RenderCadenceCompositorAppConfigProviderTests.cpp b/tests/RenderCadenceCompositorAppConfigProviderTests.cpp index e73e741..30f71e6 100644 --- a/tests/RenderCadenceCompositorAppConfigProviderTests.cpp +++ b/tests/RenderCadenceCompositorAppConfigProviderTests.cpp @@ -99,7 +99,7 @@ void TestPreviewDefaultsAreOptIn() const AppConfig config = DefaultAppConfig(); Expect(!config.previewEnabled, "preview is disabled by default"); - Expect(config.previewFps == 30.0, "preview fps default is 30"); + Expect(config.previewFps == 60.0, "preview fps default is 60"); } void TestHelpers() diff --git a/tests/RenderCadenceCompositorPreviewConfigTests.cpp b/tests/RenderCadenceCompositorPreviewConfigTests.cpp index c7f2e3e..63793c9 100644 --- a/tests/RenderCadenceCompositorPreviewConfigTests.cpp +++ b/tests/RenderCadenceCompositorPreviewConfigTests.cpp @@ -19,6 +19,7 @@ void TestTimerIntervalUsesConfiguredFps() { Expect(RenderCadenceCompositor::PreviewTimerIntervalMilliseconds(25.0) == 40, "25 fps maps to 40 ms"); Expect(RenderCadenceCompositor::PreviewTimerIntervalMilliseconds(50.0) == 20, "50 fps maps to 20 ms"); + Expect(RenderCadenceCompositor::PreviewTimerIntervalMilliseconds(59.94) == 16, "59.94 fps maps to 16 ms"); } void TestInvalidFpsUsesDefault()