From 1bfa4876f688412c97043408561a4d895ebf08cc Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Fri, 28 Jun 2024 12:50:24 +0200 Subject: [PATCH] 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 Part-of: --- dix/colormap.c | 26 +++++++++++++------------- dix/colormap_priv.h | 6 ++++++ dix/dispatch.c | 4 ++-- doc/Xserver-spec.xml | 2 +- hw/xwin/winshadddnl.c | 4 +++- hw/xwin/winshadgdi.c | 4 +++- include/colormap.h | 6 ------ include/colormapst.h | 4 ++-- 8 files changed, 30 insertions(+), 26 deletions(-) diff --git a/dix/colormap.c b/dix/colormap.c index 193f286bd..b7ce8da5e 100644 --- a/dix/colormap.c +++ b/dix/colormap.c @@ -292,7 +292,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, pmap->mid = mid; pmap->flags = 0; /* start out with all flags clear */ if (mid == pScreen->defColormap) - pmap->flags |= IsDefault; + pmap->flags |= CM_IsDefault; pmap->pScreen = pScreen; pmap->pVisual = pVisual; pmap->class = class; @@ -306,7 +306,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, *pptr = (Pixel *) NULL; if (alloc == AllocAll) { if (class & DynamicClass) - pmap->flags |= AllAllocated; + pmap->flags |= CM_AllAllocated; for (pent = &pmap->red[size - 1]; pent >= pmap->red; pent--) pent->refcnt = AllocPrivate; pmap->freeRed = 0; @@ -379,7 +379,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, pmap->numPixelsBlue[client] = size; } } - pmap->flags |= BeingCreated; + pmap->flags |= CM_BeingCreated; if (!AddResource(mid, X11_RESTYPE_COLORMAP, (void *) pmap)) return BadAlloc; @@ -401,7 +401,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, FreeResource(mid, X11_RESTYPE_NONE); return BadAlloc; } - pmap->flags &= ~BeingCreated; + pmap->flags &= ~CM_BeingCreated; *ppcmap = pmap; 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); free(pmap); } @@ -548,7 +548,7 @@ CopyColormapAndFree(Colormap mid, ColormapPtr pSrc, int client) pScreen = pSrc->pScreen; pVisual = pSrc->pVisual; midSrc = pSrc->mid; - alloc = ((pSrc->flags & AllAllocated) && CLIENT_ID(midSrc) == client) ? + alloc = ((pSrc->flags & CM_AllAllocated) && CLIENT_ID(midSrc) == client) ? AllocAll : AllocNone; size = pVisual->ColormapEntries; @@ -564,7 +564,7 @@ CopyColormapAndFree(Colormap mid, ColormapPtr pSrc, int client) memmove((char *) pmap->blue, (char *) pSrc->blue, size * sizeof(Entry)); } - pSrc->flags &= ~AllAllocated; + pSrc->flags &= ~CM_AllAllocated; FreePixels(pSrc, client); doUpdateColors(pmap); 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 * the first free cell we can find, not to minimize the number * of entries we use. So don't look any further. */ - if (pmap->flags & BeingCreated) + if (pmap->flags & CM_BeingCreated) break; } pixel++; @@ -883,7 +883,7 @@ FindColor(ColormapPtr pmap, EntryPtr pentFirst, int size, xrgb * prgb, *pPixel = def.pixel; gotit: - if (pmap->flags & BeingCreated || client == -1) + if (pmap->flags & CM_BeingCreated || client == -1) return Success; /* Now remember the pixel, for freeing later */ switch (channel) { @@ -957,7 +957,7 @@ AllocColor(ColormapPtr pmap, * the colormap, even if it's a static type. Otherwise, we'd never be * able to initialize static colormaps */ - if (pmap->flags & BeingCreated) + if (pmap->flags & CM_BeingCreated) class |= DynamicClass; /* 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 * should be freed when the client dies */ if ((pmap->numPixelsRed[client] == 1) && - (CLIENT_ID(pmap->mid) != client) && !(pmap->flags & BeingCreated)) { + (CLIENT_ID(pmap->mid) != client) && !(pmap->flags & CM_BeingCreated)) { colorResource *pcr; pcr = malloc(sizeof(colorResource)); @@ -2078,7 +2078,7 @@ FreeColors(ColormapPtr pmap, int client, int count, Pixel * pixels, Pixel mask) Pixel rmask; class = pmap->class; - if (pmap->flags & AllAllocated) + if (pmap->flags & CM_AllAllocated) return BadAccess; if ((class | DynamicClass) == DirectColor) { rmask = mask & RGBMASK(pmap->pVisual); @@ -2260,7 +2260,7 @@ StoreColors(ColormapPtr pmap, int count, xColorItem * defs, ClientPtr client) int ok; class = pmap->class; - if (!(class & DynamicClass) && !(pmap->flags & BeingCreated)) { + if (!(class & DynamicClass) && !(pmap->flags & CM_BeingCreated)) { return BadAccess; } pVisual = pmap->pVisual; diff --git a/dix/colormap_priv.h b/dix/colormap_priv.h index 90ec1600f..04a55b07a 100644 --- a/dix/colormap_priv.h +++ b/dix/colormap_priv.h @@ -13,6 +13,12 @@ #include "include/dix.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; int CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, diff --git a/dix/dispatch.c b/dix/dispatch.c index eea2bc105..f41d3704d 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -2481,7 +2481,7 @@ ProcFreeColormap(ClientPtr client) client, DixDestroyAccess); if (rc == Success) { /* Freeing a default colormap is a no-op */ - if (!(pmap->flags & IsDefault)) + if (!(pmap->flags & CM_IsDefault)) FreeResource(stuff->id, X11_RESTYPE_NONE); return Success; } @@ -2827,7 +2827,7 @@ ProcFreeColors(ClientPtr client) if (rc == Success) { int count; - if (pcmp->flags & AllAllocated) + if (pcmp->flags & CM_AllAllocated) return BadAccess; count = bytes_to_int32((client->req_len << 2) - sizeof(xFreeColorsReq)); return FreeColors(pcmp, client->index, count, diff --git a/doc/Xserver-spec.xml b/doc/Xserver-spec.xml index fdbb84170..7736cb292 100644 --- a/doc/Xserver-spec.xml +++ b/doc/Xserver-spec.xml @@ -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 color for that pixel. 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. (Of course, you picked those values to begin with.) diff --git a/hw/xwin/winshadddnl.c b/hw/xwin/winshadddnl.c index 2884134b4..38ce01f08 100644 --- a/hw/xwin/winshadddnl.c +++ b/hw/xwin/winshadddnl.c @@ -36,6 +36,8 @@ #endif #include "win.h" +#include "dix/colormap_priv.h" + #define FAIL_MSG_MAX_BLT 10 /* @@ -1135,7 +1137,7 @@ winDestroyColormapShadowDDNL(ColormapPtr pColormap) * will not have had winUninstallColormap called on it. Thus, * we need to handle the default colormap in a special way. */ - if (pColormap->flags & IsDefault) { + if (pColormap->flags & CM_IsDefault) { #if ENABLE_DEBUG winDebug ("winDestroyColormapShadowDDNL - Destroying default colormap\n"); diff --git a/hw/xwin/winshadgdi.c b/hw/xwin/winshadgdi.c index 560b50cf9..f8317ad27 100644 --- a/hw/xwin/winshadgdi.c +++ b/hw/xwin/winshadgdi.c @@ -33,6 +33,8 @@ #endif #include "win.h" +#include "dix/colormap_priv.h" + /* * Local function prototypes */ @@ -1209,7 +1211,7 @@ winDestroyColormapShadowGDI(ColormapPtr pColormap) * will not have had winUninstallColormap called on it. Thus, * we need to handle the default colormap in a special way. */ - if (pColormap->flags & IsDefault) { + if (pColormap->flags & CM_IsDefault) { #if ENABLE_DEBUG winDebug("winDestroyColormapShadowGDI - Destroying default " "colormap\n"); diff --git a/include/colormap.h b/include/colormap.h index 016c76d63..216a4c932 100644 --- a/include/colormap.h +++ b/include/colormap.h @@ -53,12 +53,6 @@ SOFTWARE. #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; extern _X_EXPORT Bool ResizeVisualArray(ScreenPtr /* pScreen */ , diff --git a/include/colormapst.h b/include/colormapst.h index 53b61cb22..78545f90d 100644 --- a/include/colormapst.h +++ b/include/colormapst.h @@ -91,8 +91,8 @@ typedef struct _ColormapRec { short class; /* PseudoColor or DirectColor */ XID mid; /* client's name for colormap */ ScreenPtr pScreen; /* screen map is associated with */ - short flags; /* 1 = IsDefault - * 2 = AllAllocated */ + short flags; /* 1 = CM_IsDefault + * 2 = CM_AllAllocated */ int freeRed; int freeGreen; int freeBlue;