Blender V4.3
COM_DistanceMatteNode.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
9
10#include "BLI_math_color.h"
11
12namespace blender::compositor {
13
15{
16 /* pass */
17}
18
20 const CompositorContext & /*context*/) const
21{
22 const bNode *editorsnode = this->get_bnode();
23 const NodeChroma *storage = (const NodeChroma *)editorsnode->storage;
24
25 NodeInput *input_socket_image = this->get_input_socket(0);
26 NodeInput *input_socket_key = this->get_input_socket(1);
27 NodeOutput *output_socket_image = this->get_output_socket(0);
28 NodeOutput *output_socket_matte = this->get_output_socket(1);
29
31 converter.add_operation(operation_alpha);
32
33 /* work in RGB color space */
34 NodeOperation *operation;
35 if (storage->channel == 1) {
37 matte->set_settings(storage);
38 converter.add_operation(matte);
39
40 converter.map_input_socket(input_socket_image, matte->get_input_socket(0));
41 converter.map_input_socket(input_socket_image, operation_alpha->get_input_socket(0));
42
43 converter.map_input_socket(input_socket_key, matte->get_input_socket(1));
44
45 operation = matte;
46 }
47 /* work in YCbCr color space */
48 else {
50 matte->set_settings(storage);
51 converter.add_operation(matte);
52
53 ConvertRGBToYCCOperation *operation_yccimage = new ConvertRGBToYCCOperation();
54 ConvertRGBToYCCOperation *operation_yccmatte = new ConvertRGBToYCCOperation();
55 operation_yccimage->set_mode(BLI_YCC_ITU_BT709);
56 operation_yccmatte->set_mode(BLI_YCC_ITU_BT709);
57 converter.add_operation(operation_yccimage);
58 converter.add_operation(operation_yccmatte);
59
60 converter.map_input_socket(input_socket_image, operation_yccimage->get_input_socket(0));
61 converter.add_link(operation_yccimage->get_output_socket(), matte->get_input_socket(0));
62 converter.add_link(operation_yccimage->get_output_socket(),
63 operation_alpha->get_input_socket(0));
64
65 converter.map_input_socket(input_socket_key, operation_yccmatte->get_input_socket(0));
66 converter.add_link(operation_yccmatte->get_output_socket(), matte->get_input_socket(1));
67
68 operation = matte;
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 (storage->channel != 1) {
76 inv_convert->set_mode(BLI_YCC_ITU_BT709);
77
78 converter.add_operation(inv_convert);
79 converter.add_link(operation_alpha->get_output_socket(0), inv_convert->get_input_socket(0));
80 converter.map_output_socket(output_socket_image, inv_convert->get_output_socket());
81 converter.add_preview(inv_convert->get_output_socket());
82 }
83 else {
84 converter.map_output_socket(output_socket_image, operation_alpha->get_output_socket());
85 converter.add_preview(operation_alpha->get_output_socket());
86 }
87}
88
89} // namespace blender::compositor
#define BLI_YCC_ITU_BT709
Overall context of the compositor.
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
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
void * storage