[Bf-blender-cvs] [01e5042cd89] compositor-full-frame: Compositor: Full frame Alpha Over node

Manuel Castilla noreply at git.blender.org
Sat Jul 24 16:14:27 CEST 2021


Commit: 01e5042cd892b8bec5e5f9352f5d4174a25a2202
Author: Manuel Castilla
Date:   Fri Jul 23 22:47:38 2021 +0200
Branches: compositor-full-frame
https://developer.blender.org/rB01e5042cd892b8bec5e5f9352f5d4174a25a2202

Compositor: Full frame Alpha Over node

Adds full frame implementation to this node operation.
No functional changes.

===================================================================

M	source/blender/compositor/operations/COM_AlphaOverKeyOperation.cc
M	source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
M	source/blender/compositor/operations/COM_AlphaOverMixedOperation.cc
M	source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
M	source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cc
M	source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h

===================================================================

diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cc b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cc
index 0c656753a51..aa9e8892945 100644
--- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cc
+++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cc
@@ -50,4 +50,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
diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
index 83713d18971..b612038e73b 100644
--- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
+++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
@@ -32,6 +32,8 @@ class AlphaOverKeyOperation : public MixBaseOperation {
    * The inner loop of this operation.
    */
   void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
+
+  void update_memory_buffer_row(PixelCursor &p) override;
 };
 
 }  // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cc b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cc
index c68c79d2263..62f9e6f469d 100644
--- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cc
+++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cc
@@ -56,4 +56,30 @@ void AlphaOverMixedOperation::executePixelSampled(float output[4],
   }
 }
 
+void AlphaOverMixedOperation::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 addfac = 1.0f - this->m_x + over_color[3] * this->m_x;
+      const float premul = value * addfac;
+      const float mul = 1.0f - value * over_color[3];
+
+      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
diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
index e2b3af84162..2b88cd5f421 100644
--- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
+++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
@@ -45,6 +45,8 @@ class AlphaOverMixedOperation : public MixBaseOperation {
   {
     this->m_x = x;
   }
+
+  void update_memory_buffer_row(PixelCursor &p) override;
 };
 
 }  // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cc b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cc
index 3dd4607e273..cbbc892fc11 100644
--- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cc
+++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cc
@@ -50,4 +50,28 @@ void AlphaOverPremultiplyOperation::executePixelSampled(float output[4],
   }
 }
 
+void AlphaOverPremultiplyOperation::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 mul = 1.0f - value * over_color[3];
+
+      p.out[0] = (mul * color1[0]) + value * over_color[0];
+      p.out[1] = (mul * color1[1]) + value * over_color[1];
+      p.out[2] = (mul * color1[2]) + value * over_color[2];
+      p.out[3] = (mul * color1[3]) + value * over_color[3];
+    }
+  }
+}
+
 }  // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h
index f1d4b668fce..e11b440a1fa 100644
--- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h
+++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h
@@ -32,6 +32,8 @@ class AlphaOverPremultiplyOperation : public MixBaseOperation {
    * The inner loop of this operation.
    */
   void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
+
+  void update_memory_buffer_row(PixelCursor &p) override;
 };
 
 }  // namespace blender::compositor



More information about the Bf-blender-cvs mailing list