Blender V5.3
node_tree_output_node_operation.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "DNA_node_types.h"
6
7#include "BKE_node.hh"
8#include "BKE_node_runtime.hh"
9
10#include "COM_context.hh"
11#include "COM_node_operation.hh"
13#include "COM_utilities.hh"
14
15namespace blender::compositor {
16
17/* A node operation representing a node tree output node that for each of its inputs gets the input
18 * and shares its data with the result of the node group operation it represents with the same
19 * identifier. Node tree output nodes include group output and zone output nodes. */
21 private:
22 Operation &operation_;
23
24 public:
26 : NodeOperation(context, node), operation_(operation)
27 {
28 for (const bNodeSocket *input : node.input_sockets()) {
29 if (!is_socket_available(input)) {
30 continue;
31 }
32
33 InputDescriptor &descriptor = this->get_input_descriptor(input->identifier);
34 /* The structure type of the inputs of Group Output nodes are inferred, so we need to
35 * make sure this is not wrongly expecting single values. */
36 descriptor.expects_single_value = false;
37 /* Groups Output nodes should not force realization since it is defined by the user, and
38 * there is currently no way for the user to define that through the UI. */
39 descriptor.realization_mode = InputRealizationMode::None;
40 }
41 }
42
43 void execute() override
44 {
45 for (const bNodeSocket *input_socket : this->node().input_sockets()) {
46 if (!is_socket_available(input_socket)) {
47 continue;
48 }
49
50 Result &operation_result = operation_.get_result(input_socket->identifier);
51 if (operation_result.should_compute()) {
52 const Result &input_result = this->get_input(input_socket->identifier);
53 operation_result.share_data(input_result);
54 }
55 }
56 }
57};
58
60 const bNode &node,
61 Operation &operation)
62{
63 return new NodeTreeOutputNodeOperation(context, node, operation);
64}
65
66} // namespace blender::compositor
NodeOperation(Context &context, const bNode &node)
NodeTreeOutputNodeOperation(Context &context, const bNode &node, Operation &operation)
Context & context() const
Definition operation.cc:57
Result & get_input(StringRef identifier) const
Definition operation.cc:35
void share_data(const Result &source)
Definition result.cc:996
bool should_compute() const
Definition result.cc:1124
bool is_socket_available(const bNodeSocket *socket)
Definition utilities.cc:26
NodeOperation * get_node_tree_output_node_operation(Context &context, const bNode &node, Operation &operation)