[gtk+/gtk-style-context] Gtk9Slice: Fix stretch rendering.
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-style-context] Gtk9Slice: Fix stretch rendering.
- Date: Wed, 1 Dec 2010 19:27:05 +0000 (UTC)
commit ed20f1669a27c8468c8ac26e0a753abf1f884fa4
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Dec 1 20:25:52 2010 +0100
Gtk9Slice: Fix stretch rendering.
"Nearest" filter used when scaling the image, so image borders
aren't blurred.
gtk/gtk9slice.c | 20 +++++++++++---------
1 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtk9slice.c b/gtk/gtk9slice.c
index 6200899..13234a8 100644
--- a/gtk/gtk9slice.c
+++ b/gtk/gtk9slice.c
@@ -192,6 +192,7 @@ render_border (cairo_t *cr,
gdouble height,
GtkSliceSideModifier modifier)
{
+ cairo_pattern_t *pattern;
cairo_matrix_t matrix;
cairo_save (cr);
@@ -199,18 +200,15 @@ render_border (cairo_t *cr,
cairo_rectangle (cr, x, y, width, height);
cairo_clip (cr);
+ pattern = cairo_pattern_create_for_surface (surface);
+
if (modifier == GTK_SLICE_REPEAT)
{
- cairo_pattern_t *pattern;
-
- pattern = cairo_pattern_create_for_surface (surface);
-
cairo_matrix_init_translate (&matrix, - x, - y);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
cairo_pattern_set_matrix (pattern, &matrix);
cairo_set_source (cr, pattern);
- cairo_pattern_destroy (pattern);
cairo_rectangle (cr, x, y, width, height);
cairo_fill (cr);
@@ -219,14 +217,16 @@ render_border (cairo_t *cr,
{
gint d;
+ /* Use nearest filter so borders aren't blurred */
+ cairo_pattern_set_filter (pattern, CAIRO_FILTER_NEAREST);
+ cairo_rectangle (cr, x, y, width, height);
+
if (side == SIDE_TOP || side == SIDE_BOTTOM)
{
d = cairo_image_surface_get_width (surface);
cairo_translate (cr, x, y);
cairo_scale (cr, width / d, 1.0);
- cairo_set_source_surface (cr, surface, 0.0, 0.0);
- cairo_paint (cr);
}
else
{
@@ -234,12 +234,14 @@ render_border (cairo_t *cr,
cairo_translate (cr, x, y);
cairo_scale (cr, 1.0, height / d);
- cairo_set_source_surface (cr, surface, 0.0, 0.0);
- cairo_paint (cr);
}
+
+ cairo_paint (cr);
}
cairo_restore (cr);
+
+ cairo_pattern_destroy (pattern);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]