diff options
Diffstat (limited to 'source/blender/compositor')
9 files changed, 94 insertions, 31 deletions
diff --git a/source/blender/compositor/nodes/COM_BlurNode.cpp b/source/blender/compositor/nodes/COM_BlurNode.cpp index 90b2481cc7d..b209e36dd48 100644 --- a/source/blender/compositor/nodes/COM_BlurNode.cpp +++ b/source/blender/compositor/nodes/COM_BlurNode.cpp @@ -37,10 +37,11 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * c { bNode *editorNode = this->getbNode(); NodeBlurData * data = (NodeBlurData*)editorNode->storage; -#if 0 + InputSocket * inputSizeSocket = this->getInputSocket(1); + bool connectedSizeSocket = inputSizeSocket->isConnected(); + const bNodeSocket *sock = this->getInputSocket(1)->getbNodeSocket(); const float size = ((const bNodeSocketValueFloat*)sock->default_value)->value; -#endif CompositorQuality quality = context->getQuality(); @@ -71,6 +72,11 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * c addLink(graph, operationx->getOutputSocket(), operationy->getInputSocket(0)); addLink(graph, operationx->getInputSocket(1)->getConnection()->getFromSocket(), operationy->getInputSocket(1)); addPreviewOperation(graph, operationy->getOutputSocket(), 5); + + if (!connectedSizeSocket) { + operationx->setSize(size); + operationy->setSize(size); + } } else { GaussianBokehBlurOperation *operation = new GaussianBokehBlurOperation(); @@ -81,5 +87,9 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * c graph->addOperation(operation); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); addPreviewOperation(graph, operation->getOutputSocket(), 5); + + if (!connectedSizeSocket) { + operation->setSize(size); + } } } diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp index 6e1a7e2a908..babea459d6a 100644 --- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp @@ -37,6 +37,7 @@ BlurBaseOperation::BlurBaseOperation(): NodeOperation() this->data = NULL; this->size = 1.0f; this->deleteData = false; + this->sizeavailable=false; } void BlurBaseOperation::initExecution() { diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.h b/source/blender/compositor/operations/COM_BlurBaseOperation.h index 13e7eb52b77..24002588413 100644 --- a/source/blender/compositor/operations/COM_BlurBaseOperation.h +++ b/source/blender/compositor/operations/COM_BlurBaseOperation.h @@ -39,6 +39,7 @@ protected: float *make_gausstab(int rad); float size; bool deleteData; + bool sizeavailable; void updateSize(MemoryBuffer **memoryBuffers); public: /** @@ -54,5 +55,7 @@ public: void setData(NodeBlurData *data) {this->data = data;} void deleteDataWhenFinished() {this->deleteData = true;} + + void setSize(float size) {this->size = size; sizeavailable = true;} }; #endif diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp index af10791590b..b5d175729f3 100644 --- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp @@ -34,11 +34,20 @@ GaussianBokehBlurOperation::GaussianBokehBlurOperation(): BlurBaseOperation() void *GaussianBokehBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - updateGauss(memoryBuffers); + if (!sizeavailable) { + updateGauss(memoryBuffers); + } void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); return buffer; } +void GaussianBokehBlurOperation::initExecution() +{ + if (this->sizeavailable) { + updateGauss(NULL); + } +} + void GaussianBokehBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) { if (this->gausstab == NULL) { @@ -51,8 +60,9 @@ void GaussianBokehBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) int j, i; const float width = this->getWidth(); const float height = this->getHeight(); - updateSize(memoryBuffers); - + if (!sizeavailable) { + updateSize(memoryBuffers); + } radxf = size*(float)this->data->sizex; if (radxf>width/2.0f) radxf = width/2.0f; @@ -163,19 +173,20 @@ bool GaussianBokehBlurOperation::determineDependingAreaOfInterest(rcti *input, R return true; } else { - if (this->gausstab) { + if (this->sizeavailable && this->gausstab != NULL) { + newInput.xmin = 0; + newInput.ymin = 0; + newInput.xmax = this->getWidth(); + newInput.ymax = this->getHeight(); + } + else { int addx = radx; int addy = rady; newInput.xmax = input->xmax + addx; newInput.xmin = input->xmin - addx; newInput.ymax = input->ymax + addy; newInput.ymin = input->ymin - addy; - } - else { - newInput.xmin = 0; - newInput.ymin = 0; - newInput.xmax = this->getWidth(); - newInput.ymax = this->getHeight(); + } return BlurBaseOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h index a7a0ee74364..78c6437eac6 100644 --- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h +++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h @@ -34,7 +34,7 @@ private: public: GaussianBokehBlurOperation(); - + void initExecution(); void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); /** * the inner loop of this program diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp index 276efd90740..121bbbd45a0 100644 --- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp @@ -36,11 +36,25 @@ GaussianXBlurOperation::GaussianXBlurOperation(): BlurBaseOperation() void *GaussianXBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - updateGauss(memoryBuffers); + if (!this->sizeavailable) { + updateGauss(memoryBuffers); + } void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); return buffer; } +void GaussianXBlurOperation::initExecution() +{ + if (this->sizeavailable) { + float rad = size*this->data->sizex; + if (rad<1) + rad = 1; + + this->rad = rad; + this->gausstab = BlurBaseOperation::make_gausstab(rad); + } +} + void GaussianXBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) { if (this->gausstab == NULL) { @@ -118,18 +132,18 @@ bool GaussianXBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadB return true; } else { - if (this->gausstab == NULL) { - newInput.xmax = this->getWidth(); - newInput.xmin = 0; - newInput.ymax = this->getHeight(); - newInput.ymin = 0; - } - else { + if (this->sizeavailable && this->gausstab != NULL) { newInput.xmax = input->xmax + rad; newInput.xmin = input->xmin - rad; newInput.ymax = input->ymax; newInput.ymin = input->ymin; } + else { + newInput.xmax = this->getWidth(); + newInput.xmin = 0; + newInput.ymax = this->getHeight(); + newInput.ymin = 0; + } return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } } diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.h b/source/blender/compositor/operations/COM_GaussianXBlurOperation.h index 704d063d28f..a957b8c12af 100644 --- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.h +++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.h @@ -34,12 +34,17 @@ public: GaussianXBlurOperation(); /** - * the inner loop of this program + *@brief the inner loop of this program */ void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data); /** - * Deinitialize the execution + *@brief initialize the execution + */ + void initExecution(); + + /** + *@brief Deinitialize the execution */ void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp index faef152dc31..1760a281785 100644 --- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp @@ -35,11 +35,25 @@ GaussianYBlurOperation::GaussianYBlurOperation(): BlurBaseOperation() void *GaussianYBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - updateGauss(memoryBuffers); + if (!this->sizeavailable) { + updateGauss(memoryBuffers); + } void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); return buffer; } +void GaussianYBlurOperation::initExecution() +{ + if (this->sizeavailable) { + float rad = size*this->data->sizex; + if (rad<1) + rad = 1; + + this->rad = rad; + this->gausstab = BlurBaseOperation::make_gausstab(rad); + } +} + void GaussianYBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) { if (this->gausstab == NULL) { @@ -115,18 +129,18 @@ bool GaussianYBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadB return true; } else { - if (this->gausstab == NULL) { - newInput.xmax = this->getWidth(); - newInput.xmin = 0; - newInput.ymax = this->getHeight(); - newInput.ymin = 0; - } - else { + if (this->sizeavailable && this->gausstab != NULL) { newInput.xmax = input->xmax; newInput.xmin = input->xmin; newInput.ymax = input->ymax + rad; newInput.ymin = input->ymin - rad; } + else { + newInput.xmax = this->getWidth(); + newInput.xmin = 0; + newInput.ymax = this->getHeight(); + newInput.ymin = 0; + } return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } } diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.h b/source/blender/compositor/operations/COM_GaussianYBlurOperation.h index c9baf27b1d6..f33d38de14e 100644 --- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.h +++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.h @@ -39,6 +39,11 @@ public: void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data); /** + *@brief initialize the execution + */ + void initExecution(); + + /** * Deinitialize the execution */ void deinitExecution(); |