This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/source/blender/compositor/operations/COM_TransformOperation.h
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00

77 lines
1.9 KiB
C++

/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2021 Blender Foundation. */
#pragma once
#include "COM_MultiThreadedOperation.h"
namespace blender::compositor {
class TransformOperation : public MultiThreadedOperation {
private:
constexpr static int IMAGE_INPUT_INDEX = 0;
constexpr static int X_INPUT_INDEX = 1;
constexpr static int Y_INPUT_INDEX = 2;
constexpr static int DEGREE_INPUT_INDEX = 3;
constexpr static int SCALE_INPUT_INDEX = 4;
float rotate_cosine_;
float rotate_sine_;
int translate_x_;
int translate_y_;
float scale_;
rcti scale_canvas_ = COM_AREA_NONE;
rcti rotate_canvas_ = COM_AREA_NONE;
rcti translate_canvas_ = COM_AREA_NONE;
/* Set variables. */
PixelSampler sampler_;
bool convert_degree_to_rad_;
float translate_factor_x_;
float translate_factor_y_;
bool invert_;
Size2f max_scale_canvas_size_;
public:
TransformOperation();
void set_translate_factor_xy(float x, float y)
{
translate_factor_x_ = x;
translate_factor_y_ = y;
}
void set_convert_rotate_degree_to_rad(bool value)
{
convert_degree_to_rad_ = value;
}
void set_sampler(PixelSampler sampler)
{
sampler_ = sampler;
}
void set_invert(bool value)
{
invert_ = value;
}
void set_scale_canvas_max_size(Size2f size);
void init_data() override;
void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override;
void update_memory_buffer_partial(MemoryBuffer *output,
const rcti &area,
Span<MemoryBuffer *> inputs) override;
void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
private:
/** Translate -> Rotate -> Scale. */
void transform(BuffersIterator<float> &it, const MemoryBuffer *input_img);
/** Scale -> Rotate -> Translate. */
void transform_inverted(BuffersIterator<float> &it, const MemoryBuffer *input_img);
};
} // namespace blender::compositor