From c724cb3720c582507d219218e6ce9c149808a3f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Sat, 3 Sep 2022 15:48:54 +0200 Subject: [PATCH] tests/monitor-test-utils: Add way to make the GAMMA_LUT zero sized This will be used to test devices that has no gamma capabilities. Part-of: --- src/tests/meta-monitor-manager-test.c | 15 ++++++++++++++- src/tests/meta-monitor-manager-test.h | 3 +++ src/tests/meta-monitor-test-utils.c | 2 ++ src/tests/meta-monitor-test-utils.h | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/tests/meta-monitor-manager-test.c b/src/tests/meta-monitor-manager-test.c index 0a36ea494..55f4100b0 100644 --- a/src/tests/meta-monitor-manager-test.c +++ b/src/tests/meta-monitor-manager-test.c @@ -488,7 +488,9 @@ meta_output_test_class_init (MetaOutputTestClass *klass) static size_t meta_crtc_test_get_gamma_lut_size (MetaCrtc *crtc) { - return GAMMA_SIZE; + MetaCrtcTest *crtc_test = META_CRTC_TEST (crtc); + + return crtc_test->gamma.size; } static MetaGammaLut * @@ -497,6 +499,8 @@ meta_crtc_test_get_gamma_lut (MetaCrtc *crtc) MetaCrtcTest *crtc_test = META_CRTC_TEST (crtc); MetaGammaLut *lut; + g_assert_cmpint (crtc_test->gamma.size, >, 0); + lut = g_new0 (MetaGammaLut, 1); lut->size = crtc_test->gamma.size; lut->red = g_memdup2 (crtc_test->gamma.red, @@ -573,3 +577,12 @@ meta_crtc_test_init (MetaCrtcTest *crtc_test) crtc_test->gamma.blue[i] = gamma; } } + +void +meta_crtc_test_disable_gamma_lut (MetaCrtcTest *crtc_test) +{ + crtc_test->gamma.size = 0; + g_clear_pointer (&crtc_test->gamma.red, g_free); + g_clear_pointer (&crtc_test->gamma.green, g_free); + g_clear_pointer (&crtc_test->gamma.blue, g_free); +} diff --git a/src/tests/meta-monitor-manager-test.h b/src/tests/meta-monitor-manager-test.h index ae5659695..52c160b6d 100644 --- a/src/tests/meta-monitor-manager-test.h +++ b/src/tests/meta-monitor-manager-test.h @@ -87,4 +87,7 @@ void meta_monitor_manager_test_set_handles_transforms (MetaMonitorManagerTest *m META_EXPORT int meta_monitor_manager_test_get_tiled_monitor_count (MetaMonitorManagerTest *manager_test); +META_EXPORT +void meta_crtc_test_disable_gamma_lut (MetaCrtcTest *crtc_test); + #endif /* META_MONITOR_MANAGER_TEST_H */ diff --git a/src/tests/meta-monitor-test-utils.c b/src/tests/meta-monitor-test-utils.c index bd30d3188..8480e4a62 100644 --- a/src/tests/meta-monitor-test-utils.c +++ b/src/tests/meta-monitor-test-utils.c @@ -666,6 +666,8 @@ meta_create_monitor_test_setup (MetaBackend *backend, "id", (uint64_t) i + 1, "gpu", meta_test_get_gpu (backend), NULL); + if (setup->crtcs[i].disable_gamma_lut) + meta_crtc_test_disable_gamma_lut (META_CRTC_TEST (crtc)); test_setup->crtcs = g_list_append (test_setup->crtcs, crtc); } diff --git a/src/tests/meta-monitor-test-utils.h b/src/tests/meta-monitor-test-utils.h index c27c64d38..278a089fa 100644 --- a/src/tests/meta-monitor-test-utils.h +++ b/src/tests/meta-monitor-test-utils.h @@ -119,6 +119,7 @@ typedef struct _MonitorTestCaseOutput typedef struct _MonitorTestCaseCrtc { int current_mode; + gboolean disable_gamma_lut; } MonitorTestCaseCrtc; typedef struct _MonitorTestCaseSetup