Blender  V3.3
COM_AlphaOverNode.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_AlphaOverNode.h"
5 
9 
10 namespace blender::compositor {
11 
13  const CompositorContext & /*context*/) const
14 {
15  NodeInput *color1Socket = this->get_input_socket(1);
16  NodeInput *color2Socket = this->get_input_socket(2);
17  bNode *editor_node = this->get_bnode();
18 
19  MixBaseOperation *convert_prog;
20  NodeTwoFloats *ntf = (NodeTwoFloats *)editor_node->storage;
21  if (ntf->x != 0.0f) {
22  AlphaOverMixedOperation *mix_operation = new AlphaOverMixedOperation();
23  mix_operation->setX(ntf->x);
24  convert_prog = mix_operation;
25  }
26  else if (editor_node->custom1) {
27  convert_prog = new AlphaOverKeyOperation();
28  }
29  else {
30  convert_prog = new AlphaOverPremultiplyOperation();
31  }
32 
33  convert_prog->set_use_value_alpha_multiply(false);
34  if (color1Socket->is_linked()) {
35  convert_prog->set_canvas_input_index(1);
36  }
37  else if (color2Socket->is_linked()) {
38  convert_prog->set_canvas_input_index(2);
39  }
40  else {
41  convert_prog->set_canvas_input_index(0);
42  }
43 
44  converter.add_operation(convert_prog);
45  converter.map_input_socket(get_input_socket(0), convert_prog->get_input_socket(0));
46  converter.map_input_socket(get_input_socket(1), convert_prog->get_input_socket(1));
47  converter.map_input_socket(get_input_socket(2), convert_prog->get_input_socket(2));
48  converter.map_output_socket(get_output_socket(0), convert_prog->get_output_socket(0));
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 set_use_value_alpha_multiply(const bool value)
void map_output_socket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
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)
void set_canvas_input_index(unsigned int index)
set the index of the input socket that will determine the canvas of this operation
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
short custom1
void * storage