forked from AuroraMiddleware/gtk
GtkIconPaintable: Always recolor when snapshotting.
It never makes sense to paint a texture that needs recoloring. If you call the regular snapshot on a symbolic texture we just use the default recoloring colors. To support this we also change gtk_css_style_snapshot_icon_paintable() to call gtk_icon_paintable_snapshot_with_colors() for IconPaintables so that we get the correct colors, and we make it not emit the color matrix. Since we now rely on the icon to do the recoloring we also drop the recolor argument in gtk_icon_paintable_snapshot_with_colors() as its not needed anymore.
This commit is contained in:
parent
c691399a80
commit
021aaef824
@ -223,8 +223,7 @@ gtk_icon_helper_paintable_snapshot (GdkPaintable *paintable,
|
||||
gtk_css_style_snapshot_icon_paintable (style,
|
||||
snapshot,
|
||||
self->paintable,
|
||||
w, h,
|
||||
self->texture_is_symbolic);
|
||||
w, h);
|
||||
gtk_snapshot_restore (snapshot);
|
||||
}
|
||||
else
|
||||
@ -232,8 +231,7 @@ gtk_icon_helper_paintable_snapshot (GdkPaintable *paintable,
|
||||
gtk_css_style_snapshot_icon_paintable (style,
|
||||
snapshot,
|
||||
self->paintable,
|
||||
w, h,
|
||||
self->texture_is_symbolic);
|
||||
w, h);
|
||||
|
||||
}
|
||||
|
||||
@ -280,8 +278,7 @@ gtk_icon_helper_paintable_snapshot (GdkPaintable *paintable,
|
||||
gtk_css_style_snapshot_icon_paintable (style,
|
||||
snapshot,
|
||||
self->paintable,
|
||||
w, h,
|
||||
self->texture_is_symbolic);
|
||||
w, h);
|
||||
gtk_snapshot_restore (snapshot);
|
||||
}
|
||||
else
|
||||
@ -289,8 +286,7 @@ gtk_icon_helper_paintable_snapshot (GdkPaintable *paintable,
|
||||
gtk_css_style_snapshot_icon_paintable (style,
|
||||
snapshot,
|
||||
self->paintable,
|
||||
w, h,
|
||||
self->texture_is_symbolic);
|
||||
w, h);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -3598,25 +3598,9 @@ icon_paintable_snapshot (GdkPaintable *paintable,
|
||||
double height)
|
||||
{
|
||||
GtkIconPaintable *icon = GTK_ICON_PAINTABLE (paintable);
|
||||
GdkTexture *texture;
|
||||
|
||||
texture = gtk_icon_paintable_download_texture (icon, NULL);
|
||||
if (texture)
|
||||
{
|
||||
if (icon->desired_scale != 1)
|
||||
{
|
||||
gtk_snapshot_save (snapshot);
|
||||
gtk_snapshot_scale (snapshot, 1.0 / icon->desired_scale, 1.0 / icon->desired_scale);
|
||||
}
|
||||
|
||||
gtk_snapshot_append_texture (snapshot, texture,
|
||||
&GRAPHENE_RECT_INIT (0, 0, width * icon->desired_scale, height * icon->desired_scale));
|
||||
|
||||
if (icon->desired_scale != 1)
|
||||
gtk_snapshot_restore (snapshot);
|
||||
|
||||
g_object_unref (texture);
|
||||
}
|
||||
gtk_icon_paintable_snapshot_with_colors (icon, snapshot, width, height,
|
||||
NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3754,7 +3738,7 @@ gtk_icon_paintable_new_for_file (GFile *file,
|
||||
|
||||
static GtkIconPaintable *
|
||||
gtk_icon_paintable_new_for_pixbuf (GtkIconTheme *icon_theme,
|
||||
GdkPixbuf *pixbuf)
|
||||
GdkPixbuf *pixbuf)
|
||||
{
|
||||
GtkIconPaintable *icon;
|
||||
gint width, height, max;
|
||||
|
@ -519,8 +519,7 @@ gtk_render_icon (GtkStyleContext *context,
|
||||
snapshot,
|
||||
GDK_PAINTABLE (texture),
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture),
|
||||
FALSE);
|
||||
gdk_texture_get_height (texture));
|
||||
node = gtk_snapshot_free_to_node (snapshot);
|
||||
if (node == NULL)
|
||||
return;
|
||||
|
@ -93,11 +93,12 @@ gtk_css_style_snapshot_icon_paintable (GtkCssStyle *style,
|
||||
GtkSnapshot *snapshot,
|
||||
GdkPaintable *paintable,
|
||||
double width,
|
||||
double height,
|
||||
gboolean recolor)
|
||||
double height)
|
||||
{
|
||||
GskTransform *transform;
|
||||
gboolean has_shadow;
|
||||
gboolean is_icon_paintable;
|
||||
GdkRGBA fg, sc, wc, ec;
|
||||
|
||||
g_return_if_fail (GTK_IS_CSS_STYLE (style));
|
||||
g_return_if_fail (snapshot != NULL);
|
||||
@ -111,31 +112,19 @@ gtk_css_style_snapshot_icon_paintable (GtkCssStyle *style,
|
||||
|
||||
has_shadow = gtk_css_shadow_value_push_snapshot (style->icon->icon_shadow, snapshot);
|
||||
|
||||
if (recolor)
|
||||
{
|
||||
graphene_matrix_t color_matrix;
|
||||
graphene_vec4_t color_offset;
|
||||
GdkRGBA fg, sc, wc, ec;
|
||||
is_icon_paintable = GTK_IS_ICON_PAINTABLE (paintable);
|
||||
if (is_icon_paintable)
|
||||
gtk_icon_theme_lookup_symbolic_colors (style, &fg, &sc, &wc, &ec);
|
||||
|
||||
gtk_icon_theme_lookup_symbolic_colors (style, &fg, &sc, &wc, &ec);
|
||||
|
||||
if (fg.alpha == 0.0f)
|
||||
goto transparent;
|
||||
|
||||
graphene_matrix_init_from_float (&color_matrix, (float[16]) {
|
||||
sc.red - fg.red, sc.green - fg.green, sc.blue - fg.blue, 0,
|
||||
wc.red - fg.red, wc.green - fg.green, wc.blue - fg.blue, 0,
|
||||
ec.red - fg.red, ec.green - fg.green, ec.blue - fg.blue, 0,
|
||||
0, 0, 0, fg.alpha
|
||||
});
|
||||
graphene_vec4_init (&color_offset, fg.red, fg.green, fg.blue, 0);
|
||||
|
||||
gtk_snapshot_push_color_matrix (snapshot, &color_matrix, &color_offset);
|
||||
}
|
||||
if (fg.alpha == 0.0f)
|
||||
goto transparent;
|
||||
|
||||
if (transform == NULL)
|
||||
{
|
||||
gdk_paintable_snapshot (paintable, snapshot, width, height);
|
||||
if (is_icon_paintable)
|
||||
gtk_icon_paintable_snapshot_with_colors (GTK_ICON_PAINTABLE (paintable), snapshot, width, height, &fg, &sc, &wc, &ec);
|
||||
else
|
||||
gdk_paintable_snapshot (paintable, snapshot, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -146,14 +135,14 @@ gtk_css_style_snapshot_icon_paintable (GtkCssStyle *style,
|
||||
gtk_snapshot_transform (snapshot, transform);
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (- width / 2.0, - height / 2.0));
|
||||
|
||||
gdk_paintable_snapshot (paintable, snapshot, width, height);
|
||||
if (is_icon_paintable)
|
||||
gtk_icon_paintable_snapshot_with_colors (GTK_ICON_PAINTABLE (paintable), snapshot, width, height, &fg, &sc, &wc, &ec);
|
||||
else
|
||||
gdk_paintable_snapshot (paintable, snapshot, width, height);
|
||||
|
||||
gtk_snapshot_restore (snapshot);
|
||||
}
|
||||
|
||||
if (recolor)
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
transparent:
|
||||
if (has_shadow)
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
@ -38,8 +38,7 @@ void gtk_css_style_snapshot_icon_paintable (GtkCssStyle *style,
|
||||
GtkSnapshot *snapshot,
|
||||
GdkPaintable *paintable,
|
||||
double width,
|
||||
double height,
|
||||
gboolean recolor);
|
||||
double height);
|
||||
|
||||
void gtk_css_style_render_icon_get_extents (GtkCssStyle *style,
|
||||
GdkRectangle *extents,
|
||||
|
Loading…
Reference in New Issue
Block a user