[PATCH] simplify convoluted code in dummy LoadPalette

Antoine Martin antoine at nagafix.co.uk
Tue Sep 20 16:06:32 UTC 2016


On 20/09/16 22:54, Antoine Martin wrote:
> Only the 15-bit mode does anything different,
> make that clearer and remove the redundant code for other bit depths
> 
> Signed-off-by: Antoine Martin <antoine at nagafix.co.uk>
> ---
>  src/dummy_driver.c | 17 ++++-------------
>  1 file changed, 4 insertions(+), 13 deletions(-)
> 
> diff --git a/src/dummy_driver.c b/src/dummy_driver.c
> index c84000f..5e0bc03 100644
> --- a/src/dummy_driver.c
> +++ b/src/dummy_driver.c
> @@ -492,26 +492,17 @@ DUMMYLoadPalette(
>     LOCO *colors,
>     VisualPtr pVisual
>  ){
> -   int i, index, shift, Gshift;
> +   int i, index, shift=0;
>     DUMMYPtr dPtr = DUMMYPTR(pScrn);
>  
> -   switch(pScrn->depth) {
> -   case 15:	
> -	shift = Gshift = 1;
> -	break;
> -   case 16:
> -	shift = 0; 
> -        Gshift = 0;
> -	break;
> -   default:
> -	shift = Gshift = 0;
> -	break;
> +   if (pScrn->depth==15) {
> +	shift = 1
>     }
>  
>     for(i = 0; i < numColors; i++) {
>         index = indices[i];
>         dPtr->colors[index].red = colors[index].red << shift;
> -       dPtr->colors[index].green = colors[index].green << Gshift;
> +       dPtr->colors[index].green = colors[index].green << shift;
>         dPtr->colors[index].blue = colors[index].blue << shift;
>     } 
>
Note: this patch does not change the current behaviour - which may well
be wrong: the fact that there was a separate variable for Gshift makes
me think that maybe the 15-bit mode is meant to use Gshift=1 but keep
shift=0? (or the other way around even)

Cheers
Antoine


More information about the xorg-devel mailing list