Atempt to fix stretched 9slice rendering

This commit is contained in:
Matthias Clasen 2010-11-23 16:14:13 -05:00 committed by Carlos Garnacho
parent 30fe448750
commit 4c04d944e8

View File

@ -213,6 +213,7 @@ render_border (cairo_t *cr,
cairo_pattern_destroy (pattern); cairo_pattern_destroy (pattern);
cairo_rectangle (cr, x, y, width, height); cairo_rectangle (cr, x, y, width, height);
cairo_fill (cr);
} }
else else
{ {
@ -222,24 +223,22 @@ render_border (cairo_t *cr,
{ {
d = cairo_image_surface_get_width (surface); d = cairo_image_surface_get_width (surface);
cairo_translate (cr, x + (width / 2), y); cairo_translate (cr, x, y);
cairo_scale (cr, width / d, 1); cairo_scale (cr, width / d, 1.0);
cairo_set_source_surface (cr, surface, - d / 2, 0); cairo_set_source_surface (cr, surface, 0.0, 0.0);
cairo_rectangle (cr, - width / 2, 0, width, height); cairo_paint (cr);
} }
else else
{ {
d = cairo_image_surface_get_height (surface); d = cairo_image_surface_get_height (surface);
cairo_translate (cr, x, y + (height / 2)); cairo_translate (cr, x, y);
cairo_scale (cr, 1, height / d); cairo_scale (cr, 1.0, height / d);
cairo_set_source_surface (cr, surface, 0, - d / 2); cairo_set_source_surface (cr, surface, 0.0, 0.0);
cairo_rectangle (cr, 0, - height / 2, width, height); cairo_paint (cr);
} }
} }
cairo_fill (cr);
cairo_restore (cr); cairo_restore (cr);
} }
@ -282,7 +281,7 @@ gtk_9slice_render (Gtk9Slice *slice,
render_border (cr, surface, SIDE_TOP, render_border (cr, surface, SIDE_TOP,
x + slice->distances[SIDE_LEFT], y, x + slice->distances[SIDE_LEFT], y,
(gdouble) width - slice->distances[SIDE_LEFT] - slice->distances[SIDE_RIGHT], width - slice->distances[SIDE_LEFT] - slice->distances[SIDE_RIGHT],
(gdouble) img_height, (gdouble) img_height,
slice->modifiers[SIDE_TOP]); slice->modifiers[SIDE_TOP]);
@ -292,7 +291,7 @@ gtk_9slice_render (Gtk9Slice *slice,
render_border (cr, surface, SIDE_BOTTOM, render_border (cr, surface, SIDE_BOTTOM,
x + slice->distances[SIDE_LEFT], y + height - img_height, x + slice->distances[SIDE_LEFT], y + height - img_height,
(gdouble) width - slice->distances[SIDE_LEFT] - slice->distances[SIDE_RIGHT], width - slice->distances[SIDE_LEFT] - slice->distances[SIDE_RIGHT],
(gdouble) img_height, (gdouble) img_height,
slice->modifiers[SIDE_BOTTOM]); slice->modifiers[SIDE_BOTTOM]);
@ -303,7 +302,7 @@ gtk_9slice_render (Gtk9Slice *slice,
render_border (cr, surface, SIDE_LEFT, render_border (cr, surface, SIDE_LEFT,
x, y + slice->distances[SIDE_TOP], x, y + slice->distances[SIDE_TOP],
(gdouble) img_width, (gdouble) img_width,
(gdouble) height - slice->distances[SIDE_TOP] - slice->distances[SIDE_BOTTOM], height - slice->distances[SIDE_TOP] - slice->distances[SIDE_BOTTOM],
slice->modifiers[SIDE_LEFT]); slice->modifiers[SIDE_LEFT]);
/* Right side */ /* Right side */
@ -312,7 +311,8 @@ gtk_9slice_render (Gtk9Slice *slice,
render_border (cr, surface, SIDE_RIGHT, render_border (cr, surface, SIDE_RIGHT,
x + width - img_width, y + slice->distances[SIDE_TOP], x + width - img_width, y + slice->distances[SIDE_TOP],
(gdouble) img_width, height - slice->distances[SIDE_TOP] - slice->distances[SIDE_BOTTOM], (gdouble) img_width,
height - slice->distances[SIDE_TOP] - slice->distances[SIDE_BOTTOM],
slice->modifiers[SIDE_RIGHT]); slice->modifiers[SIDE_RIGHT]);
/* Top/Left corner */ /* Top/Left corner */