Files
test2/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cc
Brecht Van Lommel 7a395e2e7f Revert changes from main commits that were merged into blender-v4.1-release
The last good commit was f57e4c5b98.

After this one more fix was committed, this one is preserved as well:
67bd678887.
2024-03-18 15:04:12 +01:00

40 lines
1.0 KiB
C++

/* SPDX-FileCopyrightText: 2011 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "COM_AlphaOverKeyOperation.h"
namespace blender::compositor {
AlphaOverKeyOperation::AlphaOverKeyOperation()
{
flags_.can_be_constant = true;
}
void AlphaOverKeyOperation::update_memory_buffer_row(PixelCursor &p)
{
for (; p.out < p.row_end; p.next()) {
const float *color1 = p.color1;
const float *over_color = p.color2;
const float value = *p.value;
if (over_color[3] <= 0.0f) {
copy_v4_v4(p.out, color1);
}
else if (value == 1.0f && over_color[3] >= 1.0f) {
copy_v4_v4(p.out, over_color);
}
else {
const float premul = value * over_color[3];
const float mul = 1.0f - premul;
p.out[0] = (mul * color1[0]) + premul * over_color[0];
p.out[1] = (mul * color1[1]) + premul * over_color[1];
p.out[2] = (mul * color1[2]) + premul * over_color[2];
p.out[3] = (mul * color1[3]) + value * over_color[3];
}
}
}
} // namespace blender::compositor