Blender V4.3
COM_SeparateColorNode.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
11SeparateColorNode::SeparateColorNode(bNode *editor_node) : Node(editor_node) {}
12
14 const CompositorContext & /*context*/) const
15{
16 NodeInput *image_socket = this->get_input_socket(0);
17 NodeOutput *output_rsocket = this->get_output_socket(0);
18 NodeOutput *output_gsocket = this->get_output_socket(1);
19 NodeOutput *output_bsocket = this->get_output_socket(2);
20 NodeOutput *output_asocket = this->get_output_socket(3);
21
22 const bNode *editor_node = this->get_bnode();
23 const NodeCMPCombSepColor *storage = (const NodeCMPCombSepColor *)editor_node->storage;
24
25 NodeOperation *color_conv = nullptr;
26 switch (storage->mode) {
28 /* Pass */
29 break;
30 }
32 color_conv = new ConvertRGBToHSVOperation();
33 break;
34 }
36 color_conv = new ConvertRGBToHSLOperation();
37 break;
38 }
41 operation->set_mode(storage->ycc_mode);
42 color_conv = operation;
43 break;
44 }
46 color_conv = new ConvertRGBToYUVOperation();
47 break;
48 }
49 default: {
51 break;
52 }
53 }
54
55 if (color_conv) {
56 converter.add_operation(color_conv);
57
58 converter.map_input_socket(image_socket, color_conv->get_input_socket(0));
59 }
60
61 {
63 operation->set_channel(0);
64 converter.add_operation(operation);
65
66 if (color_conv) {
67 converter.add_link(color_conv->get_output_socket(), operation->get_input_socket(0));
68 }
69 else {
70 converter.map_input_socket(image_socket, operation->get_input_socket(0));
71 }
72 converter.map_output_socket(output_rsocket, operation->get_output_socket(0));
73 }
74
75 {
77 operation->set_channel(1);
78 converter.add_operation(operation);
79
80 if (color_conv) {
81 converter.add_link(color_conv->get_output_socket(), operation->get_input_socket(0));
82 }
83 else {
84 converter.map_input_socket(image_socket, operation->get_input_socket(0));
85 }
86 converter.map_output_socket(output_gsocket, operation->get_output_socket(0));
87 }
88
89 {
91 operation->set_channel(2);
92 converter.add_operation(operation);
93
94 if (color_conv) {
95 converter.add_link(color_conv->get_output_socket(), operation->get_input_socket(0));
96 }
97 else {
98 converter.map_input_socket(image_socket, operation->get_input_socket(0));
99 }
100 converter.map_output_socket(output_bsocket, operation->get_output_socket(0));
101 }
102
103 {
105 operation->set_channel(3);
106 converter.add_operation(operation);
107
108 if (color_conv) {
109 converter.add_link(color_conv->get_output_socket(), operation->get_input_socket(0));
110 }
111 else {
112 converter.map_input_socket(image_socket, operation->get_input_socket(0));
113 }
114 converter.map_output_socket(output_asocket, operation->get_output_socket(0));
115 }
116}
117
118} // 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
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)
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 convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
void * storage