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/intern | |
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/intern')
8 files changed, 65 insertions, 9 deletions
diff --git a/source/blender/compositor/intern/COM_ConstantFolder.cc b/source/blender/compositor/intern/COM_ConstantFolder.cc index 15450572958..5b48ff8fc08 100644 --- a/source/blender/compositor/intern/COM_ConstantFolder.cc +++ b/source/blender/compositor/intern/COM_ConstantFolder.cc @@ -94,6 +94,7 @@ ConstantOperation *ConstantFolder::fold_operation(NodeOperation *operation) const DataType data_type = operation->getOutputSocket()->getDataType(); MemoryBuffer fold_buf(data_type, first_elem_area_); Vector<MemoryBuffer *> input_bufs = get_constant_input_buffers(operation); + operation->init_data(); operation->render(&fold_buf, {first_elem_area_}, input_bufs); MemoryBuffer *constant_buf = create_constant_buffer(data_type); diff --git a/source/blender/compositor/intern/COM_Converter.cc b/source/blender/compositor/intern/COM_Converter.cc index 18973bb5a00..1983eb190e2 100644 --- a/source/blender/compositor/intern/COM_Converter.cc +++ b/source/blender/compositor/intern/COM_Converter.cc @@ -518,7 +518,7 @@ void COM_convert_resolution(NodeOperationBuilder &builder, NodeOperation *first = nullptr; ScaleOperation *scaleOperation = nullptr; if (doScale) { - scaleOperation = new ScaleOperation(fromSocket->getDataType()); + scaleOperation = new ScaleRelativeOperation(fromSocket->getDataType()); scaleOperation->getInputSocket(1)->setResizeMode(ResizeMode::None); scaleOperation->getInputSocket(2)->setResizeMode(ResizeMode::None); first = scaleOperation; diff --git a/source/blender/compositor/intern/COM_Enums.cc b/source/blender/compositor/intern/COM_Enums.cc index d218de92544..2f20d2652ba 100644 --- a/source/blender/compositor/intern/COM_Enums.cc +++ b/source/blender/compositor/intern/COM_Enums.cc @@ -17,9 +17,28 @@ */ #include "COM_Enums.h" +#include "BLI_rect.h" namespace blender::compositor { +void expand_area_for_sampler(rcti &area, PixelSampler sampler) +{ + switch (sampler) { + case PixelSampler::Nearest: + break; + case PixelSampler::Bilinear: + area.xmax += 1; + area.ymax += 1; + break; + case PixelSampler::Bicubic: + area.xmin -= 1; + area.xmax += 2; + area.ymin -= 1; + area.ymax += 2; + break; + } +} + std::ostream &operator<<(std::ostream &os, const eCompositorPriority &priority) { switch (priority) { diff --git a/source/blender/compositor/intern/COM_Enums.h b/source/blender/compositor/intern/COM_Enums.h index 519e7df940e..7e5a1b73132 100644 --- a/source/blender/compositor/intern/COM_Enums.h +++ b/source/blender/compositor/intern/COM_Enums.h @@ -22,6 +22,8 @@ #include <ostream> +struct rcti; + namespace blender::compositor { /** @@ -85,6 +87,13 @@ enum class eWorkPackageType { CustomFunction = 1 }; +enum class PixelSampler { + Nearest = 0, + Bilinear = 1, + Bicubic = 2, +}; +void expand_area_for_sampler(rcti &area, PixelSampler sampler); + std::ostream &operator<<(std::ostream &os, const eCompositorPriority &priority); std::ostream &operator<<(std::ostream &os, const eWorkPackageState &execution_state); diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cc b/source/blender/compositor/intern/COM_ExecutionSystem.cc index 60caf22be1b..cd2738fc2c7 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cc +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cc @@ -112,6 +112,9 @@ void ExecutionSystem::set_operations(const Vector<NodeOperation *> &operations, void ExecutionSystem::execute() { DebugInfo::execute_started(this); + for (NodeOperation *op : m_operations) { + op->init_data(); + } execution_model_->execute(*this); } diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h index 048ed4c5d6e..ae12c444dc1 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.h +++ b/source/blender/compositor/intern/COM_MemoryBuffer.h @@ -189,6 +189,25 @@ class MemoryBuffer { return m_buffer + get_coords_offset(x, y); } + void read_elem(int x, int y, float *out) const + { + memcpy(out, get_elem(x, y), m_num_channels * sizeof(float)); + } + + void read_elem_sampled(float x, float y, PixelSampler sampler, float *out) const + { + switch (sampler) { + case PixelSampler::Nearest: + this->read_elem(x, y, out); + break; + case PixelSampler::Bilinear: + case PixelSampler::Bicubic: + /* No bicubic. Current implementation produces fuzzy results. */ + this->readBilinear(out, x, y); + break; + } + } + /** * Get channel value at given coordinates. */ @@ -330,7 +349,7 @@ class MemoryBuffer { inline void wrap_pixel(float &x, float &y, MemoryBufferExtend extend_x, - MemoryBufferExtend extend_y) + MemoryBufferExtend extend_y) const { const float w = (float)getWidth(); const float h = (float)getHeight(); @@ -427,7 +446,7 @@ class MemoryBuffer { float x, float y, MemoryBufferExtend extend_x = MemoryBufferExtend::Clip, - MemoryBufferExtend extend_y = MemoryBufferExtend::Clip) + MemoryBufferExtend extend_y = MemoryBufferExtend::Clip) const { float u = x; float v = y; diff --git a/source/blender/compositor/intern/COM_NodeOperation.cc b/source/blender/compositor/intern/COM_NodeOperation.cc index 4e115cb3f2f..575e8446abe 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.cc +++ b/source/blender/compositor/intern/COM_NodeOperation.cc @@ -100,6 +100,11 @@ void NodeOperation::setResolutionInputSocketIndex(unsigned int index) { this->m_resolutionInputSocketIndex = index; } + +void NodeOperation::init_data() +{ + /* Pass. */ +} void NodeOperation::initExecution() { /* pass */ diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h index fb9ec1e7a83..934007d25ce 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.h +++ b/source/blender/compositor/intern/COM_NodeOperation.h @@ -75,12 +75,6 @@ enum class ResizeMode { Stretch = NS_CR_STRETCH, }; -enum class PixelSampler { - Nearest = 0, - Bilinear = 1, - Bicubic = 2, -}; - class NodeOperationInput { private: NodeOperation *m_operation; @@ -424,6 +418,12 @@ class NodeOperation { exec_system_ = system; } + /** + * Initializes operation data needed after operations are linked and resolutions determined. For + * rendering heap memory data use initExecution(). + */ + virtual void init_data(); + virtual void initExecution(); /** |