From 3221a8bdab456fb539398740e17ea3faa5ba7373 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 9 Jul 2024 08:02:56 +0200 Subject: [PATCH] gdk: Rename GdkTextureTransform to GdkDihedral ... and put it into its own header. We want to use it in more places and the name and location are awkward. --- gdk/gdkdihedralprivate.h | 36 +++++++++++++++++++++++++++++ gdk/gdksubsurface.c | 6 ++--- gdk/gdksubsurfaceprivate.h | 20 ++++------------ gdk/wayland/gdksubsurface-wayland.c | 10 ++++---- gsk/gskoffload.c | 24 +++++++++---------- gsk/gskoffloadprivate.h | 2 +- testsuite/gdk/subsurface.c | 16 ++++++------- 7 files changed, 70 insertions(+), 44 deletions(-) create mode 100644 gdk/gdkdihedralprivate.h diff --git a/gdk/gdkdihedralprivate.h b/gdk/gdkdihedralprivate.h new file mode 100644 index 0000000000..8b6765f762 --- /dev/null +++ b/gdk/gdkdihedralprivate.h @@ -0,0 +1,36 @@ +/* GDK - The GIMP Drawing Kit + * Copyright (C) 2024 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ + +#pragma once + +#include + +G_BEGIN_DECLS + +typedef enum { + GDK_DIHEDRAL_NORMAL, + GDK_DIHEDRAL_90, + GDK_DIHEDRAL_180, + GDK_DIHEDRAL_270, + GDK_DIHEDRAL_FLIPPED, + GDK_DIHEDRAL_FLIPPED_90, + GDK_DIHEDRAL_FLIPPED_180, + GDK_DIHEDRAL_FLIPPED_270, +} GdkDihedral; + +G_END_DECLS + diff --git a/gdk/gdksubsurface.c b/gdk/gdksubsurface.c index 20d4810a4c..c2d2eb96d0 100644 --- a/gdk/gdksubsurface.c +++ b/gdk/gdksubsurface.c @@ -144,7 +144,7 @@ gdk_subsurface_attach (GdkSubsurface *subsurface, GdkTexture *texture, const graphene_rect_t *source, const graphene_rect_t *dest, - GdkTextureTransform transform, + GdkDihedral transform, const graphene_rect_t *background, gboolean above, GdkSubsurface *sibling) @@ -320,10 +320,10 @@ gdk_subsurface_get_sibling (GdkSubsurface *subsurface, * * Returns: the transform */ -GdkTextureTransform +GdkDihedral gdk_subsurface_get_transform (GdkSubsurface *subsurface) { - g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), GDK_TEXTURE_TRANSFORM_NORMAL); + g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), GDK_DIHEDRAL_NORMAL); return GDK_SUBSURFACE_GET_CLASS (subsurface)->get_transform (subsurface); } diff --git a/gdk/gdksubsurfaceprivate.h b/gdk/gdksubsurfaceprivate.h index 6a28ac3f1d..3cce7f0cf8 100644 --- a/gdk/gdksubsurfaceprivate.h +++ b/gdk/gdksubsurfaceprivate.h @@ -20,6 +20,7 @@ #pragma once #include "gdkenumtypes.h" +#include "gdkdihedralprivate.h" #include "gdksurface.h" #include @@ -47,17 +48,6 @@ struct _GdkSubsurface GdkSubsurface *sibling_below; }; -typedef enum { - GDK_TEXTURE_TRANSFORM_NORMAL, - GDK_TEXTURE_TRANSFORM_90, - GDK_TEXTURE_TRANSFORM_180, - GDK_TEXTURE_TRANSFORM_270, - GDK_TEXTURE_TRANSFORM_FLIPPED, - GDK_TEXTURE_TRANSFORM_FLIPPED_90, - GDK_TEXTURE_TRANSFORM_FLIPPED_180, - GDK_TEXTURE_TRANSFORM_FLIPPED_270, -} GdkTextureTransform; - struct _GdkSubsurfaceClass { GObjectClass parent_class; @@ -66,7 +56,7 @@ struct _GdkSubsurfaceClass GdkTexture *texture, const graphene_rect_t *source, const graphene_rect_t *dest, - GdkTextureTransform transform, + GdkDihedral transform, const graphene_rect_t *bg, gboolean above, GdkSubsurface *sibling); @@ -76,7 +66,7 @@ struct _GdkSubsurfaceClass graphene_rect_t *rect); void (* get_texture_rect) (GdkSubsurface *subsurface, graphene_rect_t *rect); - GdkTextureTransform + GdkDihedral (* get_transform) (GdkSubsurface *subsurface); gboolean (* get_background_rect) (GdkSubsurface *subsurface, graphene_rect_t *rect); @@ -90,7 +80,7 @@ gboolean gdk_subsurface_attach (GdkSubsurface *subsu GdkTexture *texture, const graphene_rect_t *source, const graphene_rect_t *dest, - GdkTextureTransform transform, + GdkDihedral transform, const graphene_rect_t *background, gboolean above, GdkSubsurface *sibling); @@ -103,7 +93,7 @@ void gdk_subsurface_get_texture_rect (GdkSubsurface *subsu gboolean gdk_subsurface_is_above_parent (GdkSubsurface *subsurface); GdkSubsurface * gdk_subsurface_get_sibling (GdkSubsurface *subsurface, gboolean above); -GdkTextureTransform +GdkDihedral gdk_subsurface_get_transform (GdkSubsurface *subsurface); gboolean gdk_subsurface_get_background_rect (GdkSubsurface *subsurface, graphene_rect_t *rect); diff --git a/gdk/wayland/gdksubsurface-wayland.c b/gdk/wayland/gdksubsurface-wayland.c index 666c66b428..5ee3ef9a51 100644 --- a/gdk/wayland/gdksubsurface-wayland.c +++ b/gdk/wayland/gdksubsurface-wayland.c @@ -242,15 +242,15 @@ get_sp_buffer (GdkWaylandSubsurface *self) } static inline enum wl_output_transform -gdk_texture_transform_to_wl (GdkTextureTransform transform) +gdk_texture_transform_to_wl (GdkDihedral transform) { return (enum wl_output_transform) transform; } -static inline GdkTextureTransform +static inline GdkDihedral wl_output_transform_to_gdk (enum wl_output_transform transform) { - return (GdkTextureTransform) transform; + return (GdkDihedral) transform; } static void @@ -304,7 +304,7 @@ gdk_wayland_subsurface_attach (GdkSubsurface *sub, GdkTexture *texture, const graphene_rect_t *source, const graphene_rect_t *dest, - GdkTextureTransform transform, + GdkDihedral transform, const graphene_rect_t *background, gboolean above, GdkSubsurface *sibling) @@ -715,7 +715,7 @@ gdk_wayland_subsurface_get_source_rect (GdkSubsurface *sub, rect->size.height = self->source.size.height; } -static GdkTextureTransform +static GdkDihedral gdk_wayland_subsurface_get_transform (GdkSubsurface *sub) { GdkWaylandSubsurface *self = GDK_WAYLAND_SUBSURFACE (sub); diff --git a/gsk/gskoffload.c b/gsk/gskoffload.c index 284643a571..23af99e652 100644 --- a/gsk/gskoffload.c +++ b/gsk/gskoffload.c @@ -56,7 +56,7 @@ struct _GskOffload GskOffloadInfo *last_info; }; -static GdkTextureTransform +static GdkDihedral find_texture_transform (GskTransform *transform) { float sx, sy, dx, dy; @@ -68,26 +68,26 @@ find_texture_transform (GskTransform *transform) if (sx > 0) { if (sy > 0) - return GDK_TEXTURE_TRANSFORM_NORMAL; + return GDK_DIHEDRAL_NORMAL; else - return GDK_TEXTURE_TRANSFORM_FLIPPED_180; + return GDK_DIHEDRAL_FLIPPED_180; } else { if (sy > 0) - return GDK_TEXTURE_TRANSFORM_FLIPPED; + return GDK_DIHEDRAL_FLIPPED; else - return GDK_TEXTURE_TRANSFORM_180; + return GDK_DIHEDRAL_180; } } static GdkTexture * -find_texture_to_attach (GskOffload *self, - const GskRenderNode *subsurface_node, - graphene_rect_t *out_texture_rect, - graphene_rect_t *out_source_rect, - gboolean *has_background, - GdkTextureTransform *out_texture_transform) +find_texture_to_attach (GskOffload *self, + const GskRenderNode *subsurface_node, + graphene_rect_t *out_texture_rect, + graphene_rect_t *out_source_rect, + gboolean *has_background, + GdkDihedral *out_texture_transform) { GdkSubsurface *subsurface; const GskRenderNode *node; @@ -97,7 +97,7 @@ find_texture_to_attach (GskOffload *self, GdkTexture *ret = NULL; *has_background = FALSE; - *out_texture_transform = GDK_TEXTURE_TRANSFORM_NORMAL; + *out_texture_transform = GDK_DIHEDRAL_NORMAL; subsurface = gsk_subsurface_node_get_subsurface (subsurface_node); node = subsurface_node; diff --git a/gsk/gskoffloadprivate.h b/gsk/gskoffloadprivate.h index 6848d83436..0e7349d453 100644 --- a/gsk/gskoffloadprivate.h +++ b/gsk/gskoffloadprivate.h @@ -33,7 +33,7 @@ typedef struct GdkSubsurface *place_above; graphene_rect_t texture_rect; graphene_rect_t source_rect; - GdkTextureTransform transform; + GdkDihedral transform; graphene_rect_t background_rect; guint was_offloaded : 1; diff --git a/testsuite/gdk/subsurface.c b/testsuite/gdk/subsurface.c index 3a63fe44b9..b5c119ca54 100644 --- a/testsuite/gdk/subsurface.c +++ b/testsuite/gdk/subsurface.c @@ -39,14 +39,14 @@ test_subsurface_basics (void) g_assert_null (gdk_subsurface_get_texture (sub)); g_assert_false (gdk_subsurface_is_above_parent (sub)); - g_assert_true (gdk_subsurface_get_transform (sub) == GDK_TEXTURE_TRANSFORM_NORMAL); + g_assert_true (gdk_subsurface_get_transform (sub) == GDK_DIHEDRAL_NORMAL); texture = gdk_texture_new_from_resource ("/org/gtk/libgtk/icons/16x16/actions/media-eject.png"); - gdk_subsurface_attach (sub, texture, &TEXTURE_RECT (texture), &GRAPHENE_RECT_INIT (0, 0, 10, 10), GDK_TEXTURE_TRANSFORM_90, &GRAPHENE_RECT_INIT (0, 0, 20, 20), TRUE, NULL); + gdk_subsurface_attach (sub, texture, &TEXTURE_RECT (texture), &GRAPHENE_RECT_INIT (0, 0, 10, 10), GDK_DIHEDRAL_90, &GRAPHENE_RECT_INIT (0, 0, 20, 20), TRUE, NULL); g_assert_true (gdk_subsurface_get_texture (sub) == texture); g_assert_true (gdk_subsurface_is_above_parent (sub)); - g_assert_true (gdk_subsurface_get_transform (sub) == GDK_TEXTURE_TRANSFORM_90); + g_assert_true (gdk_subsurface_get_transform (sub) == GDK_DIHEDRAL_90); gdk_subsurface_get_source_rect (sub, &rect); g_assert_true (graphene_rect_equal (&rect, &TEXTURE_RECT (texture))); gdk_subsurface_get_texture_rect (sub, &rect); @@ -90,9 +90,9 @@ test_subsurface_stacking (void) texture = gdk_texture_new_from_resource ("/org/gtk/libgtk/icons/16x16/actions/media-eject.png"); - gdk_subsurface_attach (sub0, texture, &TEXTURE_RECT (texture), &GRAPHENE_RECT_INIT (0, 0, 10, 10), GDK_TEXTURE_TRANSFORM_NORMAL, NULL, TRUE, NULL); - gdk_subsurface_attach (sub1, texture, &TEXTURE_RECT (texture), &GRAPHENE_RECT_INIT (0, 0, 10, 10), GDK_TEXTURE_TRANSFORM_NORMAL, NULL, TRUE, NULL); - gdk_subsurface_attach (sub2, texture, &TEXTURE_RECT (texture), &GRAPHENE_RECT_INIT (0, 0, 10, 10), GDK_TEXTURE_TRANSFORM_NORMAL, NULL, TRUE, NULL); + gdk_subsurface_attach (sub0, texture, &TEXTURE_RECT (texture), &GRAPHENE_RECT_INIT (0, 0, 10, 10), GDK_DIHEDRAL_NORMAL, NULL, TRUE, NULL); + gdk_subsurface_attach (sub1, texture, &TEXTURE_RECT (texture), &GRAPHENE_RECT_INIT (0, 0, 10, 10), GDK_DIHEDRAL_NORMAL, NULL, TRUE, NULL); + gdk_subsurface_attach (sub2, texture, &TEXTURE_RECT (texture), &GRAPHENE_RECT_INIT (0, 0, 10, 10), GDK_DIHEDRAL_NORMAL, NULL, TRUE, NULL); g_assert_true (surface->subsurfaces_above == sub2); g_assert_true (sub2->sibling_below == NULL); @@ -115,7 +115,7 @@ test_subsurface_stacking (void) g_assert_true (sub0->sibling_above == NULL); g_assert_true (sub0->above_parent); - gdk_subsurface_attach (sub2, texture, &TEXTURE_RECT (texture), &GRAPHENE_RECT_INIT (0, 0, 10, 10), GDK_TEXTURE_TRANSFORM_NORMAL, NULL, FALSE, NULL); + gdk_subsurface_attach (sub2, texture, &TEXTURE_RECT (texture), &GRAPHENE_RECT_INIT (0, 0, 10, 10), GDK_DIHEDRAL_NORMAL, NULL, FALSE, NULL); g_assert_true (surface->subsurfaces_above == sub0); g_assert_true (sub0->sibling_below == NULL); @@ -127,7 +127,7 @@ test_subsurface_stacking (void) g_assert_true (sub2->sibling_above == NULL); g_assert_false (sub2->above_parent); - gdk_subsurface_attach (sub1, texture, &TEXTURE_RECT (texture), &GRAPHENE_RECT_INIT (0, 0, 10, 10), GDK_TEXTURE_TRANSFORM_NORMAL, NULL, TRUE, sub2); + gdk_subsurface_attach (sub1, texture, &TEXTURE_RECT (texture), &GRAPHENE_RECT_INIT (0, 0, 10, 10), GDK_DIHEDRAL_NORMAL, NULL, TRUE, sub2); g_assert_true (surface->subsurfaces_below == sub1); g_assert_true (sub1->sibling_above == NULL);