[mutter] kms/update: Add init helper macros for fixed 16 rects
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] kms/update: Add init helper macros for fixed 16 rects
- Date: Tue, 25 Jan 2022 16:25:06 +0000 (UTC)
commit de06d5d9e7bf77ec8f0d06c05c90778cffce16d4
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Tue Jun 22 16:08:30 2021 +0200
kms/update: Add init helper macros for fixed 16 rects
META_FIXED_16_INIT(), taking MetaFixed16's, and META_FIXED_16_INIT_INT()
taking integers, converting them to MetaFixed16.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
src/backends/native/meta-kms-update.h | 9 +++++++++
src/tests/native-kms-updates.c | 19 +++++++++++++++++++
2 files changed, 28 insertions(+)
---
diff --git a/src/backends/native/meta-kms-update.h b/src/backends/native/meta-kms-update.h
index 70febb5663..deadbd5fcc 100644
--- a/src/backends/native/meta-kms-update.h
+++ b/src/backends/native/meta-kms-update.h
@@ -191,6 +191,15 @@ meta_fixed_16_rectangle_to_rectangle (MetaFixed16Rectangle fixed_rect)
};
}
+#define META_FIXED_16_RECTANGLE_INIT(_x,_y,_w,_h) \
+ (MetaFixed16Rectangle) { .x = (_x), .y = (_y), .width = (_w), .height = (_h) }
+
+#define META_FIXED_16_RECTANGLE_INIT_INT(_x,_y,_w,_h) \
+ META_FIXED_16_RECTANGLE_INIT (meta_fixed_16_from_int (_x), \
+ meta_fixed_16_from_int (_y), \
+ meta_fixed_16_from_int (_w), \
+ meta_fixed_16_from_int (_h))
+
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaKmsFeedback, meta_kms_feedback_free)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaKmsUpdate, meta_kms_update_free)
diff --git a/src/tests/native-kms-updates.c b/src/tests/native-kms-updates.c
index 28799c7120..86e99e2c9b 100644
--- a/src/tests/native-kms-updates.c
+++ b/src/tests/native-kms-updates.c
@@ -83,11 +83,30 @@ meta_test_kms_update_sanity (void)
meta_kms_update_free (update);
}
+static void
+meta_test_kms_update_fixed16 (void)
+{
+ MetaFixed16Rectangle rect16;
+
+ g_assert_cmpint (meta_fixed_16_from_int (12345), ==, 809041920);
+ g_assert_cmpint (meta_fixed_16_to_int (809041920), ==, 12345);
+ g_assert_cmpint (meta_fixed_16_from_int (-12345), ==, -809041920);
+ g_assert_cmpint (meta_fixed_16_to_int (-809041920), ==, -12345);
+
+ rect16 = META_FIXED_16_RECTANGLE_INIT_INT (100, 200, 300, 400);
+ g_assert_cmpint (rect16.x, ==, 6553600);
+ g_assert_cmpint (rect16.y, ==, 13107200);
+ g_assert_cmpint (rect16.width, ==, 19660800);
+ g_assert_cmpint (rect16.height, ==, 26214400);
+}
+
static void
init_tests (void)
{
g_test_add_func ("/backends/native/kms/update/sanity",
meta_test_kms_update_sanity);
+ g_test_add_func ("/backends/native/kms/update/fixed16",
+ meta_test_kms_update_fixed16);
}
int
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]