Blender V4.3
COM_FlipOperation.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "COM_FlipOperation.h"
6
7namespace blender::compositor {
8
10{
14 flip_x_ = true;
15 flip_y_ = false;
17}
18
19void FlipOperation::get_area_of_interest(const int input_idx,
20 const rcti & /*output_area*/,
21 rcti &r_input_area)
22{
23 BLI_assert(input_idx == 0);
24 UNUSED_VARS_NDEBUG(input_idx);
25
26 /* The full input image should be flipped to avoid cropping effects caused by previous scaling or
27 * translating, or a smaller output area. */
28 r_input_area = get_canvas();
29}
30
32 const rcti &area,
34{
35 const MemoryBuffer *input_img = inputs[0];
36 if (input_img->is_a_single_elem()) {
37 copy_v4_v4(output->get_elem(0, 0), input_img->get_elem(0, 0));
38 return;
39 }
40 const int input_offset_x = input_img->get_rect().xmin;
41 const int input_offset_y = input_img->get_rect().ymin;
42 for (BuffersIterator<float> it = output->iterate_with({}, area); !it.is_end(); ++it) {
43 const int nx = flip_x_ ? (int(this->get_width()) - 1) - it.x : it.x;
44 const int ny = flip_y_ ? (int(this->get_height()) - 1) - it.y : it.y;
45 input_img->read_elem(input_offset_x + nx, input_offset_y + ny, it.out);
46 }
47}
48
49} // namespace blender::compositor
#define BLI_assert(a)
Definition BLI_assert.h:50
MINLINE void copy_v4_v4(float r[4], const float a[4])
#define UNUSED_VARS_NDEBUG(...)
void update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span< MemoryBuffer * > inputs) override
void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override
Get input operation area being read by this operation on rendering given output area.
a MemoryBuffer contains access to the data
const rcti & get_rect() const
get the rect of this MemoryBuffer
void read_elem(int x, int y, float *out) const
void add_output_socket(DataType datatype)
void add_input_socket(DataType datatype, ResizeMode resize_mode=ResizeMode::Center)
void set_canvas_input_index(unsigned int index)
set the index of the input socket that will determine the canvas of this operation
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
typename BuffersIteratorBuilder< T >::Iterator BuffersIterator
int ymin
int xmin