diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-21 12:20:32 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-21 12:20:32 +0400 |
commit | 49d3766ceb17082fd64cdc0f01224237f1098564 (patch) | |
tree | 060e3303a7fc4876dd5ba7521705de5ee499077c /source/blender/compositor | |
parent | 77f47799ddff99da672aa58e5d989237403e7707 (diff) |
code cleanup: use math functions for curve compo code.
Diffstat (limited to 'source/blender/compositor')
3 files changed, 13 insertions, 16 deletions
diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp index dfbbef8c56e..aa4d0932c92 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp @@ -61,9 +61,9 @@ void ColorBalanceASCCDLOperation::executePixel(float output[4], float x, float y fac = min(1.0f, fac); const float mfac = 1.0f - fac; - output[0] = mfac * inputColor[0] + fac *colorbalance_cdl(inputColor[0], this->m_lift[0], this->m_gamma[0], this->m_gain[0]); - output[1] = mfac * inputColor[1] + fac *colorbalance_cdl(inputColor[1], this->m_lift[1], this->m_gamma[1], this->m_gain[1]); - output[2] = mfac * inputColor[2] + fac *colorbalance_cdl(inputColor[2], this->m_lift[2], this->m_gamma[2], this->m_gain[2]); + output[0] = mfac * inputColor[0] + fac * colorbalance_cdl(inputColor[0], this->m_lift[0], this->m_gamma[0], this->m_gain[0]); + output[1] = mfac * inputColor[1] + fac * colorbalance_cdl(inputColor[1], this->m_lift[1], this->m_gamma[1], this->m_gain[1]); + output[2] = mfac * inputColor[2] + fac * colorbalance_cdl(inputColor[2], this->m_lift[2], this->m_gamma[2], this->m_gain[2]); output[3] = inputColor[3]; } diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp index 44784837301..ff2cf96d0ad 100644 --- a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp @@ -76,17 +76,16 @@ void ColorCurveOperation::executePixel(float output[4], float x, float y, PixelS this->m_inputFacProgram->read(fac, x, y, sampler); this->m_inputImageProgram->read(image, x, y, sampler); - if (*fac >= 1.0f) + if (*fac >= 1.0f) { curvemapping_evaluate_premulRGBF(workingCopy, output, image); + } else if (*fac <= 0.0f) { copy_v3_v3(output, image); } else { - float col[4], mfac = 1.0f - *fac; + float col[4]; curvemapping_evaluate_premulRGBF(workingCopy, col, image); - output[0] = mfac * image[0] + *fac * col[0]; - output[1] = mfac * image[1] + *fac * col[1]; - output[2] = mfac * image[2] + *fac * col[2]; + interp_v3_v3v3(output, image, col, *fac); } output[3] = image[3]; MEM_freeN(workingCopy); @@ -131,21 +130,19 @@ void ConstantLevelColorCurveOperation::executePixel(float output[4], float x, fl float fac[4]; float image[4]; - this->m_inputFacProgram->read(fac, x, y, sampler); this->m_inputImageProgram->read(image, x, y, sampler); - if (*fac >= 1.0f) + if (*fac >= 1.0f) { curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, image); + } else if (*fac <= 0.0f) { copy_v3_v3(output, image); } else { - float col[4], mfac = 1.0f - *fac; + float col[4]; curvemapping_evaluate_premulRGBF(this->m_curveMapping, col, image); - output[0] = mfac * image[0] + *fac * col[0]; - output[1] = mfac * image[1] + *fac * col[1]; - output[2] = mfac * image[2] + *fac * col[2]; + interp_v3_v3v3(output, image, col, *fac); } output[3] = image[3]; } diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.h b/source/blender/compositor/operations/COM_ColorCurveOperation.h index 063873c6443..7dc1913b85a 100644 --- a/source/blender/compositor/operations/COM_ColorCurveOperation.h +++ b/source/blender/compositor/operations/COM_ColorCurveOperation.h @@ -82,8 +82,8 @@ public: */ void deinitExecution(); - void setBlackLevel(float black[3]) { this->m_black[0] = black[0]; this->m_black[1] = black[1]; this->m_black[2] = black[2]; } - void setWhiteLevel(float white[3]) { this->m_white[0] = white[0]; this->m_white[1] = white[1]; this->m_white[2] = white[2]; } + void setBlackLevel(float black[3]) { copy_v3_v3(this->m_black, black); } + void setWhiteLevel(float white[3]) { copy_v3_v3(this->m_white, white); } }; #endif |