From 6a9e2e9e2d4180b836ab66f31171c91af03286e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 24 Jun 2021 14:43:52 +0200 Subject: [PATCH] tests/kms-utils: Add helpers for common buffer sizes This makes it more convenient to allocate and configure buffers covering the whole primary plane given a mode. Part-of: --- src/tests/meta-kms-test-utils.c | 27 +++++++++++++++++++++++++++ src/tests/meta-kms-test-utils.h | 8 ++++++++ src/tests/native-kms-updates.c | 10 +++------- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/tests/meta-kms-test-utils.c b/src/tests/meta-kms-test-utils.c index 671719f62..468ca3a7f 100644 --- a/src/tests/meta-kms-test-utils.c +++ b/src/tests/meta-kms-test-utils.c @@ -30,6 +30,8 @@ #include "backends/native/meta-kms-connector.h" #include "backends/native/meta-kms-crtc.h" #include "backends/native/meta-kms-device.h" +#include "backends/native/meta-kms-mode.h" +#include "backends/native/meta-kms-update.h" #include "backends/native/meta-kms.h" MetaKmsDevice * @@ -103,3 +105,28 @@ meta_create_test_dumb_buffer (MetaKmsDevice *device, return META_DRM_BUFFER (dumb_buffer); } + +MetaDrmBuffer * +meta_create_test_mode_dumb_buffer (MetaKmsDevice *device, + MetaKmsMode *mode) +{ + return meta_create_test_dumb_buffer (device, + meta_kms_mode_get_width (mode), + meta_kms_mode_get_height (mode)); +} + +MetaFixed16Rectangle +meta_get_mode_fixed_rect_16 (MetaKmsMode *mode) +{ + return META_FIXED_16_RECTANGLE_INIT_INT (0, 0, + meta_kms_mode_get_width (mode), + meta_kms_mode_get_height (mode)); +} + +MetaRectangle +meta_get_mode_rect (MetaKmsMode *mode) +{ + return META_RECTANGLE_INIT (0, 0, + meta_kms_mode_get_width (mode), + meta_kms_mode_get_height (mode)); +} diff --git a/src/tests/meta-kms-test-utils.h b/src/tests/meta-kms-test-utils.h index 77b6ad827..e28a1425f 100644 --- a/src/tests/meta-kms-test-utils.h +++ b/src/tests/meta-kms-test-utils.h @@ -24,6 +24,7 @@ #include "backends/native/meta-drm-buffer.h" #include "backends/native/meta-kms-types.h" #include "meta/meta-context.h" +#include "meta/boxes.h" MetaKmsDevice * meta_get_test_kms_device (MetaContext *context); @@ -35,4 +36,11 @@ MetaDrmBuffer * meta_create_test_dumb_buffer (MetaKmsDevice *device, int width, int height); +MetaDrmBuffer * meta_create_test_mode_dumb_buffer (MetaKmsDevice *device, + MetaKmsMode *mode); + +MetaFixed16Rectangle meta_get_mode_fixed_rect_16 (MetaKmsMode *mode); + +MetaRectangle meta_get_mode_rect (MetaKmsMode *mode); + #endif /* META_KMS_TEST_UTILS_H */ diff --git a/src/tests/native-kms-updates.c b/src/tests/native-kms-updates.c index 882f61de5..ff983f004 100644 --- a/src/tests/native-kms-updates.c +++ b/src/tests/native-kms-updates.c @@ -106,19 +106,15 @@ meta_test_kms_update_plane_assignments (void) mode_width = meta_kms_mode_get_width (mode); mode_height = meta_kms_mode_get_height (mode); - primary_buffer = meta_create_test_dumb_buffer (device, - mode_width, mode_height); + primary_buffer = meta_create_test_mode_dumb_buffer (device, mode); primary_plane_assignment = meta_kms_update_assign_plane (update, crtc, primary_plane, primary_buffer, - META_FIXED_16_RECTANGLE_INIT_INT (0, 0, - mode_width, - mode_height), - META_RECTANGLE_INIT (0, 0, - mode_width, mode_height), + meta_get_mode_fixed_rect_16 (mode), + meta_get_mode_rect (mode), META_KMS_ASSIGN_PLANE_FLAG_NONE); g_assert_nonnull (primary_plane_assignment); g_assert_cmpint (primary_plane_assignment->src_rect.x, ==, 0);