diff --git a/apps/LoopThroughWithOpenGLCompositing/gl/RuntimeUpdateController.cpp b/apps/LoopThroughWithOpenGLCompositing/gl/RuntimeUpdateController.cpp index 83d31d9..286482a 100644 --- a/apps/LoopThroughWithOpenGLCompositing/gl/RuntimeUpdateController.cpp +++ b/apps/LoopThroughWithOpenGLCompositing/gl/RuntimeUpdateController.cpp @@ -1,6 +1,7 @@ #include "RuntimeUpdateController.h" #include "RenderEngine.h" +#include "RuntimeEventDispatcher.h" #include "RuntimeServices.h" #include "RuntimeStore.h" #include "ShaderBuildQueue.h" @@ -24,6 +25,9 @@ RuntimeUpdateController::RuntimeUpdateController( mShaderBuildQueue(shaderBuildQueue), mVideoBackend(videoBackend) { + mRuntimeEventDispatcher.Subscribe( + RuntimeEventType::RuntimeStateBroadcastRequested, + [this](const RuntimeEvent& event) { HandleRuntimeStateBroadcastRequested(event); }); } bool RuntimeUpdateController::ApplyRuntimeCoordinatorResult(const RuntimeCoordinatorResult& result, std::string* error) @@ -62,6 +66,8 @@ bool RuntimeUpdateController::ApplyRuntimeCoordinatorResult(const RuntimeCoordin bool RuntimeUpdateController::ProcessRuntimeWork() { + mRuntimeEventDispatcher.DispatchPending(); + bool shaderBuildRequested = false; std::vector serviceResults; mRuntimeServices.ConsumeRuntimeCoordinatorResults(serviceResults); @@ -101,5 +107,19 @@ void RuntimeUpdateController::RequestShaderBuild() void RuntimeUpdateController::BroadcastRuntimeState() { + RuntimeStateBroadcastRequestedEvent event; + event.reason = "runtime-state-changed"; + if (!mRuntimeEventDispatcher.PublishPayload(event, "RuntimeUpdateController")) + { + mRuntimeServices.BroadcastState(); + return; + } + + mRuntimeEventDispatcher.DispatchPending(); +} + +void RuntimeUpdateController::HandleRuntimeStateBroadcastRequested(const RuntimeEvent& event) +{ + (void)event; mRuntimeServices.BroadcastState(); } diff --git a/apps/LoopThroughWithOpenGLCompositing/gl/RuntimeUpdateController.h b/apps/LoopThroughWithOpenGLCompositing/gl/RuntimeUpdateController.h index f3d25e3..f30a0f9 100644 --- a/apps/LoopThroughWithOpenGLCompositing/gl/RuntimeUpdateController.h +++ b/apps/LoopThroughWithOpenGLCompositing/gl/RuntimeUpdateController.h @@ -5,6 +5,7 @@ #include class RenderEngine; +struct RuntimeEvent; class RuntimeEventDispatcher; class RuntimeServices; class RuntimeStore; @@ -29,6 +30,8 @@ public: void BroadcastRuntimeState(); private: + void HandleRuntimeStateBroadcastRequested(const RuntimeEvent& event); + RuntimeStore& mRuntimeStore; RuntimeCoordinator& mRuntimeCoordinator; RuntimeEventDispatcher& mRuntimeEventDispatcher;