[gtk+] Gtk9Slice: Fix stretch rendering.
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Gtk9Slice: Fix stretch rendering.
- Date: Sat, 4 Dec 2010 15:27:23 +0000 (UTC)
commit 0d2d60cf8a93b0599220fb44355d2965c3698852
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 | 29 +++++++++++++++--------------
1 files changed, 15 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtk9slice.c b/gtk/gtk9slice.c
index 6200899..c3e824b 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,47 +200,47 @@ 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);
}
else
{
- gint d;
+ /* Use nearest filter so borders aren't blurred */
+ cairo_pattern_set_filter (pattern, CAIRO_FILTER_NEAREST);
if (side == SIDE_TOP || side == SIDE_BOTTOM)
{
- d = cairo_image_surface_get_width (surface);
+ gint w = 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);
+ cairo_scale (cr, width / w, 1.0);
}
else
{
- d = cairo_image_surface_get_height (surface);
+ gint h = cairo_image_surface_get_height (surface);
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_scale (cr, 1.0, height / h);
}
+
+ cairo_set_source (cr, pattern);
+ cairo_rectangle (cr, x, y, width, height);
+ 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]