Blender V4.3
COM_AlphaOverNode.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
5#include "COM_AlphaOverNode.h"
6
10
11namespace blender::compositor {
12
14 const CompositorContext & /*context*/) const
15{
16 NodeInput *color1Socket = this->get_input_socket(1);
17 NodeInput *color2Socket = this->get_input_socket(2);
18 const bNode *editor_node = this->get_bnode();
19
20 MixBaseOperation *convert_prog;
21 const NodeTwoFloats *ntf = (const NodeTwoFloats *)editor_node->storage;
22 if (ntf->x != 0.0f) {
24 mix_operation->setX(ntf->x);
25 convert_prog = mix_operation;
26 }
27 else if (editor_node->custom1) {
28 convert_prog = new AlphaOverKeyOperation();
29 }
30 else {
31 convert_prog = new AlphaOverPremultiplyOperation();
32 }
33
34 convert_prog->set_use_value_alpha_multiply(false);
35 if (color1Socket->is_linked()) {
36 convert_prog->set_canvas_input_index(1);
37 }
38 else if (color2Socket->is_linked()) {
39 convert_prog->set_canvas_input_index(2);
40 }
41 else {
42 convert_prog->set_canvas_input_index(0);
43 }
44
45 converter.add_operation(convert_prog);
46 converter.map_input_socket(get_input_socket(0), convert_prog->get_input_socket(0));
47 converter.map_input_socket(get_input_socket(1), convert_prog->get_input_socket(1));
48 converter.map_input_socket(get_input_socket(2), convert_prog->get_input_socket(2));
49 converter.map_output_socket(get_output_socket(0), convert_prog->get_output_socket(0));
50}
51
52} // 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:191
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: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
int16_t custom1
void * storage