diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-08-28 02:33:58 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-08-28 02:33:58 +0200 |
commit | c7a3a6765971700334bbdc72f1def1f42d44c546 (patch) | |
tree | 1d432c6d64f39ed7e3d86d158099fdb5d920f5cd /src | |
parent | initialisation of dummy sites and dummy partitions (diff) | |
download | libgamma-c7a3a6765971700334bbdc72f1def1f42d44c546.tar.gz libgamma-c7a3a6765971700334bbdc72f1def1f42d44c546.tar.bz2 libgamma-c7a3a6765971700334bbdc72f1def1f42d44c546.tar.xz |
m
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/lib/gamma-dummy.c | 55 |
1 files changed, 15 insertions, 40 deletions
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; } |