From 660b3e108259354b15d3c187b65550707855b5e7 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 16 Apr 2014 01:29:36 +0200 Subject: missed to read gamma ramp size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blueshift_quartz_c.c | 13 +++++++++++++ src/fake_quartz.c | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/blueshift_quartz_c.c b/src/blueshift_quartz_c.c index 54f8826..19ffbe9 100644 --- a/src/blueshift_quartz_c.c +++ b/src/blueshift_quartz_c.c @@ -42,6 +42,7 @@ static uint32_t* gamma_sizes = NULL; int blueshift_quartz_open(void) { uint32_t cap = 4; + uint32_t i; CGError r; crtcs = malloc((size_t)cap * sizeof(CGDirectDisplayID)); @@ -92,6 +93,18 @@ int blueshift_quartz_open(void) close_fake_quartz(); return -1; } + for (i = 0; i < crtc_count; i++) + { + gamma_sizes[i] = CGDisplayGammaTableCapacity(crtcs[i]); + if (gamma_sizes[i] < 2) + { + fprintf(stderr, "Quartz reported impossibly small gamma ramps.\n"); + free(gamma_sizes); + free(crtcs); + close_fake_quartz(); + return -1; + } + } } return 0; diff --git a/src/fake_quartz.c b/src/fake_quartz.c index 3fe821c..840f5b1 100644 --- a/src/fake_quartz.c +++ b/src/fake_quartz.c @@ -153,7 +153,7 @@ CGError CGGetDisplayTransferByTable(CGDirectDisplayID display, uint32_t gamma_si if (gamma_size != 256) { - fprintf(stderr, "Gamma size should be 256\n"); + fprintf(stderr, "Gamma size should be 256, got %u\n", gamma_size); abort(); } -- cgit v1.2.3-70-g09d2