[Bf-blender-cvs] [9dcac5e859b] compositor-full-frame: Compositor: Full frame Invert node

Manuel Castilla noreply at git.blender.org
Tue Jul 27 23:26:02 CEST 2021


Commit: 9dcac5e859b1a64d328fcc98e8efbf176b19b35f
Author: Manuel Castilla
Date:   Sun Jul 25 17:58:44 2021 +0200
Branches: compositor-full-frame
https://developer.blender.org/rB9dcac5e859b1a64d328fcc98e8efbf176b19b35f

Compositor: Full frame Invert node

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

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

M	source/blender/compositor/operations/COM_InvertOperation.cc
M	source/blender/compositor/operations/COM_InvertOperation.h

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

diff --git a/source/blender/compositor/operations/COM_InvertOperation.cc b/source/blender/compositor/operations/COM_InvertOperation.cc
index 339e40a5d1f..64f3bef2eca 100644
--- a/source/blender/compositor/operations/COM_InvertOperation.cc
+++ b/source/blender/compositor/operations/COM_InvertOperation.cc
@@ -30,7 +30,9 @@ InvertOperation::InvertOperation()
   this->m_color = true;
   this->m_alpha = false;
   setResolutionInputSocketIndex(1);
+  this->flags.can_be_constant = true;
 }
+
 void InvertOperation::initExecution()
 {
   this->m_inputValueProgram = this->getInputSocketReader(0);
@@ -70,4 +72,31 @@ void InvertOperation::deinitExecution()
   this->m_inputColorProgram = nullptr;
 }
 
+void InvertOperation::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 value = *it.in(0);
+    const float inverted_value = 1.0f - value;
+    const float *color = it.in(1);
+
+    if (this->m_color) {
+      it.out[0] = (1.0f - color[0]) * value + color[0] * inverted_value;
+      it.out[1] = (1.0f - color[1]) * value + color[1] * inverted_value;
+      it.out[2] = (1.0f - color[2]) * value + color[2] * inverted_value;
+    }
+    else {
+      copy_v3_v3(it.out, color);
+    }
+
+    if (this->m_alpha) {
+      it.out[3] = (1.0f - color[3]) * value + color[3] * inverted_value;
+    }
+    else {
+      it.out[3] = color[3];
+    }
+  }
+}
+
 }  // namespace blender::compositor
diff --git a/source/blender/compositor/operations/COM_InvertOperation.h b/source/blender/compositor/operations/COM_InvertOperation.h
index 17e5eb95f3e..a084bf5d559 100644
--- a/source/blender/compositor/operations/COM_InvertOperation.h
+++ b/source/blender/compositor/operations/COM_InvertOperation.h
@@ -18,11 +18,11 @@
 
 #pragma once
 
-#include "COM_NodeOperation.h"
+#include "COM_MultiThreadedOperation.h"
 
 namespace blender::compositor {
 
-class InvertOperation : public NodeOperation {
+class InvertOperation : public MultiThreadedOperation {
  private:
   /**
    * Cached reference to the inputProgram
@@ -59,6 +59,10 @@ class InvertOperation : public NodeOperation {
   {
     this->m_alpha = alpha;
   }
+
+  void update_memory_buffer_partial(MemoryBuffer *output,
+                                    const rcti &area,
+                                    Span<MemoryBuffer *> inputs) override;
 };
 
 }  // namespace blender::compositor



More information about the Bf-blender-cvs mailing list