[PATCH] mi: track screens' installed colormaps as screen privates
Tiago Vignatti
tiago.vignatti at nokia.com
Thu Apr 22 10:16:58 PDT 2010
Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
---
hw/xfree86/common/xf86DGA.c | 2 +-
hw/xfree86/common/xf86cmap.c | 49 ++++++++++++++++++++---------------------
hw/xfree86/vgahw/vgaCmap.c | 14 ++++++------
mi/micmap.c | 15 ++++++------
mi/micmap.h | 9 ++++++-
5 files changed, 47 insertions(+), 42 deletions(-)
diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index 804fd37..1a10327 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -731,7 +731,7 @@ DGAInstallCmap(ColormapPtr cmap)
/* We rely on the extension to check that DGA is active */
if(!pScreenPriv->dgaColormap)
- pScreenPriv->savedColormap = miInstalledMaps[pScreen->myNum];
+ pScreenPriv->savedColormap = GetInstalledmiColormap(pScreen);
pScreenPriv->dgaColormap = cmap;
diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c
index f60d96e..e266ffb 100644
--- a/hw/xfree86/common/xf86cmap.c
+++ b/hw/xfree86/common/xf86cmap.c
@@ -63,10 +63,10 @@
#define SCREEN_EPILOGUE(pScreen, field, wrapper)\
((pScreen)->field = wrapper)
-#define LOAD_PALETTE(pmap, index) \
- ((pmap == miInstalledMaps[index]) && \
+#define LOAD_PALETTE(pmap) \
+ ((pmap == GetInstalledmiColormap(pmap->pScreen)) && \
((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) || \
- xf86Screens[index]->vtSema || pScreenPriv->isDGAmode))
+ xf86Screens[pmap->pScreen->myNum]->vtSema || pScreenPriv->isDGAmode))
typedef struct _CMapLink {
@@ -221,7 +221,7 @@ Bool xf86HandleColormaps(
}
/* Force the initial map to be loaded */
- miInstalledMaps[pScreen->myNum] = NULL;
+ SetInstalledmiColormap(pScreen, NULL);
CMapInstallColormap(pDefMap);
return TRUE;
}
@@ -425,11 +425,10 @@ static void
CMapInstallColormap(ColormapPtr pmap)
{
ScreenPtr pScreen = pmap->pScreen;
- int index = pScreen->myNum;
CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
&pScreen->devPrivates, CMapScreenKey);
- if (pmap == miInstalledMaps[index])
+ if (pmap == GetInstalledmiColormap(pmap->pScreen))
return;
pScreen->InstallColormap = pScreenPriv->InstallColormap;
@@ -438,15 +437,15 @@ CMapInstallColormap(ColormapPtr pmap)
/* Important. We let the lower layers, namely DGA,
overwrite the choice of Colormap to install */
- if (miInstalledMaps[index])
- pmap = miInstalledMaps[index];
+ if (GetInstalledmiColormap(pmap->pScreen))
+ pmap = GetInstalledmiColormap(pmap->pScreen);
if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) &&
(pmap->pVisual->class == TrueColor) &&
CMapColormapUseMax(pmap->pVisual, pScreenPriv))
return;
- if(LOAD_PALETTE(pmap, index))
+ if(LOAD_PALETTE(pmap))
CMapReinstallMap(pmap);
}
@@ -461,8 +460,8 @@ CMapEnterVT(int index, int flags)
&pScreen->devPrivates, CMapScreenKey);
if((*pScreenPriv->EnterVT)(index, flags)) {
- if(miInstalledMaps[index])
- CMapReinstallMap(miInstalledMaps[index]);
+ if(GetInstalledmiColormap(pScreen))
+ CMapReinstallMap(GetInstalledmiColormap(pScreen));
return TRUE;
}
return FALSE;
@@ -477,8 +476,8 @@ CMapSwitchMode(int index, DisplayModePtr mode, int flags)
&pScreen->devPrivates, CMapScreenKey);
if((*pScreenPriv->SwitchMode)(index, mode, flags)) {
- if(miInstalledMaps[index])
- CMapReinstallMap(miInstalledMaps[index]);
+ if(GetInstalledmiColormap(pScreen))
+ CMapReinstallMap(GetInstalledmiColormap(pScreen));
return TRUE;
}
return FALSE;
@@ -497,9 +496,9 @@ CMapSetDGAMode(int index, int num, DGADevicePtr dev)
pScreenPriv->isDGAmode = DGAActive(index);
- if(!pScreenPriv->isDGAmode && miInstalledMaps[index]
+ if(!pScreenPriv->isDGAmode && GetInstalledmiColormap(pScreen)
&& xf86Screens[pScreen->myNum]->vtSema)
- CMapReinstallMap(miInstalledMaps[index]);
+ CMapReinstallMap(GetInstalledmiColormap(pScreen));
return ret;
}
@@ -649,7 +648,7 @@ CMapRefreshColors(ColormapPtr pmap, int defs, int* indices)
}
- if(LOAD_PALETTE(pmap, pmap->pScreen->myNum))
+ if(LOAD_PALETTE(pmap))
(*pScrn->LoadPalette)(pScreenPriv->pScrn, defs, indices,
colors, pmap->pVisual);
@@ -802,7 +801,7 @@ CMapSetOverscan(ColormapPtr pmap, int defs, int *indices)
}
if (newOverscan) {
pColPriv->overscan = overscan;
- if (LOAD_PALETTE(pmap, pmap->pScreen->myNum)) {
+ if (LOAD_PALETTE(pmap)) {
#ifdef DEBUGOVERSCAN
ErrorF("SetOverscan() called from CmapSetOverscan\n");
#endif
@@ -929,10 +928,10 @@ CMapChangeGamma(
pLink = pLink->next;
}
- if(miInstalledMaps[pScreen->myNum] &&
+ if(GetInstalledmiColormap(pScreen) &&
((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) ||
pScrn->vtSema || pScreenPriv->isDGAmode)) {
- ColormapPtr pMap = miInstalledMaps[pScreen->myNum];
+ ColormapPtr pMap = GetInstalledmiColormap(pScreen);
if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) &&
(pMap->pVisual->class == TrueColor) &&
@@ -951,9 +950,9 @@ CMapChangeGamma(
if(pLink) {
/* need to trick CMapRefreshColors() into thinking
this is the currently installed map */
- miInstalledMaps[pScreen->myNum] = pLink->cmap;
+ SetInstalledmiColormap(pScreen, pLink->cmap);
CMapReinstallMap(pLink->cmap);
- miInstalledMaps[pScreen->myNum] = pMap;
+ SetInstalledmiColormap(pScreen, pMap);
}
} else
CMapReinstallMap(pMap);
@@ -1035,10 +1034,10 @@ xf86ChangeGammaRamp(
pLink = pLink->next;
}
- if(miInstalledMaps[pScreen->myNum] &&
+ if(GetInstalledmiColormap(pScreen) &&
((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) ||
pScrn->vtSema || pScreenPriv->isDGAmode)) {
- ColormapPtr pMap = miInstalledMaps[pScreen->myNum];
+ ColormapPtr pMap = GetInstalledmiColormap(pScreen);
if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) &&
(pMap->pVisual->class == TrueColor) &&
@@ -1057,9 +1056,9 @@ xf86ChangeGammaRamp(
if(pLink) {
/* need to trick CMapRefreshColors() into thinking
this is the currently installed map */
- miInstalledMaps[pScreen->myNum] = pLink->cmap;
+ SetInstalledmiColormap(pScreen, pLink->cmap);
CMapReinstallMap(pLink->cmap);
- miInstalledMaps[pScreen->myNum] = pMap;
+ SetInstalledmiColormap(pScreen, pMap);
}
} else
CMapReinstallMap(pMap);
diff --git a/hw/xfree86/vgahw/vgaCmap.c b/hw/xfree86/vgahw/vgaCmap.c
index 5bd38b4..06eeb4c 100644
--- a/hw/xfree86/vgahw/vgaCmap.c
+++ b/hw/xfree86/vgahw/vgaCmap.c
@@ -50,7 +50,7 @@ vgaListInstalledColormaps(pScreen, pmaps)
/* By the time we are processing requests, we can guarantee that there
* is always a colormap installed */
- *pmaps = miInstalledMaps[pScreen->myNum]->mid;
+ *pmaps = GetInstalledmiColormap(pScreen)->mid;
return(1);
}
@@ -62,13 +62,13 @@ vgaGetInstalledColormaps(pScreen, pmaps)
/* By the time we are processing requests, we can guarantee that there
* is always a colormap installed */
- *pmaps = miInstalledMaps[pScreen->myNum];
+ *pmaps = GetInstalledmiColormap(pScreen);
return(1);
}
int vgaCheckColorMap(ColormapPtr pmap)
{
- return (pmap != miInstalledMaps[pmap->pScreen->myNum]);
+ return (pmap != GetInstalledmiColormap(pmap->pScreen));
}
@@ -217,7 +217,7 @@ void
vgaInstallColormap(pmap)
ColormapPtr pmap;
{
- ColormapPtr oldmap = miInstalledMaps[pmap->pScreen->myNum];
+ ColormapPtr oldmap = GetInstalledmiColormap(pmap->pScreen);
int entries;
Pixel * ppix;
xrgb * prgb;
@@ -242,7 +242,7 @@ vgaInstallColormap(pmap)
if ( oldmap != NOMAPYET)
WalkTree( pmap->pScreen, TellLostMap, &oldmap->mid);
- miInstalledMaps[pmap->pScreen->myNum] = pmap;
+ SetInstalledmiColormap(pmap->pScreen, pmap);
for ( i=0; i<entries; i++) ppix[i] = i;
@@ -273,13 +273,13 @@ vgaUninstallColormap(pmap)
ColormapPtr defColormap;
- if ( pmap != miInstalledMaps[pmap->pScreen->myNum] )
+ if ( pmap != GetInstalledmiColormap(pmap->pScreen))
return;
dixLookupResourceByType((pointer *)&defColormap, pmap->pScreen->defColormap,
RT_COLORMAP, serverClient, DixInstallAccess);
- if (defColormap == miInstalledMaps[pmap->pScreen->myNum])
+ if (defColormap == GetInstalledmiColormap(pmap->pScreen))
return;
(*pmap->pScreen->InstallColormap) (defColormap);
diff --git a/mi/micmap.c b/mi/micmap.c
index e832be7..3fded02 100644
--- a/mi/micmap.c
+++ b/mi/micmap.c
@@ -40,13 +40,14 @@
#include "globals.h"
#include "micmap.h"
-ColormapPtr miInstalledMaps[MAXSCREENS];
+int micmapScrPrivateKeyIndex;
+DevPrivateKey micmapScrPrivateKey = &micmapScrPrivateKeyIndex;
int
miListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
{
- if (miInstalledMaps[pScreen->myNum]) {
- *pmaps = miInstalledMaps[pScreen->myNum]->mid;
+ if (GetInstalledmiColormap(pScreen)) {
+ *pmaps = GetInstalledmiColormap(pScreen)->mid;
return (1);
}
return 0;
@@ -55,8 +56,7 @@ miListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
void
miInstallColormap(ColormapPtr pmap)
{
- int index = pmap->pScreen->myNum;
- ColormapPtr oldpmap = miInstalledMaps[index];
+ ColormapPtr oldpmap = GetInstalledmiColormap(pmap->pScreen);
if(pmap != oldpmap)
{
@@ -65,7 +65,7 @@ miInstallColormap(ColormapPtr pmap)
if(oldpmap != (ColormapPtr)None)
WalkTree(pmap->pScreen, TellLostMap, (char *)&oldpmap->mid);
/* Install pmap */
- miInstalledMaps[index] = pmap;
+ SetInstalledmiColormap(pmap->pScreen, pmap);
WalkTree(pmap->pScreen, TellGainedMap, (char *)&pmap->mid);
}
@@ -74,8 +74,7 @@ miInstallColormap(ColormapPtr pmap)
void
miUninstallColormap(ColormapPtr pmap)
{
- int index = pmap->pScreen->myNum;
- ColormapPtr curpmap = miInstalledMaps[index];
+ ColormapPtr curpmap = GetInstalledmiColormap(pmap->pScreen);
if(pmap == curpmap)
{
diff --git a/mi/micmap.h b/mi/micmap.h
index 5c8448a..c84a9cd 100644
--- a/mi/micmap.h
+++ b/mi/micmap.h
@@ -4,7 +4,14 @@
#ifndef _MICMAP_H_
#define _MICMAP_H_
-extern _X_EXPORT ColormapPtr miInstalledMaps[MAXSCREENS];
+#define GetInstalledmiColormap(s) \
+ ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, micmapScrPrivateKey))
+#define SetInstalledmiColormap(s,c) \
+ (dixSetPrivate(&(s)->devPrivates, micmapScrPrivateKey, c))
+
+extern _X_EXPORT int micmapScrPrivateKeyIndex;
+extern _X_EXPORT DevPrivateKey micmapScrPrivateKey;
+
typedef Bool (* miInitVisualsProcPtr)(VisualPtr *, DepthPtr *, int *, int *,
int *, VisualID *, unsigned long, int,
--
1.6.0.4
--cNdxnHkX5QqsyA0e--
More information about the xorg-devel
mailing list