code cleanup: use math functions for curve compo code.
authorCampbell Barton <ideasman42@gmail.com>
Tue, 21 Aug 2012 08:20:32 +0000 (08:20 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 21 Aug 2012 08:20:32 +0000 (08:20 +0000)
source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
source/blender/compositor/operations/COM_ColorCurveOperation.cpp
source/blender/compositor/operations/COM_ColorCurveOperation.h

index dfbbef8c56e3a0be0aa6ac8a9d392fff35c76089..aa4d0932c92ebd74df5afab7030cbfc8777902fb 100644 (file)
@@ -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];
 
 }
index 44784837301f5630e85f05d80fe5f974703e4fbc..ff2cf96d0adf050c42088b126fb31d1424dcb8b2 100644 (file)
@@ -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];
 }
index 063873c6443e431c1f8604efa370ec731dad5bfa..7dc1913b85af04887dca4be3cb852b745fba40e0 100644 (file)
@@ -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