[Bf-blender-cvs] [f725f42af5a] master: Cleanup: Remove SocketReader.

Jeroen Bakker noreply at git.blender.org
Fri Mar 26 16:03:40 CET 2021


Commit: f725f42af5a2c992c8cef8aa79bfc8e687df13c7
Author: Jeroen Bakker
Date:   Fri Mar 26 14:02:36 2021 +0100
Branches: master
https://developer.blender.org/rBf725f42af5a2c992c8cef8aa79bfc8e687df13c7

Cleanup: Remove SocketReader.

SocketReader was added as an easier to understand interface on top of
the NodeOperation. It was implemented as a base class of the
NodeOperation and adds an additional hierarchy level.

Ths change replaces the abstract class with a typedef. In the end we
want to remove the typedef but will wait for some new nodes before doing
so.

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

M	source/blender/compositor/CMakeLists.txt
M	source/blender/compositor/intern/COM_MemoryBuffer.h
M	source/blender/compositor/intern/COM_NodeOperation.h
D	source/blender/compositor/intern/COM_SocketReader.cc
D	source/blender/compositor/intern/COM_SocketReader.h
M	source/blender/compositor/operations/COM_WriteBufferOperation.h

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

diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt
index 64033cbe5c4..6ae7fc04237 100644
--- a/source/blender/compositor/CMakeLists.txt
+++ b/source/blender/compositor/CMakeLists.txt
@@ -87,8 +87,6 @@ set(SRC
   intern/COM_OpenCLDevice.h
   intern/COM_SingleThreadedOperation.cc
   intern/COM_SingleThreadedOperation.h
-  intern/COM_SocketReader.cc
-  intern/COM_SocketReader.h
   intern/COM_WorkPackage.cc
   intern/COM_WorkPackage.h
   intern/COM_WorkScheduler.cc
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h
index 6f719b61122..a72e0654360 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.h
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.h
@@ -22,7 +22,6 @@ class MemoryBuffer;
 
 #include "COM_ExecutionGroup.h"
 #include "COM_MemoryProxy.h"
-#include "COM_SocketReader.h"
 
 #include "BLI_math.h"
 #include "BLI_rect.h"
diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h
index 7857837a95d..7ac48ad00dd 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.h
+++ b/source/blender/compositor/intern/COM_NodeOperation.h
@@ -28,8 +28,8 @@
 
 #include "COM_MemoryBuffer.h"
 #include "COM_MemoryProxy.h"
+#include "COM_MetaData.h"
 #include "COM_Node.h"
-#include "COM_SocketReader.h"
 
 #include "clew.h"
 
@@ -40,6 +40,9 @@ class WriteBufferOperation;
 class NodeOperationInput;
 class NodeOperationOutput;
 
+class NodeOperation;
+typedef NodeOperation SocketReader;
+
 /**
  * \brief Resize modes of inputsockets
  * How are the input and working resolutions matched
@@ -64,13 +67,19 @@ typedef enum InputResizeMode {
   COM_SC_STRETCH = NS_CR_STRETCH,
 } InputResizeMode;
 
+enum class PixelSampler {
+  Nearest = 0,
+  Bilinear = 1,
+  Bicubic = 2,
+};
+
 /**
  * \brief NodeOperation contains calculation logic
  *
  * Subclasses needs to implement the execution method (defined in SocketReader) to implement logic.
  * \ingroup Model
  */
-class NodeOperation : public SocketReader {
+class NodeOperation {
  public:
   typedef std::vector<NodeOperationInput *> Inputs;
   typedef std::vector<NodeOperationOutput *> Outputs;
@@ -119,6 +128,17 @@ class NodeOperation : public SocketReader {
    */
   bool m_isResolutionSet;
 
+ protected:
+  /**
+   * Width of the output of this operation.
+   */
+  unsigned int m_width;
+
+  /**
+   * Height of the output of this operation.
+   */
+  unsigned int m_height;
+
  public:
   virtual ~NodeOperation();
 
@@ -373,6 +393,54 @@ class NodeOperation : public SocketReader {
     }
   }
 
+  unsigned int getWidth() const
+  {
+    return m_width;
+  }
+
+  unsigned int getHeight() const
+  {
+    return m_height;
+  }
+
+  inline void readSampled(float result[4], float x, float y, PixelSampler sampler)
+  {
+    executePixelSampled(result, x, y, sampler);
+  }
+
+  inline void readFiltered(float result[4], float x, float y, float dx[2], float dy[2])
+  {
+    executePixelFiltered(result, x, y, dx, dy);
+  }
+
+  inline void read(float result[4], int x, int y, void *chunkData)
+  {
+    executePixel(result, x, y, chunkData);
+  }
+
+  virtual void *initializeTileData(rcti * /*rect*/)
+  {
+    return 0;
+  }
+
+  virtual void deinitializeTileData(rcti * /*rect*/, void * /*data*/)
+  {
+  }
+
+  virtual MemoryBuffer *getInputMemoryBuffer(MemoryBuffer ** /*memoryBuffers*/)
+  {
+    return 0;
+  }
+
+  /**
+   * Return the meta data associated with this branch.
+   *
+   * The return parameter holds an instance or is an nullptr. */
+  virtual std::unique_ptr<MetaData> getMetaData() const
+  {
+    return std::unique_ptr<MetaData>();
+  }
+
  protected:
   NodeOperation();
 
@@ -416,6 +484,50 @@ class NodeOperation : public SocketReader {
     this->m_openCL = openCL;
   }
 
+  /**
+   * \brief calculate a single pixel
+   * \note this method is called for non-complex
+   * \param result: is a float[4] array to store the result
+   * \param x: the x-coordinate of the pixel to calculate in image space
+   * \param y: the y-coordinate of the pixel to calculate in image space
+   * \param inputBuffers: chunks that can be read by their ReadBufferOperation.
+   */
+  virtual void executePixelSampled(float /*output*/[4],
+                                   float /*x*/,
+                                   float /*y*/,
+                                   PixelSampler /*sampler*/)
+  {
+  }
+
+  /**
+   * \brief calculate a single pixel
+   * \note this method is called for complex
+   * \param result: is a float[4] array to store the result
+   * \param x: the x-coordinate of the pixel to calculate in image space
+   * \param y: the y-coordinate of the pixel to calculate in image space
+   * \param inputBuffers: chunks that can be read by their ReadBufferOperation.
+   * \param chunkData: chunk specific data a during execution time.
+   */
+  virtual void executePixel(float output[4], int x, int y, void * /*chunkData*/)
+  {
+    executePixelSampled(output, x, y, PixelSampler::Nearest);
+  }
+
+  /**
+   * \brief calculate a single pixel using an EWA filter
+   * \note this method is called for complex
+   * \param result: is a float[4] array to store the result
+   * \param x: the x-coordinate of the pixel to calculate in image space
+   * \param y: the y-coordinate of the pixel to calculate in image space
+   * \param dx:
+   * \param dy:
+   * \param inputBuffers: chunks that can be read by their ReadBufferOperation.
+   */
+  virtual void executePixelFiltered(
+      float /*output*/[4], float /*x*/, float /*y*/, float /*dx*/[2], float /*dy*/[2])
+  {
+  }
+
   /* allow the DebugInfo class to look at internals */
   friend class DebugInfo;
 
diff --git a/source/blender/compositor/intern/COM_SocketReader.cc b/source/blender/compositor/intern/COM_SocketReader.cc
deleted file mode 100644
index 93c8a143b86..00000000000
--- a/source/blender/compositor/intern/COM_SocketReader.cc
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Copyright 2011, Blender Foundation.
- */
-
-#include "COM_SocketReader.h"
diff --git a/source/blender/compositor/intern/COM_SocketReader.h b/source/blender/compositor/intern/COM_SocketReader.h
deleted file mode 100644
index 4074f5e759f..00000000000
--- a/source/blender/compositor/intern/COM_SocketReader.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Copyright 2011, Blender Foundation.
- */
-
-#pragma once
-
-#include "BLI_rect.h"
-#include "COM_MetaData.h"
-#include "COM_defines.h"
-
-#include <memory>
-#include <optional>
-
-#ifdef WITH_CXX_GUARDEDALLOC
-#  include "MEM_guardedalloc.h"
-#endif
-
-enum class PixelSampler {
-  Nearest = 0,
-  Bilinear = 1,
-  Bicubic = 2,
-};
-
-class MemoryBuffer;
-
-/**
- * \brief Helper class for reading socket data.
- * Only use this class for dispatching (un-ary and n-ary) executions.
- * \ingroup Execution
- */
-class SocketReader {
- private:
- protected:
-  /**
-   * \brief Holds the width of the output of this operation.
-   */
-  unsigned int m_width;
-
-  /**
-   * \brief Holds the height of the output of this operation.
-   */
-  unsigned int m_height;
-
-  /**
-   * \brief calculate a single pixel
-   * \note this method is called for non-complex
-   * \param result: is a float[4] array to store the result
-   * \param x: the x-coordinate of the pixel to calculate in image space
-   * \param y: the y-coordinate of the pixel to calculate in image space
-   * \param inputBuffers: chunks that can be read by their ReadBufferOperation.
-   */
-  virtual void executePixelSampled(float /*output*/[4],
-                                   float /*x*/,
-                                   float /*y*/,
-                                   PixelSampler /*sampler*/)
-  {
-  }
-
-  /**
-   * \brief calculate a single pixel
-   * \note this method is called for complex
-   * \param result: is a float[4] array to store the result
-   * \param x: the x-coordinate of the pixel to calculate in image space
-   * \param y: the y-coordinate of the pixel to calculate in image space
-   * \param inputBuffers: chunks that can be read by their ReadBufferOperation.
-   * \param chunkData: chunk specific data a during execution time.
-   */
-  virtual void executePixel(float output[4], int x, int y, void * /*chunkData*/)
-  {
-    executePixelSampled(output, x, y, PixelSampler::Nearest);
-  }
-
-  /**
-   * \brief calculate a single pixel using an EWA filter
-   * \note this method is called for complex
-   * \param result: is a float[4] array to store the result
-   * \param x: the x-coordinate of the pixel to calculate in image space
-   * \param y: the y-coordinate of the pixel to calculate in image space
-   * \param dx:
-   * \param dy:
-   * \param inputBuffers: 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list