diff options
Diffstat (limited to 'source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp')
-rw-r--r-- | source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp index f84f4e3b094..40f74ad4485 100644 --- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp @@ -79,8 +79,14 @@ void GaussianAlphaYBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) } } +BLI_INLINE float finv_test(const float f, const bool test) +{ + return (LIKELY(test == false)) ? f : 1.0f - f; +} + void GaussianAlphaYBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { + const bool do_invert = this->do_subtract; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); int bufferwidth = inputBuffer->getWidth(); @@ -104,14 +110,14 @@ void GaussianAlphaYBlurOperation::executePixel(float *color, int x, int y, Memor float overallmultiplyer = 0.0f; /* dilate */ - float value_max = buffer[(x * 4) + (y * 4 * bufferwidth)]; /* init with the current color to avoid unneeded lookups */ + float value_max = finv_test(buffer[(x * 4) + (y * 4 * bufferwidth)], do_invert); /* init with the current color to avoid unneeded lookups */ float distfacinv_max = 1.0f; /* 0 to 1 */ for (int ny = miny; ny < maxy; ny += step) { int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth); const int index = (ny - y) + this->rad; - float value = buffer[bufferindex]; + float value = finv_test(buffer[bufferindex], do_invert); float multiplyer; /* gauss */ @@ -140,7 +146,7 @@ void GaussianAlphaYBlurOperation::executePixel(float *color, int x, int y, Memor /* blend between the max value and gauss blue - gives nice feather */ const float value_gauss = tempColor / overallmultiplyer; const float value_final = (value_max * distfacinv_max) + (value_gauss * (1.0f - distfacinv_max)); - color[0] = value_final; + color[0] = finv_test(value_final, do_invert); } void GaussianAlphaYBlurOperation::deinitExecution() |