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:
authorCampbell Barton <ideasman42@gmail.com>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff)
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp')
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp248
1 files changed, 125 insertions, 123 deletions
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
index 058718c6a97..37109b4a03e 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
@@ -21,169 +21,171 @@
#include "MEM_guardedalloc.h"
extern "C" {
-# include "RE_pipeline.h"
+#include "RE_pipeline.h"
}
GaussianAlphaYBlurOperation::GaussianAlphaYBlurOperation() : BlurBaseOperation(COM_DT_VALUE)
{
- this->m_gausstab = NULL;
- this->m_filtersize = 0;
- this->m_falloff = -1; /* intentionally invalid, so we can detect uninitialized values */
+ this->m_gausstab = NULL;
+ this->m_filtersize = 0;
+ this->m_falloff = -1; /* intentionally invalid, so we can detect uninitialized values */
}
void *GaussianAlphaYBlurOperation::initializeTileData(rcti * /*rect*/)
{
- lockMutex();
- if (!this->m_sizeavailable) {
- updateGauss();
- }
- void *buffer = getInputOperation(0)->initializeTileData(NULL);
- unlockMutex();
- return buffer;
+ lockMutex();
+ if (!this->m_sizeavailable) {
+ updateGauss();
+ }
+ void *buffer = getInputOperation(0)->initializeTileData(NULL);
+ unlockMutex();
+ return buffer;
}
void GaussianAlphaYBlurOperation::initExecution()
{
- /* BlurBaseOperation::initExecution(); */ /* until we suppoer size input - comment this */
+ /* BlurBaseOperation::initExecution(); */ /* until we suppoer size input - comment this */
- initMutex();
+ initMutex();
- if (this->m_sizeavailable) {
- float rad = max_ff(m_size * m_data.sizey, 0.0f);
- m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
+ if (this->m_sizeavailable) {
+ float rad = max_ff(m_size * m_data.sizey, 0.0f);
+ m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
- m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
- m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, m_filtersize, m_falloff);
- }
+ m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
+ m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, m_filtersize, m_falloff);
+ }
}
void GaussianAlphaYBlurOperation::updateGauss()
{
- if (this->m_gausstab == NULL) {
- updateSize();
- float rad = max_ff(m_size * m_data.sizey, 0.0f);
- m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
+ if (this->m_gausstab == NULL) {
+ updateSize();
+ float rad = max_ff(m_size * m_data.sizey, 0.0f);
+ m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
- m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
- }
+ m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
+ }
- if (this->m_distbuf_inv == NULL) {
- updateSize();
- float rad = max_ff(m_size * m_data.sizey, 0.0f);
- m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
+ if (this->m_distbuf_inv == NULL) {
+ updateSize();
+ float rad = max_ff(m_size * m_data.sizey, 0.0f);
+ m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
- m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, m_filtersize, m_falloff);
- }
+ m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, m_filtersize, m_falloff);
+ }
}
BLI_INLINE float finv_test(const float f, const bool test)
{
- return (LIKELY(test == false)) ? f : 1.0f - f;
+ return (LIKELY(test == false)) ? f : 1.0f - f;
}
void GaussianAlphaYBlurOperation::executePixel(float output[4], int x, int y, void *data)
{
- const bool do_invert = this->m_do_subtract;
- MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
- float *buffer = inputBuffer->getBuffer();
- int bufferwidth = inputBuffer->getWidth();
- int bufferstartx = inputBuffer->getRect()->xmin;
- int bufferstarty = inputBuffer->getRect()->ymin;
-
- rcti &rect = *inputBuffer->getRect();
- int xmin = max_ii(x, rect.xmin);
- int ymin = max_ii(y - m_filtersize, rect.ymin);
- int ymax = min_ii(y + m_filtersize + 1, rect.ymax);
-
- /* *** this is the main part which is different to 'GaussianYBlurOperation' *** */
- int step = getStep();
-
- /* gauss */
- float alpha_accum = 0.0f;
- float multiplier_accum = 0.0f;
-
- /* dilate */
- float value_max = finv_test(buffer[(x) + (y * bufferwidth)], do_invert); /* init with the current color to avoid unneeded lookups */
- float distfacinv_max = 1.0f; /* 0 to 1 */
-
- for (int ny = ymin; ny < ymax; ny += step) {
- int bufferindex = ((xmin - bufferstartx)) + ((ny - bufferstarty) * bufferwidth);
-
- const int index = (ny - y) + this->m_filtersize;
- float value = finv_test(buffer[bufferindex], do_invert);
- float multiplier;
-
- /* gauss */
- {
- multiplier = this->m_gausstab[index];
- alpha_accum += value * multiplier;
- multiplier_accum += multiplier;
- }
-
- /* dilate - find most extreme color */
- if (value > value_max) {
- multiplier = this->m_distbuf_inv[index];
- value *= multiplier;
- if (value > value_max) {
- value_max = value;
- distfacinv_max = multiplier;
- }
- }
-
- }
-
- /* blend between the max value and gauss blue - gives nice feather */
- const float value_blur = alpha_accum / multiplier_accum;
- const float value_final = (value_max * distfacinv_max) + (value_blur * (1.0f - distfacinv_max));
- output[0] = finv_test(value_final, do_invert);
+ const bool do_invert = this->m_do_subtract;
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
+ float *buffer = inputBuffer->getBuffer();
+ int bufferwidth = inputBuffer->getWidth();
+ int bufferstartx = inputBuffer->getRect()->xmin;
+ int bufferstarty = inputBuffer->getRect()->ymin;
+
+ rcti &rect = *inputBuffer->getRect();
+ int xmin = max_ii(x, rect.xmin);
+ int ymin = max_ii(y - m_filtersize, rect.ymin);
+ int ymax = min_ii(y + m_filtersize + 1, rect.ymax);
+
+ /* *** this is the main part which is different to 'GaussianYBlurOperation' *** */
+ int step = getStep();
+
+ /* gauss */
+ float alpha_accum = 0.0f;
+ float multiplier_accum = 0.0f;
+
+ /* dilate */
+ float value_max = finv_test(
+ buffer[(x) + (y * bufferwidth)],
+ do_invert); /* init with the current color to avoid unneeded lookups */
+ float distfacinv_max = 1.0f; /* 0 to 1 */
+
+ for (int ny = ymin; ny < ymax; ny += step) {
+ int bufferindex = ((xmin - bufferstartx)) + ((ny - bufferstarty) * bufferwidth);
+
+ const int index = (ny - y) + this->m_filtersize;
+ float value = finv_test(buffer[bufferindex], do_invert);
+ float multiplier;
+
+ /* gauss */
+ {
+ multiplier = this->m_gausstab[index];
+ alpha_accum += value * multiplier;
+ multiplier_accum += multiplier;
+ }
+
+ /* dilate - find most extreme color */
+ if (value > value_max) {
+ multiplier = this->m_distbuf_inv[index];
+ value *= multiplier;
+ if (value > value_max) {
+ value_max = value;
+ distfacinv_max = multiplier;
+ }
+ }
+ }
+
+ /* blend between the max value and gauss blue - gives nice feather */
+ const float value_blur = alpha_accum / multiplier_accum;
+ const float value_final = (value_max * distfacinv_max) + (value_blur * (1.0f - distfacinv_max));
+ output[0] = finv_test(value_final, do_invert);
}
void GaussianAlphaYBlurOperation::deinitExecution()
{
- BlurBaseOperation::deinitExecution();
+ BlurBaseOperation::deinitExecution();
- if (this->m_gausstab) {
- MEM_freeN(this->m_gausstab);
- this->m_gausstab = NULL;
- }
+ if (this->m_gausstab) {
+ MEM_freeN(this->m_gausstab);
+ this->m_gausstab = NULL;
+ }
- if (this->m_distbuf_inv) {
- MEM_freeN(this->m_distbuf_inv);
- this->m_distbuf_inv = NULL;
- }
+ if (this->m_distbuf_inv) {
+ MEM_freeN(this->m_distbuf_inv);
+ this->m_distbuf_inv = NULL;
+ }
- deinitMutex();
+ deinitMutex();
}
-bool GaussianAlphaYBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool GaussianAlphaYBlurOperation::determineDependingAreaOfInterest(
+ rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
- rcti newInput;
+ rcti newInput;
#if 0 /* until we add size input */
- rcti sizeInput;
- sizeInput.xmin = 0;
- sizeInput.ymin = 0;
- sizeInput.xmax = 5;
- sizeInput.ymax = 5;
-
- NodeOperation *operation = this->getInputOperation(1);
- if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
- return true;
- }
- else
+ rcti sizeInput;
+ sizeInput.xmin = 0;
+ sizeInput.ymin = 0;
+ sizeInput.xmax = 5;
+ sizeInput.ymax = 5;
+
+ NodeOperation *operation = this->getInputOperation(1);
+ if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
+ return true;
+ }
+ else
#endif
- {
- if (this->m_sizeavailable && this->m_gausstab != NULL) {
- newInput.xmax = input->xmax;
- newInput.xmin = input->xmin;
- newInput.ymax = input->ymax + this->m_filtersize + 1;
- newInput.ymin = input->ymin - this->m_filtersize - 1;
- }
- else {
- newInput.xmax = this->getWidth();
- newInput.xmin = 0;
- newInput.ymax = this->getHeight();
- newInput.ymin = 0;
- }
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
- }
+ {
+ if (this->m_sizeavailable && this->m_gausstab != NULL) {
+ newInput.xmax = input->xmax;
+ newInput.xmin = input->xmin;
+ newInput.ymax = input->ymax + this->m_filtersize + 1;
+ newInput.ymin = input->ymin - this->m_filtersize - 1;
+ }
+ else {
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
+ }
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ }
}