diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/compositor/operations/COM_BlurBaseOperation.cpp | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (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_BlurBaseOperation.cpp')
-rw-r--r-- | source/blender/compositor/operations/COM_BlurBaseOperation.cpp | 224 |
1 files changed, 111 insertions, 113 deletions
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp index d1a55de1431..aca98085a3e 100644 --- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp @@ -21,82 +21,81 @@ #include "MEM_guardedalloc.h" extern "C" { -# include "RE_pipeline.h" +#include "RE_pipeline.h" } BlurBaseOperation::BlurBaseOperation(DataType data_type) : NodeOperation() { - /* data_type is almost always COM_DT_COLOR except for alpha-blur */ - this->addInputSocket(data_type); - this->addInputSocket(COM_DT_VALUE); - this->addOutputSocket(data_type); - this->setComplex(true); - this->m_inputProgram = NULL; - memset(&m_data, 0, sizeof(NodeBlurData)); - this->m_size = 1.0f; - this->m_sizeavailable = false; - this->m_extend_bounds = false; + /* data_type is almost always COM_DT_COLOR except for alpha-blur */ + this->addInputSocket(data_type); + this->addInputSocket(COM_DT_VALUE); + this->addOutputSocket(data_type); + this->setComplex(true); + this->m_inputProgram = NULL; + memset(&m_data, 0, sizeof(NodeBlurData)); + this->m_size = 1.0f; + this->m_sizeavailable = false; + this->m_extend_bounds = false; } void BlurBaseOperation::initExecution() { - this->m_inputProgram = this->getInputSocketReader(0); - this->m_inputSize = this->getInputSocketReader(1); - this->m_data.image_in_width = this->getWidth(); - this->m_data.image_in_height = this->getHeight(); - if (this->m_data.relative) { - switch (this->m_data.aspect) { - case CMP_NODE_BLUR_ASPECT_NONE: - this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_width); - this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_height); - break; - case CMP_NODE_BLUR_ASPECT_Y: - this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_width); - this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_width); - break; - case CMP_NODE_BLUR_ASPECT_X: - this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_height); - this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_height); - break; - } - } - - QualityStepHelper::initExecution(COM_QH_MULTIPLY); - + this->m_inputProgram = this->getInputSocketReader(0); + this->m_inputSize = this->getInputSocketReader(1); + this->m_data.image_in_width = this->getWidth(); + this->m_data.image_in_height = this->getHeight(); + if (this->m_data.relative) { + switch (this->m_data.aspect) { + case CMP_NODE_BLUR_ASPECT_NONE: + this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_width); + this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_height); + break; + case CMP_NODE_BLUR_ASPECT_Y: + this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_width); + this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_width); + break; + case CMP_NODE_BLUR_ASPECT_X: + this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_height); + this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_height); + break; + } + } + + QualityStepHelper::initExecution(COM_QH_MULTIPLY); } float *BlurBaseOperation::make_gausstab(float rad, int size) { - float *gausstab, sum, val; - int i, n; + float *gausstab, sum, val; + int i, n; - n = 2 * size + 1; + n = 2 * size + 1; - gausstab = (float *)MEM_mallocN(sizeof(float) * n, __func__); + gausstab = (float *)MEM_mallocN(sizeof(float) * n, __func__); - sum = 0.0f; - float fac = (rad > 0.0f ? 1.0f / rad : 0.0f); - for (i = -size; i <= size; i++) { - val = RE_filter_value(this->m_data.filtertype, (float)i * fac); - sum += val; - gausstab[i + size] = val; - } + sum = 0.0f; + float fac = (rad > 0.0f ? 1.0f / rad : 0.0f); + for (i = -size; i <= size; i++) { + val = RE_filter_value(this->m_data.filtertype, (float)i * fac); + sum += val; + gausstab[i + size] = val; + } - sum = 1.0f / sum; - for (i = 0; i < n; i++) - gausstab[i] *= sum; + sum = 1.0f / sum; + for (i = 0; i < n; i++) + gausstab[i] *= sum; - return gausstab; + return gausstab; } #ifdef __SSE2__ __m128 *BlurBaseOperation::convert_gausstab_sse(const float *gausstab, int size) { - int n = 2 * size + 1; - __m128 *gausstab_sse = (__m128 *) MEM_mallocN_aligned(sizeof(__m128) * n, 16, "gausstab sse"); - for (int i = 0; i < n; ++i) { - gausstab_sse[i] = _mm_set1_ps(gausstab[i]); - } - return gausstab_sse; + int n = 2 * size + 1; + __m128 *gausstab_sse = (__m128 *)MEM_mallocN_aligned(sizeof(__m128) * n, 16, "gausstab sse"); + for (int i = 0; i < n; ++i) { + gausstab_sse[i] = _mm_set1_ps(gausstab[i]); + } + return gausstab_sse; } #endif @@ -104,81 +103,80 @@ __m128 *BlurBaseOperation::convert_gausstab_sse(const float *gausstab, int size) * 'ease' is applied after, looks nicer */ float *BlurBaseOperation::make_dist_fac_inverse(float rad, int size, int falloff) { - float *dist_fac_invert, val; - int i, n; - - n = 2 * size + 1; - - dist_fac_invert = (float *)MEM_mallocN(sizeof(float) * n, __func__); - - float fac = (rad > 0.0f ? 1.0f / rad : 0.0f); - for (i = -size; i <= size; i++) { - val = 1.0f - fabsf((float)i * fac); - - /* keep in sync with rna_enum_proportional_falloff_curve_only_items */ - switch (falloff) { - case PROP_SMOOTH: - /* ease - gives less hard lines for dilate/erode feather */ - val = (3.0f * val * val - 2.0f * val * val * val); - break; - case PROP_SPHERE: - val = sqrtf(2.0f * val - val * val); - break; - case PROP_ROOT: - val = sqrtf(val); - break; - case PROP_SHARP: - val = val * val; - break; - case PROP_INVSQUARE: - val = val * (2.0f - val); - break; - case PROP_LIN: - /* fall-through */ + float *dist_fac_invert, val; + int i, n; + + n = 2 * size + 1; + + dist_fac_invert = (float *)MEM_mallocN(sizeof(float) * n, __func__); + + float fac = (rad > 0.0f ? 1.0f / rad : 0.0f); + for (i = -size; i <= size; i++) { + val = 1.0f - fabsf((float)i * fac); + + /* keep in sync with rna_enum_proportional_falloff_curve_only_items */ + switch (falloff) { + case PROP_SMOOTH: + /* ease - gives less hard lines for dilate/erode feather */ + val = (3.0f * val * val - 2.0f * val * val * val); + break; + case PROP_SPHERE: + val = sqrtf(2.0f * val - val * val); + break; + case PROP_ROOT: + val = sqrtf(val); + break; + case PROP_SHARP: + val = val * val; + break; + case PROP_INVSQUARE: + val = val * (2.0f - val); + break; + case PROP_LIN: + /* fall-through */ #ifndef NDEBUG - case -1: - /* uninitialized! */ - BLI_assert(0); - break; + case -1: + /* uninitialized! */ + BLI_assert(0); + break; #endif - default: - /* nothing */ - break; - } - dist_fac_invert[i + size] = val; - } - - return dist_fac_invert; + default: + /* nothing */ + break; + } + dist_fac_invert[i + size] = val; + } + + return dist_fac_invert; } void BlurBaseOperation::deinitExecution() { - this->m_inputProgram = NULL; - this->m_inputSize = NULL; + this->m_inputProgram = NULL; + this->m_inputSize = NULL; } void BlurBaseOperation::setData(const NodeBlurData *data) { - memcpy(&m_data, data, sizeof(NodeBlurData)); + memcpy(&m_data, data, sizeof(NodeBlurData)); } void BlurBaseOperation::updateSize() { - if (!this->m_sizeavailable) { - float result[4]; - this->getInputSocketReader(1)->readSampled(result, 0, 0, COM_PS_NEAREST); - this->m_size = result[0]; - this->m_sizeavailable = true; - } + if (!this->m_sizeavailable) { + float result[4]; + this->getInputSocketReader(1)->readSampled(result, 0, 0, COM_PS_NEAREST); + this->m_size = result[0]; + this->m_sizeavailable = true; + } } void BlurBaseOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]) { - NodeOperation::determineResolution(resolution, - preferredResolution); - if (this->m_extend_bounds) { - resolution[0] += 2 * this->m_size * m_data.sizex; - resolution[1] += 2 * this->m_size * m_data.sizey; - } + NodeOperation::determineResolution(resolution, preferredResolution); + if (this->m_extend_bounds) { + resolution[0] += 2 * this->m_size * m_data.sizex; + resolution[1] += 2 * this->m_size * m_data.sizey; + } } |