From 988df245519352ab80d8ad488660a0a2f7a963d3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Aug 2012 08:30:45 +0000 Subject: compositor color curve was MEM_dupallocN'ing the curve for every pixel calculation (when there were black or white inputs on the curve node). avoid allocation by using local vars for black/white storage & curve calculation. --- .../compositor/operations/COM_ColorCurveOperation.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'source/blender/compositor') diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp index ff2cf96d0ad..81205514040 100644 --- a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp @@ -61,34 +61,39 @@ void ColorCurveOperation::initExecution() void ColorCurveOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) { CurveMapping *cumap = this->m_curveMapping; - CurveMapping *workingCopy = (CurveMapping *)MEM_dupallocN(cumap); - float black[4]; - float white[4]; float fac[4]; float image[4]; + /* local versions of cumap->black, cumap->white, cumap->bwmul */ + float black[4]; + float white[4]; + float bwmul[3]; + this->m_inputBlackProgram->read(black, x, y, sampler); this->m_inputWhiteProgram->read(white, x, y, sampler); - curvemapping_set_black_white(workingCopy, black, white); + /* get our own local bwmul value, + * since we can't be threadsafe and use cumap->bwmul & friends */ + curvemapping_set_black_white_ex(black, white, bwmul); this->m_inputFacProgram->read(fac, x, y, sampler); this->m_inputImageProgram->read(image, x, y, sampler); if (*fac >= 1.0f) { - curvemapping_evaluate_premulRGBF(workingCopy, output, image); + curvemapping_evaluate_premulRGBF_ex(cumap, output, image, + black, bwmul); } else if (*fac <= 0.0f) { copy_v3_v3(output, image); } else { float col[4]; - curvemapping_evaluate_premulRGBF(workingCopy, col, image); + curvemapping_evaluate_premulRGBF_ex(cumap, col, image, + black, bwmul); interp_v3_v3v3(output, image, col, *fac); } output[3] = image[3]; - MEM_freeN(workingCopy); } void ColorCurveOperation::deinitExecution() -- cgit v1.2.3