diff options
author | Jeroen Bakker <jeroen@blender.org> | 2021-03-26 16:02:36 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-03-26 17:51:06 +0300 |
commit | f725f42af5a2c992c8cef8aa79bfc8e687df13c7 (patch) | |
tree | dc44c92511922eec2c24c27a0790d094cf4910fb /source/blender/compositor | |
parent | e5fb7eac85f60a301f7bf742b12bb04a795d0f31 (diff) |
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.
Diffstat (limited to 'source/blender/compositor')
6 files changed, 114 insertions, 178 deletions
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: chunks that can be read by their ReadBufferOperation. - */ - virtual void executePixelFiltered( - float /*output*/[4], float /*x*/, float /*y*/, float /*dx*/[2], float /*dy*/[2]) - { - } - - public: - inline void readSampled(float result[4], float x, float y, PixelSampler sampler) - { - executePixelSampled(result, x, y, sampler); - } - inline void read(float result[4], int x, int y, void *chunkData) - { - executePixel(result, x, y, chunkData); - } - inline void readFiltered(float result[4], float x, float y, float dx[2], float dy[2]) - { - executePixelFiltered(result, x, y, dx, dy); - } - - virtual void *initializeTileData(rcti * /*rect*/) - { - return 0; - } - virtual void deinitializeTileData(rcti * /*rect*/, void * /*data*/) - { - } - - virtual ~SocketReader() - { - } - - virtual MemoryBuffer *getInputMemoryBuffer(MemoryBuffer ** /*memoryBuffers*/) - { - return 0; - } - - inline unsigned int getWidth() const - { - return this->m_width; - } - inline unsigned int getHeight() const - { - return this->m_height; - } - - /* 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>(); - } - -#ifdef WITH_CXX_GUARDEDALLOC - MEM_CXX_CLASS_ALLOC_FUNCS("COM:SocketReader") -#endif -}; diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.h b/source/blender/compositor/operations/COM_WriteBufferOperation.h index 00d48e38fca..2f90df8960a 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.h +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.h @@ -20,7 +20,6 @@ #include "COM_MemoryProxy.h" #include "COM_NodeOperation.h" -#include "COM_SocketReader.h" /** * \brief NodeOperation to write to a tile * \ingroup Operation |