diff options
Diffstat (limited to 'source/blender/compositor/operations/COM_ColorCurveOperation.cc')
-rw-r--r-- | source/blender/compositor/operations/COM_ColorCurveOperation.cc | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cc b/source/blender/compositor/operations/COM_ColorCurveOperation.cc index cb0565a81a2..1b7ad0ea608 100644 --- a/source/blender/compositor/operations/COM_ColorCurveOperation.cc +++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cc @@ -98,6 +98,36 @@ void ColorCurveOperation::deinitExecution() this->m_inputWhiteProgram = nullptr; } +void ColorCurveOperation::update_memory_buffer_partial(MemoryBuffer *output, + const rcti &area, + Span<MemoryBuffer *> inputs) +{ + CurveMapping *cumap = this->m_curveMapping; + float bwmul[3]; + for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) { + /* Local versions of `cumap->black` and `cumap->white`. */ + const float *black = it.in(2); + const float *white = it.in(3); + /* Get a local `bwmul` value, it's not threadsafe using `cumap->bwmul` and others. */ + BKE_curvemapping_set_black_white_ex(black, white, bwmul); + + const float fac = *it.in(0); + const float *image = it.in(1); + if (fac >= 1.0f) { + BKE_curvemapping_evaluate_premulRGBF_ex(cumap, it.out, image, black, bwmul); + } + else if (fac <= 0.0f) { + copy_v3_v3(it.out, image); + } + else { + float col[4]; + BKE_curvemapping_evaluate_premulRGBF_ex(cumap, col, image, black, bwmul); + interp_v3_v3v3(it.out, image, col, fac); + } + it.out[3] = image[3]; + } +} + // Constant level curve mapping ConstantLevelColorCurveOperation::ConstantLevelColorCurveOperation() @@ -154,4 +184,27 @@ void ConstantLevelColorCurveOperation::deinitExecution() this->m_inputImageProgram = nullptr; } +void ConstantLevelColorCurveOperation::update_memory_buffer_partial(MemoryBuffer *output, + const rcti &area, + Span<MemoryBuffer *> inputs) +{ + CurveMapping *cumap = this->m_curveMapping; + for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) { + const float fac = *it.in(0); + const float *image = it.in(1); + if (fac >= 1.0f) { + BKE_curvemapping_evaluate_premulRGBF(cumap, it.out, image); + } + else if (fac <= 0.0f) { + copy_v3_v3(it.out, image); + } + else { + float col[4]; + BKE_curvemapping_evaluate_premulRGBF(cumap, col, image); + interp_v3_v3v3(it.out, image, col, fac); + } + it.out[3] = image[3]; + } +} + } // namespace blender::compositor |