- {
- cairo_pattern_get_surface (image->source, &surface);
- cairo_surface_reference (surface);
-
- width = cairo_image_surface_get_width (surface);
- height = cairo_image_surface_get_height (surface);
- }
-
- /* Top /left corner */
- image->surfaces[BORDER_LEFT][BORDER_TOP] =
- cairo_surface_create_similar (surface, CAIRO_CONTENT_COLOR_ALPHA,
- image->slice.left, image->slice.top);
- cr = cairo_create (image->surfaces[BORDER_LEFT][BORDER_TOP]);
- cairo_set_source_surface (cr, surface, 0, 0);
- cairo_paint (cr);
-
- cairo_destroy (cr);
-
- /* Top/right corner */
- image->surfaces[BORDER_RIGHT][BORDER_TOP] =
- cairo_surface_create_similar (surface, CAIRO_CONTENT_COLOR_ALPHA,
- image->slice.right, image->slice.top);
- cr = cairo_create (image->surfaces[BORDER_RIGHT][BORDER_TOP]);
- cairo_set_source_surface (cr, surface,
- - width + image->slice.right,
- 0);
- cairo_paint (cr);
- cairo_destroy (cr);
-
- /* Bottom/left corner */
- image->surfaces[BORDER_LEFT][BORDER_BOTTOM] =
- cairo_surface_create_similar (surface, CAIRO_CONTENT_COLOR_ALPHA,
- image->slice.left, image->slice.bottom);
- cr = cairo_create (image->surfaces[BORDER_LEFT][BORDER_BOTTOM]);
- cairo_set_source_surface (cr, surface,
- 0,
- - height + image->slice.bottom);
- cairo_paint (cr);
- cairo_destroy (cr);
-
- /* Bottom/right corner */
- image->surfaces[BORDER_RIGHT][BORDER_BOTTOM] =
- cairo_surface_create_similar (surface, CAIRO_CONTENT_COLOR_ALPHA,
- image->slice.right, image->slice.bottom);
- cr = cairo_create (image->surfaces[BORDER_RIGHT][BORDER_BOTTOM]);
- cairo_set_source_surface (cr, surface,
- - width + image->slice.right,
- - height + image->slice.bottom);
- cairo_paint (cr);
- cairo_destroy (cr);
-
- if ((image->slice.left + image->slice.right) < width)
- {
- /* Top side */
- image->surfaces[BORDER_MIDDLE][BORDER_TOP] =
- cairo_surface_create_similar (surface,
- CAIRO_CONTENT_COLOR_ALPHA,
- width - image->slice.left - image->slice.right,
- image->slice.top);
- cr = cairo_create (image->surfaces[BORDER_MIDDLE][BORDER_TOP]);
- cairo_set_source_surface (cr, surface,
- - image->slice.left,
- 0);
- cairo_paint (cr);
- cairo_destroy (cr);
-
- /* Bottom side */
- image->surfaces[BORDER_MIDDLE][BORDER_BOTTOM] =
- cairo_surface_create_similar (surface,
- CAIRO_CONTENT_COLOR_ALPHA,
- width - image->slice.left - image->slice.right,
- image->slice.bottom);
- cr = cairo_create (image->surfaces[BORDER_MIDDLE][BORDER_BOTTOM]);
- cairo_set_source_surface (cr, surface,
- - image->slice.left,
- - height + image->slice.bottom);
- cairo_paint (cr);
- cairo_destroy (cr);
- }