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:
authorMonique Dewanchand <m.dewanchand@atmind.nl>2012-06-01 15:50:32 +0400
committerMonique Dewanchand <m.dewanchand@atmind.nl>2012-06-01 15:50:32 +0400
commit5fbeda7efd62e251dac2af881de9fe042f30a7a7 (patch)
tree573791adbcfc7725a841fc7e213494b80a8eeae2 /source/blender/compositor/operations
parent7941ebf66e15df1ca4b7b5439a5bbc90254479f4 (diff)
Optimize Gaussian blurs
Diffstat (limited to 'source/blender/compositor/operations')
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.cpp1
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp31
-rw-r--r--source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp30
-rw-r--r--source/blender/compositor/operations/COM_GaussianXBlurOperation.h9
-rw-r--r--source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp30
-rw-r--r--source/blender/compositor/operations/COM_GaussianYBlurOperation.h5
8 files changed, 82 insertions, 29 deletions
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();