Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <j.bakker@atmind.nl>2012-06-08 13:17:07 +0400
committerJeroen Bakker <j.bakker@atmind.nl>2012-06-08 13:17:07 +0400
commitde7fe937ff24121ce8c66af902639cd96244a55f (patch)
tree625821742e2a136e10fe1cd76a81303766b8633f /source/blender/compositor/operations/COM_ColorCurveOperation.cpp
parent95641388471d178552fea26bb477c13536bd58ef (diff)
* Added OpenCL kernel for bokeh blur
* Uncomment COM_OPENCL_ENABLED from COM_defines.h to test
Diffstat (limited to 'source/blender/compositor/operations/COM_ColorCurveOperation.cpp')
-rw-r--r--source/blender/compositor/operations/COM_ColorCurveOperation.cpp69
1 files changed, 66 insertions, 3 deletions
diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
index 8aee54013b1..069bbde5e73 100644
--- a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
@@ -28,6 +28,7 @@ extern "C" {
#include "BKE_colortools.h"
#ifdef __cplusplus
}
+#include "MEM_guardedalloc.h"
#endif
ColorCurveOperation::ColorCurveOperation(): CurveBaseOperation()
@@ -59,6 +60,9 @@ void ColorCurveOperation::initExecution()
void ColorCurveOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{
+ CurveMapping* cumap = this->curveMapping;
+ CurveMapping* workingCopy = (CurveMapping*)MEM_dupallocN(cumap);
+
float black[4];
float white[4];
float fac[4];
@@ -67,13 +71,13 @@ void ColorCurveOperation::executePixel(float *color, float x, float y, PixelSamp
this->inputBlackProgram->read(black, x, y, sampler, inputBuffers);
this->inputWhiteProgram->read(white, x, y, sampler, inputBuffers);
- curvemapping_set_black_white(this->curveMapping, black, white);
+ curvemapping_set_black_white(workingCopy, black, white);
this->inputFacProgram->read(fac, x, y, sampler, inputBuffers);
this->inputImageProgram->read(image, x, y, sampler, inputBuffers);
if (fac[0] >= 1.0)
- curvemapping_evaluate_premulRGBF(this->curveMapping, color, image);
+ curvemapping_evaluate_premulRGBF(workingCopy, color, image);
else if (*fac<=0.0) {
color[0] = image[0];
color[1] = image[1];
@@ -81,12 +85,13 @@ void ColorCurveOperation::executePixel(float *color, float x, float y, PixelSamp
}
else {
float col[4], mfac = 1.0f-*fac;
- curvemapping_evaluate_premulRGBF(this->curveMapping, col, image);
+ curvemapping_evaluate_premulRGBF(workingCopy, col, image);
color[0] = mfac*image[0] + *fac*col[0];
color[1] = mfac*image[1] + *fac*col[1];
color[2] = mfac*image[2] + *fac*col[2];
}
color[3] = image[3];
+ MEM_freeN(workingCopy);
}
void ColorCurveOperation::deinitExecution()
@@ -97,3 +102,61 @@ void ColorCurveOperation::deinitExecution()
this->inputWhiteProgram = NULL;
curvemapping_premultiply(this->curveMapping, 1);
}
+
+
+// Constant level curve mapping
+
+ConstantLevelColorCurveOperation::ConstantLevelColorCurveOperation(): CurveBaseOperation()
+{
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+
+ this->inputFacProgram = NULL;
+ this->inputImageProgram = NULL;
+
+ this->setResolutionInputSocketIndex(1);
+}
+void ConstantLevelColorCurveOperation::initExecution()
+{
+ CurveBaseOperation::initExecution();
+ this->inputFacProgram = this->getInputSocketReader(0);
+ this->inputImageProgram = this->getInputSocketReader(1);
+
+ curvemapping_premultiply(this->curveMapping, 0);
+
+ curvemapping_set_black_white(this->curveMapping, this->black, this->white);
+}
+
+void ConstantLevelColorCurveOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+{
+ float fac[4];
+ float image[4];
+
+
+ this->inputFacProgram->read(fac, x, y, sampler, inputBuffers);
+ this->inputImageProgram->read(image, x, y, sampler, inputBuffers);
+
+ if (fac[0] >= 1.0)
+ curvemapping_evaluate_premulRGBF(this->curveMapping, color, image);
+ else if (*fac<=0.0) {
+ color[0] = image[0];
+ color[1] = image[1];
+ color[2] = image[2];
+ }
+ else {
+ float col[4], mfac = 1.0f-*fac;
+ curvemapping_evaluate_premulRGBF(this->curveMapping, col, image);
+ color[0] = mfac*image[0] + *fac*col[0];
+ color[1] = mfac*image[1] + *fac*col[1];
+ color[2] = mfac*image[2] + *fac*col[2];
+ }
+ color[3] = image[3];
+}
+
+void ConstantLevelColorCurveOperation::deinitExecution()
+{
+ this->inputFacProgram = NULL;
+ this->inputImageProgram = NULL;
+ curvemapping_premultiply(this->curveMapping, 1);
+}