iconfactory: cache/invalidate pixbufs according to the effect
The state of the widget is not enough now to cache the pixbuf - we also have to take into consideration the image effect itself, since the state on the actual GtkStyleContext we use might not change, e.g. because the change was on a parent context. https://bugzilla.gnome.org/show_bug.cgi?id=705443
This commit is contained in:
@ -30,6 +30,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "gtkcssenumvalueprivate.h"
|
||||||
#include "gtkiconfactory.h"
|
#include "gtkiconfactory.h"
|
||||||
#include "gtkiconcache.h"
|
#include "gtkiconcache.h"
|
||||||
#include "gtkdebug.h"
|
#include "gtkdebug.h"
|
||||||
@ -42,6 +43,7 @@
|
|||||||
#include "gtkbuilderprivate.h"
|
#include "gtkbuilderprivate.h"
|
||||||
#include "gtktypebuiltins.h"
|
#include "gtktypebuiltins.h"
|
||||||
#include "gtkstyle.h"
|
#include "gtkstyle.h"
|
||||||
|
#include "gtkstylecontextprivate.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SECTION:gtkiconfactory
|
* SECTION:gtkiconfactory
|
||||||
@ -993,13 +995,15 @@ static GdkPixbuf *find_in_cache (GtkIconSet *icon_set,
|
|||||||
GtkTextDirection direction,
|
GtkTextDirection direction,
|
||||||
GtkStateType state,
|
GtkStateType state,
|
||||||
GtkIconSize size,
|
GtkIconSize size,
|
||||||
gint scale);
|
gint scale,
|
||||||
|
GtkCssImageEffect effect);
|
||||||
static void add_to_cache (GtkIconSet *icon_set,
|
static void add_to_cache (GtkIconSet *icon_set,
|
||||||
GtkStyleContext *style_context,
|
GtkStyleContext *style_context,
|
||||||
GtkTextDirection direction,
|
GtkTextDirection direction,
|
||||||
GtkStateType state,
|
GtkStateType state,
|
||||||
GtkIconSize size,
|
GtkIconSize size,
|
||||||
gint scale,
|
gint scale,
|
||||||
|
GtkCssImageEffect effect,
|
||||||
GdkPixbuf *pixbuf);
|
GdkPixbuf *pixbuf);
|
||||||
/* Clear icon set contents, drop references to all contained
|
/* Clear icon set contents, drop references to all contained
|
||||||
* GdkPixbuf objects and forget all GtkIconSources. Used to
|
* GdkPixbuf objects and forget all GtkIconSources. Used to
|
||||||
@ -1512,6 +1516,7 @@ gtk_icon_set_render_icon_pixbuf_for_scale (GtkIconSet *icon_set,
|
|||||||
GtkStateFlags flags = 0;
|
GtkStateFlags flags = 0;
|
||||||
GtkStateType state;
|
GtkStateType state;
|
||||||
GtkTextDirection direction;
|
GtkTextDirection direction;
|
||||||
|
GtkCssImageEffect effect;
|
||||||
|
|
||||||
g_return_val_if_fail (icon_set != NULL, NULL);
|
g_return_val_if_fail (icon_set != NULL, NULL);
|
||||||
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
|
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
|
||||||
@ -1528,9 +1533,12 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
|||||||
direction = gtk_style_context_get_direction (context);
|
direction = gtk_style_context_get_direction (context);
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||||
|
|
||||||
|
effect = _gtk_css_image_effect_value_get
|
||||||
|
(_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_GTK_IMAGE_EFFECT));
|
||||||
|
|
||||||
if (icon_set->sources)
|
if (icon_set->sources)
|
||||||
{
|
{
|
||||||
icon = find_in_cache (icon_set, context, direction, state, size, scale);
|
icon = find_in_cache (icon_set, context, direction, state, size, scale, effect);
|
||||||
if (icon)
|
if (icon)
|
||||||
return g_object_ref (icon);
|
return g_object_ref (icon);
|
||||||
}
|
}
|
||||||
@ -1542,7 +1550,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS;
|
|||||||
if (icon == NULL)
|
if (icon == NULL)
|
||||||
icon = render_fallback_image (context, direction, state, size);
|
icon = render_fallback_image (context, direction, state, size);
|
||||||
|
|
||||||
add_to_cache (icon_set, context, direction, state, size, scale, icon);
|
add_to_cache (icon_set, context, direction, state, size, scale, effect, icon);
|
||||||
|
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
@ -2466,6 +2474,7 @@ struct _CachedIcon
|
|||||||
GtkStateType state;
|
GtkStateType state;
|
||||||
GtkIconSize size;
|
GtkIconSize size;
|
||||||
gint scale;
|
gint scale;
|
||||||
|
GtkCssImageEffect effect;
|
||||||
|
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
};
|
};
|
||||||
@ -2495,7 +2504,8 @@ find_in_cache (GtkIconSet *icon_set,
|
|||||||
GtkTextDirection direction,
|
GtkTextDirection direction,
|
||||||
GtkStateType state,
|
GtkStateType state,
|
||||||
GtkIconSize size,
|
GtkIconSize size,
|
||||||
gint scale)
|
gint scale,
|
||||||
|
GtkCssImageEffect effect)
|
||||||
{
|
{
|
||||||
GSList *tmp_list;
|
GSList *tmp_list;
|
||||||
GSList *prev;
|
GSList *prev;
|
||||||
@ -2511,6 +2521,7 @@ find_in_cache (GtkIconSet *icon_set,
|
|||||||
if (icon->style == style_context &&
|
if (icon->style == style_context &&
|
||||||
icon->direction == direction &&
|
icon->direction == direction &&
|
||||||
icon->state == state &&
|
icon->state == state &&
|
||||||
|
icon->effect == effect &&
|
||||||
(size == (GtkIconSize)-1 || icon->size == size))
|
(size == (GtkIconSize)-1 || icon->size == size))
|
||||||
{
|
{
|
||||||
if (prev)
|
if (prev)
|
||||||
@ -2538,6 +2549,7 @@ add_to_cache (GtkIconSet *icon_set,
|
|||||||
GtkStateType state,
|
GtkStateType state,
|
||||||
GtkIconSize size,
|
GtkIconSize size,
|
||||||
gint scale,
|
gint scale,
|
||||||
|
GtkCssImageEffect effect,
|
||||||
GdkPixbuf *pixbuf)
|
GdkPixbuf *pixbuf)
|
||||||
{
|
{
|
||||||
CachedIcon *icon;
|
CachedIcon *icon;
|
||||||
@ -2555,6 +2567,7 @@ add_to_cache (GtkIconSet *icon_set,
|
|||||||
icon->state = state;
|
icon->state = state;
|
||||||
icon->size = size;
|
icon->size = size;
|
||||||
icon->scale = scale;
|
icon->scale = scale;
|
||||||
|
icon->effect = effect;
|
||||||
icon->pixbuf = pixbuf;
|
icon->pixbuf = pixbuf;
|
||||||
attach_to_style (icon_set, icon->style);
|
attach_to_style (icon_set, icon->style);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user