Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <j.bakker@atmind.nl>2012-07-04 14:01:45 +0400
committerJeroen Bakker <j.bakker@atmind.nl>2012-07-04 14:01:45 +0400
commit33e12a298350d9aa684381a71a639864bf9bee3c (patch)
tree544c4634134527f205e9c16ef47e60683ae07aed /source/blender/compositor/operations
parent592196cb701f72780288a3606e5186fd42b6b850 (diff)
Highlight nodes that are being processed
Diffstat (limited to 'source/blender/compositor/operations')
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp144
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h42
-rw-r--r--source/blender/compositor/operations/COM_WriteBufferOperation.cpp9
3 files changed, 188 insertions, 7 deletions
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
index 9eb004b3686..46101f6355d 100644
--- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
@@ -33,6 +33,9 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation
this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // do not resize the bokeh image.
this->addInputSocket(COM_DT_VALUE); // radius
this->addInputSocket(COM_DT_VALUE); // depth
+#ifdef COM_DEFOCUS_SEARCH
+ this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // inverse search radius optimization structure.
+#endif
this->addOutputSocket(COM_DT_COLOR);
this->setComplex(true);
@@ -42,6 +45,9 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation
this->m_inputDepthProgram = NULL;
this->m_maxBlur = 32.0f;
this->m_threshold = 1.0f;
+#ifdef COM_DEFOCUS_SEARCH
+ this->m_inputSearchProgram = NULL;
+#endif
}
@@ -51,6 +57,9 @@ void VariableSizeBokehBlurOperation::initExecution()
this->m_inputBokehProgram = getInputSocketReader(1);
this->m_inputSizeProgram = getInputSocketReader(2);
this->m_inputDepthProgram = getInputSocketReader(3);
+#ifdef COM_DEFOCUS_SEARCH
+ this->m_inputSearchProgram = getInputSocketReader(4);
+#endif
QualityStepHelper::initExecution(COM_QH_INCREASE);
}
@@ -63,10 +72,19 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
float color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- int miny = y - this->m_maxBlur;
- int maxy = y + this->m_maxBlur;
- int minx = x - this->m_maxBlur;
- int maxx = x + this->m_maxBlur;
+#ifdef COM_DEFOCUS_SEARCH
+ float search[4];
+ this->inputSearchProgram->read(search, x/InverseSearchRadiusOperation::DIVIDER, y/InverseSearchRadiusOperation::DIVIDER, inputBuffers, NULL);
+ int minx = search[0];
+ int miny = search[1];
+ int maxx = search[2];
+ int maxy = search[3];
+#else
+ int minx = MAX2(x - this->m_maxBlur, 0.0f);
+ int miny = MAX2(y - this->m_maxBlur, 0.0f);
+ int maxx = MIN2(x + this->m_maxBlur, m_width);
+ int maxy = MIN2(y + this->m_maxBlur, m_height);
+#endif
{
this->m_inputSizeProgram->read(tempSize, x, y, COM_PS_NEAREST, inputBuffers);
this->m_inputDepthProgram->read(tempDepth, x, y, COM_PS_NEAREST, inputBuffers);
@@ -80,9 +98,9 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
for (int nx = minx; nx < maxx; nx += QualityStepHelper::getStep()) {
if (nx >= 0 && nx < this->getWidth() && ny >= 0 && ny < getHeight()) {
this->m_inputDepthProgram->read(tempDepth, nx, ny, COM_PS_NEAREST, inputBuffers);
- this->m_inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers);
- float size = tempSize[0];
if (tempDepth[0] < centerDepth) {
+ this->m_inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers);
+ float size = tempSize[0];
if ((sizeCenter > this->m_threshold && size > this->m_threshold) || size <= this->m_threshold) {
float dx = nx - x;
float dy = ny - y;
@@ -115,6 +133,10 @@ void VariableSizeBokehBlurOperation::deinitExecution()
this->m_inputProgram = NULL;
this->m_inputBokehProgram = NULL;
this->m_inputSizeProgram = NULL;
+ this->m_inputDepthProgram = NULL;
+#ifdef COM_DEFOCUS_SEARCH
+ this->m_inputSearchProgram = NULL;
+#endif
}
bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
@@ -130,6 +152,7 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *inpu
bokehInput.xmin = 0;
bokehInput.ymax = 512;
bokehInput.ymin = 0;
+
NodeOperation *operation = getInputOperation(2);
if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) {
@@ -143,9 +166,118 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *inpu
if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) {
return true;
}
+#ifdef COM_DEFOCUS_SEARCH
+ rcti searchInput;
+ searchInput.xmax = (input->xmax/InverseSearchRadiusOperation::DIVIDER)+1;
+ searchInput.xmin = (input->xmin/InverseSearchRadiusOperation::DIVIDER)-1;
+ searchInput.ymax = (input->ymax/InverseSearchRadiusOperation::DIVIDER)+1;
+ searchInput.ymin = (input->ymin/InverseSearchRadiusOperation::DIVIDER)-1;
+ operation = getInputOperation(4);
+ if (operation->determineDependingAreaOfInterest(&searchInput, readOperation, output) ) {
+ return true;
+ }
+#endif
operation = getInputOperation(0);
if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) {
return true;
}
return false;
}
+
+#ifdef COM_DEFOCUS_SEARCH
+// InverseSearchRadiusOperation
+InverseSearchRadiusOperation::InverseSearchRadiusOperation() : NodeOperation()
+{
+ this->addInputSocket(COM_DT_VALUE, COM_SC_NO_RESIZE); // radius
+ this->addInputSocket(COM_DT_VALUE, COM_SC_NO_RESIZE); // depth
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
+ this->inputRadius = NULL;
+ this->inputDepth = NULL;
+}
+
+void InverseSearchRadiusOperation::initExecution()
+{
+ this->inputRadius = this->getInputSocketReader(0);
+ this->inputDepth = this->getInputSocketReader(1);
+}
+
+void* InverseSearchRadiusOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
+{
+ MemoryBuffer * data = new MemoryBuffer(NULL, rect);
+ int x, y;
+ float width = this->inputRadius->getWidth();
+ float height = this->inputRadius->getHeight();
+
+ for (x = rect->xmin; x < rect->xmax ; x++) {
+ for (y = rect->ymin; y < rect->ymax ; y++) {
+ float[4] temp;
+ int rx = x * DIVIDER;
+ int ry = y * DIVIDER;
+ this->inputRadius->read(temp, rx, ry, memoryBuffers, NULL);
+ float centerRadius = temp[0];
+ this->inputDepth->read(temp, rx, ry, memoryBuffers, NULL);
+ float centerDepth = temp[0];
+ t[0] = MAX2(rx - this->maxBlur, 0.0f);
+ t[1] = MAX2(ry - this->maxBlur, 0.0f);
+ t[2] = MIN2(rx + this->maxBlur, width);
+ t[3] = MIN2(ry + this->maxBlur, height);
+ int minx = t[0];
+ int miny = t[1];
+ int maxx = t[2];
+ int maxy = t[3];
+ int sminx = rx;
+ int smaxx = rx;
+ int sminy = ry;
+ int smaxy = ry;
+ for (int nx = minx ; nx < maxx ; nx ++) {
+ for (int ny = miny ; ny < maxy ; ny ++) {
+ this->inputRadius->read(temp, nx, ny, memoryBuffers, NULL);
+ if (nx < rx && temp[0])
+
+ }
+ }
+ float t[4];
+ data->writePixel(x, y, t);
+ }
+ }
+ return data;
+}
+
+void InverseSearchRadiusOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
+{
+ MemoryBuffer *buffer = (MemoryBuffer*)data;
+ buffer->read(color, x, y);
+}
+
+void InverseSearchRadiusOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data)
+{
+ if (data) {
+ MemoryBuffer* mb = (MemoryBuffer*)data;
+ delete mb;
+ }
+}
+
+void InverseSearchRadiusOperation::deinitExecution()
+{
+ this->inputRadius = NULL;
+ this->inputDepth = NULL;
+}
+
+void InverseSearchRadiusOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
+{
+ NodeOperation::determineResolution(resolution, preferredResolution);
+ resolution[0] = resolution[0] / DIVIDER;
+ resolution[1] = resolution[1] / DIVIDER;
+}
+
+bool InverseSearchRadiusOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+{
+ rcti newRect;
+ newRect.ymin = input->ymin*DIVIDER;
+ newRect.ymax = input->ymax*DIVIDER;
+ newRect.xmin = input->xmin*DIVIDER;
+ newRect.xmax = input->xmax*DIVIDER;
+ return NodeOperation::determineDependingAreaOfInterest(&newRect, readOperation, output);
+}
+#endif
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
index 8e59a43fcb1..4bf597ff831 100644
--- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
@@ -25,6 +25,7 @@
#include "COM_NodeOperation.h"
#include "COM_QualityStepHelper.h"
+
class VariableSizeBokehBlurOperation : public NodeOperation, public QualityStepHelper {
private:
int m_maxBlur;
@@ -33,6 +34,9 @@ private:
SocketReader *m_inputBokehProgram;
SocketReader *m_inputSizeProgram;
SocketReader *m_inputDepthProgram;
+#ifdef COM_DEFOCUS_SEARCH
+ SocketReader *inputSearchProgram;
+#endif
public:
VariableSizeBokehBlurOperation();
@@ -60,4 +64,42 @@ public:
};
+
+#ifdef COM_DEFOCUS_SEARCH
+class InverseSearchRadiusOperation : public NodeOperation {
+private:
+ int maxBlur;
+ float threshold;
+ SocketReader *inputDepth;
+ SocketReader *inputRadius;
+public:
+ static const int DIVIDER = 4;
+
+ InverseSearchRadiusOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+ void* initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+ void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data);
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+
+ void setMaxBlur(int maxRadius) { this->maxBlur = maxRadius; }
+
+ void setThreshold(float threshold) { this->threshold = threshold; }
+};
+#endif
#endif
diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
index 7259db34134..1a319d67115 100644
--- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
+++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
@@ -63,6 +63,9 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me
MemoryBuffer *memoryBuffer = this->m_memoryProxy->getBuffer();
float *buffer = memoryBuffer->getBuffer();
if (this->m_input->isComplex()) {
+ bNode* bnode = this->m_input->getbNode();
+ if (bnode&& bnode->new_node) bnode->new_node->highlight++;
+
void *data = this->m_input->initializeTileData(rect, memoryBuffers);
int x1 = rect->xmin;
int y1 = rect->ymin;
@@ -87,6 +90,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me
this->m_input->deinitializeTileData(rect, memoryBuffers, data);
data = NULL;
}
+ if (bnode&& bnode->new_node) bnode->new_node->highlight++;
}
else {
int x1 = rect->xmin;
@@ -139,6 +143,8 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice* device, rcti *rect,
list<cl_mem> *clMemToCleanUp = new list<cl_mem>();
clMemToCleanUp->push_back(clOutputBuffer);
list<cl_kernel> *clKernelsToCleanUp = new list<cl_kernel>();
+ bNode* bnode = this->m_input->getbNode();
+ if (bnode&& bnode->new_node) bnode->new_node->highlight++;
this->m_input->executeOpenCL(device, outputBuffer, clOutputBuffer, inputMemoryBuffers, clMemToCleanUp, clKernelsToCleanUp);
@@ -156,7 +162,8 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice* device, rcti *rect,
if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
this->getMemoryProxy()->getBuffer()->copyContentFrom(outputBuffer);
-
+
+ if (bnode&& bnode->new_node) bnode->new_node->highlight++;
// STEP 4