Blender  V3.3
COM_CombineColorNode.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_CombineColorNode.h"
5 
6 #include "COM_ConvertOperation.h"
7 
8 namespace blender::compositor {
9 
10 CombineColorNode::CombineColorNode(bNode *editor_node) : Node(editor_node)
11 {
12 }
13 
15  const CompositorContext &UNUSED(context)) const
16 {
17  NodeInput *input_rsocket = this->get_input_socket(0);
18  NodeInput *input_gsocket = this->get_input_socket(1);
19  NodeInput *input_bsocket = this->get_input_socket(2);
20  NodeInput *input_asocket = this->get_input_socket(3);
21  NodeOutput *output_socket = this->get_output_socket(0);
22 
24  if (input_rsocket->is_linked()) {
25  operation->set_canvas_input_index(0);
26  }
27  else if (input_gsocket->is_linked()) {
28  operation->set_canvas_input_index(1);
29  }
30  else if (input_bsocket->is_linked()) {
31  operation->set_canvas_input_index(2);
32  }
33  else {
34  operation->set_canvas_input_index(3);
35  }
36  converter.add_operation(operation);
37 
38  converter.map_input_socket(input_rsocket, operation->get_input_socket(0));
39  converter.map_input_socket(input_gsocket, operation->get_input_socket(1));
40  converter.map_input_socket(input_bsocket, operation->get_input_socket(2));
41  converter.map_input_socket(input_asocket, operation->get_input_socket(3));
42 
43  bNode *editor_node = this->get_bnode();
44  NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)editor_node->storage;
45 
46  NodeOperation *color_conv = nullptr;
47  switch (storage->mode) {
49  /* Pass */
50  break;
51  }
53  color_conv = new ConvertHSVToRGBOperation();
54  break;
55  }
57  color_conv = new ConvertHSLToRGBOperation();
58  break;
59  }
62  operation->set_mode(storage->ycc_mode);
63  color_conv = operation;
64  break;
65  }
67  color_conv = new ConvertYUVToRGBOperation();
68  break;
69  }
70  default: {
72  break;
73  }
74  }
75 
76  if (color_conv) {
77  converter.add_operation(color_conv);
78 
79  converter.add_link(operation->get_output_socket(), color_conv->get_input_socket(0));
80  converter.map_output_socket(output_socket, color_conv->get_output_socket());
81  }
82  else {
83  converter.map_output_socket(output_socket, operation->get_output_socket());
84  }
85 }
86 
87 } // namespace blender::compositor
#define BLI_assert_unreachable()
Definition: BLI_assert.h:93
#define UNUSED(x)
@ CMP_NODE_COMBSEP_COLOR_YCC
@ CMP_NODE_COMBSEP_COLOR_YUV
@ CMP_NODE_COMBSEP_COLOR_RGB
@ CMP_NODE_COMBSEP_COLOR_HSV
@ CMP_NODE_COMBSEP_COLOR_HSL
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
Overall context of the compositor.
void add_link(NodeOperationOutput *from, NodeOperationInput *to)
void map_output_socket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
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
NodeOperation contains calculation logic.
NodeOperationOutput * get_output_socket(unsigned int index=0)
NodeOperationInput * get_input_socket(unsigned int index)
void set_canvas_input_index(unsigned int index)
set the index of the input socket that will determine the canvas of this operation
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
bNode * get_bnode() const
get the reference to the SDNA bNode struct
Definition: COM_Node.h:64
NodeInput * get_input_socket(unsigned int index) const
Definition: COM_Node.cc:89
void * storage