From e07f8e2e625fb34f9ad795ca8fffc9a9e88e25b2 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 27 Mar 2014 23:06:15 +0000 Subject: [PATCH] sna: Fix 2-color to ARGB cursor conversion It helps to remember to advance through the source/mask images after each row. Signed-off-by: Chris Wilson --- src/sna/sna_display.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index 5ed6d211..0eac2672 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -3147,6 +3147,7 @@ static struct sna_cursor *__sna_get_cursor(struct sna *sna, xf86CrtcPtr crtc) if (src == NULL) { const uint8_t *source = sna->cursor.ref->bits->source; const uint8_t *mask = sna->cursor.ref->bits->mask; + int pitch = BitmapBytePad(width); uint32_t *p; __DBG(("%s: converting from 2-color to ARGB\n", __FUNCTION__)); @@ -3157,20 +3158,21 @@ static struct sna_cursor *__sna_get_cursor(struct sna *sna, xf86CrtcPtr crtc) p = src; for (y = 0; y < height; y++) { - for (x = 0; x < width / 8; x++) { + for (x = 0; x < width; x++) { + int byte = x / 8; + int bit = x & 7; uint32_t pixel; - for (i = 0; i < 8; i++) { - if (mask[x] & (1 << i)) { - if (source[x] & (1 << i)) - pixel = sna->cursor.fg; - else - pixel = sna->cursor.bg; - } else - pixel = 0; - *p++ = pixel; - - } + if (mask[byte] & (1 << bit)) { + if (source[byte] & (1 << bit)) + pixel = sna->cursor.fg; + else + pixel = sna->cursor.bg; + } else + pixel = 0; + *p++ = pixel; } + mask += pitch; + source += pitch; } }