Blender V4.3
pixel_operation.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include <string>
6
7#include "BLI_map.hh"
8#include "BLI_string_ref.hh"
9
11
12#include "COM_context.hh"
13#include "COM_operation.hh"
15#include "COM_result.hh"
16#include "COM_scheduler.hh"
17#include "COM_utilities.hh"
18
20
21using namespace nodes::derived_node_tree_types;
22
24 PixelCompileUnit &compile_unit,
25 const Schedule &schedule)
26 : Operation(context), compile_unit_(compile_unit), schedule_(schedule)
27{
28}
29
31{
32 for (const DOutputSocket &output : preview_outputs_) {
34 compute_preview_from_result(context(), output.node(), result);
35 /* Preview results gets as an extra reference in pixel operations as can be seen in the
36 * compute_results_reference_counts method, so release it after computing preview. */
37 result.release();
38 }
39}
40
45
50
52{
53 for (const auto item : output_sockets_to_output_identifiers_map_.items()) {
55 item.key, [&](DInputSocket input) {
56 /* We only consider inputs that are not part of the pixel operations, because inputs
57 * that are part of the pixel operations are internal and do not deal with the result
58 * directly. */
59 return schedule.contains(input.node()) && !compile_unit_.contains(input.node());
60 });
61
62 if (preview_outputs_.contains(item.key)) {
63 reference_count++;
64 }
65
66 get_result(item.value).set_initial_reference_count(reference_count);
67 }
68}
69
70} // namespace blender::realtime_compositor
const Value & lookup(const Key &key) const
Definition BLI_map.hh:506
ItemIterator items() const
Definition BLI_map.hh:864
bool contains(const Key &key) const
Result & get_result(StringRef identifier)
Definition operation.cc:46
Map< std::string, DOutputSocket > & get_inputs_to_linked_outputs_map()
PixelOperation(Context &context, PixelCompileUnit &compile_unit, const Schedule &schedule)
void compute_results_reference_counts(const Schedule &schedule)
StringRef get_output_identifier_from_output_socket(DOutputSocket output_socket)
Map< DOutputSocket, std::string > output_sockets_to_output_identifiers_map_
Map< std::string, DOutputSocket > inputs_to_linked_outputs_map_
void set_initial_reference_count(int count)
Definition result.cc:587
void compute_preview_from_result(Context &context, const DNode &node, Result &input_result)
Definition utilities.cc:190
int number_of_inputs_linked_to_output_conditioned(DOutputSocket output, FunctionRef< bool(DInputSocket)> condition)
Definition utilities.cc:91