diff -urN xc-HEAD.orig/programs/Xserver/hw/xfree86/common/xf86cmap.c xc-HEAD/programs/Xserver/hw/xfree86/common/xf86cmap.c --- xc-HEAD.orig/programs/Xserver/hw/xfree86/common/xf86cmap.c 2005-08-17 11:55:35.000000000 +1000 +++ xc-HEAD/programs/Xserver/hw/xfree86/common/xf86cmap.c 2005-09-05 16:28:42.000000000 +1000 @@ -246,6 +246,14 @@ } static Bool +CMapColormapUseMax(VisualPtr pVisual, CMapScreenPtr pScreenPriv) +{ + if (pVisual->nplanes > 16) + return TRUE; + return ((1 << pVisual->nplanes) > pScreenPriv->maxColors); +} + +static Bool CMapAllocateColormapPrivate(ColormapPtr pmap) { CMapScreenPtr pScreenPriv = @@ -255,7 +263,7 @@ int numColors; LOCO *colors; - if((1 << pmap->pVisual->nplanes) > pScreenPriv->maxColors) + if (CMapColormapUseMax(pmap->pVisual, pScreenPriv)) numColors = pmap->pVisual->ColormapEntries; else numColors = 1 << pmap->pVisual->nplanes; @@ -371,7 +379,7 @@ (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr; int i; - if((1 << pVisual->nplanes) > pScreenPriv->maxColors) { + if (CMapColormapUseMax(pVisual, pScreenPriv)) { int index; num = 0; @@ -440,10 +448,10 @@ if (miInstalledMaps[index]) pmap = miInstalledMaps[index]; - if(!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) && - (pmap->pVisual->class == TrueColor) && - ((1 << pmap->pVisual->nplanes) > pScreenPriv->maxColors)) - return; + if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) && + (pmap->pVisual->class == TrueColor) && + CMapColormapUseMax(pmap->pVisual, pScreenPriv)) + return; if(LOAD_PALETTE(pmap, index)) CMapReinstallMap(pmap); @@ -572,7 +580,7 @@ } break; case TrueColor: - if((1 << pVisual->nplanes) > pScreenPriv->maxColors) { + if (CMapColormapUseMax(pVisual, pScreenPriv)) { for(i = 0; i <= reds; i++) colors[i].red = gamma[i * maxValue / reds].red; for(i = 0; i <= greens; i++) @@ -615,7 +623,7 @@ } break; case DirectColor: - if((1 << pVisual->nplanes) > pScreenPriv->maxColors) { + if (CMapColormapUseMax(pVisual, pScreenPriv)) { for(i = 0; i < defs; i++) { index = indices[i]; if(index <= reds) @@ -930,9 +938,9 @@ pScrn->vtSema || pScreenPriv->isDGAmode)) { ColormapPtr pMap = miInstalledMaps[pScreen->myNum]; - if(!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) && + if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) && (pMap->pVisual->class == TrueColor) && - ((1 << pMap->pVisual->nplanes) > pScreenPriv->maxColors)) { + CMapColormapUseMax(pMap->pVisual, pScreenPriv)) { /* if the current map doesn't have a palette look for another map to change the gamma on. */ @@ -1017,9 +1025,9 @@ pScrn->vtSema || pScreenPriv->isDGAmode)) { ColormapPtr pMap = miInstalledMaps[pScreen->myNum]; - if(!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) && + if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) && (pMap->pVisual->class == TrueColor) && - ((1 << pMap->pVisual->nplanes) > pScreenPriv->maxColors)) { + CMapColormapUseMax(pMap->pVisual, pScreenPriv)) { /* if the current map doesn't have a palette look for another map to change the gamma on. */