Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/compositor/operations/COM_AlphaOverKeyOperation.cc')
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverKeyOperation.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cc b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cc
index 0c656753a51..30e7fab4027 100644
--- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cc
+++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cc
@@ -20,6 +20,11 @@
namespace blender::compositor {
+AlphaOverKeyOperation::AlphaOverKeyOperation()
+{
+ this->flags.can_be_constant = true;
+}
+
void AlphaOverKeyOperation::executePixelSampled(float output[4],
float x,
float y,
@@ -50,4 +55,29 @@ void AlphaOverKeyOperation::executePixelSampled(float output[4],
}
}
+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