From ef0679333da881bd83b0bb4db546ea9c68f81f89 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 12 Jul 2010 16:07:27 +0100 Subject: [PATCH] image: Manually clip against bounds when rendering directly This is path is slightly peculiar in that it explicitly avoid the intermediate mask and the geometry is not pre-clipped. This in conjunction with the previous commit fixes: Clip doesn't work for text https://bugs.freedesktop.org/show_bug.cgi?id=29008 which is captured in test/partial-clip-text. --- src/cairo-image-surface.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c index 1f8e9b1ac..e11197323 100644 --- a/src/cairo-image-surface.c +++ b/src/cairo-image-surface.c @@ -3939,6 +3939,8 @@ _composite_glyphs (void *closure, glyph_surface = scaled_glyph->surface; if (glyph_surface->width && glyph_surface->height) { + int x1, y1, x2, y2; + /* round glyph locations to the nearest pixel */ /* XXX: FRAGILE: We're ignoring device_transform scaling here. A bug? */ x = _cairo_lround (info->glyphs[i].x - @@ -3946,13 +3948,26 @@ _composite_glyphs (void *closure, y = _cairo_lround (info->glyphs[i].y - glyph_surface->base.device_transform.y0); + x1 = x; + if (x1 < extents->x) + x1 = extents->x; + x2 = x + glyph_surface->width; + if (x2 > extents->x + extents->width) + x2 = extents->x + extents->width; + + y1 = y; + if (y1 < extents->y) + y1 = extents->y; + y2 = y + glyph_surface->height; + if (y2 > extents->y + extents->height) + y2 = extents->y + extents->height; + pixman_image_composite32 (pixman_op, src, glyph_surface->pixman_image, dst, - x + src_x, y + src_y, + x1 + src_x, y1 + src_y, 0, 0, - x - dst_x, y - dst_y, - glyph_surface->width, - glyph_surface->height); + x1 - dst_x, y1 - dst_y, + x2 - x1, y2 - y1); } } _cairo_scaled_font_thaw_cache (info->font);