Files
video-shader-toys/apps/LoopThroughWithOpenGLCompositing/runtime/live/RuntimeLiveState.h
Aiden 0808171677
All checks were successful
CI / React UI Build (push) Successful in 11s
CI / Native Windows Build And Tests (push) Successful in 2m32s
CI / Windows Release Package (push) Successful in 2m34s
GROUND WORK PHASE 3
2026-05-11 16:32:51 +10:00

72 lines
1.6 KiB
C++

#pragma once
#include "RuntimeJson.h"
#include "ShaderTypes.h"
#include <chrono>
#include <cstdint>
#include <map>
#include <string>
#include <vector>
struct RuntimeLiveOscUpdate
{
std::string routeKey;
std::string layerKey;
std::string parameterKey;
JsonValue targetValue;
};
struct RuntimeLiveOscCommitCompletion
{
std::string routeKey;
uint64_t generation = 0;
};
struct RuntimeLiveOscCommitRequest
{
std::string routeKey;
std::string layerKey;
std::string parameterKey;
JsonValue value;
uint64_t generation = 0;
};
struct RuntimeLiveStateApplyOptions
{
bool allowCommit = false;
double smoothing = 0.0;
std::chrono::milliseconds commitDelay = std::chrono::milliseconds(150);
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
};
class RuntimeLiveState
{
public:
void Clear();
std::size_t OverlayCount() const;
void ApplyOscUpdates(const std::vector<RuntimeLiveOscUpdate>& updates);
void ApplyOscCommitCompletions(const std::vector<RuntimeLiveOscCommitCompletion>& completedCommits);
void ApplyToLayerStates(
std::vector<RuntimeRenderState>& states,
const RuntimeLiveStateApplyOptions& options,
std::vector<RuntimeLiveOscCommitRequest>* commitRequests);
private:
struct OscOverlayState
{
std::string layerKey;
std::string parameterKey;
JsonValue targetValue;
ShaderParameterValue currentValue;
bool hasCurrentValue = false;
std::chrono::steady_clock::time_point lastUpdatedTime;
std::chrono::steady_clock::time_point lastAppliedTime;
uint64_t generation = 0;
uint64_t pendingCommitGeneration = 0;
bool commitQueued = false;
};
std::map<std::string, OscOverlayState> mOscOverlayStates;
};