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