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.
This commit is contained in:
Benjamin Otte 2024-07-09 08:02:56 +02:00
parent 930f059f5e
commit 3221a8bdab
7 changed files with 70 additions and 44 deletions

36
gdk/gdkdihedralprivate.h Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <glib.h>
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

View File

@ -144,7 +144,7 @@ gdk_subsurface_attach (GdkSubsurface *subsurface,
GdkTexture *texture, GdkTexture *texture,
const graphene_rect_t *source, const graphene_rect_t *source,
const graphene_rect_t *dest, const graphene_rect_t *dest,
GdkTextureTransform transform, GdkDihedral transform,
const graphene_rect_t *background, const graphene_rect_t *background,
gboolean above, gboolean above,
GdkSubsurface *sibling) GdkSubsurface *sibling)
@ -320,10 +320,10 @@ gdk_subsurface_get_sibling (GdkSubsurface *subsurface,
* *
* Returns: the transform * Returns: the transform
*/ */
GdkTextureTransform GdkDihedral
gdk_subsurface_get_transform (GdkSubsurface *subsurface) 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); return GDK_SUBSURFACE_GET_CLASS (subsurface)->get_transform (subsurface);
} }

View File

@ -20,6 +20,7 @@
#pragma once #pragma once
#include "gdkenumtypes.h" #include "gdkenumtypes.h"
#include "gdkdihedralprivate.h"
#include "gdksurface.h" #include "gdksurface.h"
#include <graphene.h> #include <graphene.h>
@ -47,17 +48,6 @@ struct _GdkSubsurface
GdkSubsurface *sibling_below; 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 struct _GdkSubsurfaceClass
{ {
GObjectClass parent_class; GObjectClass parent_class;
@ -66,7 +56,7 @@ struct _GdkSubsurfaceClass
GdkTexture *texture, GdkTexture *texture,
const graphene_rect_t *source, const graphene_rect_t *source,
const graphene_rect_t *dest, const graphene_rect_t *dest,
GdkTextureTransform transform, GdkDihedral transform,
const graphene_rect_t *bg, const graphene_rect_t *bg,
gboolean above, gboolean above,
GdkSubsurface *sibling); GdkSubsurface *sibling);
@ -76,7 +66,7 @@ struct _GdkSubsurfaceClass
graphene_rect_t *rect); graphene_rect_t *rect);
void (* get_texture_rect) (GdkSubsurface *subsurface, void (* get_texture_rect) (GdkSubsurface *subsurface,
graphene_rect_t *rect); graphene_rect_t *rect);
GdkTextureTransform GdkDihedral
(* get_transform) (GdkSubsurface *subsurface); (* get_transform) (GdkSubsurface *subsurface);
gboolean (* get_background_rect) (GdkSubsurface *subsurface, gboolean (* get_background_rect) (GdkSubsurface *subsurface,
graphene_rect_t *rect); graphene_rect_t *rect);
@ -90,7 +80,7 @@ gboolean gdk_subsurface_attach (GdkSubsurface *subsu
GdkTexture *texture, GdkTexture *texture,
const graphene_rect_t *source, const graphene_rect_t *source,
const graphene_rect_t *dest, const graphene_rect_t *dest,
GdkTextureTransform transform, GdkDihedral transform,
const graphene_rect_t *background, const graphene_rect_t *background,
gboolean above, gboolean above,
GdkSubsurface *sibling); GdkSubsurface *sibling);
@ -103,7 +93,7 @@ void gdk_subsurface_get_texture_rect (GdkSubsurface *subsu
gboolean gdk_subsurface_is_above_parent (GdkSubsurface *subsurface); gboolean gdk_subsurface_is_above_parent (GdkSubsurface *subsurface);
GdkSubsurface * gdk_subsurface_get_sibling (GdkSubsurface *subsurface, GdkSubsurface * gdk_subsurface_get_sibling (GdkSubsurface *subsurface,
gboolean above); gboolean above);
GdkTextureTransform GdkDihedral
gdk_subsurface_get_transform (GdkSubsurface *subsurface); gdk_subsurface_get_transform (GdkSubsurface *subsurface);
gboolean gdk_subsurface_get_background_rect (GdkSubsurface *subsurface, gboolean gdk_subsurface_get_background_rect (GdkSubsurface *subsurface,
graphene_rect_t *rect); graphene_rect_t *rect);

View File

@ -242,15 +242,15 @@ get_sp_buffer (GdkWaylandSubsurface *self)
} }
static inline enum wl_output_transform 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; return (enum wl_output_transform) transform;
} }
static inline GdkTextureTransform static inline GdkDihedral
wl_output_transform_to_gdk (enum wl_output_transform transform) wl_output_transform_to_gdk (enum wl_output_transform transform)
{ {
return (GdkTextureTransform) transform; return (GdkDihedral) transform;
} }
static void static void
@ -304,7 +304,7 @@ gdk_wayland_subsurface_attach (GdkSubsurface *sub,
GdkTexture *texture, GdkTexture *texture,
const graphene_rect_t *source, const graphene_rect_t *source,
const graphene_rect_t *dest, const graphene_rect_t *dest,
GdkTextureTransform transform, GdkDihedral transform,
const graphene_rect_t *background, const graphene_rect_t *background,
gboolean above, gboolean above,
GdkSubsurface *sibling) GdkSubsurface *sibling)
@ -715,7 +715,7 @@ gdk_wayland_subsurface_get_source_rect (GdkSubsurface *sub,
rect->size.height = self->source.size.height; rect->size.height = self->source.size.height;
} }
static GdkTextureTransform static GdkDihedral
gdk_wayland_subsurface_get_transform (GdkSubsurface *sub) gdk_wayland_subsurface_get_transform (GdkSubsurface *sub)
{ {
GdkWaylandSubsurface *self = GDK_WAYLAND_SUBSURFACE (sub); GdkWaylandSubsurface *self = GDK_WAYLAND_SUBSURFACE (sub);

View File

@ -56,7 +56,7 @@ struct _GskOffload
GskOffloadInfo *last_info; GskOffloadInfo *last_info;
}; };
static GdkTextureTransform static GdkDihedral
find_texture_transform (GskTransform *transform) find_texture_transform (GskTransform *transform)
{ {
float sx, sy, dx, dy; float sx, sy, dx, dy;
@ -68,26 +68,26 @@ find_texture_transform (GskTransform *transform)
if (sx > 0) if (sx > 0)
{ {
if (sy > 0) if (sy > 0)
return GDK_TEXTURE_TRANSFORM_NORMAL; return GDK_DIHEDRAL_NORMAL;
else else
return GDK_TEXTURE_TRANSFORM_FLIPPED_180; return GDK_DIHEDRAL_FLIPPED_180;
} }
else else
{ {
if (sy > 0) if (sy > 0)
return GDK_TEXTURE_TRANSFORM_FLIPPED; return GDK_DIHEDRAL_FLIPPED;
else else
return GDK_TEXTURE_TRANSFORM_180; return GDK_DIHEDRAL_180;
} }
} }
static GdkTexture * static GdkTexture *
find_texture_to_attach (GskOffload *self, find_texture_to_attach (GskOffload *self,
const GskRenderNode *subsurface_node, const GskRenderNode *subsurface_node,
graphene_rect_t *out_texture_rect, graphene_rect_t *out_texture_rect,
graphene_rect_t *out_source_rect, graphene_rect_t *out_source_rect,
gboolean *has_background, gboolean *has_background,
GdkTextureTransform *out_texture_transform) GdkDihedral *out_texture_transform)
{ {
GdkSubsurface *subsurface; GdkSubsurface *subsurface;
const GskRenderNode *node; const GskRenderNode *node;
@ -97,7 +97,7 @@ find_texture_to_attach (GskOffload *self,
GdkTexture *ret = NULL; GdkTexture *ret = NULL;
*has_background = FALSE; *has_background = FALSE;
*out_texture_transform = GDK_TEXTURE_TRANSFORM_NORMAL; *out_texture_transform = GDK_DIHEDRAL_NORMAL;
subsurface = gsk_subsurface_node_get_subsurface (subsurface_node); subsurface = gsk_subsurface_node_get_subsurface (subsurface_node);
node = subsurface_node; node = subsurface_node;

View File

@ -33,7 +33,7 @@ typedef struct
GdkSubsurface *place_above; GdkSubsurface *place_above;
graphene_rect_t texture_rect; graphene_rect_t texture_rect;
graphene_rect_t source_rect; graphene_rect_t source_rect;
GdkTextureTransform transform; GdkDihedral transform;
graphene_rect_t background_rect; graphene_rect_t background_rect;
guint was_offloaded : 1; guint was_offloaded : 1;

View File

@ -39,14 +39,14 @@ test_subsurface_basics (void)
g_assert_null (gdk_subsurface_get_texture (sub)); g_assert_null (gdk_subsurface_get_texture (sub));
g_assert_false (gdk_subsurface_is_above_parent (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"); 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_get_texture (sub) == texture);
g_assert_true (gdk_subsurface_is_above_parent (sub)); 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); gdk_subsurface_get_source_rect (sub, &rect);
g_assert_true (graphene_rect_equal (&rect, &TEXTURE_RECT (texture))); g_assert_true (graphene_rect_equal (&rect, &TEXTURE_RECT (texture)));
gdk_subsurface_get_texture_rect (sub, &rect); 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"); 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 (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_TEXTURE_TRANSFORM_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_TEXTURE_TRANSFORM_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 (surface->subsurfaces_above == sub2);
g_assert_true (sub2->sibling_below == NULL); 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->sibling_above == NULL);
g_assert_true (sub0->above_parent); 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 (surface->subsurfaces_above == sub0);
g_assert_true (sub0->sibling_below == NULL); g_assert_true (sub0->sibling_below == NULL);
@ -127,7 +127,7 @@ test_subsurface_stacking (void)
g_assert_true (sub2->sibling_above == NULL); g_assert_true (sub2->sibling_above == NULL);
g_assert_false (sub2->above_parent); 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 (surface->subsurfaces_below == sub1);
g_assert_true (sub1->sibling_above == NULL); g_assert_true (sub1->sibling_above == NULL);