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
56 lines
1.6 KiB
C++
56 lines
1.6 KiB
C++
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
* Copyright 2011 Blender Foundation. */
|
|
|
|
#include "COM_SetAlphaReplaceOperation.h"
|
|
|
|
namespace blender::compositor {
|
|
|
|
SetAlphaReplaceOperation::SetAlphaReplaceOperation()
|
|
{
|
|
this->add_input_socket(DataType::Color);
|
|
this->add_input_socket(DataType::Value);
|
|
this->add_output_socket(DataType::Color);
|
|
|
|
input_color_ = nullptr;
|
|
input_alpha_ = nullptr;
|
|
flags_.can_be_constant = true;
|
|
}
|
|
|
|
void SetAlphaReplaceOperation::init_execution()
|
|
{
|
|
input_color_ = get_input_socket_reader(0);
|
|
input_alpha_ = get_input_socket_reader(1);
|
|
}
|
|
|
|
void SetAlphaReplaceOperation::execute_pixel_sampled(float output[4],
|
|
float x,
|
|
float y,
|
|
PixelSampler sampler)
|
|
{
|
|
float alpha_input[4];
|
|
|
|
input_color_->read_sampled(output, x, y, sampler);
|
|
input_alpha_->read_sampled(alpha_input, x, y, sampler);
|
|
output[3] = alpha_input[0];
|
|
}
|
|
|
|
void SetAlphaReplaceOperation::deinit_execution()
|
|
{
|
|
input_color_ = nullptr;
|
|
input_alpha_ = nullptr;
|
|
}
|
|
|
|
void SetAlphaReplaceOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
|
const rcti &area,
|
|
Span<MemoryBuffer *> inputs)
|
|
{
|
|
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
|
const float *color = it.in(0);
|
|
const float alpha = *it.in(1);
|
|
copy_v3_v3(it.out, color);
|
|
it.out[3] = alpha;
|
|
}
|
|
}
|
|
|
|
} // namespace blender::compositor
|