From c7a3a6765971700334bbdc72f1def1f42d44c546 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 28 Aug 2014 02:33:58 +0200 Subject: m MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/lib/gamma-dummy.c | 55 ++++++++++++++------------------------------------- 1 file changed, 15 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/lib/gamma-dummy.c b/src/lib/gamma-dummy.c index 395d0a1..6c8d720 100644 --- a/src/lib/gamma-dummy.c +++ b/src/lib/gamma-dummy.c @@ -526,46 +526,19 @@ static int libgamma_dummy_crtc_restore_forced(libgamma_dummy_crtc_t* restrict da if (data->gamma_red == NULL) return 0; - if (data->gamma_depth == 8) - { - int8_t* red = data->gamma_red; - int8_t* green = data->gamma_green; - int8_t* blue = data->gamma_blue; - double max = (double)INT8_MAX; - for (i = 0; i < n; i++) - red[i] = green[i] = blue[i] = - (int8_t)(max * ((double)i / (double)(n - 1))); - } - else if (data->gamma_depth == 16) - { - int16_t* red = data->gamma_red; - int16_t* green = data->gamma_green; - int16_t* blue = data->gamma_blue; - double max = (double)INT16_MAX; - for (i = 0; i < n; i++) - red[i] = green[i] = blue[i] = - (int16_t)(max * ((double)i / (double)(n - 1))); - } - else if (data->gamma_depth == 32) - { - int32_t* red = data->gamma_red; - int32_t* green = data->gamma_green; - int32_t* blue = data->gamma_blue; - double max = (double)INT32_MAX; - for (i = 0; i < n; i++) - red[i] = green[i] = blue[i] = - (int32_t)(max * ((double)i / (double)(n - 1))); - } - else if (data->gamma_depth == 64) - { - int64_t* red = data->gamma_red; - int64_t* green = data->gamma_green; - int64_t* blue = data->gamma_blue; - double max = (double)INT64_MAX; - for (i = 0; i < n; i++) - red[i] = green[i] = blue[i] = - (int64_t)(max * ((double)i / (double)(n - 1))); - } +#define __reset_ramps(BITS) \ + int ## BITS ## _t* red = data->gamma_red; \ + int ## BITS ## _t* green = data->gamma_green; \ + int ## BITS ## _t* blue = data->gamma_blue; \ + double max = (double)INT ## BITS ## _MAX; \ + for (i = 0; i < n; i++) \ + red[i] = green[i] = blue[i] = \ + (int ## BITS ## _t)(max * ((double)i / (double)(n - 1))) + + if (data->gamma_depth == 8) { __reset_ramps(8); } + else if (data->gamma_depth == 16) { __reset_ramps(16); } + else if (data->gamma_depth == 32) { __reset_ramps(32); } + else if (data->gamma_depth == 64) { __reset_ramps(64); } else if (data->gamma_depth == -1) { float* red = data->gamma_red; @@ -585,6 +558,8 @@ static int libgamma_dummy_crtc_restore_forced(libgamma_dummy_crtc_t* restrict da (double)i / (double)(n - 1); } +#undef __reset_ramps + return 0; } -- cgit v1.2.3-70-g09d2