#define MAX_FRAME_AGE 60
-typedef struct
-{
- graphene_rect_t texture_rect;
- GskGLTextureAtlas *atlas;
- GdkTexture *source_texture;
- guint accessed : 1;
- guint used : 1;
-} IconData;
-
static void
icon_data_free (gpointer p)
{
{
if (icon_data->used)
{
- const int w = icon_data->texture_rect.size.width * icon_data->atlas->width;
- const int h = icon_data->texture_rect.size.height * icon_data->atlas->height;
- gsk_gl_texture_atlas_mark_unused (icon_data->atlas, w + 2, h + 2);
+ const int width = gdk_texture_get_width (icon_data->source_texture);
+ const int height = gdk_texture_get_height (icon_data->source_texture);
+ gsk_gl_texture_atlas_mark_unused (icon_data->atlas, width + 2, height + 2);
icon_data->used = FALSE;
}
}
void
gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
GdkTexture *texture,
- int *out_texture_id,
- graphene_rect_t *out_texture_rect)
+ const IconData **out_icon_data)
{
IconData *icon_data = g_hash_table_lookup (self->icons, texture);
{
if (!icon_data->used)
{
- const int w = icon_data->texture_rect.size.width * icon_data->atlas->width;
- const int h = icon_data->texture_rect.size.height * icon_data->atlas->height;
+ const int width = gdk_texture_get_width (texture);
+ const int height = gdk_texture_get_height (texture);
- gsk_gl_texture_atlas_mark_used (icon_data->atlas, w + 2, h + 2);
+ gsk_gl_texture_atlas_mark_used (icon_data->atlas, width + 2, height + 2);
icon_data->used = TRUE;
}
icon_data->accessed = TRUE;
- *out_texture_id = icon_data->atlas->texture_id;
- *out_texture_rect = icon_data->texture_rect;
+ *out_icon_data = icon_data;
return;
}
icon_data->atlas = atlas;
icon_data->accessed = TRUE;
icon_data->used = TRUE;
+ icon_data->texture_id = atlas->texture_id;
icon_data->source_texture = g_object_ref (texture);
- graphene_rect_init (&icon_data->texture_rect,
- (float)(packed_x + 1) / atlas->width,
- (float)(packed_y + 1) / atlas->height,
- (float)width / atlas->width,
- (float)height / atlas->height);
+ icon_data->x = (float)(packed_x + 1) / atlas->width;
+ icon_data->y = (float)(packed_y + 1) / atlas->width;
+ icon_data->x2 = icon_data->x + (float)width / atlas->width;
+ icon_data->y2 = icon_data->y + (float)height / atlas->height;
g_hash_table_insert (self->icons, texture, icon_data);
gdk_gl_context_pop_debug_group (gdk_gl_context_get_current ());
- *out_texture_id = atlas->texture_id;
- *out_texture_rect = icon_data->texture_rect;
+ *out_icon_data = icon_data;
cairo_surface_destroy (surface);
int timestamp;
} GskGLIconCache;
+typedef struct
+{
+ float x, y, x2, y2;
+ GskGLTextureAtlas *atlas;
+ guint used : 1;
+ guint accessed : 1;
+ int texture_id;
+ GdkTexture *source_texture;
+} IconData;
+
GskGLIconCache * gsk_gl_icon_cache_new (GdkDisplay *display,
GskGLTextureAtlases *atlases);
GskGLIconCache * gsk_gl_icon_cache_ref (GskGLIconCache *self);
GPtrArray *removed_atlases);
void gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
GdkTexture *texture,
- int *out_texture_id,
- graphene_rect_t *out_texture_rect);
+ const IconData **out_icon_data);
#endif
GdkTexture *texture,
TextureRegion *out_region)
{
- int texture_id;
-
if (texture->width <= 128 &&
texture->height <= 128 &&
!GDK_IS_GL_TEXTURE (texture))
{
- graphene_rect_t trect;
+ const IconData *icon_data;
gsk_gl_icon_cache_lookup_or_add (self->icon_cache,
texture,
- &texture_id,
- &trect);
- out_region->x = trect.origin.x;
- out_region->y = trect.origin.y;
- out_region->x2 = out_region->x + trect.size.width;
- out_region->y2 = out_region->y + trect.size.height;
+ &icon_data);
+
+ out_region->texture_id = icon_data->texture_id;
+ out_region->x = icon_data->x;
+ out_region->y = icon_data->y;
+ out_region->x2 = icon_data->x2;
+ out_region->y2 = icon_data->y2;
}
else
{
- texture_id = gsk_gl_driver_get_texture_for_texture (self->gl_driver,
- texture,
- GL_LINEAR,
- GL_LINEAR);
+ out_region->texture_id =
+ gsk_gl_driver_get_texture_for_texture (self->gl_driver,
+ texture,
+ GL_LINEAR,
+ GL_LINEAR);
+
out_region->x = 0;
out_region->y = 0;
out_region->x2 = 1;
out_region->y2 = 1;
}
-
- out_region->texture_id = texture_id;
}
static inline void