Loading...
Searching...
No Matches
ISFExecutorNode.hpp
1#pragma once
2#include <Gfx/GfxExecNode.hpp>
3#include <Gfx/Graph/ISFNode.hpp>
4
5#include <isf.hpp>
6namespace Gfx
7{
8
9class filter_node final : public gfx_exec_node
10{
11public:
13 const isf::descriptor& isf, const QString& vert, const QString& frag,
15 : gfx_exec_node{ctx}
16 {
17 auto n = std::make_unique<score::gfx::ISFNode>(isf, vert, frag);
18
19 id = exec_context->ui->register_node(std::move(n));
20 }
21
22 void set_script(const isf::descriptor& isf, const QString& vert, const QString& frag)
23 {
24 exec_context->ui->unregister_node(id);
25 id = score::gfx::invalid_node_index;
26
27 for(int i = 0, n = std::ssize(controls); i < n; i++)
28 {
29 auto& ctl = controls[i];
30 ctl->port->write_value(ctl->value, 0);
31 }
32
33 auto n = std::make_unique<score::gfx::ISFNode>(isf, vert, frag);
34
35 {
36 score::gfx::Message msg = exec_context->allocateMessage(this->m_inlets.size() + 1);
37 msg.node_id = id;
38 msg.token.date = m_last_flicks;
39 msg.token.parent_duration = ossia::time_value{}; // FIXME
40 msg.input.resize(this->m_inlets.size());
41 int inlet_i = 0;
42 for(ossia::inlet* inlet : this->m_inlets)
43 {
44 switch(inlet->which())
45 {
46 case ossia::value_port::which: {
47 auto& p = inlet->cast<ossia::value_port>();
48 if(!p.get_data().empty())
49 {
50 msg.input[inlet_i] = std::move(p.get_data().back().value);
51 p.get_data().clear();
52 }
53
54 break;
55 }
56 }
57 inlet_i++;
58 }
59 n->process(std::move(msg)); // note: node_id is incorrect at that point, it's ok
60 }
61 id = exec_context->ui->register_node(std::move(n));
62 }
63
65 const isf::descriptor& isf, const QString& compute, GfxExecutionAction& ctx)
66 : gfx_exec_node{ctx}
67 {
68 auto n = std::make_unique<score::gfx::ISFNode>(isf, compute);
69
70 id = exec_context->ui->register_node(std::move(n));
71 }
72
73 void set_script(const isf::descriptor& isf, const QString& compute)
74 {
75 exec_context->ui->unregister_node(id);
76 id = score::gfx::invalid_node_index;
77
78 for(int i = 0, n = std::ssize(controls); i < n; i++)
79 {
80 auto& ctl = controls[i];
81 ctl->port->write_value(ctl->value, 0);
82 }
83
84 auto n = std::make_unique<score::gfx::ISFNode>(isf, compute);
85
86 {
87 score::gfx::Message msg = exec_context->allocateMessage(this->m_inlets.size() + 1);
88 msg.node_id = id;
89 msg.token.date = m_last_flicks;
90 msg.token.parent_duration = ossia::time_value{}; // FIXME
91 msg.input.resize(this->m_inlets.size());
92 int inlet_i = 0;
93 for(ossia::inlet* inlet : this->m_inlets)
94 {
95 switch(inlet->which())
96 {
97 case ossia::value_port::which: {
98 auto& p = inlet->cast<ossia::value_port>();
99 if(!p.get_data().empty())
100 {
101 msg.input[inlet_i] = std::move(p.get_data().back().value);
102 p.get_data().clear();
103 }
104
105 break;
106 }
107 }
108 inlet_i++;
109 }
110 n->process(std::move(msg)); // note: node_id is incorrect at that point, it's ok
111 }
112 id = exec_context->ui->register_node(std::move(n));
113 }
114
115 ~filter_node() { exec_context->ui->unregister_node(id); }
116
117 std::string label() const noexcept override { return "Gfx::filter_node"; }
118};
119
120}
Definition GfxExecContext.hpp:16
Definition ISFExecutorNode.hpp:10
Definition GfxExecNode.hpp:40
Binds the rendering pipeline to ossia processes.
Definition CameraDevice.cpp:30
Definition score-plugin-gfx/Gfx/Graph/Node.hpp:49