Blender  V3.3
COM_ColorMatteNode.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2011 Blender Foundation. */
3 
4 #include "COM_ColorMatteNode.h"
6 #include "COM_ConvertOperation.h"
8 
9 namespace blender::compositor {
10 
11 ColorMatteNode::ColorMatteNode(bNode *editor_node) : Node(editor_node)
12 {
13  /* pass */
14 }
15 
17  const CompositorContext & /*context*/) const
18 {
19  bNode *editorsnode = get_bnode();
20 
21  NodeInput *input_socket_image = this->get_input_socket(0);
22  NodeInput *input_socket_key = this->get_input_socket(1);
23  NodeOutput *output_socket_image = this->get_output_socket(0);
24  NodeOutput *output_socket_matte = this->get_output_socket(1);
25 
26  ConvertRGBToHSVOperation *operationRGBToHSV_Image = new ConvertRGBToHSVOperation();
27  ConvertRGBToHSVOperation *operationRGBToHSV_Key = new ConvertRGBToHSVOperation();
28  converter.add_operation(operationRGBToHSV_Image);
29  converter.add_operation(operationRGBToHSV_Key);
30 
31  ColorMatteOperation *operation = new ColorMatteOperation();
32  operation->set_settings((NodeChroma *)editorsnode->storage);
33  converter.add_operation(operation);
34 
36  converter.add_operation(operation_alpha);
37 
38  converter.map_input_socket(input_socket_image, operationRGBToHSV_Image->get_input_socket(0));
39  converter.map_input_socket(input_socket_key, operationRGBToHSV_Key->get_input_socket(0));
40  converter.add_link(operationRGBToHSV_Image->get_output_socket(), operation->get_input_socket(0));
41  converter.add_link(operationRGBToHSV_Key->get_output_socket(), operation->get_input_socket(1));
42  converter.map_output_socket(output_socket_matte, operation->get_output_socket(0));
43 
44  converter.map_input_socket(input_socket_image, operation_alpha->get_input_socket(0));
45  converter.add_link(operation->get_output_socket(), operation_alpha->get_input_socket(1));
46  converter.map_output_socket(output_socket_image, operation_alpha->get_output_socket());
47 
48  converter.add_preview(operation_alpha->get_output_socket());
49 }
50 
51 } // namespace blender::compositor
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
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
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