Simplify the gtk_snapshot_icon_texture API
Instead of passing the color matrix in from the outside, just pass a boolean and set up the matrix internally.
This commit is contained in:
@@ -609,38 +609,18 @@ gtk_icon_helper_snapshot (GtkIconHelper *self,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkCssStyle *style;
|
||||
GdkTexture *texture;
|
||||
graphene_matrix_t matrix;
|
||||
graphene_vec4_t offset;
|
||||
|
||||
style = gtk_css_node_get_style (self->node);
|
||||
|
||||
gtk_icon_helper_ensure_texture (self);
|
||||
texture = self->texture;
|
||||
if (texture == NULL)
|
||||
if (self->texture == NULL)
|
||||
return;
|
||||
|
||||
if (self->texture_is_symbolic)
|
||||
{
|
||||
GdkRGBA fg, sc, wc, ec;
|
||||
|
||||
gtk_icon_theme_lookup_symbolic_colors (style, &fg, &sc, &wc, &ec);
|
||||
|
||||
graphene_matrix_init_from_float (&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 (&offset, fg.red, fg.green, fg.blue, 0);
|
||||
}
|
||||
|
||||
gtk_css_style_snapshot_icon_texture (style,
|
||||
snapshot,
|
||||
texture,
|
||||
self->texture,
|
||||
self->texture_scale,
|
||||
self->texture_is_symbolic ? &matrix : NULL,
|
||||
self->texture_is_symbolic ? &offset : NULL);
|
||||
self->texture_is_symbolic);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
||||
@@ -264,12 +264,11 @@ gtk_css_style_render_icon_get_extents (GtkCssStyle *style,
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_style_snapshot_icon_texture (GtkCssStyle *style,
|
||||
GtkSnapshot *snapshot,
|
||||
GdkTexture *texture,
|
||||
double texture_scale,
|
||||
graphene_matrix_t *color_matrix,
|
||||
graphene_vec4_t * color_offset)
|
||||
gtk_css_style_snapshot_icon_texture (GtkCssStyle *style,
|
||||
GtkSnapshot *snapshot,
|
||||
GdkTexture *texture,
|
||||
double texture_scale,
|
||||
gboolean recolor)
|
||||
{
|
||||
const GtkCssValue *shadows_value, *transform_value, *filter_value;
|
||||
graphene_matrix_t transform_matrix;
|
||||
@@ -295,8 +294,24 @@ gtk_css_style_snapshot_icon_texture (GtkCssStyle *style,
|
||||
|
||||
has_shadow = gtk_css_shadows_value_push_snapshot (shadows_value, snapshot);
|
||||
|
||||
if (color_matrix)
|
||||
gtk_snapshot_push_color_matrix (snapshot, color_matrix, color_offset, "Recoloring Icon");
|
||||
if (recolor)
|
||||
{
|
||||
graphene_matrix_t color_matrix;
|
||||
graphene_vec4_t color_offset;
|
||||
GdkRGBA fg, sc, wc, ec;
|
||||
|
||||
gtk_icon_theme_lookup_symbolic_colors (style, &fg, &sc, &wc, &ec);
|
||||
|
||||
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, "Recoloring Icon");
|
||||
}
|
||||
|
||||
if (graphene_matrix_is_identity (&transform_matrix))
|
||||
{
|
||||
@@ -322,7 +337,7 @@ gtk_css_style_snapshot_icon_texture (GtkCssStyle *style,
|
||||
gtk_snapshot_pop (snapshot);
|
||||
}
|
||||
|
||||
if (color_matrix)
|
||||
if (recolor)
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
if (has_shadow)
|
||||
|
||||
@@ -51,8 +51,7 @@ void gtk_css_style_snapshot_icon_texture (GtkCssStyle *style,
|
||||
GtkSnapshot *snapshot,
|
||||
GdkTexture *texture,
|
||||
double texture_scale,
|
||||
graphene_matrix_t * color_matrix,
|
||||
graphene_vec4_t * color_offset);
|
||||
gboolean recolor);
|
||||
|
||||
void gtk_css_style_render_icon_get_extents (GtkCssStyle *style,
|
||||
GdkRectangle *extents,
|
||||
|
||||
@@ -1510,7 +1510,7 @@ gtk_snapshot_render_icon (GtkSnapshot *snapshot,
|
||||
snapshot,
|
||||
texture,
|
||||
1,
|
||||
NULL, NULL);
|
||||
FALSE);
|
||||
gtk_snapshot_offset (snapshot, -x, -y);
|
||||
g_object_unref (texture);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user