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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
This commit is contained in:
Jonas Ådahl 2021-06-24 14:43:52 +02:00 committed by Marge Bot
parent c35e8f5a51
commit 6a9e2e9e2d
3 changed files with 38 additions and 7 deletions

View File

@ -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));
}

View File

@ -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 */

View File

@ -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);