[Bf-blender-cvs] [064167fce70] master: Compositor: Full frame transform nodes

Manuel Castilla noreply at git.blender.org
Mon Aug 23 17:18:41 CEST 2021


Commit: 064167fce70e3d7c382c374334a1bd0b520fe9fe
Author: Manuel Castilla
Date:   Mon Aug 23 15:30:01 2021 +0200
Branches: master
https://developer.blender.org/rB064167fce70e3d7c382c374334a1bd0b520fe9fe

Compositor: Full frame transform nodes

Adds full frame implementation to "Rotate", "Transform" and
"Stabilize2D" nodes.
To avoid sampling twice when concatenating scale and rotate
operations, a `TransformOperation` is implemented with all
the functionality.
The nodes have no functional changes.

Part of T88150.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D12165

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

M	source/blender/compositor/CMakeLists.txt
M	source/blender/compositor/COM_defines.h
M	source/blender/compositor/nodes/COM_RotateNode.cc
M	source/blender/compositor/nodes/COM_Stabilize2dNode.cc
M	source/blender/compositor/nodes/COM_TransformNode.cc
M	source/blender/compositor/operations/COM_RotateOperation.cc
M	source/blender/compositor/operations/COM_RotateOperation.h
M	source/blender/compositor/operations/COM_ScaleOperation.cc
M	source/blender/compositor/operations/COM_ScaleOperation.h
A	source/blender/compositor/operations/COM_TransformOperation.cc
A	source/blender/compositor/operations/COM_TransformOperation.h

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

diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt
index ee287c65fe9..dba2d1e1e67 100644
--- a/source/blender/compositor/CMakeLists.txt
+++ b/source/blender/compositor/CMakeLists.txt
@@ -515,6 +515,8 @@ set(SRC
   operations/COM_ScaleOperation.h
   operations/COM_ScreenLensDistortionOperation.cc
   operations/COM_ScreenLensDistortionOperation.h
+  operations/COM_TransformOperation.cc
+  operations/COM_TransformOperation.h
   operations/COM_TranslateOperation.cc
   operations/COM_TranslateOperation.h
   operations/COM_WrapOperation.cc
diff --git a/source/blender/compositor/COM_defines.h b/source/blender/compositor/COM_defines.h
index 40a1e0da2a8..ee9bea7b2c6 100644
--- a/source/blender/compositor/COM_defines.h
+++ b/source/blender/compositor/COM_defines.h
@@ -119,6 +119,8 @@ constexpr float COM_PREVIEW_SIZE = 140.f;
 constexpr float COM_RULE_OF_THIRDS_DIVIDER = 100.0f;
 constexpr float COM_BLUR_BOKEH_PIXELS = 512;
 
+constexpr rcti COM_SINGLE_ELEM_AREA = {0, 1, 0, 1};
+
 constexpr IndexRange XRange(const rcti &area)
 {
   return IndexRange(area.xmin, area.xmax - area.xmin);
diff --git a/source/blender/compositor/nodes/COM_RotateNode.cc b/source/blender/compositor/nodes/COM_RotateNode.cc
index af5baa733dc..c2fd8ed5594 100644
--- a/source/blender/compositor/nodes/COM_RotateNode.cc
+++ b/source/blender/compositor/nodes/COM_RotateNode.cc
@@ -30,20 +30,31 @@ RotateNode::RotateNode(bNode *editorNode) : Node(editorNode)
 }
 
 void RotateNode::convertToOperations(NodeConverter &converter,
-                                     const CompositorContext & /*context*/) const
+                                     const CompositorContext &context) const
 {
   NodeInput *inputSocket = this->getInputSocket(0);
   NodeInput *inputDegreeSocket = this->getInputSocket(1);
   NodeOutput *outputSocket = this->getOutputSocket(0);
   RotateOperation *operation = new RotateOperation();
-  SetSamplerOperation *sampler = new SetSamplerOperation();
-  sampler->setSampler((PixelSampler)this->getbNode()->custom1);
-
-  converter.addOperation(sampler);
   converter.addOperation(operation);
 
-  converter.addLink(sampler->getOutputSocket(), operation->getInputSocket(0));
-  converter.mapInputSocket(inputSocket, sampler->getInputSocket(0));
+  PixelSampler sampler = (PixelSampler)this->getbNode()->custom1;
+  switch (context.get_execution_model()) {
+    case eExecutionModel::Tiled: {
+      SetSamplerOperation *sampler_op = new SetSamplerOperation();
+      sampler_op->setSampler(sampler);
+      converter.addOperation(sampler_op);
+      converter.addLink(sampler_op->getOutputSocket(), operation->getInputSocket(0));
+      converter.mapInputSocket(inputSocket, sampler_op->getInputSocket(0));
+      break;
+    }
+    case eExecutionModel::FullFrame: {
+      operation->set_sampler(sampler);
+      converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+      break;
+    }
+  }
+
   converter.mapInputSocket(inputDegreeSocket, operation->getInputSocket(1));
   converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
 }
diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.cc b/source/blender/compositor/nodes/COM_Stabilize2dNode.cc
index 0262f653d1a..7b2388bebca 100644
--- a/source/blender/compositor/nodes/COM_Stabilize2dNode.cc
+++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.cc
@@ -22,6 +22,7 @@
 #include "COM_RotateOperation.h"
 #include "COM_ScaleOperation.h"
 #include "COM_SetSamplerOperation.h"
+#include "COM_TransformOperation.h"
 #include "COM_TranslateOperation.h"
 
 #include "BKE_tracking.h"
@@ -42,18 +43,12 @@ void Stabilize2dNode::convertToOperations(NodeConverter &converter,
   NodeInput *imageInput = this->getInputSocket(0);
   MovieClip *clip = (MovieClip *)editorNode->id;
   bool invert = (editorNode->custom2 & CMP_NODEFLAG_STABILIZE_INVERSE) != 0;
+  const PixelSampler sampler = (PixelSampler)editorNode->custom1;
 
-  ScaleRelativeOperation *scaleOperation = new ScaleRelativeOperation();
-  scaleOperation->setSampler((PixelSampler)editorNode->custom1);
-  RotateOperation *rotateOperation = new RotateOperation();
-  rotateOperation->setDoDegree2RadConversion(false);
-  TranslateOperation *translateOperation = new TranslateOperation();
   MovieClipAttributeOperation *scaleAttribute = new MovieClipAttributeOperation();
   MovieClipAttributeOperation *angleAttribute = new MovieClipAttributeOperation();
   MovieClipAttributeOperation *xAttribute = new MovieClipAttributeOperation();
   MovieClipAttributeOperation *yAttribute = new MovieClipAttributeOperation();
-  SetSamplerOperation *psoperation = new SetSamplerOperation();
-  psoperation->setSampler((PixelSampler)editorNode->custom1);
 
   scaleAttribute->setAttribute(MCA_SCALE);
   scaleAttribute->setFramenumber(context.getFramenumber());
@@ -79,38 +74,67 @@ void Stabilize2dNode::convertToOperations(NodeConverter &converter,
   converter.addOperation(angleAttribute);
   converter.addOperation(xAttribute);
   converter.addOperation(yAttribute);
-  converter.addOperation(scaleOperation);
-  converter.addOperation(translateOperation);
-  converter.addOperation(rotateOperation);
-  converter.addOperation(psoperation);
 
-  converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(1));
-  converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(2));
-
-  converter.addLink(angleAttribute->getOutputSocket(), rotateOperation->getInputSocket(1));
-
-  converter.addLink(xAttribute->getOutputSocket(), translateOperation->getInputSocket(1));
-  converter.addLink(yAttribute->getOutputSocket(), translateOperation->getInputSocket(2));
-
-  converter.mapOutputSocket(getOutputSocket(), psoperation->getOutputSocket());
-
-  if (invert) {
-    // Translate -> Rotate -> Scale.
-    converter.mapInputSocket(imageInput, translateOperation->getInputSocket(0));
-
-    converter.addLink(translateOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
-    converter.addLink(rotateOperation->getOutputSocket(), scaleOperation->getInputSocket(0));
-
-    converter.addLink(scaleOperation->getOutputSocket(), psoperation->getInputSocket(0));
-  }
-  else {
-    // Scale  -> Rotate -> Translate.
-    converter.mapInputSocket(imageInput, scaleOperation->getInputSocket(0));
-
-    converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
-    converter.addLink(rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0));
-
-    converter.addLink(translateOperation->getOutputSocket(), psoperation->getInputSocket(0));
+  switch (context.get_execution_model()) {
+    case eExecutionModel::Tiled: {
+      ScaleRelativeOperation *scaleOperation = new ScaleRelativeOperation();
+      scaleOperation->setSampler(sampler);
+      RotateOperation *rotateOperation = new RotateOperation();
+      rotateOperation->setDoDegree2RadConversion(false);
+      TranslateOperation *translateOperation = new TranslateOperation();
+      SetSamplerOperation *psoperation = new SetSamplerOperation();
+      psoperation->setSampler(sampler);
+
+      converter.addOperation(scaleOperation);
+      converter.addOperation(translateOperation);
+      converter.addOperation(rotateOperation);
+      converter.addOperation(psoperation);
+
+      converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(1));
+      converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(2));
+
+      converter.addLink(angleAttribute->getOutputSocket(), rotateOperation->getInputSocket(1));
+
+      converter.addLink(xAttribute->getOutputSocket(), translateOperation->getInputSocket(1));
+      converter.addLink(yAttribute->getOutputSocket(), translateOperation->getInputSocket(2));
+
+      converter.mapOutputSocket(getOutputSocket(), psoperation->getOutputSocket());
+
+      if (invert) {
+        // Translate -> Rotate -> Scale.
+        converter.mapInputSocket(imageInput, translateOperation->getInputSocket(0));
+
+        converter.addLink(translateOperation->getOutputSocket(),
+                          rotateOperation->getInputSocket(0));
+        converter.addLink(rotateOperation->getOutputSocket(), scaleOperation->getInputSocket(0));
+
+        converter.addLink(scaleOperation->getOutputSocket(), psoperation->getInputSocket(0));
+      }
+      else {
+        // Scale  -> Rotate -> Translate.
+        converter.mapInputSocket(imageInput, scaleOperation->getInputSocket(0));
+
+        converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
+        converter.addLink(rotateOperation->getOutputSocket(),
+                          translateOperation->getInputSocket(0));
+
+        converter.addLink(translateOperation->getOutputSocket(), psoperation->getInputSocket(0));
+      }
+      break;
+    }
+    case eExecutionModel::FullFrame: {
+      TransformOperation *transform_op = new TransformOperation();
+      transform_op->set_sampler(sampler);
+      transform_op->set_convert_rotate_degree_to_rad(false);
+      transform_op->set_invert(invert);
+      converter.addOperation(transform_op);
+      converter.mapInputSocket(imageInput, transform_op->getInputSocket(0));
+      converter.addLink(xAttribute->getOutputSocket(), transform_op->getInputSocket(1));
+      converter.addLink(yAttribute->getOutputSocket(), transform_op->getInputSocket(2));
+      converter.addLink(angleAttribute->getOutputSocket(), transform_op->getInputSocket(3));
+      converter.addLink(scaleAttribute->getOutputSocket(), transform_op->getInputSocket(4));
+      converter.mapOutputSocket(getOutputSocket(), transform_op->getOutputSocket());
+    }
   }
 }
 
diff --git a/source/blender/compositor/nodes/COM_TransformNode.cc b/source/blender/compositor/nodes/COM_TransformNode.cc
index e1deaf616a4..d2fb7b54633 100644
--- a/source/blender/compositor/nodes/COM_TransformNode.cc
+++ b/source/blender/compositor/nodes/COM_TransformNode.cc
@@ -22,6 +22,7 @@
 #include "COM_ScaleOperation.h"
 #include "COM_SetSamplerOperation.h"
 #include "COM_SetValueOperation.h"
+#include "COM_TransformOperation.h"
 #include "COM_TranslateOperation.h"
 
 namespace bl

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list