Color management: added utility function to apply processor on a pixel

It applies color management on a pixel in a way, based on number of
channels of this pixel.

Simplifies partial update code a bit.
This commit is contained in:
Sergey Sharybin 2013-12-18 15:51:09 +06:00
parent d791e60687
commit 2249d71e26
2 changed files with 20 additions and 11 deletions

View File

@ -166,6 +166,7 @@ struct ColormanageProcessor *IMB_colormanagement_colorspace_processor_new(const
void IMB_colormanagement_processor_apply_v4(struct ColormanageProcessor *cm_processor, float pixel[4]);
void IMB_colormanagement_processor_apply_v4_predivide(struct ColormanageProcessor *cm_processor, float pixel[4]);
void IMB_colormanagement_processor_apply_v3(struct ColormanageProcessor *cm_processor, float pixel[3]);
void IMB_colormanagement_processor_apply_pixel(struct ColormanageProcessor *cm_processor, float *pixel, int channels);
void IMB_colormanagement_processor_apply(struct ColormanageProcessor *cm_processor, float *buffer, int width, int height,
int channels, bool predivide);
void IMB_colormanagement_processor_free(struct ColormanageProcessor *cm_processor);

View File

@ -2690,17 +2690,7 @@ static void partial_buffer_update_rect(ImBuf *ibuf, unsigned char *display_buffe
}
if (!is_data) {
if (channels == 4) {
IMB_colormanagement_processor_apply_v4_predivide(cm_processor, pixel);
}
else if (channels == 3) {
IMB_colormanagement_processor_apply_v3(cm_processor, pixel);
}
else /* if (channels == 1) */ {
if (cm_processor->curve_mapping) {
curve_mapping_apply_pixel(cm_processor->curve_mapping, pixel, 1);
}
}
IMB_colormanagement_processor_apply_pixel(cm_processor, pixel, channels);
}
if (display_buffer_float) {
@ -2917,6 +2907,24 @@ void IMB_colormanagement_processor_apply_v3(ColormanageProcessor *cm_processor,
OCIO_processorApplyRGB(cm_processor->processor, pixel);
}
void IMB_colormanagement_processor_apply_pixel(struct ColormanageProcessor *cm_processor, float *pixel, int channels)
{
if (channels == 4) {
IMB_colormanagement_processor_apply_v4_predivide(cm_processor, pixel);
}
else if (channels == 3) {
IMB_colormanagement_processor_apply_v3(cm_processor, pixel);
}
else if (channels == 1) {
if (cm_processor->curve_mapping) {
curve_mapping_apply_pixel(cm_processor->curve_mapping, pixel, 1);
}
}
else {
BLI_assert(!"Incorrect number of channels passed to IMB_colormanagement_processor_apply_pixel");
}
}
void IMB_colormanagement_processor_apply(ColormanageProcessor *cm_processor, float *buffer, int width, int height,
int channels, bool predivide)
{