Blender  V3.3
COM_SocketProxyNode.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2011 Blender Foundation. */
3 
4 #include "COM_SocketProxyNode.h"
7 
8 namespace blender::compositor {
9 
11  bNodeSocket *editor_input,
12  bNodeSocket *editor_output,
13  bool use_conversion)
14  : Node(editor_node, false), use_conversion_(use_conversion)
15 {
16  DataType dt;
17 
18  dt = DataType::Value;
19  if (editor_input->type == SOCK_RGBA) {
20  dt = DataType::Color;
21  }
22  if (editor_input->type == SOCK_VECTOR) {
23  dt = DataType::Vector;
24  }
25  this->add_input_socket(dt, editor_input);
26 
27  dt = DataType::Value;
28  if (editor_output->type == SOCK_RGBA) {
29  dt = DataType::Color;
30  }
31  if (editor_output->type == SOCK_VECTOR) {
32  dt = DataType::Vector;
33  }
34  this->add_output_socket(dt, editor_output);
35 }
36 
38  const CompositorContext & /*context*/) const
39 {
40  NodeOperationOutput *proxy_output = converter.add_input_proxy(get_input_socket(0),
41  use_conversion_);
42  converter.map_output_socket(get_output_socket(), proxy_output);
43 }
44 
46  bNodeSocket *editor_input,
47  bNodeSocket *editor_output)
48  : Node(editor_node, false)
49 {
50  DataType dt;
51 
52  dt = DataType::Value;
53  if (editor_input->type == SOCK_RGBA) {
54  dt = DataType::Color;
55  }
56  if (editor_input->type == SOCK_VECTOR) {
57  dt = DataType::Vector;
58  }
59  this->add_input_socket(dt, editor_input);
60 
61  dt = DataType::Value;
62  if (editor_output->type == SOCK_RGBA) {
63  dt = DataType::Color;
64  }
65  if (editor_output->type == SOCK_VECTOR) {
66  dt = DataType::Vector;
67  }
68  this->add_output_socket(dt, editor_output);
69 }
70 
72  const CompositorContext & /*context*/) const
73 {
75  NodeInput *input = this->get_input_socket(0);
76 
77  DataType datatype = output->get_data_type();
78  WriteBufferOperation *write_operation = new WriteBufferOperation(datatype);
79  ReadBufferOperation *read_operation = new ReadBufferOperation(datatype);
80  read_operation->set_memory_proxy(write_operation->get_memory_proxy());
81  converter.add_operation(write_operation);
82  converter.add_operation(read_operation);
83 
84  converter.map_input_socket(input, write_operation->get_input_socket(0));
85  converter.map_output_socket(output, read_operation->get_output_socket());
86 }
87 
88 } // namespace blender::compositor
@ SOCK_VECTOR
@ SOCK_RGBA
Overall context of the compositor.
void map_output_socket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
NodeOperationOutput * add_input_proxy(NodeInput *input, bool use_conversion)
void add_operation(NodeOperation *operation)
void map_input_socket(NodeInput *node_socket, NodeOperationInput *operation_socket)
NodeInput are sockets that can receive data/input.
Definition: COM_Node.h:190
NodeOperationOutput * get_output_socket(unsigned int index=0)
NodeOperationInput * get_input_socket(unsigned int index)
NodeOutput are sockets that can send data/input.
Definition: COM_Node.h:238
NodeOutput * get_output_socket(unsigned int index=0) const
Definition: COM_Node.cc:84
void add_output_socket(DataType datatype)
add an NodeOutput to the collection of output-sockets
Definition: COM_Node.cc:74
NodeInput * get_input_socket(unsigned int index) const
Definition: COM_Node.cc:89
void add_input_socket(DataType datatype)
add an NodeInput to the collection of input-sockets
Definition: COM_Node.cc:63
void set_memory_proxy(MemoryProxy *memory_proxy)
SocketBufferNode(bNode *editor_node, bNodeSocket *editor_input, bNodeSocket *editor_output)
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
SocketProxyNode(bNode *editor_node, bNodeSocket *editor_input, bNodeSocket *editor_output, bool use_conversion)
DataType
possible data types for sockets
Definition: COM_defines.h:30
@ Vector
Vector data type.
ccl_global KernelShaderEvalInput ccl_global float * output
ccl_global KernelShaderEvalInput * input