dix: move colormap flags into colormap_priv.h and rename them
These aren't used by any drivers/modules, so no need to keep them exported. As already touching them, give them a proper name prefix for clarity. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1581>
This commit is contained in:
parent
7ba3fc3a54
commit
1bfa4876f6
|
@ -292,7 +292,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
|
||||||
pmap->mid = mid;
|
pmap->mid = mid;
|
||||||
pmap->flags = 0; /* start out with all flags clear */
|
pmap->flags = 0; /* start out with all flags clear */
|
||||||
if (mid == pScreen->defColormap)
|
if (mid == pScreen->defColormap)
|
||||||
pmap->flags |= IsDefault;
|
pmap->flags |= CM_IsDefault;
|
||||||
pmap->pScreen = pScreen;
|
pmap->pScreen = pScreen;
|
||||||
pmap->pVisual = pVisual;
|
pmap->pVisual = pVisual;
|
||||||
pmap->class = class;
|
pmap->class = class;
|
||||||
|
@ -306,7 +306,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
|
||||||
*pptr = (Pixel *) NULL;
|
*pptr = (Pixel *) NULL;
|
||||||
if (alloc == AllocAll) {
|
if (alloc == AllocAll) {
|
||||||
if (class & DynamicClass)
|
if (class & DynamicClass)
|
||||||
pmap->flags |= AllAllocated;
|
pmap->flags |= CM_AllAllocated;
|
||||||
for (pent = &pmap->red[size - 1]; pent >= pmap->red; pent--)
|
for (pent = &pmap->red[size - 1]; pent >= pmap->red; pent--)
|
||||||
pent->refcnt = AllocPrivate;
|
pent->refcnt = AllocPrivate;
|
||||||
pmap->freeRed = 0;
|
pmap->freeRed = 0;
|
||||||
|
@ -379,7 +379,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
|
||||||
pmap->numPixelsBlue[client] = size;
|
pmap->numPixelsBlue[client] = size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pmap->flags |= BeingCreated;
|
pmap->flags |= CM_BeingCreated;
|
||||||
|
|
||||||
if (!AddResource(mid, X11_RESTYPE_COLORMAP, (void *) pmap))
|
if (!AddResource(mid, X11_RESTYPE_COLORMAP, (void *) pmap))
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
|
@ -401,7 +401,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
|
||||||
FreeResource(mid, X11_RESTYPE_NONE);
|
FreeResource(mid, X11_RESTYPE_NONE);
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
}
|
}
|
||||||
pmap->flags &= ~BeingCreated;
|
pmap->flags &= ~CM_BeingCreated;
|
||||||
*ppcmap = pmap;
|
*ppcmap = pmap;
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
@ -451,7 +451,7 @@ FreeColormap(void *value, XID mid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pmap->flags & IsDefault) {
|
if (pmap->flags & CM_IsDefault) {
|
||||||
dixFreePrivates(pmap->devPrivates, PRIVATE_COLORMAP);
|
dixFreePrivates(pmap->devPrivates, PRIVATE_COLORMAP);
|
||||||
free(pmap);
|
free(pmap);
|
||||||
}
|
}
|
||||||
|
@ -548,7 +548,7 @@ CopyColormapAndFree(Colormap mid, ColormapPtr pSrc, int client)
|
||||||
pScreen = pSrc->pScreen;
|
pScreen = pSrc->pScreen;
|
||||||
pVisual = pSrc->pVisual;
|
pVisual = pSrc->pVisual;
|
||||||
midSrc = pSrc->mid;
|
midSrc = pSrc->mid;
|
||||||
alloc = ((pSrc->flags & AllAllocated) && CLIENT_ID(midSrc) == client) ?
|
alloc = ((pSrc->flags & CM_AllAllocated) && CLIENT_ID(midSrc) == client) ?
|
||||||
AllocAll : AllocNone;
|
AllocAll : AllocNone;
|
||||||
size = pVisual->ColormapEntries;
|
size = pVisual->ColormapEntries;
|
||||||
|
|
||||||
|
@ -564,7 +564,7 @@ CopyColormapAndFree(Colormap mid, ColormapPtr pSrc, int client)
|
||||||
memmove((char *) pmap->blue, (char *) pSrc->blue,
|
memmove((char *) pmap->blue, (char *) pSrc->blue,
|
||||||
size * sizeof(Entry));
|
size * sizeof(Entry));
|
||||||
}
|
}
|
||||||
pSrc->flags &= ~AllAllocated;
|
pSrc->flags &= ~CM_AllAllocated;
|
||||||
FreePixels(pSrc, client);
|
FreePixels(pSrc, client);
|
||||||
doUpdateColors(pmap);
|
doUpdateColors(pmap);
|
||||||
return Success;
|
return Success;
|
||||||
|
@ -810,7 +810,7 @@ FindColor(ColormapPtr pmap, EntryPtr pentFirst, int size, xrgb * prgb,
|
||||||
/* If we're initializing the colormap, then we are looking for
|
/* If we're initializing the colormap, then we are looking for
|
||||||
* the first free cell we can find, not to minimize the number
|
* the first free cell we can find, not to minimize the number
|
||||||
* of entries we use. So don't look any further. */
|
* of entries we use. So don't look any further. */
|
||||||
if (pmap->flags & BeingCreated)
|
if (pmap->flags & CM_BeingCreated)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pixel++;
|
pixel++;
|
||||||
|
@ -883,7 +883,7 @@ FindColor(ColormapPtr pmap, EntryPtr pentFirst, int size, xrgb * prgb,
|
||||||
*pPixel = def.pixel;
|
*pPixel = def.pixel;
|
||||||
|
|
||||||
gotit:
|
gotit:
|
||||||
if (pmap->flags & BeingCreated || client == -1)
|
if (pmap->flags & CM_BeingCreated || client == -1)
|
||||||
return Success;
|
return Success;
|
||||||
/* Now remember the pixel, for freeing later */
|
/* Now remember the pixel, for freeing later */
|
||||||
switch (channel) {
|
switch (channel) {
|
||||||
|
@ -957,7 +957,7 @@ AllocColor(ColormapPtr pmap,
|
||||||
* the colormap, even if it's a static type. Otherwise, we'd never be
|
* the colormap, even if it's a static type. Otherwise, we'd never be
|
||||||
* able to initialize static colormaps
|
* able to initialize static colormaps
|
||||||
*/
|
*/
|
||||||
if (pmap->flags & BeingCreated)
|
if (pmap->flags & CM_BeingCreated)
|
||||||
class |= DynamicClass;
|
class |= DynamicClass;
|
||||||
|
|
||||||
/* If this is one of the static storage classes, and we're not initializing
|
/* If this is one of the static storage classes, and we're not initializing
|
||||||
|
@ -1088,7 +1088,7 @@ AllocColor(ColormapPtr pmap,
|
||||||
* resource manager that the client has pixels in this colormap which
|
* resource manager that the client has pixels in this colormap which
|
||||||
* should be freed when the client dies */
|
* should be freed when the client dies */
|
||||||
if ((pmap->numPixelsRed[client] == 1) &&
|
if ((pmap->numPixelsRed[client] == 1) &&
|
||||||
(CLIENT_ID(pmap->mid) != client) && !(pmap->flags & BeingCreated)) {
|
(CLIENT_ID(pmap->mid) != client) && !(pmap->flags & CM_BeingCreated)) {
|
||||||
colorResource *pcr;
|
colorResource *pcr;
|
||||||
|
|
||||||
pcr = malloc(sizeof(colorResource));
|
pcr = malloc(sizeof(colorResource));
|
||||||
|
@ -2078,7 +2078,7 @@ FreeColors(ColormapPtr pmap, int client, int count, Pixel * pixels, Pixel mask)
|
||||||
Pixel rmask;
|
Pixel rmask;
|
||||||
|
|
||||||
class = pmap->class;
|
class = pmap->class;
|
||||||
if (pmap->flags & AllAllocated)
|
if (pmap->flags & CM_AllAllocated)
|
||||||
return BadAccess;
|
return BadAccess;
|
||||||
if ((class | DynamicClass) == DirectColor) {
|
if ((class | DynamicClass) == DirectColor) {
|
||||||
rmask = mask & RGBMASK(pmap->pVisual);
|
rmask = mask & RGBMASK(pmap->pVisual);
|
||||||
|
@ -2260,7 +2260,7 @@ StoreColors(ColormapPtr pmap, int count, xColorItem * defs, ClientPtr client)
|
||||||
int ok;
|
int ok;
|
||||||
|
|
||||||
class = pmap->class;
|
class = pmap->class;
|
||||||
if (!(class & DynamicClass) && !(pmap->flags & BeingCreated)) {
|
if (!(class & DynamicClass) && !(pmap->flags & CM_BeingCreated)) {
|
||||||
return BadAccess;
|
return BadAccess;
|
||||||
}
|
}
|
||||||
pVisual = pmap->pVisual;
|
pVisual = pmap->pVisual;
|
||||||
|
|
|
@ -13,6 +13,12 @@
|
||||||
#include "include/dix.h"
|
#include "include/dix.h"
|
||||||
#include "include/window.h"
|
#include "include/window.h"
|
||||||
|
|
||||||
|
/* Values for the flags field of a colormap. These should have 1 bit set
|
||||||
|
* and not overlap */
|
||||||
|
#define CM_IsDefault 1
|
||||||
|
#define CM_AllAllocated 2
|
||||||
|
#define CM_BeingCreated 4
|
||||||
|
|
||||||
typedef struct _CMEntry *EntryPtr;
|
typedef struct _CMEntry *EntryPtr;
|
||||||
|
|
||||||
int CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
|
int CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
|
||||||
|
|
|
@ -2481,7 +2481,7 @@ ProcFreeColormap(ClientPtr client)
|
||||||
client, DixDestroyAccess);
|
client, DixDestroyAccess);
|
||||||
if (rc == Success) {
|
if (rc == Success) {
|
||||||
/* Freeing a default colormap is a no-op */
|
/* Freeing a default colormap is a no-op */
|
||||||
if (!(pmap->flags & IsDefault))
|
if (!(pmap->flags & CM_IsDefault))
|
||||||
FreeResource(stuff->id, X11_RESTYPE_NONE);
|
FreeResource(stuff->id, X11_RESTYPE_NONE);
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
@ -2827,7 +2827,7 @@ ProcFreeColors(ClientPtr client)
|
||||||
if (rc == Success) {
|
if (rc == Success) {
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
if (pcmp->flags & AllAllocated)
|
if (pcmp->flags & CM_AllAllocated)
|
||||||
return BadAccess;
|
return BadAccess;
|
||||||
count = bytes_to_int32((client->req_len << 2) - sizeof(xFreeColorsReq));
|
count = bytes_to_int32((client->req_len << 2) - sizeof(xFreeColorsReq));
|
||||||
return FreeColors(pcmp, client->index, count,
|
return FreeColors(pcmp, client->index, count,
|
||||||
|
|
|
@ -2736,7 +2736,7 @@ If the colormap is static, which you can tell by looking at the class field,
|
||||||
you will want to fill in each color cell to match the hardwares notion of the
|
you will want to fill in each color cell to match the hardwares notion of the
|
||||||
color for that pixel.
|
color for that pixel.
|
||||||
If the colormap is the default for the screen, which you can tell by looking
|
If the colormap is the default for the screen, which you can tell by looking
|
||||||
at the IsDefault bit in the flags field, you should allocate BlackPixel
|
at the CM_IsDefault bit in the flags field, you should allocate BlackPixel
|
||||||
and WhitePixel to match the values you set in the pScreen structure.
|
and WhitePixel to match the values you set in the pScreen structure.
|
||||||
(Of course, you picked those values to begin with.)</para>
|
(Of course, you picked those values to begin with.)</para>
|
||||||
<para>
|
<para>
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
#endif
|
#endif
|
||||||
#include "win.h"
|
#include "win.h"
|
||||||
|
|
||||||
|
#include "dix/colormap_priv.h"
|
||||||
|
|
||||||
#define FAIL_MSG_MAX_BLT 10
|
#define FAIL_MSG_MAX_BLT 10
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1135,7 +1137,7 @@ winDestroyColormapShadowDDNL(ColormapPtr pColormap)
|
||||||
* will not have had winUninstallColormap called on it. Thus,
|
* will not have had winUninstallColormap called on it. Thus,
|
||||||
* we need to handle the default colormap in a special way.
|
* we need to handle the default colormap in a special way.
|
||||||
*/
|
*/
|
||||||
if (pColormap->flags & IsDefault) {
|
if (pColormap->flags & CM_IsDefault) {
|
||||||
#if ENABLE_DEBUG
|
#if ENABLE_DEBUG
|
||||||
winDebug
|
winDebug
|
||||||
("winDestroyColormapShadowDDNL - Destroying default colormap\n");
|
("winDestroyColormapShadowDDNL - Destroying default colormap\n");
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#endif
|
#endif
|
||||||
#include "win.h"
|
#include "win.h"
|
||||||
|
|
||||||
|
#include "dix/colormap_priv.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Local function prototypes
|
* Local function prototypes
|
||||||
*/
|
*/
|
||||||
|
@ -1209,7 +1211,7 @@ winDestroyColormapShadowGDI(ColormapPtr pColormap)
|
||||||
* will not have had winUninstallColormap called on it. Thus,
|
* will not have had winUninstallColormap called on it. Thus,
|
||||||
* we need to handle the default colormap in a special way.
|
* we need to handle the default colormap in a special way.
|
||||||
*/
|
*/
|
||||||
if (pColormap->flags & IsDefault) {
|
if (pColormap->flags & CM_IsDefault) {
|
||||||
#if ENABLE_DEBUG
|
#if ENABLE_DEBUG
|
||||||
winDebug("winDestroyColormapShadowGDI - Destroying default "
|
winDebug("winDestroyColormapShadowGDI - Destroying default "
|
||||||
"colormap\n");
|
"colormap\n");
|
||||||
|
|
|
@ -53,12 +53,6 @@ SOFTWARE.
|
||||||
|
|
||||||
#define DynamicClass 1
|
#define DynamicClass 1
|
||||||
|
|
||||||
/* Values for the flags field of a colormap. These should have 1 bit set
|
|
||||||
* and not overlap */
|
|
||||||
#define IsDefault 1
|
|
||||||
#define AllAllocated 2
|
|
||||||
#define BeingCreated 4
|
|
||||||
|
|
||||||
typedef CARD32 Pixel;
|
typedef CARD32 Pixel;
|
||||||
|
|
||||||
extern _X_EXPORT Bool ResizeVisualArray(ScreenPtr /* pScreen */ ,
|
extern _X_EXPORT Bool ResizeVisualArray(ScreenPtr /* pScreen */ ,
|
||||||
|
|
|
@ -91,8 +91,8 @@ typedef struct _ColormapRec {
|
||||||
short class; /* PseudoColor or DirectColor */
|
short class; /* PseudoColor or DirectColor */
|
||||||
XID mid; /* client's name for colormap */
|
XID mid; /* client's name for colormap */
|
||||||
ScreenPtr pScreen; /* screen map is associated with */
|
ScreenPtr pScreen; /* screen map is associated with */
|
||||||
short flags; /* 1 = IsDefault
|
short flags; /* 1 = CM_IsDefault
|
||||||
* 2 = AllAllocated */
|
* 2 = CM_AllAllocated */
|
||||||
int freeRed;
|
int freeRed;
|
||||||
int freeGreen;
|
int freeGreen;
|
||||||
int freeBlue;
|
int freeBlue;
|
||||||
|
|
Loading…
Reference in New Issue