Blender  V3.3
COM_ChannelMatteNode.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2012 Blender Foundation. */
3 
4 #include "COM_ChannelMatteNode.h"
6 #include "COM_ConvertOperation.h"
8 
9 namespace blender::compositor {
10 
11 ChannelMatteNode::ChannelMatteNode(bNode *editor_node) : Node(editor_node)
12 {
13  /* pass */
14 }
15 
17  const CompositorContext & /*context*/) const
18 {
19  bNode *node = this->get_bnode();
20 
21  NodeInput *input_socket_image = this->get_input_socket(0);
22  NodeOutput *output_socket_image = this->get_output_socket(0);
23  NodeOutput *output_socket_matte = this->get_output_socket(1);
24 
25  NodeOperation *convert = nullptr, *inv_convert = nullptr;
26  /* color-space */
27  switch (node->custom1) {
29  break;
30  case CMP_NODE_CHANNEL_MATTE_CS_HSV: /* HSV */
32  inv_convert = new ConvertHSVToRGBOperation();
33  break;
34  case CMP_NODE_CHANNEL_MATTE_CS_YUV: /* YUV */
36  inv_convert = new ConvertYUVToRGBOperation();
37  break;
38  case CMP_NODE_CHANNEL_MATTE_CS_YCC: /* YCC */
41  inv_convert = new ConvertYCCToRGBOperation();
42  ((ConvertYCCToRGBOperation *)inv_convert)->set_mode(BLI_YCC_ITU_BT709);
43  break;
44  default:
45  break;
46  }
47 
49  /* pass the ui properties to the operation */
50  operation->set_settings((NodeChroma *)node->storage, node->custom2);
51  converter.add_operation(operation);
52 
54  converter.add_operation(operation_alpha);
55 
56  if (convert != nullptr) {
57  converter.add_operation(convert);
58 
59  converter.map_input_socket(input_socket_image, convert->get_input_socket(0));
60  converter.add_link(convert->get_output_socket(), operation->get_input_socket(0));
61  converter.add_link(convert->get_output_socket(), operation_alpha->get_input_socket(0));
62  }
63  else {
64  converter.map_input_socket(input_socket_image, operation->get_input_socket(0));
65  converter.map_input_socket(input_socket_image, operation_alpha->get_input_socket(0));
66  }
67 
68  converter.map_output_socket(output_socket_matte, operation->get_output_socket(0));
69  converter.add_link(operation->get_output_socket(), operation_alpha->get_input_socket(1));
70 
71  if (inv_convert != nullptr) {
72  converter.add_operation(inv_convert);
73  converter.add_link(operation_alpha->get_output_socket(0), inv_convert->get_input_socket(0));
74  converter.map_output_socket(output_socket_image, inv_convert->get_output_socket());
75  converter.add_preview(inv_convert->get_output_socket());
76  }
77  else {
78  converter.map_output_socket(output_socket_image, operation_alpha->get_output_socket());
79  converter.add_preview(operation_alpha->get_output_socket());
80  }
81 }
82 
83 } // namespace blender::compositor
#define BLI_YCC_ITU_BT709
#define CMP_NODE_CHANNEL_MATTE_CS_HSV
#define CMP_NODE_CHANNEL_MATTE_CS_YUV
#define CMP_NODE_CHANNEL_MATTE_CS_RGB
#define CMP_NODE_CHANNEL_MATTE_CS_YCC
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
void set_settings(NodeChroma *node_chroma, const int custom2)
Overall context of the compositor.
void add_link(NodeOperationOutput *from, NodeOperationInput *to)
void map_output_socket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
void add_preview(NodeOperationOutput *output)
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
OperationNode * node
uint convert(uint c, uint inbits, uint outbits)
Definition: PixelFormat.h:45