From 49d3766ceb17082fd64cdc0f01224237f1098564 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Aug 2012 08:20:32 +0000 Subject: code cleanup: use math functions for curve compo code. --- .../compositor/operations/COM_ColorCurveOperation.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'source/blender/compositor/operations/COM_ColorCurveOperation.cpp') 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]; } -- cgit v1.2.3