diff --git a/src/tests/meta-monitor-manager-test.c b/src/tests/meta-monitor-manager-test.c index fe435288a..0a36ea494 100644 --- a/src/tests/meta-monitor-manager-test.c +++ b/src/tests/meta-monitor-manager-test.c @@ -483,12 +483,93 @@ meta_output_test_class_init (MetaOutputTestClass *klass) { } -static void -meta_crtc_test_init (MetaCrtcTest *crtc_test) +#define GAMMA_SIZE 256 + +static size_t +meta_crtc_test_get_gamma_lut_size (MetaCrtc *crtc) { + return GAMMA_SIZE; +} + +static MetaGammaLut * +meta_crtc_test_get_gamma_lut (MetaCrtc *crtc) +{ + MetaCrtcTest *crtc_test = META_CRTC_TEST (crtc); + MetaGammaLut *lut; + + lut = g_new0 (MetaGammaLut, 1); + lut->size = crtc_test->gamma.size; + lut->red = g_memdup2 (crtc_test->gamma.red, + lut->size * sizeof (uint16_t)); + lut->green = g_memdup2 (crtc_test->gamma.green, + lut->size * sizeof (uint16_t)); + lut->blue = g_memdup2 (crtc_test->gamma.blue, + lut->size * sizeof (uint16_t)); + return lut; +} + +static void +meta_crtc_test_set_gamma_lut (MetaCrtc *crtc, + const MetaGammaLut *lut) +{ + MetaCrtcTest *crtc_test = META_CRTC_TEST (crtc); + + g_assert_cmpint (crtc_test->gamma.size, ==, lut->size); + + g_free (crtc_test->gamma.red); + g_free (crtc_test->gamma.green); + g_free (crtc_test->gamma.blue); + + crtc_test->gamma.red = g_memdup2 (lut->red, + sizeof (uint16_t) * lut->size); + crtc_test->gamma.green = g_memdup2 (lut->green, + sizeof (uint16_t) * lut->size); + crtc_test->gamma.blue = g_memdup2 (lut->blue, + sizeof (uint16_t) * lut->size); +} + +static void +meta_crtc_test_finalize (GObject *object) +{ + MetaCrtcTest *crtc_test = META_CRTC_TEST (object); + + g_free (crtc_test->gamma.red); + g_free (crtc_test->gamma.green); + g_free (crtc_test->gamma.blue); + + G_OBJECT_CLASS (meta_crtc_test_parent_class)->finalize (object); } static void meta_crtc_test_class_init (MetaCrtcTestClass *klass) { + GObjectClass *object_class = G_OBJECT_CLASS (klass); + MetaCrtcClass *crtc_class = META_CRTC_CLASS (klass); + + object_class->finalize = meta_crtc_test_finalize; + + crtc_class->get_gamma_lut_size = meta_crtc_test_get_gamma_lut_size; + crtc_class->get_gamma_lut = meta_crtc_test_get_gamma_lut; + crtc_class->set_gamma_lut = meta_crtc_test_set_gamma_lut; +} + +static void +meta_crtc_test_init (MetaCrtcTest *crtc_test) +{ + int i; + + crtc_test->gamma.size = GAMMA_SIZE; + crtc_test->gamma.red = g_new0 (uint16_t, GAMMA_SIZE); + crtc_test->gamma.green = g_new0 (uint16_t, GAMMA_SIZE); + crtc_test->gamma.blue = g_new0 (uint16_t, GAMMA_SIZE); + + for (i = 0; i < GAMMA_SIZE; i++) + { + uint16_t gamma; + + gamma = ((float) i / GAMMA_SIZE) * UINT16_MAX; + crtc_test->gamma.red[i] = gamma; + crtc_test->gamma.green[i] = gamma; + crtc_test->gamma.blue[i] = gamma; + } } diff --git a/src/tests/meta-monitor-manager-test.h b/src/tests/meta-monitor-manager-test.h index c339ec5be..ae5659695 100644 --- a/src/tests/meta-monitor-manager-test.h +++ b/src/tests/meta-monitor-manager-test.h @@ -35,6 +35,13 @@ typedef struct _MetaMonitorTestSetup struct _MetaCrtcTest { MetaCrtc parent; + + struct { + size_t size; + uint16_t *red; + uint16_t *green; + uint16_t *blue; + } gamma; }; struct _MetaOutputTest