Files
video-shader-toys/apps/LoopThroughWithOpenGLCompositing/control/RuntimeServiceLiveBridge.cpp
Aiden 06f3dd4942
Some checks failed
CI / React UI Build (push) Successful in 10s
CI / Native Windows Build And Tests (push) Successful in 2m33s
CI / Windows Release Package (push) Has been cancelled
Phase 3 refactor in progress
2026-05-11 16:48:52 +10:00

78 lines
2.5 KiB
C++

#include "RuntimeServiceLiveBridge.h"
#include "RuntimeServices.h"
#include <windows.h>
void RuntimeServiceLiveBridge::DrainServiceEvents(RuntimeServices& runtimeServices, RenderEngine& renderEngine)
{
std::vector<RuntimeServices::AppliedOscUpdate> appliedOscUpdates;
std::vector<RuntimeServices::CompletedOscCommit> completedOscCommits;
std::string oscError;
if (!runtimeServices.ApplyPendingOscUpdates(appliedOscUpdates, oscError) && !oscError.empty())
OutputDebugStringA(("OSC apply failed: " + oscError + "\n").c_str());
runtimeServices.ConsumeCompletedOscCommits(completedOscCommits);
std::vector<RenderEngine::OscOverlayUpdate> overlayUpdates;
overlayUpdates.reserve(appliedOscUpdates.size());
for (const RuntimeServices::AppliedOscUpdate& update : appliedOscUpdates)
{
overlayUpdates.push_back({ update.routeKey, update.layerKey, update.parameterKey, update.targetValue });
}
std::vector<RenderEngine::OscOverlayCommitCompletion> overlayCommitCompletions;
overlayCommitCompletions.reserve(completedOscCommits.size());
for (const RuntimeServices::CompletedOscCommit& completedCommit : completedOscCommits)
{
overlayCommitCompletions.push_back({ completedCommit.routeKey, completedCommit.generation });
}
renderEngine.UpdateOscOverlayState(overlayUpdates, overlayCommitCompletions);
}
void RuntimeServiceLiveBridge::QueueServiceCommitRequests(
RuntimeServices& runtimeServices,
const std::vector<RenderEngine::OscOverlayCommitRequest>& commitRequests)
{
for (const RenderEngine::OscOverlayCommitRequest& commitRequest : commitRequests)
{
std::string commitError;
if (!runtimeServices.QueueOscCommit(
commitRequest.routeKey,
commitRequest.layerKey,
commitRequest.parameterKey,
commitRequest.value,
commitRequest.generation,
commitError) &&
!commitError.empty())
{
OutputDebugStringA(("OSC commit queue failed: " + commitError + "\n").c_str());
}
}
}
bool RuntimeServiceLiveBridge::PrepareLiveRenderLayerStates(
RuntimeServices& runtimeServices,
RenderEngine& renderEngine,
bool useCommittedLayerStates,
unsigned renderWidth,
unsigned renderHeight,
double oscSmoothing,
std::vector<RuntimeRenderState>& layerStates)
{
DrainServiceEvents(runtimeServices, renderEngine);
std::vector<RenderEngine::OscOverlayCommitRequest> commitRequests;
const bool resolved = renderEngine.ResolveRenderLayerStates(
useCommittedLayerStates,
renderWidth,
renderHeight,
oscSmoothing,
&commitRequests,
layerStates);
QueueServiceCommitRequests(runtimeServices, commitRequests);
return resolved;
}