From b5b58ced2a8c0d5282074643b1bd13422d976447 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 10 Jul 2024 12:34:59 -0400 Subject: [PATCH] Add gdk_dihedral_get_name And use it everywhere we want to print out debug spew about dihedral transforms. --- gdk/gdkdihedral.c | 10 ++++++++++ gdk/gdkdihedralprivate.h | 2 ++ gdk/wayland/gdkdisplay-wayland.c | 27 ++------------------------- gdk/wayland/gdksubsurface-wayland.c | 10 +--------- gdk/wayland/gdksurface-wayland.c | 5 +---- 5 files changed, 16 insertions(+), 38 deletions(-) diff --git a/gdk/gdkdihedral.c b/gdk/gdkdihedral.c index 6628e6fc60..92da37c1fb 100644 --- a/gdk/gdkdihedral.c +++ b/gdk/gdkdihedral.c @@ -70,3 +70,13 @@ gdk_dihedral_swaps_xy (GdkDihedral self) { return (self & 1) ? TRUE : FALSE; } + +const char * +gdk_dihedral_get_name (GdkDihedral self) +{ + const char *name[] = { + "normal", "90", "180", "270", "flipped", "flipped-90", "flipped-180", "flipped-270" + }; + + return name[self]; +} diff --git a/gdk/gdkdihedralprivate.h b/gdk/gdkdihedralprivate.h index 472cd74a1a..996bf8471d 100644 --- a/gdk/gdkdihedralprivate.h +++ b/gdk/gdkdihedralprivate.h @@ -43,5 +43,7 @@ GdkDihedral gdk_dihedral_combine (GdkDihedral GdkDihedral gdk_dihedral_invert (GdkDihedral self); gboolean gdk_dihedral_swaps_xy (GdkDihedral self); +const char * gdk_dihedral_get_name (GdkDihedral self); + G_END_DECLS diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index 1c187e0091..0f26412c94 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -50,6 +50,7 @@ #include "gdkvulkancontext-wayland.h" #include "gdkwaylandmonitor.h" #include "gdkprofilerprivate.h" +#include "gdkdihedralprivate.h" #include "gdktoplevel-wayland-private.h" #include #include "tablet-unstable-v2-client-protocol.h" @@ -2307,30 +2308,6 @@ subpixel_to_string (int layout) return NULL; } -static const char * -transform_to_string (int transform) -{ - int i; - struct { int transform; const char *name; } transforms[] = { - { WL_OUTPUT_TRANSFORM_NORMAL, "normal" }, - { WL_OUTPUT_TRANSFORM_90, "90" }, - { WL_OUTPUT_TRANSFORM_180, "180" }, - { WL_OUTPUT_TRANSFORM_270, "270" }, - { WL_OUTPUT_TRANSFORM_FLIPPED, "flipped" }, - { WL_OUTPUT_TRANSFORM_FLIPPED_90, "flipped 90" }, - { WL_OUTPUT_TRANSFORM_FLIPPED_180, "flipped 180" }, - { WL_OUTPUT_TRANSFORM_FLIPPED_270, "flipped 270" }, - { 0xffffffff, NULL } - }; - - for (i = 0; transforms[i].name; i++) - { - if (transforms[i].transform == transform) - return transforms[i].name; - } - return NULL; -} - static void update_scale (GdkDisplay *display) { @@ -2561,7 +2538,7 @@ output_handle_geometry (void *data, physical_width, physical_height, subpixel_to_string (subpixel), make, model, - transform_to_string (transform)); + gdk_dihedral_get_name ((GdkDihedral) transform)); monitor->output_geometry.x = x; monitor->output_geometry.y = y; diff --git a/gdk/wayland/gdksubsurface-wayland.c b/gdk/wayland/gdksubsurface-wayland.c index ca4165e3c8..d0ff087dcf 100644 --- a/gdk/wayland/gdksubsurface-wayland.c +++ b/gdk/wayland/gdksubsurface-wayland.c @@ -247,14 +247,6 @@ gdk_texture_transform_to_wl (GdkDihedral transform) return (enum wl_output_transform) transform; } -static inline const char * -transform_name (GdkDihedral transform) -{ - const char *name[] = { "normal", "90", "180", "270", "flipped", "flipped 90", "flipped 180", "flipped 270" }; - - return name[transform]; -} - static inline GdkDihedral wl_output_transform_to_gdk (enum wl_output_transform transform) { @@ -521,7 +513,7 @@ gdk_wayland_subsurface_attach (GdkSubsurface *sub, self->dest.x, self->dest.y, self->dest.width, self->dest.height, transform != GDK_DIHEDRAL_NORMAL ? " (" : "", - transform != GDK_DIHEDRAL_NORMAL ? transform_name (transform): "", + transform != GDK_DIHEDRAL_NORMAL ? gdk_dihedral_get_name (transform) : "", transform != GDK_DIHEDRAL_NORMAL ? " )" : "" ); result = TRUE; diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index 2ebeed05da..4155766a3e 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -893,13 +893,10 @@ surface_preferred_buffer_transform (void *data, uint32_t transform) { GdkSurface *surface = GDK_SURFACE (data); - const char *transform_name[] = { - "normal", "90", "180", "270", "flipped", "flipped-90", "flipped-180", "flipped-270" - }; GDK_DISPLAY_DEBUG (gdk_surface_get_display (surface), EVENTS, "preferred buffer transform, surface %p transform %s", - surface, transform_name[transform]); + surface, gdk_dihedral_get_name ((GdkDihedral) transform)); } static const struct wl_surface_listener surface_listener = {