diff --git a/src/cairo-font.c b/src/cairo-font.c index 20ecc5323..b4b08a6b2 100644 --- a/src/cairo-font.c +++ b/src/cairo-font.c @@ -281,9 +281,11 @@ _cairo_glyph_surface_init (cairo_font_t *font, CAIRO_FORMAT_A8, 0, glyph_surface->size.width, glyph_surface->size.height); - if (glyph_surface->surface == NULL) + if (glyph_surface->surface == NULL) { + glyph_surface->surface = image; return; - + } + status = _cairo_surface_set_image (glyph_surface->surface, (cairo_image_surface_t *) image); if (status) { diff --git a/src/cairo-surface.c b/src/cairo-surface.c index e17679778..e42cd5528 100644 --- a/src/cairo-surface.c +++ b/src/cairo-surface.c @@ -60,17 +60,11 @@ _cairo_surface_create_similar_scratch (cairo_surface_t *other, int width, int height) { - cairo_surface_t *surface; - if (other == NULL) return NULL; - surface = other->backend->create_similar (other, format, drawable, - width, height); - if (surface == NULL) - surface = cairo_image_surface_create (format, width, height); - - return surface; + return other->backend->create_similar (other, format, drawable, + width, height); } cairo_surface_t * @@ -103,6 +97,10 @@ _cairo_surface_create_similar_solid (cairo_surface_t *other, surface = _cairo_surface_create_similar_scratch (other, format, 1, width, height); + + if (surface == NULL) + surface = cairo_image_surface_create (format, width, height); + status = _cairo_surface_fill_rectangle (surface, CAIRO_OPERATOR_SRC, color, 0, 0, width, height); diff --git a/src/cairo_font.c b/src/cairo_font.c index 20ecc5323..b4b08a6b2 100644 --- a/src/cairo_font.c +++ b/src/cairo_font.c @@ -281,9 +281,11 @@ _cairo_glyph_surface_init (cairo_font_t *font, CAIRO_FORMAT_A8, 0, glyph_surface->size.width, glyph_surface->size.height); - if (glyph_surface->surface == NULL) + if (glyph_surface->surface == NULL) { + glyph_surface->surface = image; return; - + } + status = _cairo_surface_set_image (glyph_surface->surface, (cairo_image_surface_t *) image); if (status) { diff --git a/src/cairo_surface.c b/src/cairo_surface.c index e17679778..e42cd5528 100644 --- a/src/cairo_surface.c +++ b/src/cairo_surface.c @@ -60,17 +60,11 @@ _cairo_surface_create_similar_scratch (cairo_surface_t *other, int width, int height) { - cairo_surface_t *surface; - if (other == NULL) return NULL; - surface = other->backend->create_similar (other, format, drawable, - width, height); - if (surface == NULL) - surface = cairo_image_surface_create (format, width, height); - - return surface; + return other->backend->create_similar (other, format, drawable, + width, height); } cairo_surface_t * @@ -103,6 +97,10 @@ _cairo_surface_create_similar_solid (cairo_surface_t *other, surface = _cairo_surface_create_similar_scratch (other, format, 1, width, height); + + if (surface == NULL) + surface = cairo_image_surface_create (format, width, height); + status = _cairo_surface_fill_rectangle (surface, CAIRO_OPERATOR_SRC, color, 0, 0, width, height);