From e573b272bf2b06fb62d0306ddc966f3230ead967 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Wed, 12 Oct 2005 07:46:36 +0000 Subject: [PATCH] Use proper access size when reading pixel based on bpp of the source pixmap --- exa/exa_render.c | 16 +++++++++++++--- hw/xfree86/exa/exa_render.c | 16 +++++++++++++--- hw/xfree86/exa/exapict.c | 16 +++++++++++++--- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/exa/exa_render.c b/exa/exa_render.c index 16ffcdcf6..9ca78dba7 100644 --- a/exa/exa_render.c +++ b/exa/exa_render.c @@ -1,7 +1,7 @@ /* - * Copyright © 2001 Keith Packard + * Copyright © 2001 Keith Packard * - * Partly based on code that is Copyright © The XFree86 Project Inc. + * Partly based on code that is Copyright © The XFree86 Project Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -261,7 +261,17 @@ exaTryDriverSolidFill(PicturePtr pSrc, exaPrepareAccess(&pSrcPix->drawable, EXA_PREPARE_SRC); - pixel = *(CARD32 *)(pSrcPix->devPrivate.ptr); + switch (pSrcPix->drawable.bitsPerPixel) { + case 32: + pixel = *(CARD32 *)(pSrcPix->devPrivate.ptr); + break; + case 16: + pixel = *(CARD16 *)(pSrcPix->devPrivate.ptr); + break; + default: + pixel = *(CARD8 *)(pSrcPix->devPrivate.ptr); + break; + } if (!exaGetRGBAFromPixel(pixel, &red, &green, &blue, &alpha, pSrc->format)) { diff --git a/hw/xfree86/exa/exa_render.c b/hw/xfree86/exa/exa_render.c index 16ffcdcf6..9ca78dba7 100644 --- a/hw/xfree86/exa/exa_render.c +++ b/hw/xfree86/exa/exa_render.c @@ -1,7 +1,7 @@ /* - * Copyright © 2001 Keith Packard + * Copyright © 2001 Keith Packard * - * Partly based on code that is Copyright © The XFree86 Project Inc. + * Partly based on code that is Copyright © The XFree86 Project Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -261,7 +261,17 @@ exaTryDriverSolidFill(PicturePtr pSrc, exaPrepareAccess(&pSrcPix->drawable, EXA_PREPARE_SRC); - pixel = *(CARD32 *)(pSrcPix->devPrivate.ptr); + switch (pSrcPix->drawable.bitsPerPixel) { + case 32: + pixel = *(CARD32 *)(pSrcPix->devPrivate.ptr); + break; + case 16: + pixel = *(CARD16 *)(pSrcPix->devPrivate.ptr); + break; + default: + pixel = *(CARD8 *)(pSrcPix->devPrivate.ptr); + break; + } if (!exaGetRGBAFromPixel(pixel, &red, &green, &blue, &alpha, pSrc->format)) { diff --git a/hw/xfree86/exa/exapict.c b/hw/xfree86/exa/exapict.c index 16ffcdcf6..9ca78dba7 100644 --- a/hw/xfree86/exa/exapict.c +++ b/hw/xfree86/exa/exapict.c @@ -1,7 +1,7 @@ /* - * Copyright © 2001 Keith Packard + * Copyright © 2001 Keith Packard * - * Partly based on code that is Copyright © The XFree86 Project Inc. + * Partly based on code that is Copyright © The XFree86 Project Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -261,7 +261,17 @@ exaTryDriverSolidFill(PicturePtr pSrc, exaPrepareAccess(&pSrcPix->drawable, EXA_PREPARE_SRC); - pixel = *(CARD32 *)(pSrcPix->devPrivate.ptr); + switch (pSrcPix->drawable.bitsPerPixel) { + case 32: + pixel = *(CARD32 *)(pSrcPix->devPrivate.ptr); + break; + case 16: + pixel = *(CARD16 *)(pSrcPix->devPrivate.ptr); + break; + default: + pixel = *(CARD8 *)(pSrcPix->devPrivate.ptr); + break; + } if (!exaGetRGBAFromPixel(pixel, &red, &green, &blue, &alpha, pSrc->format)) {