68 lines
1.9 KiB
C++
68 lines
1.9 KiB
C++
#include "ShaderRuntimeContentController.h"
|
|
|
|
#include "../control/RuntimeControlCommand.h"
|
|
#include "../control/RuntimeStateJson.h"
|
|
|
|
#include <utility>
|
|
|
|
namespace RenderCadenceCompositor
|
|
{
|
|
ShaderRuntimeContentController::ShaderRuntimeContentController(RenderLayerPublisher publisher) :
|
|
mRuntimeLayers(std::move(publisher))
|
|
{
|
|
}
|
|
|
|
ShaderRuntimeContentController::~ShaderRuntimeContentController()
|
|
{
|
|
Stop();
|
|
}
|
|
|
|
void ShaderRuntimeContentController::Initialize(AppConfig& config)
|
|
{
|
|
mRuntimeLayers.Initialize(
|
|
config.shaderLibrary,
|
|
static_cast<unsigned>(config.maxTemporalHistoryFrames),
|
|
config.runtimeShaderId);
|
|
mStartupShaderId = config.runtimeShaderId;
|
|
}
|
|
|
|
void ShaderRuntimeContentController::Start()
|
|
{
|
|
mRuntimeLayers.StartStartupBuild(mStartupShaderId);
|
|
}
|
|
|
|
void ShaderRuntimeContentController::Stop()
|
|
{
|
|
mRuntimeLayers.Stop();
|
|
}
|
|
|
|
ControlActionResult ShaderRuntimeContentController::HandlePost(const std::string& path, const std::string& body)
|
|
{
|
|
if (path == "/api/layers/add")
|
|
return mRuntimeLayers.HandleAddLayer(body);
|
|
if (path == "/api/layers/remove")
|
|
return mRuntimeLayers.HandleRemoveLayer(body);
|
|
|
|
RuntimeControlCommand command;
|
|
std::string error;
|
|
if (!ParseRuntimeControlCommand(path, body, command, error))
|
|
return ControlActionResult{ false, error };
|
|
return mRuntimeLayers.HandleControlCommand(command);
|
|
}
|
|
|
|
void ShaderRuntimeContentController::WriteRuntimeJson(JsonWriter& writer, const CadenceTelemetrySnapshot& telemetry) const
|
|
{
|
|
WriteShaderRuntimeJson(writer, mRuntimeLayers.Snapshot(telemetry));
|
|
}
|
|
|
|
void ShaderRuntimeContentController::WriteCatalogJson(JsonWriter& writer) const
|
|
{
|
|
WriteShaderCatalogJson(writer, mRuntimeLayers.ShaderCatalog());
|
|
}
|
|
|
|
void ShaderRuntimeContentController::WriteLayersJson(JsonWriter& writer, const CadenceTelemetrySnapshot& telemetry) const
|
|
{
|
|
WriteRuntimeShaderLayersJson(writer, mRuntimeLayers.ShaderCatalog(), mRuntimeLayers.Snapshot(telemetry));
|
|
}
|
|
}
|