Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/operations/COM_ScaleOperation.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 BaseScaleOperation : public NodeOperation { | class BaseScaleOperation : public MultiThreadedOperation { | ||||
| public: | public: | ||||
| void setSampler(PixelSampler sampler) | void setSampler(PixelSampler sampler) | ||||
| { | { | ||||
| this->m_sampler = (int)sampler; | this->m_sampler = (int)sampler; | ||||
| } | } | ||||
| void setVariableSize(bool variable_size) | void setVariableSize(bool variable_size) | ||||
| { | { | ||||
| m_variable_size = variable_size; | m_variable_size = variable_size; | ||||
| }; | }; | ||||
| protected: | protected: | ||||
| BaseScaleOperation(); | BaseScaleOperation(); | ||||
| PixelSampler getEffectiveSampler(PixelSampler sampler) | PixelSampler getEffectiveSampler(PixelSampler sampler) | ||||
| { | { | ||||
| return (m_sampler == -1) ? sampler : (PixelSampler)m_sampler; | return (m_sampler == -1) ? sampler : (PixelSampler)m_sampler; | ||||
| } | } | ||||
| int m_sampler; | int m_sampler; | ||||
| bool m_variable_size; | bool m_variable_size; | ||||
| }; | }; | ||||
| class ScaleOperation : public BaseScaleOperation { | class ScaleOperation : public BaseScaleOperation { | ||||
| private: | protected: | ||||
| SocketReader *m_inputOperation; | SocketReader *m_inputOperation; | ||||
| SocketReader *m_inputXOperation; | SocketReader *m_inputXOperation; | ||||
| SocketReader *m_inputYOperation; | SocketReader *m_inputYOperation; | ||||
| float m_centerX; | float m_centerX; | ||||
| float m_centerY; | float m_centerY; | ||||
| public: | public: | ||||
| ScaleOperation(); | ScaleOperation(); | ||||
| ScaleOperation(DataType data_type); | ScaleOperation(DataType data_type); | ||||
| bool determineDependingAreaOfInterest(rcti *input, | |||||
| ReadBufferOperation *readOperation, | |||||
| rcti *output) override; | |||||
| void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override; | |||||
| void init_data() override; | |||||
| void initExecution() override; | void initExecution() override; | ||||
| void deinitExecution() override; | void deinitExecution() override; | ||||
| }; | |||||
| class ScaleAbsoluteOperation : public BaseScaleOperation { | void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override; | ||||
| SocketReader *m_inputOperation; | void update_memory_buffer_partial(MemoryBuffer *output, | ||||
| SocketReader *m_inputXOperation; | const rcti &area, | ||||
| SocketReader *m_inputYOperation; | Span<MemoryBuffer *> inputs) override; | ||||
| float m_centerX; | |||||
| float m_centerY; | protected: | ||||
| virtual float get_relative_scale_x_factor() = 0; | |||||
| virtual float get_relative_scale_y_factor() = 0; | |||||
| private: | |||||
| float get_constant_scale(int input_op_idx, float factor); | |||||
| float get_constant_scale_x(); | |||||
| float get_constant_scale_y(); | |||||
| void scale_area(rcti &rect, float scale_x, float scale_y); | |||||
| }; | |||||
| class ScaleRelativeOperation : public ScaleOperation { | |||||
| public: | public: | ||||
| ScaleAbsoluteOperation(); | ScaleRelativeOperation(); | ||||
| ScaleRelativeOperation(DataType data_type); | |||||
| bool determineDependingAreaOfInterest(rcti *input, | bool determineDependingAreaOfInterest(rcti *input, | ||||
| ReadBufferOperation *readOperation, | ReadBufferOperation *readOperation, | ||||
| rcti *output) override; | rcti *output) override; | ||||
| void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override; | void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override; | ||||
| float get_relative_scale_x_factor() override | |||||
| { | |||||
| return 1.0f; | |||||
| } | |||||
| float get_relative_scale_y_factor() override | |||||
| { | |||||
| return 1.0f; | |||||
| } | |||||
| }; | |||||
| void initExecution() override; | class ScaleAbsoluteOperation : public ScaleOperation { | ||||
| void deinitExecution() override; | public: | ||||
| bool determineDependingAreaOfInterest(rcti *input, | |||||
| ReadBufferOperation *readOperation, | |||||
| rcti *output) override; | |||||
| void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override; | |||||
| float get_relative_scale_x_factor() override | |||||
| { | |||||
| return 1.0f / getWidth(); | |||||
| } | |||||
| float get_relative_scale_y_factor() override | |||||
| { | |||||
| return 1.0f / getHeight(); | |||||
| } | |||||
| }; | }; | ||||
| class ScaleFixedSizeOperation : public BaseScaleOperation { | class ScaleFixedSizeOperation : public BaseScaleOperation { | ||||
| SocketReader *m_inputOperation; | SocketReader *m_inputOperation; | ||||
| int m_newWidth; | int m_newWidth; | ||||
| int m_newHeight; | int m_newHeight; | ||||
| float m_relX; | float m_relX; | ||||
| float m_relY; | float m_relY; | ||||
| Show All 11 Lines | public: | ||||
| ScaleFixedSizeOperation(); | ScaleFixedSizeOperation(); | ||||
| bool determineDependingAreaOfInterest(rcti *input, | bool determineDependingAreaOfInterest(rcti *input, | ||||
| ReadBufferOperation *readOperation, | ReadBufferOperation *readOperation, | ||||
| rcti *output) override; | rcti *output) override; | ||||
| void determineResolution(unsigned int resolution[2], | void determineResolution(unsigned int resolution[2], | ||||
| unsigned int preferredResolution[2]) override; | unsigned int preferredResolution[2]) override; | ||||
| void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override; | void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override; | ||||
| void init_data() override; | |||||
| void initExecution() override; | void initExecution() override; | ||||
| void deinitExecution() override; | void deinitExecution() override; | ||||
| void setNewWidth(int width) | void setNewWidth(int width) | ||||
| { | { | ||||
| this->m_newWidth = width; | this->m_newWidth = width; | ||||
| } | } | ||||
| void setNewHeight(int height) | void setNewHeight(int height) | ||||
| { | { | ||||
| this->m_newHeight = height; | this->m_newHeight = height; | ||||
| } | } | ||||
| void setIsAspect(bool is_aspect) | void setIsAspect(bool is_aspect) | ||||
| { | { | ||||
| this->m_is_aspect = is_aspect; | this->m_is_aspect = is_aspect; | ||||
| } | } | ||||
| void setIsCrop(bool is_crop) | void setIsCrop(bool is_crop) | ||||
| { | { | ||||
| this->m_is_crop = is_crop; | this->m_is_crop = is_crop; | ||||
| } | } | ||||
| void setOffset(float x, float y) | void setOffset(float x, float y) | ||||
| { | { | ||||
| this->m_offsetX = x; | this->m_offsetX = x; | ||||
| this->m_offsetY = y; | this->m_offsetY = y; | ||||
| } | } | ||||
| 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 | ||||