From dd0c756e5113f3238989da4aa9df942411b20296 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 4 Jun 2014 00:58:49 +0200 Subject: test applying gamma ramp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/test/test.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'src/test') diff --git a/src/test/test.c b/src/test/test.c index 49c5f8b..7ddab54 100644 --- a/src/test/test.c +++ b/src/test/test.c @@ -21,6 +21,7 @@ #include #include #include +#include #ifdef __GNUC__ @@ -423,6 +424,7 @@ int main(void) libgamma_partition_state_t* restrict part_state = malloc(sizeof(libgamma_partition_state_t)); libgamma_crtc_state_t* restrict crtc_state = malloc(sizeof(libgamma_crtc_state_t)); libgamma_crtc_information_t info; + libgamma_gamma_ramps_t old_ramps; libgamma_gamma_ramps_t ramps; size_t i, n; int r; @@ -439,11 +441,14 @@ int main(void) crtc_information(crtc_state); libgamma_get_crtc_information(&info, crtc_state, LIBGAMMA_CRTC_INFO_GAMMA_SIZE); - ramps.red_size = info.red_gamma_size; - ramps.green_size = info.green_gamma_size; - ramps.blue_size = info.blue_gamma_size; + old_ramps.red_size = info.red_gamma_size; + old_ramps.green_size = info.green_gamma_size; + old_ramps.blue_size = info.blue_gamma_size; + ramps = old_ramps; + libgamma_gamma_ramps_initialise(&old_ramps); libgamma_gamma_ramps_initialise(&ramps); + libgamma_crtc_get_gamma_ramps(crtc_state, &old_ramps); r = libgamma_crtc_get_gamma_ramps(crtc_state, &ramps); if (r) libgamma_perror("libgamma_crtc_get_gamma_ramps", r); @@ -469,10 +474,24 @@ int main(void) printf(" "); printf("\n"); } + printf("\n"); + + for (i = 0; i < ramps.red_size + ramps.green_size + ramps.blue_size; i++) + ramps.red[i] /= 2; + + printf("Dimming monitor for 1 second...\n"); + r = libgamma_crtc_set_gamma_ramps(crtc_state, ramps); + if (r) + libgamma_perror("libgamma_crtc_set_gamma_ramps", r); + sleep(1); + r = libgamma_crtc_set_gamma_ramps(crtc_state, old_ramps); + if (r) + libgamma_perror("libgamma_crtc_set_gamma_ramps", r); + printf("Done!\n"); } - printf("\n"); libgamma_gamma_ramps_destroy(&ramps); + libgamma_gamma_ramps_destroy(&old_ramps); libgamma_crtc_free(crtc_state); libgamma_partition_free(part_state); libgamma_site_free(site_state); -- cgit v1.2.3-70-g09d2