Blender V4.3
node_composite_flip.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2006 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "BLI_assert.h"
10#include "BLI_utildefines.h"
11
12#include "UI_interface.hh"
13#include "UI_resources.hh"
14
15#include "GPU_shader.hh"
16#include "GPU_texture.hh"
17
18#include "COM_node_operation.hh"
19#include "COM_utilities.hh"
20
22
23/* **************** Flip ******************** */
24
26
28{
29 b.add_input<decl::Color>("Image")
30 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
31 .compositor_domain_priority(0);
32 b.add_output<decl::Color>("Image");
33}
34
36{
37 uiItemR(layout, ptr, "axis", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
38}
39
40using namespace blender::realtime_compositor;
41
43 public:
45
46 void execute() override
47 {
48 Result &input = get_input("Image");
49 Result &result = get_result("Image");
50
51 /* Can't flip a single value, pass it through to the output. */
52 if (input.is_single_value()) {
53 input.pass_through(result);
54 return;
55 }
56
57 GPUShader *shader = context().get_shader("compositor_flip");
58 GPU_shader_bind(shader);
59
64
65 input.bind_as_texture(shader, "input_tx");
66
67 const Domain domain = compute_domain();
68
69 result.allocate_texture(domain);
70 result.bind_as_image(shader, "output_img");
71
72 compute_dispatch_threads_at_least(shader, domain.size);
73
74 input.unbind_as_texture();
75 result.unbind_as_image();
77 }
78
83};
84
86{
87 return new FlipOperation(context, node);
88}
89
90} // namespace blender::nodes::node_composite_flip_cc
91
93{
95
96 static blender::bke::bNodeType ntype;
97
98 cmp_node_type_base(&ntype, CMP_NODE_FLIP, "Flip", NODE_CLASS_DISTORT);
99 ntype.declare = file_ns::cmp_node_flip_declare;
100 ntype.draw_buttons = file_ns::node_composit_buts_flip;
101 ntype.get_compositor_operation = file_ns::get_compositor_operation;
102
104}
#define NODE_CLASS_DISTORT
Definition BKE_node.hh:412
#define ELEM(...)
CMPNodeFlipMode
@ CMP_NODE_FLIP_X
@ CMP_NODE_FLIP_X_Y
@ CMP_NODE_FLIP_Y
void GPU_shader_bind(GPUShader *shader)
void GPU_shader_uniform_1b(GPUShader *sh, const char *name, bool value)
void GPU_shader_unbind()
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
struct GPUShader GPUShader
GPUShader * get_shader(const char *info_name, ResultPrecision precision)
NodeOperation(Context &context, DNode node)
Result & get_input(StringRef identifier) const
Definition operation.cc:144
Result & get_result(StringRef identifier)
Definition operation.cc:46
local_group_size(16, 16) .push_constant(Type b
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
static void node_composit_buts_flip(uiLayout *layout, bContext *, PointerRNA *ptr)
static NodeOperation * get_compositor_operation(Context &context, DNode node)
static void cmp_node_flip_declare(NodeDeclarationBuilder &b)
void compute_dispatch_threads_at_least(GPUShader *shader, int2 threads_range, int2 local_size=int2(16))
Definition utilities.cc:131
void register_node_type_cmp_flip()
void cmp_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
int16_t custom1
Defines a node type.
Definition BKE_node.hh:218
NodeGetCompositorOperationFunction get_compositor_operation
Definition BKE_node.hh:324
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:238
NodeDeclareFunction declare
Definition BKE_node.hh:347
PointerRNA * ptr
Definition wm_files.cc:4126