Blender  V3.3
COM_BokehBlurNode.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_BokehBlurNode.h"
7 
8 namespace blender::compositor {
9 
10 BokehBlurNode::BokehBlurNode(bNode *editor_node) : Node(editor_node)
11 {
12  /* pass */
13 }
14 
16  const CompositorContext &context) const
17 {
18  bNode *b_node = this->get_bnode();
19 
20  NodeInput *input_size_socket = this->get_input_socket(2);
21 
22  bool connected_size_socket = input_size_socket->is_linked();
23  const bool extend_bounds = (b_node->custom1 & CMP_NODEFLAG_BLUR_EXTEND_BOUNDS) != 0;
24 
25  if ((b_node->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) && connected_size_socket) {
27  operation->set_quality(context.get_quality());
28  operation->set_threshold(0.0f);
29  operation->set_max_blur(b_node->custom4);
30  operation->set_do_scale_size(true);
31 
32  converter.add_operation(operation);
33  converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
34  converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
35  converter.map_input_socket(get_input_socket(2), operation->get_input_socket(2));
36  converter.map_output_socket(get_output_socket(0), operation->get_output_socket());
37  }
38  else {
39  BokehBlurOperation *operation = new BokehBlurOperation();
40  operation->set_quality(context.get_quality());
41  operation->set_extend_bounds(extend_bounds);
42 
43  converter.add_operation(operation);
44  converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
45  converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
46 
47  /* NOTE: on the bokeh blur operation the sockets are switched.
48  * for this reason the next two lines are correct. Fix for T43771. */
49  converter.map_input_socket(get_input_socket(2), operation->get_input_socket(3));
50  converter.map_input_socket(get_input_socket(3), operation->get_input_socket(2));
51 
52  converter.map_output_socket(get_output_socket(0), operation->get_output_socket());
53 
54  if (!connected_size_socket) {
55  operation->set_size(this->get_input_socket(2)->get_editor_value_float());
56  }
57  }
58 }
59 
60 } // namespace blender::compositor
@ CMP_NODEFLAG_BLUR_VARIABLE_SIZE
@ CMP_NODEFLAG_BLUR_EXTEND_BOUNDS
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
Overall context of the compositor.
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)
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 set_quality(eCompositorQuality quality)
short custom1
float custom4