Loading...
Searching...
No Matches
score-plugin-gfx/Gfx/Graph/Graph.hpp
1#pragma once
2#include <Process/Dataflow/CableData.hpp>
3
4#include <Gfx/Graph/Node.hpp>
5#include <Gfx/Graph/RenderList.hpp>
6
7#include <ossia/detail/algorithms.hpp>
8
9#include <score_plugin_gfx_export.h>
10namespace Gfx
11{
12class AssetTable;
13}
14namespace score::gfx
15{
16class OutputNode;
17class Window;
21struct SCORE_PLUGIN_GFX_EXPORT Graph
22{
26 explicit Graph();
27
28 ~Graph();
29
33 void addNode(score::gfx::Node* n);
34
38 void removeNode(score::gfx::Node* n);
39
43 void addEdge(Port* source, Port* sink, Process::CableType t);
44
48 void removeEdge(Port* source, Port* sink);
49
51 Edge* findEdge(Port* source, Port* sink);
52
54 void removeNodeFromRenderLists(Node* node);
55
59 void removeNodeAndEdges(Node* node);
60
70 void
71 onEdgeRemoved(Edge& edge, const ossia::hash_set<const Port*>* preserveSinks = nullptr);
72
75 void updateSinkSampler(Edge& edge);
76
78 void createAllMissingPasses();
79 void updateAllSinkSamplers();
80
83 void createPassForEdgeIfMissing(Edge& edge);
84
88 void reconcileAllRenderLists();
89
93 void clearEdges();
94
98 void createAllRenderLists(GraphicsApi graphicsApi);
99
103 void createSingleRenderList(score::gfx::OutputNode& node, GraphicsApi graphicsApi);
104
108 void destroyOutputRenderList(score::gfx::OutputNode& node);
109
118 void releaseOutputRenderList(score::gfx::OutputNode& node);
119
123 void relinkGraph();
124
128 bool canDoVSync() const noexcept;
129
139 void createMissingRenderLists();
140
141 const std::vector<std::shared_ptr<RenderList>>& renderLists() const noexcept
142 {
143 return m_renderers;
144 }
145
146 std::span<OutputNode* const> outputs() const noexcept
147 {
148 return m_outputs;
149 }
150
162 void setAssetTable(Gfx::AssetTable* a) noexcept { m_assetTable = a; }
163 Gfx::AssetTable* assetTable() const noexcept { return m_assetTable; }
164
165private:
167 void retopologicalSort(RenderList& rl);
168
169 void initializeOutput(OutputNode* output, GraphicsApi graphicsApi);
170 void createOutputRenderList(OutputNode& output);
171 void recreateOutputRenderList(OutputNode& output);
172 std::shared_ptr<RenderList>
173 createRenderList(OutputNode*, std::shared_ptr<RenderState> state);
174
175 std::vector<std::shared_ptr<RenderList>> m_renderers;
176 std::vector<std::shared_ptr<Window>> m_unused_windows;
177
178 std::vector<score::gfx::Node*> m_nodes;
179 std::vector<Edge*> m_edges;
180
181 std::vector<OutputNode*> m_outputs;
182
183 // Session-wide decode cache. Non-owning; GfxContext owns the
184 // actual AssetTable. May be null in tests or during teardown.
185 Gfx::AssetTable* m_assetTable{};
186};
187}
Cross-RenderList content-hash dedup for decoded asset bytes.
Definition AssetTable.hpp:71
Root data model for visual nodes.
Definition score-plugin-gfx/Gfx/Graph/Node.hpp:74
Base class for sink nodes (QWindow, spout, syphon, NDI output, ...)
Definition OutputNode.hpp:54
Binds the rendering pipeline to ossia processes.
Definition AssetTable.cpp:7
@ Window
A separate top-level window.
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
GraphicsApi
Available graphics APIs to use.
Definition RenderState.hpp:22
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:103
Represents a graph of renderers.
Definition score-plugin-gfx/Gfx/Graph/Graph.hpp:22
void setAssetTable(Gfx::AssetTable *a) noexcept
Inject the session-wide AssetTable.
Definition score-plugin-gfx/Gfx/Graph/Graph.hpp:162
Port of a score::gfx::Node.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:82