78 using NodePtr = std::unique_ptr<score::gfx::Node>;
83 int32_t register_node(NodePtr node);
84 int32_t register_preview_node(std::unique_ptr<score::gfx::OutputNode> node);
85 void connect_preview_node(
EdgeSpec e);
86 void disconnect_preview_node(
EdgeSpec e);
87 void unregister_node(int32_t idx);
88 void unregister_preview_node(int32_t idx);
100 port_index producer, QSize size, std::shared_ptr<QRhiReadbackResult> readback);
101 void set_preview_producer(int32_t
id, port_index producer);
102 void set_preview_size(int32_t
id, QSize size);
103 void remove_preview(int32_t
id);
105 bool preview_is_tapped(int32_t
id)
const noexcept;
107 bool preview_is_on_hub(int32_t
id)
const noexcept;
110 void want_preview_frame(int32_t
id)
const noexcept;
112 static constexpr int max_preview_size = 1024;
123 std::span<score::gfx::OutputNode* const> outputs() const noexcept;
125 void recompute_edges();
126 void recompute_graph();
127 void recompute_connections();
128 void recomputeTimers();
129 void recomputeGraphTopology();
130 void incrementalEdgeUpdate(
131 const ossia::flat_set<
EdgeSpec>& old_edges,
132 const ossia::flat_set<
EdgeSpec>& cur_edges);
134 void update_inputs();
160 void renderFrames(
int frames);
163 double stepRate() const noexcept {
return m_stepRate; }
167 void setStepRate(
double fps);
170 bool executionStepped() const noexcept;
180 bool renderInProgress() const noexcept;
182 void send_message(
score::gfx::Message&& msg) noexcept
184 tick_messages.enqueue(std::move(msg));
197 const AssetTable& assets() const noexcept {
return m_assets; }
201 void updatePreviews();
204 port_index producer{-1, -1};
206 std::shared_ptr<QRhiReadbackResult> readback;
207 std::shared_ptr<score::gfx::PreviewTap> tap;
209 int32_t tappedNode{-1};
212 port_index hubProducer{-1, -1};
215 bool hubUnreadable{};
217 int32_t fallbackId{-1};
219 port_index fallbackProducer{-1, -1};
221 bool joinPreviewHub(Preview& p);
222 void releaseUnusedPreviewHub();
223 void leavePreviewHub(Preview& p);
224 void startPreviewFallback(Preview& p);
225 void stopPreviewFallback(Preview& p);
229 int32_t m_previewHubId{-1};
230 ossia::flat_map<int32_t, Preview> m_previews;
231 int32_t m_nextPreview{1};
235 void remove_preview_output();
236 void add_edge(EdgeSpec e);
237 void remove_edge(EdgeSpec e);
238 void forgetDeferredEdge(
const EdgeSpec& spec)
noexcept;
239 void remove_node(std::vector<std::unique_ptr<score::gfx::Node>>& nursery, int32_t
id);
244 bool frameInProgress() const noexcept;
245 bool refuseNestedRender(const
char* entry) noexcept;
247 const
score::DocumentContext& m_context;
248 std::atomic_int32_t index{1};
249 ossia::hash_map<int32_t, NodePtr> nodes;
254 double m_stepRate{60.};
255 int64_t m_stepFrame{};
256 int64_t m_stepPlayCount{-1};
269 std::unique_ptr<score::gfx::Node> node;
276 CONNECT_PREVIEW_NODE,
277 DISCONNECT_PREVIEW_NODE
282 using Command = ossia::variant<NodeCommand, EdgeCommand>;
283 moodycamel::ConcurrentQueue<Command> tick_commands;
284 moodycamel::ConcurrentQueue<score::gfx::Message> tick_messages;
285 std::vector<std::pair<score::gfx::Message, int>> m_deferredMessages;
287 std::vector<score::gfx::Message> m_drainedMessages;
288 std::vector<std::pair<EdgeSpec, int>> m_deferredEdges;
290 std::mutex m_disownedLock;
291 ossia::flat_set<int32_t> m_disownedPending;
292 bool isDisownedPending(int32_t index);
294 std::mutex edges_lock;
295 ossia::flat_set<EdgeSpec> new_edges TS_GUARDED_BY(edges_lock);
296 ossia::flat_set<EdgeSpec> edges TS_GUARDED_BY(edges_lock);
297 ossia::flat_set<EdgeSpec> preview_edges TS_GUARDED_BY(edges_lock);
298 std::atomic_bool edges_changed{};
299 bool m_fullRebuildThisFrame{};
304 QTimer* m_freewheel_timer{};
311 std::vector<std::unique_ptr<score::gfx::TimerClock>> m_renderClocks;
312 std::unique_ptr<score::gfx::DisplayVSyncClock> m_vsyncClock;
314 ossia::object_pool<std::vector<score::gfx::gfx_input>> m_buffers;
321 int m_nestedRenders{};
Definition GfxContext.hpp:74
AssetTable & assets() noexcept
Session-wide content-hash decode cache.
Definition GfxContext.hpp:196
Definition DocumentContext.hpp:18