Blender  V2.93
COM_SocketProxyNode.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * Copyright 2011, Blender Foundation.
17  */
18 
19 #include "COM_SocketProxyNode.h"
20 #include "COM_ExecutionSystem.h"
22 #include "COM_SetColorOperation.h"
23 #include "COM_SetValueOperation.h"
24 #include "COM_SetVectorOperation.h"
27 
28 namespace blender::compositor {
29 
31  bNodeSocket *editorInput,
32  bNodeSocket *editorOutput,
33  bool use_conversion)
34  : Node(editorNode, false), m_use_conversion(use_conversion)
35 {
36  DataType dt;
37 
38  dt = DataType::Value;
39  if (editorInput->type == SOCK_RGBA) {
40  dt = DataType::Color;
41  }
42  if (editorInput->type == SOCK_VECTOR) {
43  dt = DataType::Vector;
44  }
45  this->addInputSocket(dt, editorInput);
46 
47  dt = DataType::Value;
48  if (editorOutput->type == SOCK_RGBA) {
49  dt = DataType::Color;
50  }
51  if (editorOutput->type == SOCK_VECTOR) {
52  dt = DataType::Vector;
53  }
54  this->addOutputSocket(dt, editorOutput);
55 }
56 
58  const CompositorContext & /*context*/) const
59 {
60  NodeOperationOutput *proxy_output = converter.addInputProxy(getInputSocket(0), m_use_conversion);
61  converter.mapOutputSocket(getOutputSocket(), proxy_output);
62 }
63 
65  bNodeSocket *editorInput,
66  bNodeSocket *editorOutput)
67  : Node(editorNode, false)
68 {
69  DataType dt;
70 
71  dt = DataType::Value;
72  if (editorInput->type == SOCK_RGBA) {
73  dt = DataType::Color;
74  }
75  if (editorInput->type == SOCK_VECTOR) {
76  dt = DataType::Vector;
77  }
78  this->addInputSocket(dt, editorInput);
79 
80  dt = DataType::Value;
81  if (editorOutput->type == SOCK_RGBA) {
82  dt = DataType::Color;
83  }
84  if (editorOutput->type == SOCK_VECTOR) {
85  dt = DataType::Vector;
86  }
87  this->addOutputSocket(dt, editorOutput);
88 }
89 
91  const CompositorContext & /*context*/) const
92 {
93  NodeOutput *output = this->getOutputSocket(0);
94  NodeInput *input = this->getInputSocket(0);
95 
96  DataType datatype = output->getDataType();
97  WriteBufferOperation *writeOperation = new WriteBufferOperation(datatype);
98  ReadBufferOperation *readOperation = new ReadBufferOperation(datatype);
99  readOperation->setMemoryProxy(writeOperation->getMemoryProxy());
100  converter.addOperation(writeOperation);
101  converter.addOperation(readOperation);
102 
103  converter.mapInputSocket(input, writeOperation->getInputSocket(0));
104  converter.mapOutputSocket(output, readOperation->getOutputSocket());
105 }
106 
107 } // namespace blender::compositor
@ SOCK_VECTOR
@ SOCK_RGBA
#define output
Overall context of the compositor.
void mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket)
void addOperation(NodeOperation *operation)
NodeOperationOutput * addInputProxy(NodeInput *input, bool use_conversion)
void mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
NodeInput are sockets that can receive data/input.
Definition: COM_Node.h:210
NodeOperationInput * getInputSocket(unsigned int index)
NodeOperationOutput * getOutputSocket(unsigned int index=0)
NodeOutput are sockets that can send data/input.
Definition: COM_Node.h:258
NodeOutput * getOutputSocket(const unsigned int index=0) const
Definition: COM_Node.cc:108
NodeInput * getInputSocket(const unsigned int index) const
Definition: COM_Node.cc:113
void addOutputSocket(DataType datatype)
add an NodeOutput to the collection of output-sockets
Definition: COM_Node.cc:98
void addInputSocket(DataType datatype)
add an NodeInput to the collection of input-sockets
Definition: COM_Node.cc:87
void setMemoryProxy(MemoryProxy *memoryProxy)
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
SocketBufferNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput)
SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput, bool use_conversion)
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
DataType
possible data types for sockets
Definition: COM_defines.h:27
@ Vector
Vector data type.