Commit: 93718956fce10825ac483b05601aedaf07351257 Author: Manuel Castilla Date: Mon Jul 26 19:07:08 2021 +0200 Branches: compositor-full-frame https://developer.blender.org/rB93718956fce10825ac483b05601aedaf07351257
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 =================================================================== M source/blender/compositor/intern/COM_ConstantFolder.cc M source/blender/compositor/intern/COM_Converter.cc M source/blender/compositor/intern/COM_Enums.cc M source/blender/compositor/intern/COM_Enums.h M source/blender/compositor/intern/COM_ExecutionSystem.cc M source/blender/compositor/intern/COM_MemoryBuffer.h M source/blender/compositor/intern/COM_NodeOperation.cc M source/blender/compositor/intern/COM_NodeOperation.h M source/blender/compositor/nodes/COM_ScaleNode.cc M source/blender/compositor/nodes/COM_Stabilize2dNode.cc M source/blender/compositor/nodes/COM_TransformNode.cc M source/blender/compositor/operations/COM_ScaleOperation.cc M source/blender/compositor/operations/COM_ScaleOperation.h =================================================================== 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(); /** diff --git a/source/blender/compositor/nodes/COM_ScaleNode.cc b/source/blender/compositor/nodes/COM_ScaleNode.cc index 50d2902f375..819d2e72f30 100644 --- a/source/blender/compositor/nodes/COM_ScaleNode.cc +++ b/source/blender/compositor/nodes/COM_ScaleNode.cc @@ -43,7 +43,7 @@ void ScaleNode::convertToOperations(NodeConverter &converter, switch (bnode->custom1) { case CMP_SCALE_RELATIVE: { - ScaleOperation *operation = new ScaleOperation(); + ScaleRelativeOperation *operation = new ScaleRelativeOperation(); converter.addOperation(operation); converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); @@ -59,7 +59,7 @@ void ScaleNode::convertToOperations(NodeConverter &converter, scaleFactorOperation->setValue(context.getRenderPercentageAsFactor()); converter.addOperation(scaleFactorOperation); - ScaleOperation *operation = new ScaleOperation(); + ScaleRelativeOperation *operation = new ScaleRelativeOperation(); converter.addOperation(operation); converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.cc b/source/blender/compositor/nodes/COM_Stabilize2dNode.cc index fc72b48eca2..0262f653d1a 100644 --- a/source/blender/compositor/nodes/COM_Stabilize2dNode.cc +++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.cc @@ -43,7 +43,7 @@ void Stabilize2dNode::convertToOperations(NodeConverter &converter, MovieClip *clip = (MovieClip *)editorNode->id; bool invert = (editorNode->custom2 & CMP_NODEFLAG_STABILIZE_INVERSE) != 0; - ScaleOperation *scaleOperation = new ScaleOperation(); + ScaleRelativeOperation *scaleOperation = new ScaleRelativeOperation(); scaleOperation->setSampler((PixelSampler)editorNode->custom1); RotateOperation *rotateOperation = new RotateOperation(); rotateOperation->setDoDegree2RadConversion(false); diff --git a/source/blender/compositor/nodes/COM_TransformNode.cc b/source/blender/compositor/nodes/COM_TransformNode.cc index cd12939ab43..e1deaf616a4 100644 --- a/source/blender/compositor/nodes/COM_TransformNode.cc +++ b/source/blender/compositor/nodes/COM_TransformNode.cc @@ -40,7 +40,7 @@ void TransformNode::convertToOperations(NodeConverter &converter, NodeInput *angleInput = this->getInputSocket(3); NodeInput *scaleInput = this->getInputSocket(4); - ScaleOperation *scaleOperation = new ScaleOperation(); + ScaleRelativeOperation *scaleOperation = new ScaleRelativeOperation(); converter.addOperation(scaleOperation); RotateOperation *rotateOperation = new RotateOperation(); diff --git a/source/blender/compositor/operations/COM_ScaleOperation.cc b/source/blender/compositor/operations/COM_ScaleOperation.cc index f03b9fcf34d..2cb61ae746b 100644 --- a/source/blender/compositor/operations/COM_ScaleOperation.cc +++ b/source/blender/compositor/operations/COM_ScaleOperation.cc @@ -17,6 +17,7 @@ */ #include "COM_ScaleOperation.h" +#include "COM_ConstantOperation.h" namespace blender::compositor { @@ -52,13 +53,60 @@ ScaleOperation::ScaleOperation(DataType data_type) : BaseScaleOperation() this->m_inputXOperation = nullptr; this->m_inputYOperation = nullptr; } + +static std::optional<float> get_constant_scale(NodeOperation *op) +{ + if (op->get_flags().is_constant_operation) { + return ((ConstantOperation *)op)->get_constant_elem()[0]; + } + + ret @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs