2009-12-16 00:54:22 +01:00
|
|
|
/*
|
2010-12-04 01:32:01 +01:00
|
|
|
* Copyright (c) 1987, Oracle and/or its affiliates. All rights reserved.
|
2009-12-16 00:54:22 +01:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This is based on cfbcmap.c. The functions here are useful independently
|
|
|
|
* of cfb, which is the reason for including them here. How "mi" these
|
|
|
|
* are may be debatable.
|
|
|
|
*/
|
|
|
|
|
2005-07-03 09:02:09 +02:00
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
2005-04-20 14:25:48 +02:00
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xproto.h>
|
2003-11-14 17:48:57 +01:00
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "colormapst.h"
|
|
|
|
#include "resource.h"
|
|
|
|
#include "globals.h"
|
|
|
|
#include "micmap.h"
|
|
|
|
|
2010-04-27 02:22:21 +02:00
|
|
|
DevPrivateKeyRec micmapScrPrivateKeyRec;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2012-03-21 20:55:09 +01:00
|
|
|
miListInstalledColormaps(ScreenPtr pScreen, Colormap * pmaps)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2010-04-22 19:20:43 +02:00
|
|
|
if (GetInstalledmiColormap(pScreen)) {
|
2012-03-21 20:55:09 +01:00
|
|
|
*pmaps = GetInstalledmiColormap(pScreen)->mid;
|
|
|
|
return 1;
|
2004-12-06 16:53:00 +01:00
|
|
|
}
|
|
|
|
return 0;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2003-11-14 17:48:57 +01:00
|
|
|
miInstallColormap(ColormapPtr pmap)
|
|
|
|
{
|
2010-04-22 19:20:43 +02:00
|
|
|
ColormapPtr oldpmap = GetInstalledmiColormap(pmap->pScreen);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
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);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2003-11-14 17:48:57 +01:00
|
|
|
miUninstallColormap(ColormapPtr pmap)
|
|
|
|
{
|
2010-04-22 19:20:43 +02:00
|
|
|
ColormapPtr curpmap = GetInstalledmiColormap(pmap->pScreen);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pmap == curpmap) {
|
|
|
|
if (pmap->mid != pmap->pScreen->defColormap) {
|
2013-12-15 10:05:51 +01:00
|
|
|
dixLookupResourceByType((void **) &curpmap,
|
2012-03-21 20:55:09 +01:00
|
|
|
pmap->pScreen->defColormap,
|
|
|
|
RT_COLORMAP, serverClient, DixUseAccess);
|
|
|
|
(*pmap->pScreen->InstallColormap) (curpmap);
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2003-11-14 17:48:57 +01:00
|
|
|
miResolveColor(unsigned short *pred, unsigned short *pgreen,
|
2012-03-21 20:55:09 +01:00
|
|
|
unsigned short *pblue, VisualPtr pVisual)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
|
|
|
int shift = 16 - pVisual->bitsPerRGBValue;
|
|
|
|
unsigned lim = (1 << pVisual->bitsPerRGBValue) - 1;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
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;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else {
|
|
|
|
/* rescale to rgb bits */
|
|
|
|
*pred = ((*pred >> shift) * 65535) / lim;
|
|
|
|
*pgreen = ((*pgreen >> shift) * 65535) / lim;
|
|
|
|
*pblue = ((*pblue >> shift) * 65535) / lim;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2003-11-14 17:48:57 +01:00
|
|
|
miInitializeColormap(ColormapPtr pmap)
|
|
|
|
{
|
2007-03-09 04:46:23 +01:00
|
|
|
unsigned i;
|
|
|
|
VisualPtr pVisual;
|
2003-11-14 17:48:57 +01:00
|
|
|
unsigned lim, maxent, shift;
|
|
|
|
|
|
|
|
pVisual = pmap->pVisual;
|
|
|
|
lim = (1 << pVisual->bitsPerRGBValue) - 1;
|
|
|
|
shift = 16 - pVisual->bitsPerRGBValue;
|
|
|
|
maxent = pVisual->ColormapEntries - 1;
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pVisual->class == TrueColor) {
|
|
|
|
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 * 65535) / limr) >> shift) * 65535) / lim;
|
|
|
|
pmap->green[i].co.local.green =
|
|
|
|
((((i * 65535) / limg) >> shift) * 65535) / lim;
|
|
|
|
pmap->blue[i].co.local.blue =
|
|
|
|
((((i * 65535) / limb) >> shift) * 65535) / lim;
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
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;
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
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;
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* When simulating DirectColor on PseudoColor hardware, multiple
|
|
|
|
entries of the colormap must be updated
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define AddElement(mask) { \
|
|
|
|
pixel = red | green | blue; \
|
|
|
|
for (i = 0; i < nresult; i++) \
|
|
|
|
if (outdefs[i].pixel == pixel) \
|
|
|
|
break; \
|
|
|
|
if (i == nresult) \
|
|
|
|
{ \
|
|
|
|
nresult++; \
|
|
|
|
outdefs[i].pixel = pixel; \
|
|
|
|
outdefs[i].flags = 0; \
|
|
|
|
} \
|
|
|
|
outdefs[i].flags |= (mask); \
|
|
|
|
outdefs[i].red = pmap->red[red >> pVisual->offsetRed].co.local.red; \
|
|
|
|
outdefs[i].green = pmap->green[green >> pVisual->offsetGreen].co.local.green; \
|
|
|
|
outdefs[i].blue = pmap->blue[blue >> pVisual->offsetBlue].co.local.blue; \
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2012-03-21 20:55:09 +01:00
|
|
|
miExpandDirectColors(ColormapPtr pmap, int ndef, xColorItem * indefs,
|
|
|
|
xColorItem * outdefs)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
int red, green, blue;
|
|
|
|
int maxred, maxgreen, maxblue;
|
|
|
|
int stepred, stepgreen, stepblue;
|
|
|
|
VisualPtr pVisual;
|
|
|
|
int pixel;
|
|
|
|
int nresult;
|
|
|
|
int i;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
pVisual = pmap->pVisual;
|
|
|
|
|
|
|
|
stepred = 1 << pVisual->offsetRed;
|
|
|
|
stepgreen = 1 << pVisual->offsetGreen;
|
|
|
|
stepblue = 1 << pVisual->offsetBlue;
|
|
|
|
maxred = pVisual->redMask;
|
|
|
|
maxgreen = pVisual->greenMask;
|
|
|
|
maxblue = pVisual->blueMask;
|
|
|
|
nresult = 0;
|
2012-03-21 20:55:09 +01:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
return nresult;
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2003-11-14 17:48:57 +01:00
|
|
|
miCreateDefColormap(ScreenPtr pScreen)
|
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
unsigned short zero = 0, ones = 0xFFFF;
|
2003-11-14 17:48:57 +01:00
|
|
|
Pixel wp, bp;
|
2012-03-21 20:55:09 +01:00
|
|
|
VisualPtr pVisual;
|
|
|
|
ColormapPtr cmap;
|
2003-11-14 17:48:57 +01:00
|
|
|
int alloctype;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2010-04-27 02:22:21 +02:00
|
|
|
if (!dixRegisterPrivateKey(&micmapScrPrivateKeyRec, PRIVATE_SCREEN, 0))
|
2012-03-21 20:55:09 +01:00
|
|
|
return FALSE;
|
2010-04-27 02:22:21 +02:00
|
|
|
|
2003-11-14 17:48:57 +01:00
|
|
|
for (pVisual = pScreen->visuals;
|
2012-03-21 20:55:09 +01:00
|
|
|
pVisual->vid != pScreen->rootVisual; pVisual++);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
if (pScreen->rootDepth == 1 || (pVisual->class & DynamicClass))
|
2012-03-21 20:55:09 +01:00
|
|
|
alloctype = AllocNone;
|
2003-11-14 17:48:57 +01:00
|
|
|
else
|
2012-03-21 20:55:09 +01:00
|
|
|
alloctype = AllocAll;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
if (CreateColormap(pScreen->defColormap, pScreen, pVisual, &cmap,
|
2012-03-21 20:55:09 +01:00
|
|
|
alloctype, 0) != Success)
|
|
|
|
return FALSE;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
if (pScreen->rootDepth > 1) {
|
2012-03-21 20:55:09 +01:00
|
|
|
wp = pScreen->whitePixel;
|
|
|
|
bp = pScreen->blackPixel;
|
|
|
|
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;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
(*pScreen->InstallColormap) (cmap);
|
2003-11-14 17:48:57 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Default true color bitmasks, should be overridden by
|
|
|
|
* driver
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define _RZ(d) ((d + 2) / 3)
|
|
|
|
#define _RS(d) 0
|
|
|
|
#define _RM(d) ((1 << _RZ(d)) - 1)
|
|
|
|
#define _GZ(d) ((d - _RZ(d) + 1) / 2)
|
|
|
|
#define _GS(d) _RZ(d)
|
|
|
|
#define _GM(d) (((1 << _GZ(d)) - 1) << _GS(d))
|
|
|
|
#define _BZ(d) (d - _RZ(d) - _GZ(d))
|
|
|
|
#define _BS(d) (_RZ(d) + _GZ(d))
|
|
|
|
#define _BM(d) (((1 << _BZ(d)) - 1) << _BS(d))
|
|
|
|
#define _CE(d) (1 << _RZ(d))
|
|
|
|
|
|
|
|
typedef struct _miVisuals {
|
2012-03-21 20:55:09 +01:00
|
|
|
struct _miVisuals *next;
|
|
|
|
int depth;
|
|
|
|
int bitsPerRGB;
|
|
|
|
int visuals;
|
|
|
|
int count;
|
|
|
|
int preferredCVC;
|
|
|
|
Pixel redMask, greenMask, blueMask;
|
2003-11-14 17:48:57 +01:00
|
|
|
} miVisualsRec, *miVisualsPtr;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
static int miVisualPriority[] = {
|
2003-11-14 17:48:57 +01:00
|
|
|
PseudoColor, GrayScale, StaticColor, TrueColor, DirectColor, StaticGray
|
|
|
|
};
|
|
|
|
|
|
|
|
#define NUM_PRIORITY 6
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
static miVisualsPtr miVisuals;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2007-04-09 23:33:15 +02:00
|
|
|
miClearVisualTypes(void)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
|
|
|
miVisualsPtr v;
|
|
|
|
|
|
|
|
while ((v = miVisuals)) {
|
2012-03-21 20:55:09 +01:00
|
|
|
miVisuals = v->next;
|
|
|
|
free(v);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
miSetVisualTypesAndMasks(int depth, int visuals, int bitsPerRGB,
|
|
|
|
int preferredCVC,
|
|
|
|
Pixel redMask, Pixel greenMask, Pixel blueMask)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
miVisualsPtr new, *prev, v;
|
|
|
|
int count;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
new = malloc(sizeof *new);
|
2003-11-14 17:48:57 +01:00
|
|
|
if (!new)
|
2012-03-21 20:55:09 +01:00
|
|
|
return FALSE;
|
|
|
|
if (!redMask || !greenMask || !blueMask) {
|
|
|
|
redMask = _RM(depth);
|
|
|
|
greenMask = _GM(depth);
|
|
|
|
blueMask = _BM(depth);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
new->next = 0;
|
|
|
|
new->depth = depth;
|
|
|
|
new->visuals = visuals;
|
|
|
|
new->bitsPerRGB = bitsPerRGB;
|
|
|
|
new->preferredCVC = preferredCVC;
|
|
|
|
new->redMask = redMask;
|
|
|
|
new->greenMask = greenMask;
|
|
|
|
new->blueMask = blueMask;
|
|
|
|
count = (visuals >> 1) & 033333333333;
|
|
|
|
count = visuals - count - ((count >> 1) & 033333333333);
|
2012-03-21 20:55:09 +01:00
|
|
|
count = (((count + (count >> 3)) & 030707070707) % 077); /* HAKMEM 169 */
|
2003-11-14 17:48:57 +01:00
|
|
|
new->count = count;
|
|
|
|
for (prev = &miVisuals; (v = *prev); prev = &v->next);
|
|
|
|
*prev = new;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2003-11-14 17:48:57 +01:00
|
|
|
miSetVisualTypes(int depth, int visuals, int bitsPerRGB, int preferredCVC)
|
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
return miSetVisualTypesAndMasks(depth, visuals, bitsPerRGB,
|
|
|
|
preferredCVC, 0, 0, 0);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2003-11-14 17:48:57 +01:00
|
|
|
miGetDefaultVisualMask(int depth)
|
|
|
|
{
|
|
|
|
if (depth > MAX_PSEUDO_DEPTH)
|
2012-03-21 20:55:09 +01:00
|
|
|
return LARGE_VISUALS;
|
2003-11-14 17:48:57 +01:00
|
|
|
else if (depth >= MIN_TRUE_DEPTH)
|
2012-03-21 20:55:09 +01:00
|
|
|
return ALL_VISUALS;
|
2003-11-14 17:48:57 +01:00
|
|
|
else if (depth == 1)
|
2012-03-21 20:55:09 +01:00
|
|
|
return StaticGrayMask;
|
2003-11-14 17:48:57 +01:00
|
|
|
else
|
2012-03-21 20:55:09 +01:00
|
|
|
return SMALL_VISUALS;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
miVisualTypesSet(int depth)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
miVisualsPtr visuals;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
for (visuals = miVisuals; visuals; visuals = visuals->next)
|
2012-03-21 20:55:09 +01:00
|
|
|
if (visuals->depth == depth)
|
|
|
|
return TRUE;
|
2003-11-14 17:48:57 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
miSetPixmapDepths(void)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
int d, f;
|
|
|
|
|
2003-11-14 17:48:57 +01:00
|
|
|
/* Add any unlisted depths from the pixmap formats */
|
2012-03-21 20:55:09 +01:00
|
|
|
for (f = 0; f < screenInfo.numPixmapFormats; f++) {
|
|
|
|
d = screenInfo.formats[f].depth;
|
|
|
|
if (!miVisualTypesSet(d)) {
|
|
|
|
if (!miSetVisualTypes(d, 0, 0, -1))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Distance to least significant one bit
|
|
|
|
*/
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
maskShift(Pixel p)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
int s;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!p)
|
|
|
|
return 0;
|
2003-11-14 17:48:57 +01:00
|
|
|
s = 0;
|
2012-03-21 20:55:09 +01:00
|
|
|
while (!(p & 1)) {
|
|
|
|
s++;
|
|
|
|
p >>= 1;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Given a list of formats for a screen, create a list
|
|
|
|
* of visuals and depths for the screen which corespond to
|
|
|
|
* the set which can be used with this version of cfb.
|
|
|
|
*/
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
miInitVisuals(VisualPtr * visualp, DepthPtr * depthp, int *nvisualp,
|
|
|
|
int *ndepthp, int *rootDepthp, VisualID * defaultVisp,
|
|
|
|
unsigned long sizes, int bitsPerRGB, int preferredVis)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
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;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
/* none specified, we'll guess from pixmap formats */
|
2012-03-21 20:55:09 +01:00
|
|
|
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;
|
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
nvisual = 0;
|
|
|
|
ndepth = 0;
|
2012-03-21 20:55:09 +01:00
|
|
|
for (visuals = miVisuals; visuals; visuals = nextVisuals) {
|
|
|
|
nextVisuals = visuals->next;
|
|
|
|
ndepth++;
|
|
|
|
nvisual += visuals->count;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
depth = malloc(ndepth * sizeof(DepthRec));
|
|
|
|
visual = malloc(nvisual * sizeof(VisualRec));
|
2010-05-05 20:44:06 +02:00
|
|
|
preferredCVCs = malloc(ndepth * sizeof(int));
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!depth || !visual || !preferredCVCs) {
|
|
|
|
free(depth);
|
|
|
|
free(visual);
|
|
|
|
free(preferredCVCs);
|
|
|
|
return FALSE;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
*depthp = depth;
|
|
|
|
*visualp = visual;
|
|
|
|
*ndepthp = ndepth;
|
|
|
|
*nvisualp = nvisual;
|
|
|
|
prefp = preferredCVCs;
|
2012-03-21 20:55:09 +01:00
|
|
|
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);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
miVisuals = NULL;
|
|
|
|
visual = *visualp;
|
|
|
|
depth = *depthp;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* if we did not supplyied by a preferred visual class
|
|
|
|
* check if there is a preferred class in one of the depth
|
|
|
|
* structures - if there is, we want to start looking for the
|
|
|
|
* default visual/depth from that depth.
|
|
|
|
*/
|
|
|
|
first_depth = 0;
|
2012-03-21 20:55:09 +01:00
|
|
|
if (preferredVis < 0 && defaultColorVisualClass < 0) {
|
|
|
|
for (i = 0; i < ndepth; i++) {
|
|
|
|
if (preferredCVCs[i] >= 0) {
|
|
|
|
first_depth = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
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;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
if (i == ndepth) {
|
2012-03-21 20:55:09 +01:00
|
|
|
i = 0;
|
|
|
|
j = 0;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
*rootDepthp = depth[i].depth;
|
|
|
|
*defaultVisp = depth[i].vids[j];
|
2010-05-05 20:44:06 +02:00
|
|
|
free(preferredCVCs);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|