iconhelper: Move invalidation check

Just do the invalidation check once, there's no need to do it in every
branch of the switch.

Also remove useless checks: These functions will not be called if we
already have a rendered surface.
This commit is contained in:
Benjamin Otte
2015-11-29 19:45:52 +01:00
parent 3bacffd063
commit 751a1a9926

View File

@ -546,12 +546,6 @@ ensure_surface_from_surface (GtkIconHelper *self,
GtkStyleContext *context,
cairo_surface_t *orig_surface)
{
if (!check_invalidate_surface (self, context))
return;
if (self->priv->rendered_surface)
return;
self->priv->rendered_surface =
cairo_surface_reference (orig_surface);
@ -622,12 +616,6 @@ ensure_surface_from_pixbuf (GtkIconHelper *self,
GdkPixbuf *pixbuf, *stated;
int scale;
if (!check_invalidate_surface (self, context))
return;
if (self->priv->rendered_surface)
return;
if (get_pixbuf_size (self,
context,
orig_pixbuf,
@ -657,9 +645,6 @@ ensure_surface_for_icon_set (GtkIconHelper *self,
{
gint scale;
if (!check_invalidate_surface (self, context))
return;
scale = get_scale_factor (self, context);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
@ -741,9 +726,6 @@ ensure_surface_for_gicon (GtkIconHelper *self,
GtkIconInfo *info;
GtkIconLookupFlags flags;
if (!check_invalidate_surface (self, context))
return;
icon_theme = gtk_icon_theme_get_for_screen (gtk_style_context_get_screen (context));
flags = get_icon_lookup_flags (self, context);
@ -769,6 +751,9 @@ _gtk_icon_helper_ensure_surface (GtkIconHelper *self,
GtkIconSet *icon_set;
GIcon *gicon;
if (!check_invalidate_surface (self, context))
return self->priv->rendered_surface;
switch (gtk_image_definition_get_storage_type (self->priv->def))
{
case GTK_IMAGE_SURFACE: