Add shell_texture_cache_pixbufs_equal
Mutter is currently creating separate pixbufs for window icons; use this to analyze them.
This commit is contained in:
parent
1a834f7d8b
commit
926643b025
@ -1236,6 +1236,35 @@ shell_texture_cache_evict_recent_thumbnail (ShellTextureCache *cache,
|
||||
shell_texture_cache_evict_thumbnail (cache, gtk_recent_info_get_uri (info));
|
||||
}
|
||||
|
||||
static size_t
|
||||
pixbuf_byte_size (GdkPixbuf *pixbuf)
|
||||
{
|
||||
/* This bit translated from gtk+/gdk-pixbuf/gdk-pixbuf.c:gdk_pixbuf_copy. The comment
|
||||
* there was:
|
||||
*
|
||||
* Calculate a semi-exact size. Here we copy with full rowstrides;
|
||||
* maybe we should copy each row individually with the minimum
|
||||
* rowstride?
|
||||
*/
|
||||
return (gdk_pixbuf_get_height (pixbuf) - 1) * gdk_pixbuf_get_rowstride (pixbuf) +
|
||||
+ gdk_pixbuf_get_width (pixbuf) * ((gdk_pixbuf_get_n_channels (pixbuf)* gdk_pixbuf_get_bits_per_sample (pixbuf) + 7) / 8);
|
||||
}
|
||||
|
||||
/**
|
||||
* shell_texture_cache_pixbuf_equal:
|
||||
*
|
||||
* Returns: %TRUE iff the given pixbufs are bytewise-equal
|
||||
*/
|
||||
gboolean
|
||||
shell_texture_cache_pixbuf_equal (ShellTextureCache *cache, GdkPixbuf *a, GdkPixbuf *b)
|
||||
{
|
||||
size_t size_a = pixbuf_byte_size (a);
|
||||
size_t size_b = pixbuf_byte_size (b);
|
||||
if (size_a != size_b)
|
||||
return FALSE;
|
||||
return memcmp (gdk_pixbuf_get_pixels (a), gdk_pixbuf_get_pixels (b), size_a) == 0;
|
||||
}
|
||||
|
||||
static ShellTextureCache *instance = NULL;
|
||||
|
||||
/**
|
||||
|
@ -79,4 +79,6 @@ ClutterActor *shell_texture_cache_load_uri_sync (ShellTextureCache *cache,
|
||||
int available_height,
|
||||
GError **error);
|
||||
|
||||
gboolean shell_texture_cache_pixbuf_equal (ShellTextureCache *cache, GdkPixbuf *a, GdkPixbuf *b);
|
||||
|
||||
#endif /* __SHELL_TEXTURE_CACHE_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user