Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/operations/COM_SMAAOperation.h
| Show All 14 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. | ||||
| * | * | ||||
| * Contributor: IRIE Shinsuke | * Contributor: IRIE Shinsuke | ||||
| */ | */ | ||||
| #pragma once | #pragma once | ||||
| #include "COM_NodeOperation.h" | #include "COM_MultiThreadedOperation.h" | ||||
| namespace blender::compositor { | namespace blender::compositor { | ||||
| /*-----------------------------------------------------------------------------*/ | /*-----------------------------------------------------------------------------*/ | ||||
| /* Edge Detection (First Pass) */ | /* Edge Detection (First Pass) */ | ||||
| class SMAAEdgeDetectionOperation : public NodeOperation { | class SMAAEdgeDetectionOperation : public MultiThreadedOperation { | ||||
| protected: | protected: | ||||
| SocketReader *m_imageReader; | SocketReader *m_imageReader; | ||||
| SocketReader *m_valueReader; | SocketReader *m_valueReader; | ||||
| float m_threshold; | float m_threshold; | ||||
| float m_contrast_limit; | float m_contrast_limit; | ||||
| public: | public: | ||||
| Show All 16 Lines | public: | ||||
| void setThreshold(float threshold); | void setThreshold(float threshold); | ||||
| void setLocalContrastAdaptationFactor(float factor); | void setLocalContrastAdaptationFactor(float factor); | ||||
| 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; | |||||
| }; | }; | ||||
| /*-----------------------------------------------------------------------------*/ | /*-----------------------------------------------------------------------------*/ | ||||
| /* Blending Weight Calculation (Second Pass) */ | /* Blending Weight Calculation (Second Pass) */ | ||||
| class SMAABlendingWeightCalculationOperation : public NodeOperation { | class SMAABlendingWeightCalculationOperation : public MultiThreadedOperation { | ||||
| private: | private: | ||||
| SocketReader *m_imageReader; | SocketReader *m_imageReader; | ||||
| std::function<void(int x, int y, float *out)> sample_image_fn_; | |||||
| int m_corner_rounding; | int m_corner_rounding; | ||||
| public: | public: | ||||
| SMAABlendingWeightCalculationOperation(); | SMAABlendingWeightCalculationOperation(); | ||||
| /** | /** | ||||
| * the inner loop of this program | * the inner loop of this program | ||||
| */ | */ | ||||
| Show All 11 Lines | public: | ||||
| void deinitExecution() override; | void deinitExecution() override; | ||||
| void setCornerRounding(float rounding); | void setCornerRounding(float rounding); | ||||
| 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_started(MemoryBuffer *output, | |||||
| const rcti &area, | |||||
| Span<MemoryBuffer *> inputs) override; | |||||
| void update_memory_buffer_partial(MemoryBuffer *output, | |||||
| const rcti &area, | |||||
| Span<MemoryBuffer *> inputs) override; | |||||
| private: | private: | ||||
| /* Diagonal Search Functions */ | /* Diagonal Search Functions */ | ||||
| int searchDiag1(int x, int y, int dir, bool *found); | int searchDiag1(int x, int y, int dir, bool *found); | ||||
| int searchDiag2(int x, int y, int dir, bool *found); | int searchDiag2(int x, int y, int dir, bool *found); | ||||
| void calculateDiagWeights(int x, int y, const float edges[2], float weights[2]); | void calculateDiagWeights(int x, int y, const float edges[2], float weights[2]); | ||||
| bool isVerticalSearchUnneeded(int x, int y); | bool isVerticalSearchUnneeded(int x, int y); | ||||
| /* Horizontal/Vertical Search Functions */ | /* Horizontal/Vertical Search Functions */ | ||||
| int searchXLeft(int x, int y); | int searchXLeft(int x, int y); | ||||
| int searchXRight(int x, int y); | int searchXRight(int x, int y); | ||||
| int searchYUp(int x, int y); | int searchYUp(int x, int y); | ||||
| int searchYDown(int x, int y); | int searchYDown(int x, int y); | ||||
| /* Corner Detection Functions */ | /* Corner Detection Functions */ | ||||
| void detectHorizontalCornerPattern(float weights[2], int left, int right, int y, int d1, int d2); | void detectHorizontalCornerPattern(float weights[2], int left, int right, int y, int d1, int d2); | ||||
| void detectVerticalCornerPattern(float weights[2], int x, int top, int bottom, int d1, int d2); | void detectVerticalCornerPattern(float weights[2], int x, int top, int bottom, int d1, int d2); | ||||
| }; | }; | ||||
| /*-----------------------------------------------------------------------------*/ | /*-----------------------------------------------------------------------------*/ | ||||
| /* Neighborhood Blending (Third Pass) */ | /* Neighborhood Blending (Third Pass) */ | ||||
| class SMAANeighborhoodBlendingOperation : public NodeOperation { | class SMAANeighborhoodBlendingOperation : public MultiThreadedOperation { | ||||
| private: | private: | ||||
| SocketReader *m_image1Reader; | SocketReader *m_image1Reader; | ||||
| SocketReader *m_image2Reader; | SocketReader *m_image2Reader; | ||||
| public: | public: | ||||
| SMAANeighborhoodBlendingOperation(); | SMAANeighborhoodBlendingOperation(); | ||||
| /** | /** | ||||
| Show All 10 Lines | public: | ||||
| /** | /** | ||||
| * Deinitialize the execution | * Deinitialize the execution | ||||
| */ | */ | ||||
| void deinitExecution() override; | void deinitExecution() override; | ||||
| 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; | |||||
| }; | }; | ||||
| } // namespace blender::compositor | } // namespace blender::compositor | ||||