Blender V5.3
bundle_item.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BLI_string_ref.hh"
6
7#include "BKE_node.hh"
9
10#include "COM_bundle_item.hh"
11#include "COM_context.hh"
12#include "COM_result.hh"
13
14namespace blender::compositor {
15
17 : result_(context.create_result(result.type(), result.precision()))
18{
19 result_.share_data(result);
20}
21
23{
24 /* Nested bundles are a special case and are stored in BundleItemSocketValue as opposed to
25 * BundleItemInternalValue. This is because the internal bundle API uses that and the compositor
26 * can't control it. */
27 if (result.type() == ResultType::Bundle) {
30 socket_type, bke::SocketValueVariant::from(result.get_single_value<nodes::BundlePtr>())}};
31 }
32
35}
36
38{
39 /* Nested bundles are a special case and are stored in BundleItemSocketValue as opposed to
40 * BundleItemInternalValue. This is because the internal bundle API uses that and the compositor
41 * can't control it. */
42 std::optional<nodes::BundlePtr> child_bundle = item_value.as<nodes::BundlePtr>();
43 if (child_bundle.has_value()) {
44 Result result = context.create_result(ResultType::Bundle);
45 result.allocate_single_value();
46 result.set_single_value(child_bundle.value());
47 return result;
48 }
49
50 /* Otherwise, the item value is stored in a BundleItemInternalValue. */
51 BLI_assert(std::get_if<nodes::BundleItemInternalValue>(&item_value.value));
52 std::optional<BundleItemPtr> bundle_item = item_value.as<BundleItemPtr>();
53 BLI_assert(bundle_item.has_value());
54
55 const Result &bundle_result = bundle_item.value()->result_;
56 Result result = context.create_result(bundle_result.type(), bundle_result.precision());
57 result.share_data(bundle_result);
58 return result;
59}
60
62{
63 return "Compositor Bundle Item";
64}
65
66void BundleItem::delete_self()
67{
68 result_.release();
69 delete this;
70}
71
72} // namespace blender::compositor
static SocketValueVariant from(T &&value)
static Result get_result(Context &context, const nodes::BundleItemValue &item_value)
StringRefNull type_name() const override
BundleItem(Context &context, Result &result)
static nodes::BundleItemValue new_bundle_item_value(Context &context, Result &result)
static ResultType type(gpu::TextureFormat format)
Definition result.cc:337
static ResultPrecision precision(gpu::TextureFormat format)
Definition result.cc:307
bNodeSocketType * node_socket_type_find_static(int type, int subtype=0)
Definition node.cc:2975
ImplicitSharingPtr< BundleItem > BundleItemPtr
ImplicitSharingPtr< Bundle > BundlePtr
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
Defines a socket type.
Definition BKE_node.hh:163
std::variant< BundleItemSocketValue, BundleItemInternalValue > value