Blender V4.3
COM_CombineColorNode.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
6
8
9namespace blender::compositor {
10
11CombineColorNode::CombineColorNode(bNode *editor_node) : Node(editor_node) {}
12
14 const CompositorContext & /*context*/) const
15{
16 NodeInput *input_rsocket = this->get_input_socket(0);
17 NodeInput *input_gsocket = this->get_input_socket(1);
18 NodeInput *input_bsocket = this->get_input_socket(2);
19 NodeInput *input_asocket = this->get_input_socket(3);
20 NodeOutput *output_socket = this->get_output_socket(0);
21
23 if (input_rsocket->is_linked()) {
24 operation->set_canvas_input_index(0);
25 }
26 else if (input_gsocket->is_linked()) {
27 operation->set_canvas_input_index(1);
28 }
29 else if (input_bsocket->is_linked()) {
30 operation->set_canvas_input_index(2);
31 }
32 else {
33 operation->set_canvas_input_index(3);
34 }
35 converter.add_operation(operation);
36
37 converter.map_input_socket(input_rsocket, operation->get_input_socket(0));
38 converter.map_input_socket(input_gsocket, operation->get_input_socket(1));
39 converter.map_input_socket(input_bsocket, operation->get_input_socket(2));
40 converter.map_input_socket(input_asocket, operation->get_input_socket(3));
41
42 const bNode *editor_node = this->get_bnode();
43 NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)editor_node->storage;
44
45 NodeOperation *color_conv = nullptr;
46 switch (storage->mode) {
48 /* Pass */
49 break;
50 }
52 color_conv = new ConvertHSVToRGBOperation();
53 break;
54 }
56 color_conv = new ConvertHSLToRGBOperation();
57 break;
58 }
61 operation->set_mode(storage->ycc_mode);
62 color_conv = operation;
63 break;
64 }
66 color_conv = new ConvertYUVToRGBOperation();
67 break;
68 }
69 default: {
71 break;
72 }
73 }
74
75 if (color_conv) {
76 converter.add_operation(color_conv);
77
78 converter.add_link(operation->get_output_socket(), color_conv->get_input_socket(0));
79 converter.map_output_socket(output_socket, color_conv->get_output_socket());
80 }
81 else {
82 converter.map_output_socket(output_socket, operation->get_output_socket());
83 }
84}
85
86} // namespace blender::compositor
#define BLI_assert_unreachable()
Definition BLI_assert.h:97
@ 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:191
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:239
NodeOutput * get_output_socket(unsigned int index=0) const
Definition COM_Node.cc:85
NodeInput * get_input_socket(unsigned int index) const
Definition COM_Node.cc:90
const bNode * get_bnode() const
get the reference to the SDNA bNode struct
Definition COM_Node.h:65
void * storage