aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/mi/micmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/mi/micmap.c')
-rw-r--r--xorg-server/mi/micmap.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/xorg-server/mi/micmap.c b/xorg-server/mi/micmap.c
index 4648b9a70..e2653cc1f 100644
--- a/xorg-server/mi/micmap.c
+++ b/xorg-server/mi/micmap.c
@@ -118,17 +118,26 @@ miInitializeColormap(ColormapPtr pmap)
unsigned limr, limg, limb;
limr = pVisual->redMask >> pVisual->offsetRed;
- limg = pVisual->greenMask >> pVisual->offsetGreen;
- limb = pVisual->blueMask >> pVisual->offsetBlue;
- for (i = 0; i <= maxent; i++) {
+ for(i = 0; i <= min(limr,maxent); i++) {
/* rescale to [0..65535] then rgb bits */
pmap->red[i].co.local.red =
((((i * 65535) / limr) >> shift) * 65535) / lim;
+ }
+ for(; i <= maxent; i++) pmap->red[i].co.local.red = 65535;
+ limg = pVisual->greenMask >> pVisual->offsetGreen;
+ for(i = 0; i <= min(limg,maxent); i++) {
+ /* rescale to [0..65535] then rgb bits */
pmap->green[i].co.local.green =
((((i * 65535) / limg) >> shift) * 65535) / lim;
+ }
+ for(; i <= maxent; i++) pmap->green[i].co.local.green = 65535;
+ limb = pVisual->blueMask >> pVisual->offsetBlue;
+ for(i = 0; i <= min(limb,maxent); i++) {
+ /* rescale to [0..65535] then rgb bits */
pmap->blue[i].co.local.blue =
((((i * 65535) / limb) >> shift) * 65535) / lim;
}
+ for(; i <= maxent; i++) pmap->blue[i].co.local.blue = 65535;
}
else if (pVisual->class == StaticColor) {
unsigned limr, limg, limb;