Merging r58475 through r58700 from trunk into soc-2013-depsgraph_mt
[blender.git] / source / blender / compositor / operations / COM_MixColorOperation.cpp
index e14b10b305e568d4d2b2aa6e8a0117682f82f6df..6919a636aeb40713aa424ec979f82ecc35564be5 100644 (file)
@@ -26,36 +26,43 @@ extern "C" {
        #include "BLI_math.h"
 }
 
-MixColorOperation::MixColorOperation(): MixBaseOperation()
+MixColorOperation::MixColorOperation() : MixBaseOperation()
 {
+       /* pass */
 }
 
-void MixColorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+void MixColorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
 {
        float inputColor1[4];
        float inputColor2[4];
-       float value;
+       float inputValue[4];
 
-       inputValueOperation->read(&value, x, y, sampler, inputBuffers);
-       inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers);
-       inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers);
+       this->m_inputValueOperation->read(inputValue, x, y, sampler);
+       this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
+       this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
 
+       float value = inputValue[0];
        if (this->useValueAlphaMultiply()) {
                value *= inputColor2[3];
        }
        float valuem = 1.0f - value;
        
-       float colH,colS,colV;
+       float colH, colS, colV;
        rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV);
-       if (colS!=0.0f) {
-               float rH,rS,rV;
-               float tmpr,tmpg,tmpb;
+       if (colS != 0.0f) {
+               float rH, rS, rV;
+               float tmpr, tmpg, tmpb;
                rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV);
-               hsv_to_rgb(colH , colS, rV, &tmpr, &tmpg, &tmpb);
-               outputValue[0] = valuem*(inputColor1[0]) + value*tmpr;
-               outputValue[1] = valuem*(inputColor1[1]) + value*tmpg;
-               outputValue[2] = valuem*(inputColor1[2]) + value*tmpb;
+               hsv_to_rgb(colH, colS, rV, &tmpr, &tmpg, &tmpb);
+               output[0] = (valuem * inputColor1[0]) + (value * tmpr);
+               output[1] = (valuem * inputColor1[1]) + (value * tmpg);
+               output[2] = (valuem * inputColor1[2]) + (value * tmpb);
        }
-       outputValue[3] = inputColor1[3];
+       else {
+               copy_v3_v3(output, inputColor1);
+       }
+       output[3] = inputColor1[3];
+
+       clampIfNeeded(output);
 }