diff options
author | Manuel Castilla <manzanillawork@gmail.com> | 2021-07-26 20:07:08 +0300 |
---|---|---|
committer | Manuel Castilla <manzanillawork@gmail.com> | 2021-07-26 21:13:03 +0300 |
commit | a117794f8c05ad2e2b7db0b0f43c3059f20e62a1 (patch) | |
tree | 8f29140bdbfc0f669f7301f5f3ccc8115bb374f9 /source/blender/compositor/operations/COM_ScaleOperation.h | |
parent | cf74cd93674c11e8e5ef599100d0c7bf3cc8a79c (diff) |
Compositor: Full frame Scale node
Adds full frame implementation to this node operations.
No functional changes.
Includes a new operation method `init_data` used to initialize any data
needed after operations are linked and resolutions determined.
Once tiled implementation is removed `initExecution` may be renamed
to `init_rendering` and `init_data` to `init_execution`.
Reviewed By: jbakker
Differential Revision: https://developer.blender.org/D11944
Diffstat (limited to 'source/blender/compositor/operations/COM_ScaleOperation.h')
-rw-r--r-- | source/blender/compositor/operations/COM_ScaleOperation.h | 67 |
1 files changed, 50 insertions, 17 deletions
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.h b/source/blender/compositor/operations/COM_ScaleOperation.h index 2f9a7be92e6..b2f41a1e98a 100644 --- a/source/blender/compositor/operations/COM_ScaleOperation.h +++ b/source/blender/compositor/operations/COM_ScaleOperation.h @@ -18,11 +18,11 @@ #pragma once -#include "COM_NodeOperation.h" +#include "COM_MultiThreadedOperation.h" namespace blender::compositor { -class BaseScaleOperation : public NodeOperation { +class BaseScaleOperation : public MultiThreadedOperation { public: void setSampler(PixelSampler sampler) { @@ -46,7 +46,7 @@ class BaseScaleOperation : public NodeOperation { }; class ScaleOperation : public BaseScaleOperation { - private: + protected: SocketReader *m_inputOperation; SocketReader *m_inputXOperation; SocketReader *m_inputYOperation; @@ -56,31 +56,58 @@ class ScaleOperation : public BaseScaleOperation { public: ScaleOperation(); 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 deinitExecution() override; -}; -class ScaleAbsoluteOperation : public BaseScaleOperation { - SocketReader *m_inputOperation; - SocketReader *m_inputXOperation; - SocketReader *m_inputYOperation; - float m_centerX; - float m_centerY; + 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; + + protected: + virtual float get_relative_scale_x_factor() = 0; + virtual float get_relative_scale_y_factor() = 0; + + private: + 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: - ScaleAbsoluteOperation(); + ScaleRelativeOperation(); + ScaleRelativeOperation(DataType data_type); 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; + } + float get_relative_scale_y_factor() override + { + return 1.0f; + } +}; - void initExecution() override; - void deinitExecution() override; +class ScaleAbsoluteOperation : public ScaleOperation { + 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 { @@ -108,6 +135,7 @@ class ScaleFixedSizeOperation : public BaseScaleOperation { unsigned int preferredResolution[2]) override; void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override; + void init_data() override; void initExecution() override; void deinitExecution() override; void setNewWidth(int width) @@ -131,6 +159,11 @@ class ScaleFixedSizeOperation : public BaseScaleOperation { this->m_offsetX = x; 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 |