summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-06-12 17:21:44 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2010-06-12 18:07:17 +0100
commit94217ed5f5a3726db3fad6cac2132d99ed45c154 (patch)
treeb585f1b09bad23ca30b397cb69090184106bc66d
parent5a0a8a1cf6d9b0616d6a097e783f2aa318b45736 (diff)
uxa: Always clip glyphs to destination.
Even if there is only a single clip rect, since the clip may be smaller than the drawing rectangle on the destination we need to actually compute the clipped glyph rectangle. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--uxa/uxa-glyphs.c64
1 files changed, 29 insertions, 35 deletions
diff --git a/uxa/uxa-glyphs.c b/uxa/uxa-glyphs.c
index 31bf9158..68d1c228 100644
--- a/uxa/uxa-glyphs.c
+++ b/uxa/uxa-glyphs.c
@@ -663,7 +663,7 @@ uxa_glyphs_to_dst(CARD8 op,
uxa_screen_t *uxa_screen = uxa_get_screen(screen);
PixmapPtr src_pixmap, dst_pixmap;
PicturePtr localSrc, glyph_atlas;
- int x, y, n, nrect;
+ int x, y, n;
BoxRec box;
if (uxa_screen->info->check_composite_texture &&
@@ -747,8 +747,9 @@ uxa_glyphs_to_dst(CARD8 op,
while (n--) {
GlyphPtr glyph = *glyphs++;
PicturePtr this_atlas;
- int mask_x, mask_y;
+ int mask_x, mask_y, nrect;
struct uxa_glyph *priv;
+ BoxPtr rects;
if (glyph->info.width == 0 || glyph->info.height == 0)
goto next_glyph;
@@ -789,41 +790,34 @@ uxa_glyphs_to_dst(CARD8 op,
glyph_atlas = this_atlas;
}
+ rects = REGION_RECTS(pDst->pCompositeClip);
nrect = REGION_NUM_RECTS(pDst->pCompositeClip);
- if (nrect == 1) {
- uxa_screen->info->composite(dst_pixmap,
- x + src_x, y + src_y,
- mask_x, mask_y,
- x - glyph->info.x,
- y - glyph->info.y,
- glyph->info.width,
- glyph->info.height);
- } else {
- BoxPtr rects = REGION_RECTS(pDst->pCompositeClip);
- while (nrect--) {
- int x1 = x - glyph->info.x, dx = 0;
- int y1 = y - glyph->info.y, dy = 0;
- int x2 = x1 + glyph->info.width;
- int y2 = y1 + glyph->info.height;
-
- if (x1 < rects->x1)
- dx = rects->x1 - x1, x1 = rects->x1;
- if (x2 > rects->x2)
- x2 = rects->x2;
- if (y1 < rects->y1)
- dy = rects->y1 - y1, y1 = rects->y1;
- if (y2 > rects->y2)
- y2 = rects->y2;
-
- if (x1 < x2 && y1 < y2) {
- uxa_screen->info->composite(dst_pixmap,
- x1 + src_x, y1 + src_y,
- dx + mask_x, dy + mask_y,
- x1, y1,
- x2 - x1, y2 - y1);
- }
- rects++;
+ while (nrect--) {
+ int x1 = x - glyph->info.x, dx = 0;
+ int y1 = y - glyph->info.y, dy = 0;
+ int x2 = x1 + glyph->info.width;
+ int y2 = y1 + glyph->info.height;
+
+ if (rects->y1 >= y2)
+ break;
+
+ if (x1 < rects->x1)
+ dx = rects->x1 - x1, x1 = rects->x1;
+ if (x2 > rects->x2)
+ x2 = rects->x2;
+ if (y1 < rects->y1)
+ dy = rects->y1 - y1, y1 = rects->y1;
+ if (y2 > rects->y2)
+ y2 = rects->y2;
+
+ if (x1 < x2 && y1 < y2) {
+ uxa_screen->info->composite(dst_pixmap,
+ x1 + src_x, y1 + src_y,
+ dx + mask_x, dy + mask_y,
+ x1, y1,
+ x2 - x1, y2 - y1);
}
+ rects++;
}
next_glyph: