Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/operations/COM_DilateErodeOperation.h
| Show All 12 Lines | |||||
| * along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| * | * | ||||
| * Copyright 2011, Blender Foundation. | * Copyright 2011, Blender Foundation. | ||||
| */ | */ | ||||
| #pragma once | #pragma once | ||||
| #include "COM_NodeOperation.h" | #include "COM_MultiThreadedOperation.h" | ||||
| namespace blender::compositor { | namespace blender::compositor { | ||||
| class DilateErodeThresholdOperation : public NodeOperation { | class DilateErodeThresholdOperation : public MultiThreadedOperation { | ||||
| public: | |||||
| struct PixelData; | |||||
| private: | private: | ||||
| /** | /** | ||||
| * Cached reference to the inputProgram | * Cached reference to the inputProgram | ||||
| */ | */ | ||||
| SocketReader *m_inputProgram; | SocketReader *m_inputProgram; | ||||
| float m_distance; | float m_distance; | ||||
| float m__switch; | float m__switch; | ||||
| float m_inset; | float m_inset; | ||||
| /** | /** | ||||
| * determines the area of interest to track pixels | * determines the area of interest to track pixels | ||||
| * keep this one as small as possible for speed gain. | * keep this one as small as possible for speed gain. | ||||
| */ | */ | ||||
| int m_scope; | int m_scope; | ||||
| public: | public: | ||||
| DilateErodeThresholdOperation(); | DilateErodeThresholdOperation(); | ||||
| /** | /** | ||||
| * The inner loop of this operation. | * The inner loop of this operation. | ||||
| */ | */ | ||||
| void executePixel(float output[4], int x, int y, void *data) override; | void executePixel(float output[4], int x, int y, void *data) override; | ||||
| void init_data() override; | |||||
| /** | /** | ||||
| * Initialize the execution | * Initialize the execution | ||||
| */ | */ | ||||
| void initExecution() override; | void initExecution() override; | ||||
| void *initializeTileData(rcti *rect) override; | void *initializeTileData(rcti *rect) override; | ||||
| /** | /** | ||||
| * Deinitialize the execution | * Deinitialize the execution | ||||
| Show All 11 Lines | public: | ||||
| void setInset(float inset) | void setInset(float inset) | ||||
| { | { | ||||
| this->m_inset = inset; | this->m_inset = inset; | ||||
| } | } | ||||
| bool determineDependingAreaOfInterest(rcti *input, | bool determineDependingAreaOfInterest(rcti *input, | ||||
| ReadBufferOperation *readOperation, | ReadBufferOperation *readOperation, | ||||
| rcti *output) override; | rcti *output) override; | ||||
| void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override; | |||||
| void update_memory_buffer_partial(MemoryBuffer *output, | |||||
| const rcti &area, | |||||
| Span<MemoryBuffer *> inputs) override; | |||||
| }; | }; | ||||
| class DilateDistanceOperation : public NodeOperation { | class DilateDistanceOperation : public MultiThreadedOperation { | ||||
| private: | public: | ||||
| struct PixelData; | |||||
| protected: | protected: | ||||
| /** | /** | ||||
| * Cached reference to the inputProgram | * Cached reference to the inputProgram | ||||
| */ | */ | ||||
| SocketReader *m_inputProgram; | SocketReader *m_inputProgram; | ||||
| float m_distance; | float m_distance; | ||||
| int m_scope; | int m_scope; | ||||
| public: | public: | ||||
| DilateDistanceOperation(); | DilateDistanceOperation(); | ||||
| /** | /** | ||||
| * The inner loop of this operation. | * The inner loop of this operation. | ||||
| */ | */ | ||||
| void executePixel(float output[4], int x, int y, void *data) override; | void executePixel(float output[4], int x, int y, void *data) override; | ||||
| void init_data() override; | |||||
| /** | /** | ||||
| * Initialize the execution | * Initialize the execution | ||||
| */ | */ | ||||
| void initExecution() override; | void initExecution() override; | ||||
| void *initializeTileData(rcti *rect) override; | void *initializeTileData(rcti *rect) override; | ||||
| /** | /** | ||||
| * Deinitialize the execution | * Deinitialize the execution | ||||
| Show All 9 Lines | bool determineDependingAreaOfInterest(rcti *input, | ||||
| rcti *output) override; | rcti *output) override; | ||||
| void executeOpenCL(OpenCLDevice *device, | void executeOpenCL(OpenCLDevice *device, | ||||
| MemoryBuffer *outputMemoryBuffer, | MemoryBuffer *outputMemoryBuffer, | ||||
| cl_mem clOutputBuffer, | cl_mem clOutputBuffer, | ||||
| MemoryBuffer **inputMemoryBuffers, | MemoryBuffer **inputMemoryBuffers, | ||||
| std::list<cl_mem> *clMemToCleanUp, | std::list<cl_mem> *clMemToCleanUp, | ||||
| std::list<cl_kernel> *clKernelsToCleanUp) override; | std::list<cl_kernel> *clKernelsToCleanUp) override; | ||||
| void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) final; | |||||
| virtual void update_memory_buffer_partial(MemoryBuffer *output, | |||||
| const rcti &area, | |||||
| Span<MemoryBuffer *> inputs) override; | |||||
| }; | }; | ||||
| class ErodeDistanceOperation : public DilateDistanceOperation { | class ErodeDistanceOperation : public DilateDistanceOperation { | ||||
| public: | public: | ||||
| ErodeDistanceOperation(); | ErodeDistanceOperation(); | ||||
| /** | /** | ||||
| * The inner loop of this operation. | * The inner loop of this operation. | ||||
| */ | */ | ||||
| void executePixel(float output[4], int x, int y, void *data) override; | void executePixel(float output[4], int x, int y, void *data) override; | ||||
| void executeOpenCL(OpenCLDevice *device, | void executeOpenCL(OpenCLDevice *device, | ||||
| MemoryBuffer *outputMemoryBuffer, | MemoryBuffer *outputMemoryBuffer, | ||||
| cl_mem clOutputBuffer, | cl_mem clOutputBuffer, | ||||
| MemoryBuffer **inputMemoryBuffers, | MemoryBuffer **inputMemoryBuffers, | ||||
| std::list<cl_mem> *clMemToCleanUp, | std::list<cl_mem> *clMemToCleanUp, | ||||
| std::list<cl_kernel> *clKernelsToCleanUp) override; | std::list<cl_kernel> *clKernelsToCleanUp) override; | ||||
| void update_memory_buffer_partial(MemoryBuffer *output, | |||||
| const rcti &area, | |||||
| Span<MemoryBuffer *> inputs) override; | |||||
| }; | }; | ||||
| class DilateStepOperation : public NodeOperation { | class DilateStepOperation : public MultiThreadedOperation { | ||||
| protected: | protected: | ||||
| /** | /** | ||||
| * Cached reference to the inputProgram | * Cached reference to the inputProgram | ||||
| */ | */ | ||||
| SocketReader *m_inputProgram; | SocketReader *m_inputProgram; | ||||
| int m_iterations; | int m_iterations; | ||||
| Show All 20 Lines | public: | ||||
| void setIterations(int iterations) | void setIterations(int iterations) | ||||
| { | { | ||||
| this->m_iterations = iterations; | this->m_iterations = iterations; | ||||
| } | } | ||||
| bool determineDependingAreaOfInterest(rcti *input, | bool determineDependingAreaOfInterest(rcti *input, | ||||
| ReadBufferOperation *readOperation, | ReadBufferOperation *readOperation, | ||||
| rcti *output) override; | rcti *output) override; | ||||
| void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) final; | |||||
| virtual void update_memory_buffer_partial(MemoryBuffer *output, | |||||
| const rcti &area, | |||||
| Span<MemoryBuffer *> inputs) override; | |||||
| }; | }; | ||||
| class ErodeStepOperation : public DilateStepOperation { | class ErodeStepOperation : public DilateStepOperation { | ||||
| public: | public: | ||||
| ErodeStepOperation(); | ErodeStepOperation(); | ||||
| void *initializeTileData(rcti *rect) override; | void *initializeTileData(rcti *rect) override; | ||||
| void update_memory_buffer_partial(MemoryBuffer *output, | |||||
| const rcti &area, | |||||
| Span<MemoryBuffer *> inputs) override; | |||||
| }; | }; | ||||
| } // namespace blender::compositor | } // namespace blender::compositor | ||||