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:
Diffstat (limited to 'source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp')
-rw-r--r--source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp56
1 files changed, 31 insertions, 25 deletions
diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
index dc9e354b124..ac91d3336e2 100644
--- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
@@ -29,15 +29,17 @@ extern "C" {
GaussianBokehBlurOperation::GaussianBokehBlurOperation() : BlurBaseOperation(COM_DT_COLOR)
{
- this->gausstab = NULL;
+ this->m_gausstab = NULL;
}
void *GaussianBokehBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
{
- if (!sizeavailable) {
+ lockMutex();
+ if (!this->m_sizeavailable) {
updateGauss(memoryBuffers);
}
void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers);
+ unlockMutex();
return buffer;
}
@@ -45,14 +47,16 @@ void GaussianBokehBlurOperation::initExecution()
{
BlurBaseOperation::initExecution();
- if (this->sizeavailable) {
+ initMutex();
+
+ if (this->m_sizeavailable) {
updateGauss(NULL);
}
}
void GaussianBokehBlurOperation::updateGauss(MemoryBuffer **memoryBuffers)
{
- if (this->gausstab == NULL) {
+ if (this->m_gausstab == NULL) {
float radxf;
float radyf;
int n;
@@ -62,37 +66,37 @@ void GaussianBokehBlurOperation::updateGauss(MemoryBuffer **memoryBuffers)
int j, i;
const float width = this->getWidth();
const float height = this->getHeight();
- if (!sizeavailable) {
+ if (!this->m_sizeavailable) {
updateSize(memoryBuffers);
}
- radxf = size * (float)this->data->sizex;
+ radxf = this->m_size * (float)this->m_data->sizex;
if (radxf > width / 2.0f)
radxf = width / 2.0f;
else if (radxf < 1.0f)
radxf = 1.0f;
/* vertical */
- radyf = size * (float)this->data->sizey;
+ radyf = this->m_size * (float)this->m_data->sizey;
if (radyf > height / 2.0f)
radyf = height / 2.0f;
else if (radyf < 1.0f)
radyf = 1.0f;
- radx = ceil(radxf);
- rady = ceil(radyf);
+ this->m_radx = ceil(radxf);
+ this->m_rady = ceil(radyf);
- n = (2 * radx + 1) * (2 * rady + 1);
+ n = (2 * this->m_radx + 1) * (2 * this->m_rady + 1);
/* create a full filter image */
ddgauss = new float[n];
dgauss = ddgauss;
val = 0.0f;
- for (j = -rady; j <= rady; j++) {
- for (i = -radx; i <= radx; i++, dgauss++) {
+ for (j = -this->m_rady; j <= this->m_rady; j++) {
+ for (i = -this->m_radx; i <= this->m_radx; i++, dgauss++) {
float fj = (float)j / radyf;
float fi = (float)i / radxf;
float dist = sqrt(fj * fj + fi * fi);
- *dgauss = RE_filter_value(this->data->filtertype, dist);
+ *dgauss = RE_filter_value(this->m_data->filtertype, dist);
val += *dgauss;
}
@@ -104,7 +108,7 @@ void GaussianBokehBlurOperation::updateGauss(MemoryBuffer **memoryBuffers)
}
else ddgauss[4] = 1.0f;
- gausstab = ddgauss;
+ this->m_gausstab = ddgauss;
}
}
@@ -122,10 +126,10 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory
int bufferstartx = inputBuffer->getRect()->xmin;
int bufferstarty = inputBuffer->getRect()->ymin;
- int miny = y - this->rady;
- int maxy = y + this->rady;
- int minx = x - this->radx;
- int maxx = x + this->radx;
+ int miny = y - this->m_rady;
+ int maxy = y + this->m_rady;
+ int minx = x - this->m_radx;
+ int maxx = x + this->m_radx;
miny = max(miny, inputBuffer->getRect()->ymin);
minx = max(minx, inputBuffer->getRect()->xmin);
maxy = min(maxy, inputBuffer->getRect()->ymax);
@@ -135,10 +139,10 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory
int step = QualityStepHelper::getStep();
int offsetadd = QualityStepHelper::getOffsetAdd();
for (int ny = miny; ny < maxy; ny += step) {
- index = ((ny - y) + this->rady) * (this->radx * 2 + 1) + (minx - x + this->radx);
+ index = ((ny - y) + this->m_rady) * (this->m_radx * 2 + 1) + (minx - x + this->m_radx);
int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth);
for (int nx = minx; nx < maxx; nx += step) {
- const float multiplier = gausstab[index];
+ const float multiplier = this->m_gausstab[index];
madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplier);
multiplier_accum += multiplier;
index += step;
@@ -152,8 +156,10 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory
void GaussianBokehBlurOperation::deinitExecution()
{
BlurBaseOperation::deinitExecution();
- delete [] this->gausstab;
- this->gausstab = NULL;
+ delete [] this->m_gausstab;
+ this->m_gausstab = NULL;
+
+ deinitMutex();
}
bool GaussianBokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
@@ -170,15 +176,15 @@ bool GaussianBokehBlurOperation::determineDependingAreaOfInterest(rcti *input, R
return true;
}
else {
- if (this->sizeavailable && this->gausstab != NULL) {
+ if (this->m_sizeavailable && this->m_gausstab != NULL) {
newInput.xmin = 0;
newInput.ymin = 0;
newInput.xmax = this->getWidth();
newInput.ymax = this->getHeight();
}
else {
- int addx = radx;
- int addy = rady;
+ int addx = this->m_radx;
+ int addy = this->m_rady;
newInput.xmax = input->xmax + addx;
newInput.xmin = input->xmin - addx;
newInput.ymax = input->ymax + addy;