1
0
Fork 0

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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3909>
This commit is contained in:
Bilal Elmoussaoui 2024-07-26 18:42:54 +02:00 committed by Marge Bot
parent 1f255be055
commit b035350ffd
7 changed files with 41 additions and 47 deletions

View file

@ -184,9 +184,9 @@ cogl_pango_glyph_cache_free (CoglPangoGlyphCache *cache)
} }
static void static void
cogl_pango_glyph_cache_update_position_cb (void *user_data, cogl_pango_glyph_cache_update_position_cb (void *user_data,
CoglTexture *new_texture, CoglTexture *new_texture,
const CoglRectangleMapEntry *rect) const MtkRectangle *rect)
{ {
CoglPangoGlyphCacheValue *value = user_data; CoglPangoGlyphCacheValue *value = user_data;
float tex_width, tex_height; float tex_width, tex_height;

View file

@ -46,7 +46,7 @@ struct _CoglAtlasTexture
/* The rectangle that was used to add this texture to the /* The rectangle that was used to add this texture to the
atlas. This includes the 1-pixel border */ 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 /* 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 an atlas then this will be NULL. A reference is taken on the

View file

@ -77,8 +77,8 @@ cogl_atlas_texture_dispose (GObject *object)
} }
static CoglTexture * static CoglTexture *
_cogl_atlas_texture_create_sub_texture (CoglTexture *full_texture, _cogl_atlas_texture_create_sub_texture (CoglTexture *full_texture,
const CoglRectangleMapEntry *rectangle) const MtkRectangle *rectangle)
{ {
CoglContext *ctx = cogl_texture_get_context (full_texture); CoglContext *ctx = cogl_texture_get_context (full_texture);
/* Create a subtexture for the given rectangle not including the /* 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 static void
_cogl_atlas_texture_update_position_cb (void *user_data, _cogl_atlas_texture_update_position_cb (void *user_data,
CoglTexture *new_texture, CoglTexture *new_texture,
const CoglRectangleMapEntry *rectangle) const MtkRectangle *rectangle)
{ {
CoglAtlasTexture *atlas_tex = user_data; CoglAtlasTexture *atlas_tex = user_data;
@ -110,7 +110,7 @@ _cogl_atlas_texture_update_position_cb (void *user_data,
static void static void
_cogl_atlas_texture_pre_reorganize_foreach_cb _cogl_atlas_texture_pre_reorganize_foreach_cb
(const CoglRectangleMapEntry *entry, (const MtkRectangle *entry,
void *rectangle_data, void *rectangle_data,
void *user_data) void *user_data)
{ {
@ -154,7 +154,7 @@ typedef struct
} CoglAtlasTextureGetRectanglesData; } CoglAtlasTextureGetRectanglesData;
static void static void
_cogl_atlas_texture_get_rectangles_cb (const CoglRectangleMapEntry *entry, _cogl_atlas_texture_get_rectangles_cb (const MtkRectangle *entry,
void *rectangle_data, void *rectangle_data,
void *user_data) void *user_data)
{ {

View file

@ -106,8 +106,8 @@ typedef struct _CoglAtlasRepositionData
/* The current user data for this texture */ /* The current user data for this texture */
void *user_data; void *user_data;
/* The old and new positions of the texture */ /* The old and new positions of the texture */
CoglRectangleMapEntry old_position; MtkRectangle old_position;
CoglRectangleMapEntry new_position; MtkRectangle new_position;
} CoglAtlasRepositionData; } CoglAtlasRepositionData;
static void static void
@ -165,9 +165,9 @@ typedef struct _CoglAtlasGetRectanglesData
} CoglAtlasGetRectanglesData; } CoglAtlasGetRectanglesData;
static void static void
_cogl_atlas_get_rectangles_cb (const CoglRectangleMapEntry *rectangle, _cogl_atlas_get_rectangles_cb (const MtkRectangle *rectangle,
void *rect_data, void *rect_data,
void *user_data) void *user_data)
{ {
CoglAtlasGetRectanglesData *data = user_data; CoglAtlasGetRectanglesData *data = user_data;
@ -393,7 +393,7 @@ cogl_atlas_reserve_space (CoglAtlas *atlas,
CoglTexture *new_tex; CoglTexture *new_tex;
unsigned int map_width = 0, map_height = 0; unsigned int map_width = 0, map_height = 0;
gboolean ret; gboolean ret;
CoglRectangleMapEntry new_position; MtkRectangle new_position;
/* Check if we can fit the rectangle into the existing map */ /* Check if we can fit the rectangle into the existing map */
if (atlas->map && if (atlas->map &&
@ -556,8 +556,8 @@ cogl_atlas_reserve_space (CoglAtlas *atlas,
} }
void void
_cogl_atlas_remove (CoglAtlas *atlas, _cogl_atlas_remove (CoglAtlas *atlas,
const CoglRectangleMapEntry *rectangle) const MtkRectangle *rectangle)
{ {
_cogl_rectangle_map_remove (atlas->map, rectangle); _cogl_rectangle_map_remove (atlas->map, rectangle);

View file

@ -32,9 +32,9 @@
#include "cogl/cogl-texture.h" #include "cogl/cogl-texture.h"
typedef void typedef void
(* CoglAtlasUpdatePositionCallback) (void *user_data, (* CoglAtlasUpdatePositionCallback) (void *user_data,
CoglTexture *new_texture, CoglTexture *new_texture,
const CoglRectangleMapEntry *rect); const MtkRectangle *rect);
typedef enum typedef enum
{ {
@ -83,8 +83,8 @@ cogl_atlas_reserve_space (CoglAtlas *atlas,
void *user_data); void *user_data);
void void
_cogl_atlas_remove (CoglAtlas *atlas, _cogl_atlas_remove (CoglAtlas *atlas,
const CoglRectangleMapEntry *rectangle); const MtkRectangle *rectangle);
CoglTexture * CoglTexture *
_cogl_atlas_copy_rectangle (CoglAtlas *atlas, _cogl_atlas_copy_rectangle (CoglAtlas *atlas,

View file

@ -79,7 +79,7 @@ struct _CoglRectangleMapNode
{ {
CoglRectangleMapNodeType type; CoglRectangleMapNodeType type;
CoglRectangleMapEntry rectangle; MtkRectangle rectangle;
unsigned int largest_gap; unsigned int largest_gap;
@ -261,10 +261,10 @@ _cogl_rectangle_map_node_split_vertically (CoglRectangleMapNode *node,
gboolean gboolean
_cogl_rectangle_map_add (CoglRectangleMap *map, _cogl_rectangle_map_add (CoglRectangleMap *map,
unsigned int width, unsigned int width,
unsigned int height, unsigned int height,
void *data, void *data,
CoglRectangleMapEntry *rectangle) MtkRectangle *rectangle)
{ {
unsigned int rectangle_size = width * height; unsigned int rectangle_size = width * height;
/* Stack of nodes to search in */ /* Stack of nodes to search in */
@ -379,8 +379,8 @@ _cogl_rectangle_map_add (CoglRectangleMap *map,
} }
void void
_cogl_rectangle_map_remove (CoglRectangleMap *map, _cogl_rectangle_map_remove (CoglRectangleMap *map,
const CoglRectangleMapEntry *rectangle) const MtkRectangle *rectangle)
{ {
CoglRectangleMapNode *node = map->root; CoglRectangleMapNode *node = map->root;
unsigned int rectangle_size = rectangle->width * rectangle->height; unsigned int rectangle_size = rectangle->width * rectangle->height;

View file

@ -31,19 +31,13 @@
#include <glib.h> #include <glib.h>
#include "cogl/cogl-types.h" #include "cogl/cogl-types.h"
#include "mtk/mtk.h"
typedef struct _CoglRectangleMap CoglRectangleMap; typedef struct _CoglRectangleMap CoglRectangleMap;
typedef struct _CoglRectangleMapEntry CoglRectangleMapEntry;
typedef void (* CoglRectangleMapCallback) (const CoglRectangleMapEntry *entry, typedef void (* CoglRectangleMapCallback) (const MtkRectangle *entry,
void *rectangle_data, void *rectangle_data,
void *user_data); void *user_data);
struct _CoglRectangleMapEntry
{
unsigned int x, y;
unsigned int width, height;
};
CoglRectangleMap * CoglRectangleMap *
_cogl_rectangle_map_new (unsigned int width, _cogl_rectangle_map_new (unsigned int width,
@ -52,14 +46,14 @@ _cogl_rectangle_map_new (unsigned int width,
gboolean gboolean
_cogl_rectangle_map_add (CoglRectangleMap *map, _cogl_rectangle_map_add (CoglRectangleMap *map,
unsigned int width, unsigned int width,
unsigned int height, unsigned int height,
void *data, void *data,
CoglRectangleMapEntry *rectangle); MtkRectangle *rectangle);
void void
_cogl_rectangle_map_remove (CoglRectangleMap *map, _cogl_rectangle_map_remove (CoglRectangleMap *map,
const CoglRectangleMapEntry *rectangle); const MtkRectangle *rectangle);
unsigned int unsigned int
_cogl_rectangle_map_get_width (CoglRectangleMap *map); _cogl_rectangle_map_get_width (CoglRectangleMap *map);