[gtk+] themingengine: Don't modify pattern
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] themingengine: Don't modify pattern
- Date: Thu, 9 Jun 2011 04:25:03 +0000 (UTC)
commit 88026c507351d620ffe9008d554cf4b36ac4068a
Author: Benjamin Otte <otte redhat com>
Date: Thu Jun 9 04:50:12 2011 +0200
themingengine: Don't modify pattern
Instead, scale/unscale the cairo_t.
gtk/gtkthemingengine.c | 42 +++++-------------------------------------
1 files changed, 5 insertions(+), 37 deletions(-)
---
diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c
index 6f0f392..9cb7e33 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]