diff options
author | marha <marha@users.sourceforge.net> | 2012-03-26 14:23:28 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-03-26 14:23:28 +0200 |
commit | 76bcc36ed305418a3ddc5752d287ede894243e1b (patch) | |
tree | bacb320c825768471ce56f058f17ce863d592376 /xorg-server/mi/micmap.c | |
parent | 7d894e32566b710952c44cbc71939ad1d9e2fa8d (diff) | |
parent | 0f834b91a4768673833ab4917e87d86c237bb1a6 (diff) | |
download | vcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.tar.gz vcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.tar.bz2 vcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.zip |
Merge remote-tracking branch 'origin/released'
Conflicts:
pixman/pixman/pixman-mmx.c
xorg-server/Xext/shm.c
xorg-server/Xext/syncsrv.h
xorg-server/Xext/xvmain.c
xorg-server/Xi/exevents.c
xorg-server/Xi/opendev.c
xorg-server/composite/compalloc.c
xorg-server/composite/compoverlay.c
xorg-server/dix/colormap.c
xorg-server/dix/devices.c
xorg-server/dix/dispatch.c
xorg-server/dix/dixfonts.c
xorg-server/dix/eventconvert.c
xorg-server/dix/events.c
xorg-server/dix/gc.c
xorg-server/dix/getevents.c
xorg-server/dix/main.c
xorg-server/dix/privates.c
xorg-server/dix/registry.c
xorg-server/dix/resource.c
xorg-server/exa/exa_accel.c
xorg-server/exa/exa_migration_classic.c
xorg-server/exa/exa_unaccel.c
xorg-server/fb/fb.h
xorg-server/fb/fbcopy.c
xorg-server/fb/fbpixmap.c
xorg-server/glx/dispatch.h
xorg-server/glx/glapi.h
xorg-server/glx/glapi_gentable.c
xorg-server/glx/glapitable.h
xorg-server/glx/glprocs.h
xorg-server/glx/glxcmds.c
xorg-server/glx/glxcmdsswap.c
xorg-server/glx/glxdricommon.c
xorg-server/glx/glxdriswrast.c
xorg-server/glx/glxext.c
xorg-server/glx/indirect_dispatch.c
xorg-server/glx/indirect_dispatch.h
xorg-server/glx/indirect_dispatch_swap.c
xorg-server/glx/indirect_size.h
xorg-server/glx/indirect_size_get.h
xorg-server/glx/indirect_table.c
xorg-server/glx/indirect_util.c
xorg-server/glx/rensize.c
xorg-server/glx/single2swap.c
xorg-server/glx/singlepix.c
xorg-server/glx/singlepixswap.c
xorg-server/glx/singlesize.c
xorg-server/hw/dmx/dmxinit.c
xorg-server/hw/kdrive/ephyr/ephyr.c
xorg-server/hw/kdrive/ephyr/hostx.c
xorg-server/hw/kdrive/ephyr/hostx.h
xorg-server/hw/kdrive/src/kinput.c
xorg-server/hw/xfree86/common/compiler.h
xorg-server/hw/xwin/InitInput.c
xorg-server/hw/xwin/InitOutput.c
xorg-server/hw/xwin/ddraw.h
xorg-server/hw/xwin/glx/glwrap.c
xorg-server/hw/xwin/glx/indirect.c
xorg-server/hw/xwin/glx/wgl_ext_api.h
xorg-server/hw/xwin/glx/winpriv.c
xorg-server/hw/xwin/win.h
xorg-server/hw/xwin/winallpriv.c
xorg-server/hw/xwin/winauth.c
xorg-server/hw/xwin/winclipboard.h
xorg-server/hw/xwin/winclipboardinit.c
xorg-server/hw/xwin/winclipboardthread.c
xorg-server/hw/xwin/winclipboardunicode.c
xorg-server/hw/xwin/winclipboardwndproc.c
xorg-server/hw/xwin/winclipboardwrappers.c
xorg-server/hw/xwin/winclipboardxevents.c
xorg-server/hw/xwin/wincmap.c
xorg-server/hw/xwin/winconfig.c
xorg-server/hw/xwin/wincreatewnd.c
xorg-server/hw/xwin/wincursor.c
xorg-server/hw/xwin/windialogs.c
xorg-server/hw/xwin/winengine.c
xorg-server/hw/xwin/winerror.c
xorg-server/hw/xwin/wingc.c
xorg-server/hw/xwin/wingetsp.c
xorg-server/hw/xwin/winkeybd.c
xorg-server/hw/xwin/winkeybd.h
xorg-server/hw/xwin/winlayouts.h
xorg-server/hw/xwin/winmisc.c
xorg-server/hw/xwin/winmonitors.c
xorg-server/hw/xwin/winmouse.c
xorg-server/hw/xwin/winmsg.c
xorg-server/hw/xwin/winmsg.h
xorg-server/hw/xwin/winmultiwindowclass.c
xorg-server/hw/xwin/winmultiwindowicons.c
xorg-server/hw/xwin/winmultiwindowshape.c
xorg-server/hw/xwin/winmultiwindowwindow.c
xorg-server/hw/xwin/winmultiwindowwm.c
xorg-server/hw/xwin/winmultiwindowwndproc.c
xorg-server/hw/xwin/winnativegdi.c
xorg-server/hw/xwin/winpfbdd.c
xorg-server/hw/xwin/winpixmap.c
xorg-server/hw/xwin/winpolyline.c
xorg-server/hw/xwin/winprefs.c
xorg-server/hw/xwin/winprocarg.c
xorg-server/hw/xwin/winregistry.c
xorg-server/hw/xwin/winscrinit.c
xorg-server/hw/xwin/winsetsp.c
xorg-server/hw/xwin/winshaddd.c
xorg-server/hw/xwin/winshadddnl.c
xorg-server/hw/xwin/winshadgdi.c
xorg-server/hw/xwin/wintrayicon.c
xorg-server/hw/xwin/winwin32rootless.c
xorg-server/hw/xwin/winwin32rootlesswindow.c
xorg-server/hw/xwin/winwin32rootlesswndproc.c
xorg-server/hw/xwin/winwindow.c
xorg-server/hw/xwin/winwindow.h
xorg-server/hw/xwin/winwindowswm.c
xorg-server/hw/xwin/winwndproc.c
xorg-server/include/callback.h
xorg-server/include/dixstruct.h
xorg-server/include/misc.h
xorg-server/include/os.h
xorg-server/include/scrnintstr.h
xorg-server/mi/micmap.c
xorg-server/mi/miinitext.c
xorg-server/mi/mioverlay.c
xorg-server/mi/misprite.c
xorg-server/mi/mivaltree.c
xorg-server/mi/miwindow.c
xorg-server/miext/damage/damage.c
xorg-server/miext/rootless/rootlessGC.c
xorg-server/miext/rootless/rootlessWindow.c
xorg-server/os/WaitFor.c
xorg-server/os/access.c
xorg-server/os/connection.c
xorg-server/os/io.c
xorg-server/os/log.c
xorg-server/os/osinit.c
xorg-server/os/utils.c
xorg-server/os/xdmcp.c
xorg-server/os/xprintf.c
xorg-server/os/xstrans.c
xorg-server/render/mipict.c
xorg-server/xkb/xkbActions.c
xorg-server/xkb/xkbInit.c
xorg-server/xkeyboard-config/compat/default.in
Diffstat (limited to 'xorg-server/mi/micmap.c')
-rw-r--r-- | xorg-server/mi/micmap.c | 705 |
1 files changed, 332 insertions, 373 deletions
diff --git a/xorg-server/mi/micmap.c b/xorg-server/mi/micmap.c index 3746cad7f..90ca85d67 100644 --- a/xorg-server/mi/micmap.c +++ b/xorg-server/mi/micmap.c @@ -27,7 +27,6 @@ * are may be debatable. */ - #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif @@ -43,11 +42,11 @@ DevPrivateKeyRec micmapScrPrivateKeyRec; int -miListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps) +miListInstalledColormaps(ScreenPtr pScreen, Colormap * pmaps) { if (GetInstalledmiColormap(pScreen)) { - *pmaps = GetInstalledmiColormap(pScreen)->mid; - return 1; + *pmaps = GetInstalledmiColormap(pScreen)->mid; + return 1; } return 0; } @@ -57,15 +56,14 @@ miInstallColormap(ColormapPtr pmap) { ColormapPtr oldpmap = GetInstalledmiColormap(pmap->pScreen); - if(pmap != oldpmap) - { - /* Uninstall pInstalledMap. No hardware changes required, just - * notify all interested parties. */ - if(oldpmap != (ColormapPtr)None) - WalkTree(pmap->pScreen, TellLostMap, (char *)&oldpmap->mid); - /* Install pmap */ - SetInstalledmiColormap(pmap->pScreen, pmap); - WalkTree(pmap->pScreen, TellGainedMap, (char *)&pmap->mid); + if (pmap != oldpmap) { + /* Uninstall pInstalledMap. No hardware changes required, just + * notify all interested parties. */ + if (oldpmap != (ColormapPtr) None) + WalkTree(pmap->pScreen, TellLostMap, (char *) &oldpmap->mid); + /* Install pmap */ + SetInstalledmiColormap(pmap->pScreen, pmap); + WalkTree(pmap->pScreen, TellGainedMap, (char *) &pmap->mid); } } @@ -75,38 +73,33 @@ miUninstallColormap(ColormapPtr pmap) { ColormapPtr curpmap = GetInstalledmiColormap(pmap->pScreen); - if(pmap == curpmap) - { - if (pmap->mid != pmap->pScreen->defColormap) - { - dixLookupResourceByType((pointer *)&curpmap, - pmap->pScreen->defColormap, - RT_COLORMAP, serverClient, - DixUseAccess); - (*pmap->pScreen->InstallColormap)(curpmap); - } + if (pmap == curpmap) { + if (pmap->mid != pmap->pScreen->defColormap) { + dixLookupResourceByType((pointer *) &curpmap, + pmap->pScreen->defColormap, + RT_COLORMAP, serverClient, DixUseAccess); + (*pmap->pScreen->InstallColormap) (curpmap); + } } } void miResolveColor(unsigned short *pred, unsigned short *pgreen, - unsigned short *pblue, VisualPtr pVisual) + unsigned short *pblue, VisualPtr pVisual) { int shift = 16 - pVisual->bitsPerRGBValue; unsigned lim = (1 << pVisual->bitsPerRGBValue) - 1; - if ((pVisual->class | DynamicClass) == GrayScale) - { - /* rescale to gray then rgb bits */ - *pred = (30L * *pred + 59L * *pgreen + 11L * *pblue) / 100; - *pblue = *pgreen = *pred = ((*pred >> shift) * 65535) / lim; + if ((pVisual->class | DynamicClass) == GrayScale) { + /* rescale to gray then rgb bits */ + *pred = (30L * *pred + 59L * *pgreen + 11L * *pblue) / 100; + *pblue = *pgreen = *pred = ((*pred >> shift) * 65535) / lim; } - else - { - /* rescale to rgb bits */ - *pred = ((*pred >> shift) * 65535) / lim; - *pgreen = ((*pgreen >> shift) * 65535) / lim; - *pblue = ((*pblue >> shift) * 65535) / lim; + else { + /* rescale to rgb bits */ + *pred = ((*pred >> shift) * 65535) / lim; + *pgreen = ((*pgreen >> shift) * 65535) / lim; + *pblue = ((*pblue >> shift) * 65535) / lim; } } @@ -121,66 +114,58 @@ miInitializeColormap(ColormapPtr pmap) lim = (1 << pVisual->bitsPerRGBValue) - 1; shift = 16 - pVisual->bitsPerRGBValue; maxent = pVisual->ColormapEntries - 1; - if (pVisual->class == TrueColor) - { - unsigned limr, limg, limb; - - limr = pVisual->redMask >> pVisual->offsetRed; - 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; + if (pVisual->class == TrueColor) { + unsigned limr, limg, limb; + + limr = pVisual->redMask >> pVisual->offsetRed; + 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; - - limr = pVisual->redMask >> pVisual->offsetRed; - limg = pVisual->greenMask >> pVisual->offsetGreen; - limb = pVisual->blueMask >> pVisual->offsetBlue; - for(i = 0; i <= maxent; i++) - { - /* rescale to [0..65535] then rgb bits */ - pmap->red[i].co.local.red = - ((((((i & pVisual->redMask) >> pVisual->offsetRed) - * 65535) / limr) >> shift) * 65535) / lim; - pmap->red[i].co.local.green = - ((((((i & pVisual->greenMask) >> pVisual->offsetGreen) - * 65535) / limg) >> shift) * 65535) / lim; - pmap->red[i].co.local.blue = - ((((((i & pVisual->blueMask) >> pVisual->offsetBlue) - * 65535) / limb) >> shift) * 65535) / lim; - } + else if (pVisual->class == StaticColor) { + 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++) { + /* rescale to [0..65535] then rgb bits */ + pmap->red[i].co.local.red = + ((((((i & pVisual->redMask) >> pVisual->offsetRed) + * 65535) / limr) >> shift) * 65535) / lim; + pmap->red[i].co.local.green = + ((((((i & pVisual->greenMask) >> pVisual->offsetGreen) + * 65535) / limg) >> shift) * 65535) / lim; + pmap->red[i].co.local.blue = + ((((((i & pVisual->blueMask) >> pVisual->offsetBlue) + * 65535) / limb) >> shift) * 65535) / lim; + } } - else if (pVisual->class == StaticGray) - { - for(i = 0; i <= maxent; i++) - { - /* rescale to [0..65535] then rgb bits */ - pmap->red[i].co.local.red = ((((i * 65535) / maxent) >> shift) - * 65535) / lim; - pmap->red[i].co.local.green = pmap->red[i].co.local.red; - pmap->red[i].co.local.blue = pmap->red[i].co.local.red; - } + else if (pVisual->class == StaticGray) { + for (i = 0; i <= maxent; i++) { + /* rescale to [0..65535] then rgb bits */ + pmap->red[i].co.local.red = ((((i * 65535) / maxent) >> shift) + * 65535) / lim; + pmap->red[i].co.local.green = pmap->red[i].co.local.red; + pmap->red[i].co.local.blue = pmap->red[i].co.local.red; + } } return TRUE; } @@ -207,16 +192,16 @@ miInitializeColormap(ColormapPtr pmap) } int -miExpandDirectColors(ColormapPtr pmap, int ndef, xColorItem *indefs, - xColorItem *outdefs) +miExpandDirectColors(ColormapPtr pmap, int ndef, xColorItem * indefs, + xColorItem * outdefs) { - int red, green, blue; - int maxred, maxgreen, maxblue; - int stepred, stepgreen, stepblue; - VisualPtr pVisual; - int pixel; - int nresult; - int i; + int red, green, blue; + int maxred, maxgreen, maxblue; + int stepred, stepgreen, stepblue; + VisualPtr pVisual; + int pixel; + int nresult; + int i; pVisual = pmap->pVisual; @@ -227,41 +212,31 @@ miExpandDirectColors(ColormapPtr pmap, int ndef, xColorItem *indefs, maxgreen = pVisual->greenMask; maxblue = pVisual->blueMask; nresult = 0; - for (;ndef--; indefs++) - { - if (indefs->flags & DoRed) - { - red = indefs->pixel & pVisual->redMask; - for (green = 0; green <= maxgreen; green += stepgreen) - { - for (blue = 0; blue <= maxblue; blue += stepblue) - { - AddElement (DoRed) - } - } - } - if (indefs->flags & DoGreen) - { - green = indefs->pixel & pVisual->greenMask; - for (red = 0; red <= maxred; red += stepred) - { - for (blue = 0; blue <= maxblue; blue += stepblue) - { - AddElement (DoGreen) - } - } - } - if (indefs->flags & DoBlue) - { - blue = indefs->pixel & pVisual->blueMask; - for (red = 0; red <= maxred; red += stepred) - { - for (green = 0; green <= maxgreen; green += stepgreen) - { - AddElement (DoBlue) - } - } - } + for (; ndef--; indefs++) { + if (indefs->flags & DoRed) { + red = indefs->pixel & pVisual->redMask; + for (green = 0; green <= maxgreen; green += stepgreen) { + for (blue = 0; blue <= maxblue; blue += stepblue) { + AddElement(DoRed) + } + } + } + if (indefs->flags & DoGreen) { + green = indefs->pixel & pVisual->greenMask; + for (red = 0; red <= maxred; red += stepred) { + for (blue = 0; blue <= maxblue; blue += stepblue) { + AddElement(DoGreen) + } + } + } + if (indefs->flags & DoBlue) { + blue = indefs->pixel & pVisual->blueMask; + for (red = 0; red <= maxred; red += stepred) { + for (green = 0; green <= maxgreen; green += stepgreen) { + AddElement(DoBlue) + } + } + } } return nresult; } @@ -279,76 +254,73 @@ miCreateDefColormap(ScreenPtr pScreen) * color specifications. */ static xColorItem citems[] = { - { 0, 0, 0, 0, 0, 0 }, - { 1, 0x8000, 0, 0, 0, 0 }, - { 2, 0, 0x8000, 0, 0, 0 }, - { 3, 0x8000, 0x8000, 0, 0, 0 }, - { 4, 0, 0, 0x8000, 0, 0 }, - { 5, 0x8000, 0, 0x8000, 0, 0 }, - { 6, 0, 0x8000, 0x8000, 0, 0 }, - { 7, 0xc000, 0xc000, 0xc000, 0, 0 }, - { 8, 0xc000, 0xdc00, 0xc000, 0, 0 }, - { 9, 0xa600, 0xca00, 0xf000, 0, 0 }, - { 246, 0xff00, 0xfb00, 0xf000, 0, 0 }, - { 247, 0xa000, 0xa000, 0xa400, 0, 0 }, - { 248, 0x8000, 0x8000, 0x8000, 0, 0 }, - { 249, 0xff00, 0, 0, 0, 0 }, - { 250, 0, 0xff00, 0, 0, 0 }, - { 251, 0xff00, 0xff00, 0, 0, 0 }, - { 252, 0, 0, 0xff00, 0, 0 }, - { 253, 0xff00, 0, 0xff00, 0, 0 }, - { 254, 0, 0xff00, 0xff00, 0, 0 }, - { 255, 0xff00, 0xff00, 0xff00, 0, 0 } + {0, 0, 0, 0, 0, 0}, + {1, 0x8000, 0, 0, 0, 0}, + {2, 0, 0x8000, 0, 0, 0}, + {3, 0x8000, 0x8000, 0, 0, 0}, + {4, 0, 0, 0x8000, 0, 0}, + {5, 0x8000, 0, 0x8000, 0, 0}, + {6, 0, 0x8000, 0x8000, 0, 0}, + {7, 0xc000, 0xc000, 0xc000, 0, 0}, + {8, 0xc000, 0xdc00, 0xc000, 0, 0}, + {9, 0xa600, 0xca00, 0xf000, 0, 0}, + {246, 0xff00, 0xfb00, 0xf000, 0, 0}, + {247, 0xa000, 0xa000, 0xa400, 0, 0}, + {248, 0x8000, 0x8000, 0x8000, 0, 0}, + {249, 0xff00, 0, 0, 0, 0}, + {250, 0, 0xff00, 0, 0, 0}, + {251, 0xff00, 0xff00, 0, 0, 0}, + {252, 0, 0, 0xff00, 0, 0}, + {253, 0xff00, 0, 0xff00, 0, 0}, + {254, 0, 0xff00, 0xff00, 0, 0}, + {255, 0xff00, 0xff00, 0xff00, 0, 0} }; #define NUM_DESKTOP_COLORS sizeof citems / sizeof citems[0] int i; #else - unsigned short zero = 0, ones = 0xFFFF; + unsigned short zero = 0, ones = 0xFFFF; #endif Pixel wp, bp; - VisualPtr pVisual; - ColormapPtr cmap; + VisualPtr pVisual; + ColormapPtr cmap; int alloctype; - + if (!dixRegisterPrivateKey(&micmapScrPrivateKeyRec, PRIVATE_SCREEN, 0)) - return FALSE; + return FALSE; for (pVisual = pScreen->visuals; - pVisual->vid != pScreen->rootVisual; - pVisual++) - ; + pVisual->vid != pScreen->rootVisual; pVisual++); if (pScreen->rootDepth == 1 || (pVisual->class & DynamicClass)) - alloctype = AllocNone; + alloctype = AllocNone; else - alloctype = AllocAll; + alloctype = AllocAll; if (CreateColormap(pScreen->defColormap, pScreen, pVisual, &cmap, - alloctype, 0) != Success) - return FALSE; + alloctype, 0) != Success) + return FALSE; if (pScreen->rootDepth > 1) { - wp = pScreen->whitePixel; - bp = pScreen->blackPixel; + wp = pScreen->whitePixel; + bp = pScreen->blackPixel; #ifdef WIN32_not_tog - for (i = 0; i < NUM_DESKTOP_COLORS; i++) { - if (AllocColor (cmap, - &citems[i].red, &citems[i].green, &citems[i].blue, - &citems[i].pixel, 0) != Success) - return FALSE; - } + for (i = 0; i < NUM_DESKTOP_COLORS; i++) { + if (AllocColor(cmap, + &citems[i].red, &citems[i].green, &citems[i].blue, + &citems[i].pixel, 0) != Success) + return FALSE; + } #else - if ((AllocColor(cmap, &ones, &ones, &ones, &wp, 0) != - Success) || - (AllocColor(cmap, &zero, &zero, &zero, &bp, 0) != - Success)) - return FALSE; - pScreen->whitePixel = wp; - pScreen->blackPixel = bp; + if ((AllocColor(cmap, &ones, &ones, &ones, &wp, 0) != + Success) || + (AllocColor(cmap, &zero, &zero, &zero, &bp, 0) != Success)) + return FALSE; + pScreen->whitePixel = wp; + pScreen->blackPixel = bp; #endif } - (*pScreen->InstallColormap)(cmap); + (*pScreen->InstallColormap) (cmap); return TRUE; } @@ -369,22 +341,22 @@ miCreateDefColormap(ScreenPtr pScreen) #define _CE(d) (1 << _RZ(d)) typedef struct _miVisuals { - struct _miVisuals *next; - int depth; - int bitsPerRGB; - int visuals; - int count; - int preferredCVC; - Pixel redMask, greenMask, blueMask; + struct _miVisuals *next; + int depth; + int bitsPerRGB; + int visuals; + int count; + int preferredCVC; + Pixel redMask, greenMask, blueMask; } miVisualsRec, *miVisualsPtr; -static int miVisualPriority[] = { +static int miVisualPriority[] = { PseudoColor, GrayScale, StaticColor, TrueColor, DirectColor, StaticGray }; #define NUM_PRIORITY 6 -static miVisualsPtr miVisuals; +static miVisualsPtr miVisuals; void miClearVisualTypes(void) @@ -392,28 +364,26 @@ miClearVisualTypes(void) miVisualsPtr v; while ((v = miVisuals)) { - miVisuals = v->next; - free(v); + miVisuals = v->next; + free(v); } } - Bool -miSetVisualTypesAndMasks(int depth, int visuals, int bitsPerRGB, - int preferredCVC, - Pixel redMask, Pixel greenMask, Pixel blueMask) +miSetVisualTypesAndMasks(int depth, int visuals, int bitsPerRGB, + int preferredCVC, + Pixel redMask, Pixel greenMask, Pixel blueMask) { - miVisualsPtr new, *prev, v; - int count; + miVisualsPtr new, *prev, v; + int count; new = malloc(sizeof *new); if (!new) - return FALSE; - if (!redMask || !greenMask || !blueMask) - { - redMask = _RM(depth); - greenMask = _GM(depth); - blueMask = _BM(depth); + return FALSE; + if (!redMask || !greenMask || !blueMask) { + redMask = _RM(depth); + greenMask = _GM(depth); + blueMask = _BM(depth); } new->next = 0; new->depth = depth; @@ -425,7 +395,7 @@ miSetVisualTypesAndMasks(int depth, int visuals, int bitsPerRGB, new->blueMask = blueMask; count = (visuals >> 1) & 033333333333; count = visuals - count - ((count >> 1) & 033333333333); - count = (((count + (count >> 3)) & 030707070707) % 077); /* HAKMEM 169 */ + count = (((count + (count >> 3)) & 030707070707) % 077); /* HAKMEM 169 */ new->count = count; for (prev = &miVisuals; (v = *prev); prev = &v->next); *prev = new; @@ -435,48 +405,46 @@ miSetVisualTypesAndMasks(int depth, int visuals, int bitsPerRGB, Bool miSetVisualTypes(int depth, int visuals, int bitsPerRGB, int preferredCVC) { - return miSetVisualTypesAndMasks (depth, visuals, bitsPerRGB, - preferredCVC, 0, 0, 0); + return miSetVisualTypesAndMasks(depth, visuals, bitsPerRGB, + preferredCVC, 0, 0, 0); } int miGetDefaultVisualMask(int depth) { if (depth > MAX_PSEUDO_DEPTH) - return LARGE_VISUALS; + return LARGE_VISUALS; else if (depth >= MIN_TRUE_DEPTH) - return ALL_VISUALS; + return ALL_VISUALS; else if (depth == 1) - return StaticGrayMask; + return StaticGrayMask; else - return SMALL_VISUALS; + return SMALL_VISUALS; } static Bool -miVisualTypesSet (int depth) +miVisualTypesSet(int depth) { - miVisualsPtr visuals; + miVisualsPtr visuals; for (visuals = miVisuals; visuals; visuals = visuals->next) - if (visuals->depth == depth) - return TRUE; + if (visuals->depth == depth) + return TRUE; return FALSE; } Bool -miSetPixmapDepths (void) +miSetPixmapDepths(void) { - int d, f; - + int d, f; + /* Add any unlisted depths from the pixmap formats */ - for (f = 0; f < screenInfo.numPixmapFormats; f++) - { - d = screenInfo.formats[f].depth; - if (!miVisualTypesSet (d)) - { - if (!miSetVisualTypes (d, 0, 0, -1)) - return FALSE; - } + for (f = 0; f < screenInfo.numPixmapFormats; f++) { + d = screenInfo.formats[f].depth; + if (!miVisualTypesSet(d)) { + if (!miSetVisualTypes(d, 0, 0, -1)) + return FALSE; + } } return TRUE; } @@ -485,16 +453,16 @@ miSetPixmapDepths (void) * Distance to least significant one bit */ static int -maskShift (Pixel p) +maskShift(Pixel p) { - int s; + int s; - if (!p) return 0; + if (!p) + return 0; s = 0; - while (!(p & 1)) - { - s++; - p >>= 1; + while (!(p & 1)) { + s++; + p >>= 1; } return s; } @@ -506,120 +474,113 @@ maskShift (Pixel p) */ Bool -miInitVisuals(VisualPtr *visualp, DepthPtr *depthp, int *nvisualp, - int *ndepthp, int *rootDepthp, VisualID *defaultVisp, - unsigned long sizes, int bitsPerRGB, int preferredVis) - +miInitVisuals(VisualPtr * visualp, DepthPtr * depthp, int *nvisualp, + int *ndepthp, int *rootDepthp, VisualID * defaultVisp, + unsigned long sizes, int bitsPerRGB, int preferredVis) { - int i, j = 0, k; - VisualPtr visual; - DepthPtr depth; - VisualID *vid; - int d, b; - int f; - int ndepth, nvisual; - int nvtype; - int vtype; - miVisualsPtr visuals, nextVisuals; - int *preferredCVCs, *prefp; - int first_depth; + int i, j = 0, k; + VisualPtr visual; + DepthPtr depth; + VisualID *vid; + int d, b; + int f; + int ndepth, nvisual; + int nvtype; + int vtype; + miVisualsPtr visuals, nextVisuals; + int *preferredCVCs, *prefp; + int first_depth; /* none specified, we'll guess from pixmap formats */ - if (!miVisuals) - { - for (f = 0; f < screenInfo.numPixmapFormats; f++) - { - d = screenInfo.formats[f].depth; - b = screenInfo.formats[f].bitsPerPixel; - if (sizes & (1 << (b - 1))) - vtype = miGetDefaultVisualMask(d); - else - vtype = 0; - if (!miSetVisualTypes (d, vtype, bitsPerRGB, -1)) - return FALSE; - } + if (!miVisuals) { + for (f = 0; f < screenInfo.numPixmapFormats; f++) { + d = screenInfo.formats[f].depth; + b = screenInfo.formats[f].bitsPerPixel; + if (sizes & (1 << (b - 1))) + vtype = miGetDefaultVisualMask(d); + else + vtype = 0; + if (!miSetVisualTypes(d, vtype, bitsPerRGB, -1)) + return FALSE; + } } nvisual = 0; ndepth = 0; - for (visuals = miVisuals; visuals; visuals = nextVisuals) - { - nextVisuals = visuals->next; - ndepth++; - nvisual += visuals->count; + for (visuals = miVisuals; visuals; visuals = nextVisuals) { + nextVisuals = visuals->next; + ndepth++; + nvisual += visuals->count; } - depth = malloc(ndepth * sizeof (DepthRec)); - visual = malloc(nvisual * sizeof (VisualRec)); + depth = malloc(ndepth * sizeof(DepthRec)); + visual = malloc(nvisual * sizeof(VisualRec)); preferredCVCs = malloc(ndepth * sizeof(int)); - if (!depth || !visual || !preferredCVCs) - { - free(depth); - free(visual); - free(preferredCVCs); - return FALSE; + if (!depth || !visual || !preferredCVCs) { + free(depth); + free(visual); + free(preferredCVCs); + return FALSE; } *depthp = depth; *visualp = visual; *ndepthp = ndepth; *nvisualp = nvisual; prefp = preferredCVCs; - for (visuals = miVisuals; visuals; visuals = nextVisuals) - { - nextVisuals = visuals->next; - d = visuals->depth; - vtype = visuals->visuals; - nvtype = visuals->count; - *prefp = visuals->preferredCVC; - prefp++; - vid = NULL; - if (nvtype) - { - vid = malloc(nvtype * sizeof (VisualID)); - if (!vid) { - free(depth); - free(visual); - free(preferredCVCs); - return FALSE; - } - } - depth->depth = d; - depth->numVids = nvtype; - depth->vids = vid; - depth++; - for (i = 0; i < NUM_PRIORITY; i++) { - if (! (vtype & (1 << miVisualPriority[i]))) - continue; - visual->class = miVisualPriority[i]; - visual->bitsPerRGBValue = visuals->bitsPerRGB; - visual->ColormapEntries = 1 << d; - visual->nplanes = d; - visual->vid = *vid = FakeClientID (0); - switch (visual->class) { - case PseudoColor: - case GrayScale: - case StaticGray: - visual->redMask = 0; - visual->greenMask = 0; - visual->blueMask = 0; - visual->offsetRed = 0; - visual->offsetGreen = 0; - visual->offsetBlue = 0; - break; - case DirectColor: - case TrueColor: - visual->ColormapEntries = _CE(d); - /* fall through */ - case StaticColor: - visual->redMask = visuals->redMask; - visual->greenMask = visuals->greenMask; - visual->blueMask = visuals->blueMask; - visual->offsetRed = maskShift (visuals->redMask); - visual->offsetGreen = maskShift (visuals->greenMask); - visual->offsetBlue = maskShift (visuals->blueMask); - } - vid++; - visual++; - } - free(visuals); + for (visuals = miVisuals; visuals; visuals = nextVisuals) { + nextVisuals = visuals->next; + d = visuals->depth; + vtype = visuals->visuals; + nvtype = visuals->count; + *prefp = visuals->preferredCVC; + prefp++; + vid = NULL; + if (nvtype) { + vid = malloc(nvtype * sizeof(VisualID)); + if (!vid) { + free(depth); + free(visual); + free(preferredCVCs); + return FALSE; + } + } + depth->depth = d; + depth->numVids = nvtype; + depth->vids = vid; + depth++; + for (i = 0; i < NUM_PRIORITY; i++) { + if (!(vtype & (1 << miVisualPriority[i]))) + continue; + visual->class = miVisualPriority[i]; + visual->bitsPerRGBValue = visuals->bitsPerRGB; + visual->ColormapEntries = 1 << d; + visual->nplanes = d; + visual->vid = *vid = FakeClientID(0); + switch (visual->class) { + case PseudoColor: + case GrayScale: + case StaticGray: + visual->redMask = 0; + visual->greenMask = 0; + visual->blueMask = 0; + visual->offsetRed = 0; + visual->offsetGreen = 0; + visual->offsetBlue = 0; + break; + case DirectColor: + case TrueColor: + visual->ColormapEntries = _CE(d); + /* fall through */ + case StaticColor: + visual->redMask = visuals->redMask; + visual->greenMask = visuals->greenMask; + visual->blueMask = visuals->blueMask; + visual->offsetRed = maskShift(visuals->redMask); + visual->offsetGreen = maskShift(visuals->greenMask); + visual->offsetBlue = maskShift(visuals->blueMask); + } + vid++; + visual++; + } + free(visuals); } miVisuals = NULL; visual = *visualp; @@ -632,46 +593,44 @@ miInitVisuals(VisualPtr *visualp, DepthPtr *depthp, int *nvisualp, * default visual/depth from that depth. */ first_depth = 0; - if (preferredVis < 0 && defaultColorVisualClass < 0 ) { - for (i = 0; i < ndepth; i++) { - if (preferredCVCs[i] >= 0) { - first_depth = i; - break; - } - } + if (preferredVis < 0 && defaultColorVisualClass < 0) { + for (i = 0; i < ndepth; i++) { + if (preferredCVCs[i] >= 0) { + first_depth = i; + break; + } + } } - for (i = first_depth; i < ndepth; i++) - { - int prefColorVisualClass = -1; - - if (defaultColorVisualClass >= 0) - prefColorVisualClass = defaultColorVisualClass; - else if (preferredVis >= 0) - prefColorVisualClass = preferredVis; - else if (preferredCVCs[i] >= 0) - prefColorVisualClass = preferredCVCs[i]; - - if (*rootDepthp && *rootDepthp != depth[i].depth) - continue; - - for (j = 0; j < depth[i].numVids; j++) - { - for (k = 0; k < nvisual; k++) - if (visual[k].vid == depth[i].vids[j]) - break; - if (k == nvisual) - continue; - if (prefColorVisualClass < 0 || - visual[k].class == prefColorVisualClass) - break; - } - if (j != depth[i].numVids) - break; + for (i = first_depth; i < ndepth; i++) { + int prefColorVisualClass = -1; + + if (defaultColorVisualClass >= 0) + prefColorVisualClass = defaultColorVisualClass; + else if (preferredVis >= 0) + prefColorVisualClass = preferredVis; + else if (preferredCVCs[i] >= 0) + prefColorVisualClass = preferredCVCs[i]; + + if (*rootDepthp && *rootDepthp != depth[i].depth) + continue; + + for (j = 0; j < depth[i].numVids; j++) { + for (k = 0; k < nvisual; k++) + if (visual[k].vid == depth[i].vids[j]) + break; + if (k == nvisual) + continue; + if (prefColorVisualClass < 0 || + visual[k].class == prefColorVisualClass) + break; + } + if (j != depth[i].numVids) + break; } if (i == ndepth) { - i = 0; - j = 0; + i = 0; + j = 0; } *rootDepthp = depth[i].depth; *defaultVisp = depth[i].vids[j]; |