diff options
5 files changed, 35 insertions, 24 deletions
diff --git a/source/blender/compositor/nodes/COM_TranslateNode.cpp b/source/blender/compositor/nodes/COM_TranslateNode.cpp index 44d796c2911..d2cd009449c 100644 --- a/source/blender/compositor/nodes/COM_TranslateNode.cpp +++ b/source/blender/compositor/nodes/COM_TranslateNode.cpp @@ -24,6 +24,7 @@ #include "COM_TranslateOperation.h" #include "COM_WrapOperation.h" +#include "COM_WriteBufferOperation.h" #include "COM_ExecutionSystem.h" TranslateNode::TranslateNode(bNode *editorNode) : Node(editorNode) @@ -43,10 +44,15 @@ void TranslateNode::convertToOperations(ExecutionSystem *graph, CompositorContex NodeTranslateData *data = (NodeTranslateData *)bnode->storage; if (data->wrap_axis) { + WriteBufferOperation *writeOperation = new WriteBufferOperation(); WrapOperation *wrapOperation = new WrapOperation(); + wrapOperation->setMemoryProxy(writeOperation->getMemoryProxy()); wrapOperation->setWrapping(data->wrap_axis); - inputSocket->relinkConnections(wrapOperation->getInputSocket(0), 0, graph); + + inputSocket->relinkConnections(writeOperation->getInputSocket(0), 0, graph); addLink(graph, wrapOperation->getOutputSocket(), operation->getInputSocket(0)); + + graph->addOperation(writeOperation); graph->addOperation(wrapOperation); } else { diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp index 369e575e976..3aeef6bf409 100644 --- a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp @@ -66,6 +66,21 @@ void ReadBufferOperation::executePixel(float output[4], float x, float y, PixelS } } +void ReadBufferOperation::executePixelExtend(float output[4], float x, float y, PixelSampler sampler, + MemoryBufferExtend extend_x, MemoryBufferExtend extend_y) +{ + if (m_single_value) { + /* write buffer has a single value stored at (0,0) */ + m_buffer->read(output, 0, 0); + } + else if (sampler == COM_PS_NEAREST) { + m_buffer->read(output, x, y, extend_x, extend_y); + } + else { + m_buffer->readBilinear(output, x, y, extend_x, extend_y); + } +} + void ReadBufferOperation::executePixel(float output[4], float x, float y, float dx, float dy, PixelSampler sampler) { if (m_single_value) { diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.h b/source/blender/compositor/operations/COM_ReadBufferOperation.h index eba54b7491e..7a67056eda6 100644 --- a/source/blender/compositor/operations/COM_ReadBufferOperation.h +++ b/source/blender/compositor/operations/COM_ReadBufferOperation.h @@ -41,6 +41,8 @@ public: void *initializeTileData(rcti *rect); void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelExtend(float output[4], float x, float y, PixelSampler sampler, + MemoryBufferExtend extend_x, MemoryBufferExtend extend_y); void executePixel(float output[4], float x, float y, float dx, float dy, PixelSampler sampler); const bool isReadBufferOperation() const { return true; } void setOffset(unsigned int offset) { this->m_offset = offset; } diff --git a/source/blender/compositor/operations/COM_WrapOperation.cpp b/source/blender/compositor/operations/COM_WrapOperation.cpp index 68c3e74a237..ea19952f60c 100644 --- a/source/blender/compositor/operations/COM_WrapOperation.cpp +++ b/source/blender/compositor/operations/COM_WrapOperation.cpp @@ -23,21 +23,9 @@ #include "COM_WrapOperation.h" -WrapOperation::WrapOperation() : NodeOperation() +WrapOperation::WrapOperation() : ReadBufferOperation() { - this->addInputSocket(COM_DT_COLOR); - this->addOutputSocket(COM_DT_COLOR); - this->setResolutionInputSocketIndex(0); - this->m_inputOperation = NULL; -} -void WrapOperation::initExecution() -{ - this->m_inputOperation = this->getInputSocketReader(0); -} - -void WrapOperation::deinitExecution() -{ - this->m_inputOperation = NULL; + this->m_wrappingType = CMP_NODE_WRAP_NONE; } inline float WrapOperation::getWrappedOriginalXPos(float x) @@ -59,6 +47,7 @@ void WrapOperation::executePixel(float output[4], float x, float y, PixelSampler float nx, ny; nx = x; ny = y; + MemoryBufferExtend extend_x = COM_MB_CLIP, extend_y = COM_MB_CLIP; switch (m_wrappingType) { case CMP_NODE_WRAP_NONE: //Intentionally empty, originalXPos and originalYPos have been set before @@ -66,20 +55,23 @@ void WrapOperation::executePixel(float output[4], float x, float y, PixelSampler case CMP_NODE_WRAP_X: // wrap only on the x-axis nx = this->getWrappedOriginalXPos(x); + extend_x = COM_MB_REPEAT; break; case CMP_NODE_WRAP_Y: // wrap only on the y-axis ny = this->getWrappedOriginalYPos(y); + extend_y = COM_MB_REPEAT; break; case CMP_NODE_WRAP_XY: // wrap on both nx = this->getWrappedOriginalXPos(x); ny = this->getWrappedOriginalYPos(y); + extend_x = COM_MB_REPEAT; + extend_y = COM_MB_REPEAT; break; } - this->m_inputOperation->read(output, nx, ny, sampler); - + executePixelExtend(output, nx, ny, sampler, extend_x, extend_y); } bool WrapOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -110,7 +102,7 @@ bool WrapOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOper } } - return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); + return ReadBufferOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } void WrapOperation::setWrapping(int wrapping_type) diff --git a/source/blender/compositor/operations/COM_WrapOperation.h b/source/blender/compositor/operations/COM_WrapOperation.h index b84d85e7b5d..ddd5fa8032d 100644 --- a/source/blender/compositor/operations/COM_WrapOperation.h +++ b/source/blender/compositor/operations/COM_WrapOperation.h @@ -23,20 +23,16 @@ #ifndef _COM_WrapOperation_h_ #define _COM_WrapOperation_h_ -#include "COM_NodeOperation.h" +#include "COM_ReadBufferOperation.h" -class WrapOperation : public NodeOperation { +class WrapOperation : public ReadBufferOperation { private: - SocketReader *m_inputOperation; int m_wrappingType; public: WrapOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); void executePixel(float output[4], float x, float y, PixelSampler sampler); - void initExecution(); - void deinitExecution(); - void setWrapping(int wrapping_type); float getWrappedOriginalXPos(float x); float getWrappedOriginalYPos(float y); |