Blender V4.3
COM_ChannelMatteNode.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2012 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9
10#include "BLI_math_color.h"
11
12namespace blender::compositor {
13
14ChannelMatteNode::ChannelMatteNode(bNode *editor_node) : Node(editor_node)
15{
16 /* pass */
17}
18
20 const CompositorContext & /*context*/) const
21{
22 const bNode *node = this->get_bnode();
23
24 NodeInput *input_socket_image = this->get_input_socket(0);
25 NodeOutput *output_socket_image = this->get_output_socket(0);
26 NodeOutput *output_socket_matte = this->get_output_socket(1);
27
28 NodeOperation *convert = nullptr, *inv_convert = nullptr;
29 /* color-space */
30 switch (node->custom1) {
32 break;
33 case CMP_NODE_CHANNEL_MATTE_CS_HSV: /* HSV */
34 convert = new ConvertRGBToHSVOperation();
35 inv_convert = new ConvertHSVToRGBOperation();
36 break;
37 case CMP_NODE_CHANNEL_MATTE_CS_YUV: /* YUV */
38 convert = new ConvertRGBToYUVOperation();
39 inv_convert = new ConvertYUVToRGBOperation();
40 break;
41 case CMP_NODE_CHANNEL_MATTE_CS_YCC: /* YCC */
42 convert = new ConvertRGBToYCCOperation();
43 ((ConvertRGBToYCCOperation *)convert)->set_mode(BLI_YCC_ITU_BT709);
44 inv_convert = new ConvertYCCToRGBOperation();
45 ((ConvertYCCToRGBOperation *)inv_convert)->set_mode(BLI_YCC_ITU_BT709);
46 break;
47 default:
48 break;
49 }
50
52 /* pass the ui properties to the operation */
53 operation->set_settings((NodeChroma *)node->storage, node->custom2);
54 converter.add_operation(operation);
55
57 converter.add_operation(operation_alpha);
58
59 if (convert != nullptr) {
60 converter.add_operation(convert);
61
62 converter.map_input_socket(input_socket_image, convert->get_input_socket(0));
63 converter.add_link(convert->get_output_socket(), operation->get_input_socket(0));
64 converter.add_link(convert->get_output_socket(), operation_alpha->get_input_socket(0));
65 }
66 else {
67 converter.map_input_socket(input_socket_image, operation->get_input_socket(0));
68 converter.map_input_socket(input_socket_image, operation_alpha->get_input_socket(0));
69 }
70
71 converter.map_output_socket(output_socket_matte, operation->get_output_socket(0));
72 converter.add_link(operation->get_output_socket(), operation_alpha->get_input_socket(1));
73
74 if (inv_convert != nullptr) {
75 converter.add_operation(inv_convert);
76 converter.add_link(operation_alpha->get_output_socket(0), inv_convert->get_input_socket(0));
77 converter.map_output_socket(output_socket_image, inv_convert->get_output_socket());
78 converter.add_preview(inv_convert->get_output_socket());
79 }
80 else {
81 converter.map_output_socket(output_socket_image, operation_alpha->get_output_socket());
82 converter.add_preview(operation_alpha->get_output_socket());
83 }
84}
85
86} // namespace blender::compositor
#define BLI_YCC_ITU_BT709
@ CMP_NODE_CHANNEL_MATTE_CS_YUV
@ CMP_NODE_CHANNEL_MATTE_CS_RGB
@ CMP_NODE_CHANNEL_MATTE_CS_HSV
@ 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: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