Blender  V3.3
COM_SeparateColorNode.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2011 Blender Foundation. */
3 
5 
6 #include "COM_ConvertOperation.h"
7 
8 namespace blender::compositor {
9 
10 SeparateColorNode::SeparateColorNode(bNode *editor_node) : Node(editor_node)
11 {
12 }
13 
15  const CompositorContext &UNUSED(context)) const
16 {
17  NodeInput *image_socket = this->get_input_socket(0);
18  NodeOutput *output_rsocket = this->get_output_socket(0);
19  NodeOutput *output_gsocket = this->get_output_socket(1);
20  NodeOutput *output_bsocket = this->get_output_socket(2);
21  NodeOutput *output_asocket = this->get_output_socket(3);
22 
23  bNode *editor_node = this->get_bnode();
24  NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)editor_node->storage;
25 
26  NodeOperation *color_conv = nullptr;
27  switch (storage->mode) {
29  /* Pass */
30  break;
31  }
33  color_conv = new ConvertRGBToHSVOperation();
34  break;
35  }
37  color_conv = new ConvertRGBToHSLOperation();
38  break;
39  }
42  operation->set_mode(storage->ycc_mode);
43  color_conv = operation;
44  break;
45  }
47  color_conv = new ConvertRGBToYUVOperation();
48  break;
49  }
50  default: {
52  break;
53  }
54  }
55 
56  if (color_conv) {
57  converter.add_operation(color_conv);
58 
59  converter.map_input_socket(image_socket, color_conv->get_input_socket(0));
60  }
61 
62  {
64  operation->set_channel(0);
65  converter.add_operation(operation);
66 
67  if (color_conv) {
68  converter.add_link(color_conv->get_output_socket(), operation->get_input_socket(0));
69  }
70  else {
71  converter.map_input_socket(image_socket, operation->get_input_socket(0));
72  }
73  converter.map_output_socket(output_rsocket, operation->get_output_socket(0));
74  }
75 
76  {
78  operation->set_channel(1);
79  converter.add_operation(operation);
80 
81  if (color_conv) {
82  converter.add_link(color_conv->get_output_socket(), operation->get_input_socket(0));
83  }
84  else {
85  converter.map_input_socket(image_socket, operation->get_input_socket(0));
86  }
87  converter.map_output_socket(output_gsocket, operation->get_output_socket(0));
88  }
89 
90  {
92  operation->set_channel(2);
93  converter.add_operation(operation);
94 
95  if (color_conv) {
96  converter.add_link(color_conv->get_output_socket(), operation->get_input_socket(0));
97  }
98  else {
99  converter.map_input_socket(image_socket, operation->get_input_socket(0));
100  }
101  converter.map_output_socket(output_bsocket, operation->get_output_socket(0));
102  }
103 
104  {
106  operation->set_channel(3);
107  converter.add_operation(operation);
108 
109  if (color_conv) {
110  converter.add_link(color_conv->get_output_socket(), operation->get_input_socket(0));
111  }
112  else {
113  converter.map_input_socket(image_socket, operation->get_input_socket(0));
114  }
115  converter.map_output_socket(output_asocket, operation->get_output_socket(0));
116  }
117 }
118 
119 } // 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
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)
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 convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
void * storage