From b035350ffd44b7ea8594b6bcf575e116b22276c7 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 26 Jul 2024 18:42:54 +0200 Subject: [PATCH] cogl: Replace RectangleMapEntry with MtkRectangle Avoids exposing the former in the next commit even if MtkRectangle uses signed integers compared to RectangleMapEntry. But as those rectangles are defined inside of Cogl, it should be okay I guess? Part-of: --- cogl/cogl-pango/cogl-pango-glyph-cache.c | 6 +++--- cogl/cogl/cogl-atlas-texture-private.h | 2 +- cogl/cogl/cogl-atlas-texture.c | 14 ++++++------- cogl/cogl/cogl-atlas.c | 16 +++++++-------- cogl/cogl/cogl-atlas.h | 10 ++++----- cogl/cogl/cogl-rectangle-map.c | 14 ++++++------- cogl/cogl/cogl-rectangle-map.h | 26 +++++++++--------------- 7 files changed, 41 insertions(+), 47 deletions(-) diff --git a/cogl/cogl-pango/cogl-pango-glyph-cache.c b/cogl/cogl-pango/cogl-pango-glyph-cache.c index 19e119de4..745ddc73c 100644 --- a/cogl/cogl-pango/cogl-pango-glyph-cache.c +++ b/cogl/cogl-pango/cogl-pango-glyph-cache.c @@ -184,9 +184,9 @@ cogl_pango_glyph_cache_free (CoglPangoGlyphCache *cache) } static void -cogl_pango_glyph_cache_update_position_cb (void *user_data, - CoglTexture *new_texture, - const CoglRectangleMapEntry *rect) +cogl_pango_glyph_cache_update_position_cb (void *user_data, + CoglTexture *new_texture, + const MtkRectangle *rect) { CoglPangoGlyphCacheValue *value = user_data; float tex_width, tex_height; diff --git a/cogl/cogl/cogl-atlas-texture-private.h b/cogl/cogl/cogl-atlas-texture-private.h index 060ab8b19..41ea903e5 100644 --- a/cogl/cogl/cogl-atlas-texture-private.h +++ b/cogl/cogl/cogl-atlas-texture-private.h @@ -46,7 +46,7 @@ struct _CoglAtlasTexture /* The rectangle that was used to add this texture to the atlas. This includes the 1-pixel border */ - CoglRectangleMapEntry rectangle; + MtkRectangle rectangle; /* The atlas that this texture is in. If the texture is no longer in an atlas then this will be NULL. A reference is taken on the diff --git a/cogl/cogl/cogl-atlas-texture.c b/cogl/cogl/cogl-atlas-texture.c index b56390bf7..7db9e13b2 100644 --- a/cogl/cogl/cogl-atlas-texture.c +++ b/cogl/cogl/cogl-atlas-texture.c @@ -77,8 +77,8 @@ cogl_atlas_texture_dispose (GObject *object) } static CoglTexture * -_cogl_atlas_texture_create_sub_texture (CoglTexture *full_texture, - const CoglRectangleMapEntry *rectangle) +_cogl_atlas_texture_create_sub_texture (CoglTexture *full_texture, + const MtkRectangle *rectangle) { CoglContext *ctx = cogl_texture_get_context (full_texture); /* Create a subtexture for the given rectangle not including the @@ -92,9 +92,9 @@ _cogl_atlas_texture_create_sub_texture (CoglTexture *full_texture, } static void -_cogl_atlas_texture_update_position_cb (void *user_data, - CoglTexture *new_texture, - const CoglRectangleMapEntry *rectangle) +_cogl_atlas_texture_update_position_cb (void *user_data, + CoglTexture *new_texture, + const MtkRectangle *rectangle) { CoglAtlasTexture *atlas_tex = user_data; @@ -110,7 +110,7 @@ _cogl_atlas_texture_update_position_cb (void *user_data, static void _cogl_atlas_texture_pre_reorganize_foreach_cb - (const CoglRectangleMapEntry *entry, + (const MtkRectangle *entry, void *rectangle_data, void *user_data) { @@ -154,7 +154,7 @@ typedef struct } CoglAtlasTextureGetRectanglesData; static void -_cogl_atlas_texture_get_rectangles_cb (const CoglRectangleMapEntry *entry, +_cogl_atlas_texture_get_rectangles_cb (const MtkRectangle *entry, void *rectangle_data, void *user_data) { diff --git a/cogl/cogl/cogl-atlas.c b/cogl/cogl/cogl-atlas.c index f53502788..a6c8b8366 100644 --- a/cogl/cogl/cogl-atlas.c +++ b/cogl/cogl/cogl-atlas.c @@ -106,8 +106,8 @@ typedef struct _CoglAtlasRepositionData /* The current user data for this texture */ void *user_data; /* The old and new positions of the texture */ - CoglRectangleMapEntry old_position; - CoglRectangleMapEntry new_position; + MtkRectangle old_position; + MtkRectangle new_position; } CoglAtlasRepositionData; static void @@ -165,9 +165,9 @@ typedef struct _CoglAtlasGetRectanglesData } CoglAtlasGetRectanglesData; static void -_cogl_atlas_get_rectangles_cb (const CoglRectangleMapEntry *rectangle, - void *rect_data, - void *user_data) +_cogl_atlas_get_rectangles_cb (const MtkRectangle *rectangle, + void *rect_data, + void *user_data) { CoglAtlasGetRectanglesData *data = user_data; @@ -393,7 +393,7 @@ cogl_atlas_reserve_space (CoglAtlas *atlas, CoglTexture *new_tex; unsigned int map_width = 0, map_height = 0; gboolean ret; - CoglRectangleMapEntry new_position; + MtkRectangle new_position; /* Check if we can fit the rectangle into the existing map */ if (atlas->map && @@ -556,8 +556,8 @@ cogl_atlas_reserve_space (CoglAtlas *atlas, } void -_cogl_atlas_remove (CoglAtlas *atlas, - const CoglRectangleMapEntry *rectangle) +_cogl_atlas_remove (CoglAtlas *atlas, + const MtkRectangle *rectangle) { _cogl_rectangle_map_remove (atlas->map, rectangle); diff --git a/cogl/cogl/cogl-atlas.h b/cogl/cogl/cogl-atlas.h index 4e712c997..d2f23e0de 100644 --- a/cogl/cogl/cogl-atlas.h +++ b/cogl/cogl/cogl-atlas.h @@ -32,9 +32,9 @@ #include "cogl/cogl-texture.h" typedef void -(* CoglAtlasUpdatePositionCallback) (void *user_data, - CoglTexture *new_texture, - const CoglRectangleMapEntry *rect); +(* CoglAtlasUpdatePositionCallback) (void *user_data, + CoglTexture *new_texture, + const MtkRectangle *rect); typedef enum { @@ -83,8 +83,8 @@ cogl_atlas_reserve_space (CoglAtlas *atlas, void *user_data); void -_cogl_atlas_remove (CoglAtlas *atlas, - const CoglRectangleMapEntry *rectangle); +_cogl_atlas_remove (CoglAtlas *atlas, + const MtkRectangle *rectangle); CoglTexture * _cogl_atlas_copy_rectangle (CoglAtlas *atlas, diff --git a/cogl/cogl/cogl-rectangle-map.c b/cogl/cogl/cogl-rectangle-map.c index ac0a587df..df389aaa5 100644 --- a/cogl/cogl/cogl-rectangle-map.c +++ b/cogl/cogl/cogl-rectangle-map.c @@ -79,7 +79,7 @@ struct _CoglRectangleMapNode { CoglRectangleMapNodeType type; - CoglRectangleMapEntry rectangle; + MtkRectangle rectangle; unsigned int largest_gap; @@ -261,10 +261,10 @@ _cogl_rectangle_map_node_split_vertically (CoglRectangleMapNode *node, gboolean _cogl_rectangle_map_add (CoglRectangleMap *map, - unsigned int width, - unsigned int height, - void *data, - CoglRectangleMapEntry *rectangle) + unsigned int width, + unsigned int height, + void *data, + MtkRectangle *rectangle) { unsigned int rectangle_size = width * height; /* Stack of nodes to search in */ @@ -379,8 +379,8 @@ _cogl_rectangle_map_add (CoglRectangleMap *map, } void -_cogl_rectangle_map_remove (CoglRectangleMap *map, - const CoglRectangleMapEntry *rectangle) +_cogl_rectangle_map_remove (CoglRectangleMap *map, + const MtkRectangle *rectangle) { CoglRectangleMapNode *node = map->root; unsigned int rectangle_size = rectangle->width * rectangle->height; diff --git a/cogl/cogl/cogl-rectangle-map.h b/cogl/cogl/cogl-rectangle-map.h index d1a69a2f5..8d95178dc 100644 --- a/cogl/cogl/cogl-rectangle-map.h +++ b/cogl/cogl/cogl-rectangle-map.h @@ -31,19 +31,13 @@ #include #include "cogl/cogl-types.h" +#include "mtk/mtk.h" typedef struct _CoglRectangleMap CoglRectangleMap; -typedef struct _CoglRectangleMapEntry CoglRectangleMapEntry; -typedef void (* CoglRectangleMapCallback) (const CoglRectangleMapEntry *entry, - void *rectangle_data, - void *user_data); - -struct _CoglRectangleMapEntry -{ - unsigned int x, y; - unsigned int width, height; -}; +typedef void (* CoglRectangleMapCallback) (const MtkRectangle *entry, + void *rectangle_data, + void *user_data); CoglRectangleMap * _cogl_rectangle_map_new (unsigned int width, @@ -52,14 +46,14 @@ _cogl_rectangle_map_new (unsigned int width, gboolean _cogl_rectangle_map_add (CoglRectangleMap *map, - unsigned int width, - unsigned int height, - void *data, - CoglRectangleMapEntry *rectangle); + unsigned int width, + unsigned int height, + void *data, + MtkRectangle *rectangle); void -_cogl_rectangle_map_remove (CoglRectangleMap *map, - const CoglRectangleMapEntry *rectangle); +_cogl_rectangle_map_remove (CoglRectangleMap *map, + const MtkRectangle *rectangle); unsigned int _cogl_rectangle_map_get_width (CoglRectangleMap *map);