Blender V4.3
COM_AlphaOverPremultiplyOperation.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
6
7namespace blender::compositor {
8
13
15{
16 for (; p.out < p.row_end; p.next()) {
17 const float *color1 = p.color1;
18 const float *over_color = p.color2;
19 const float value = *p.value;
20
21 /* Zero alpha values should still permit an add of RGB data. */
22 if (over_color[3] < 0.0f) {
23 copy_v4_v4(p.out, color1);
24 }
25 else if (value == 1.0f && over_color[3] >= 1.0f) {
26 copy_v4_v4(p.out, over_color);
27 }
28 else {
29 const float mul = 1.0f - value * over_color[3];
30
31 p.out[0] = (mul * color1[0]) + value * over_color[0];
32 p.out[1] = (mul * color1[1]) + value * over_color[1];
33 p.out[2] = (mul * color1[2]) + value * over_color[2];
34 p.out[3] = (mul * color1[3]) + value * over_color[3];
35 }
36 }
37}
38
39} // namespace blender::compositor
MINLINE void copy_v4_v4(float r[4], const float a[4])
static void mul(btAlignedObjectArray< T > &items, const Q &value)