forked from AuroraMiddleware/gtk
icon theme: Add a texture cache
Return cached textures for icons. This lets us avoid duplicate texture uploads for icons whose surfaces we already cache.
This commit is contained in:
parent
6c7d9c6445
commit
02db8ccd89
@ -5446,6 +5446,7 @@ gtk_icon_theme_lookup_by_gicon_for_scale
|
||||
gtk_icon_theme_load_icon
|
||||
gtk_icon_theme_load_icon_for_scale
|
||||
gtk_icon_theme_load_surface
|
||||
gtk_icon_theme_load_texture
|
||||
gtk_icon_theme_list_contexts
|
||||
gtk_icon_theme_list_icons
|
||||
gtk_icon_theme_get_icon_sizes
|
||||
|
@ -225,6 +225,7 @@ struct _GtkIconInfo
|
||||
*/
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkPixbuf *proxy_pixbuf;
|
||||
GskTexture *texture;
|
||||
GError *load_error;
|
||||
gdouble unscaled_scale;
|
||||
gdouble scale;
|
||||
@ -4004,6 +4005,40 @@ gtk_icon_info_load_icon (GtkIconInfo *icon_info,
|
||||
return icon_info->proxy_pixbuf;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_icon_info_load_texture:
|
||||
* @icon_info: a #GtkIconInfo
|
||||
*
|
||||
* Returns a texture object that can be used to render the icon
|
||||
* with GSK.
|
||||
*
|
||||
* Returns: (transfer full): the icon texture; this may be a newly
|
||||
* created texture or a new reference to an exiting texture, so you must
|
||||
* not modify the icon. Use g_object_unref() to release your
|
||||
* reference.
|
||||
*
|
||||
* Since: 3.94
|
||||
*/
|
||||
GskTexture *
|
||||
gtk_icon_info_load_texture (GtkIconInfo *icon_info)
|
||||
{
|
||||
if (!icon_info->texture)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
|
||||
icon_info->texture = gsk_texture_new_for_pixbuf (pixbuf);
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
g_object_add_weak_pointer (icon_info->texture, &icon_info->texture);
|
||||
}
|
||||
|
||||
if (icon_info->in_cache != NULL)
|
||||
ensure_in_lru_cache (icon_info->in_cache, icon_info);
|
||||
|
||||
return g_object_ref (icon_info->texture);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_icon_info_load_surface:
|
||||
* @icon_info: a #GtkIconInfo from gtk_icon_theme_lookup_icon()
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <gdk/gdk.h>
|
||||
#include <gtk/gtkstylecontext.h>
|
||||
#include <gsk/gsk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -293,6 +294,9 @@ GDK_AVAILABLE_IN_3_10
|
||||
cairo_surface_t * gtk_icon_info_load_surface (GtkIconInfo *icon_info,
|
||||
GdkWindow *for_window,
|
||||
GError **error);
|
||||
GDK_AVAILABLE_IN_3_94
|
||||
GskTexture * gtk_icon_info_load_texture (GtkIconInfo *icon_info);
|
||||
|
||||
GDK_AVAILABLE_IN_3_8
|
||||
void gtk_icon_info_load_icon_async (GtkIconInfo *icon_info,
|
||||
GCancellable *cancellable,
|
||||
|
Loading…
Reference in New Issue
Block a user