summaryrefslogtreecommitdiff
path: root/gtk/gtkthemingengine.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2011-06-09 04:50:12 +0200
committerBenjamin Otte <otte@redhat.com>2011-06-09 05:51:54 +0200
commit88026c507351d620ffe9008d554cf4b36ac4068a (patch)
treec511864c132efea6ea308ae5737978ea246f4d77 /gtk/gtkthemingengine.c
parent9affa9fc4d05bed45a5b9c4ad98a92503674f51a (diff)
downloadgtk+-88026c507351d620ffe9008d554cf4b36ac4068a.tar.gz
themingengine: Don't modify pattern
Instead, scale/unscale the cairo_t.
Diffstat (limited to 'gtk/gtkthemingengine.c')
-rw-r--r--gtk/gtkthemingengine.c42
1 files changed, 5 insertions, 37 deletions
diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c
index 6f0f392dba..9cb7e33728 100644
--- a/gtk/gtkthemingengine.c
+++ b/gtk/gtkthemingengine.c
@@ -1490,32 +1490,6 @@ _cairo_uneven_frame (cairo_t *cr,
SIDE_ALL);
}
-/* Set the appropriate matrix for
- * patterns coming from the style context
- */
-static void
-style_pattern_set_matrix (cairo_pattern_t *pattern,
- gdouble width,
- gdouble height)
-{
- cairo_matrix_t matrix;
- gint w, h;
-
- if (cairo_pattern_get_type (pattern) == CAIRO_PATTERN_TYPE_SURFACE)
- {
- cairo_surface_t *surface;
-
- cairo_pattern_get_surface (pattern, &surface);
- w = cairo_image_surface_get_width (surface);
- h = cairo_image_surface_get_height (surface);
- }
- else
- w = h = 1;
-
- cairo_matrix_init_scale (&matrix, (gdouble) w / width, (gdouble) h / height);
- cairo_pattern_set_matrix (pattern, &matrix);
-}
-
static void
render_background_internal (GtkThemingEngine *engine,
cairo_t *cr,
@@ -1537,7 +1511,6 @@ render_background_internal (GtkThemingEngine *engine,
gint border_width;
GtkBorderStyle border_style;
gdouble mat_w, mat_h;
- cairo_matrix_t identity;
/* Use unmodified size for pattern scaling */
mat_w = width;
@@ -1545,8 +1518,6 @@ render_background_internal (GtkThemingEngine *engine,
flags = gtk_theming_engine_get_state (engine);
- cairo_matrix_init_identity (&identity);
-
gtk_theming_engine_get_background_color (engine, flags, &bg_color);
gtk_theming_engine_get_border (engine, flags, &border);
@@ -1703,12 +1674,11 @@ render_background_internal (GtkThemingEngine *engine,
0, 0, width, height,
SIDE_ALL);
- style_pattern_set_matrix (other_pattern, mat_w, mat_h);
+ cairo_scale (cr, mat_w, mat_h);
cairo_set_source (cr, other_pattern);
+ cairo_scale (cr, 1.0 / mat_w, 1.0 / mat_h);
cairo_fill_preserve (cr);
- cairo_pattern_set_matrix (other_pattern, &identity);
-
/* Set alpha for posterior drawing
* of the target pattern
*/
@@ -1789,8 +1759,9 @@ render_background_internal (GtkThemingEngine *engine,
SIDE_ALL);
if (pattern)
{
- style_pattern_set_matrix (pattern, mat_w, mat_h);
+ cairo_scale (cr, mat_w, mat_h);
cairo_set_source (cr, pattern);
+ cairo_scale (cr, 1.0 / mat_w, 1.0 / mat_h);
}
else
gdk_cairo_set_source_rgba (cr, &bg_color);
@@ -1826,10 +1797,7 @@ render_background_internal (GtkThemingEngine *engine,
}
if (pattern)
- {
- cairo_pattern_set_matrix (pattern, &identity);
- cairo_pattern_destroy (pattern);
- }
+ cairo_pattern_destroy (pattern);
cairo_restore (cr);
}