Blender  V3.3
COM_DistanceMatteNode.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2011 Blender Foundation. */
3 
5 #include "COM_ConvertOperation.h"
8 
9 namespace blender::compositor {
10 
11 DistanceMatteNode::DistanceMatteNode(bNode *editor_node) : Node(editor_node)
12 {
13  /* pass */
14 }
15 
17  const CompositorContext & /*context*/) const
18 {
19  bNode *editorsnode = get_bnode();
20  NodeChroma *storage = (NodeChroma *)editorsnode->storage;
21 
22  NodeInput *input_socket_image = this->get_input_socket(0);
23  NodeInput *input_socket_key = this->get_input_socket(1);
24  NodeOutput *output_socket_image = this->get_output_socket(0);
25  NodeOutput *output_socket_matte = this->get_output_socket(1);
26 
28  converter.add_operation(operation_alpha);
29 
30  /* work in RGB color space */
31  NodeOperation *operation;
32  if (storage->channel == 1) {
34  matte->set_settings(storage);
35  converter.add_operation(matte);
36 
37  converter.map_input_socket(input_socket_image, matte->get_input_socket(0));
38  converter.map_input_socket(input_socket_image, operation_alpha->get_input_socket(0));
39 
40  converter.map_input_socket(input_socket_key, matte->get_input_socket(1));
41 
42  operation = matte;
43  }
44  /* work in YCbCr color space */
45  else {
47  matte->set_settings(storage);
48  converter.add_operation(matte);
49 
50  ConvertRGBToYCCOperation *operation_yccimage = new ConvertRGBToYCCOperation();
51  ConvertRGBToYCCOperation *operation_yccmatte = new ConvertRGBToYCCOperation();
52  operation_yccimage->set_mode(BLI_YCC_ITU_BT709);
53  operation_yccmatte->set_mode(BLI_YCC_ITU_BT709);
54  converter.add_operation(operation_yccimage);
55  converter.add_operation(operation_yccmatte);
56 
57  converter.map_input_socket(input_socket_image, operation_yccimage->get_input_socket(0));
58  converter.add_link(operation_yccimage->get_output_socket(), matte->get_input_socket(0));
59  converter.add_link(operation_yccimage->get_output_socket(),
60  operation_alpha->get_input_socket(0));
61 
62  converter.map_input_socket(input_socket_key, operation_yccmatte->get_input_socket(0));
63  converter.add_link(operation_yccmatte->get_output_socket(), matte->get_input_socket(1));
64 
65  operation = matte;
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 (storage->channel != 1) {
73  inv_convert->set_mode(BLI_YCC_ITU_BT709);
74 
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
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: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 * storage