Compare commits

...

4 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult 7b00d306b3 xv: use embedded private instead of pointer
The private struct is pretty small and it needs to be allocated anyways,
so save an extra allocation by directly embedding it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-02 19:45:18 +02:00
Enrico Weigelt, metux IT consult 2ad1d1d6cb xfree86: drop XF86XvScreenKey field
Not used by any drivers anymore, so no need to keep it around any longer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-02 19:45:18 +02:00
Enrico Weigelt, metux IT consult 14c785aa6f shm: use embedded private instead of pointer
The private struct is pretty small and it needs to be allocated anyways,
so save an extra allocation by directly embedding it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-02 19:45:18 +02:00
Enrico Weigelt, metux IT consult fda404fd15 (!1950) xfixes: use embedded private instead of pointer
The private struct is pretty small and it needs to be allocated anyways,
so save an extra allocation by directly embedding it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-02 19:41:49 +02:00
6 changed files with 22 additions and 56 deletions

View File

@ -96,6 +96,7 @@ in this Software without prior written authorization from The Open Group.
#endif /* XINERAMA */
typedef struct _ShmScrPrivateRec {
Bool initialized;
CloseScreenProcPtr CloseScreen;
ShmFuncsPtr shmFuncs;
DestroyPixmapProcPtr destroyPixmap;
@ -199,10 +200,10 @@ static Bool
ShmCloseScreen(ScreenPtr pScreen)
{
ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(pScreen);
pScreen->CloseScreen = screen_priv->CloseScreen;
dixSetPrivate(&pScreen->devPrivates, shmScrPrivateKey, NULL);
free(screen_priv);
if (screen_priv->initialized) {
pScreen->CloseScreen = screen_priv->CloseScreen;
screen_priv->initialized = FALSE;
}
return (*pScreen->CloseScreen) (pScreen);
}
@ -211,11 +212,10 @@ ShmInitScreenPriv(ScreenPtr pScreen)
{
ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(pScreen);
if (!screen_priv) {
screen_priv = calloc(1, sizeof(ShmScrPrivateRec));
if (!screen_priv->initialized) {
screen_priv->CloseScreen = pScreen->CloseScreen;
dixSetPrivate(&pScreen->devPrivates, shmScrPrivateKey, screen_priv);
pScreen->CloseScreen = ShmCloseScreen;
screen_priv->initialized = TRUE;
}
return screen_priv;
}
@ -223,7 +223,7 @@ ShmInitScreenPriv(ScreenPtr pScreen)
static Bool
ShmRegisterPrivates(void)
{
if (!dixRegisterPrivateKey(&shmScrPrivateKeyRec, PRIVATE_SCREEN, 0))
if (!dixRegisterPrivateKey(&shmScrPrivateKeyRec, PRIVATE_SCREEN, sizeof(ShmScrPrivateRec)))
return FALSE;
if (!dixRegisterPrivateKey(&shmPixmapPrivateKeyRec, PRIVATE_PIXMAP, 0))
return FALSE;

View File

@ -103,7 +103,7 @@ SOFTWARE.
#include "xvdisp.h"
#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = ((XvScreenPtr) \
dixLookupPrivate(&(pScreen)->devPrivates, XvScreenKey))->field)
dixLookupPrivate(&(pScreen)->devPrivates, &XvScreenKeyRec))->field)
#define SCREEN_EPILOGUE(pScreen, field, wrapper)\
((pScreen)->field = wrapper)
@ -119,7 +119,6 @@ static DevPrivateKeyRec XvScreenKeyRec;
Bool noXvExtension = FALSE;
#define XvScreenKey (&XvScreenKeyRec)
static unsigned long XvExtensionGeneration = 0;
static unsigned long XvScreenGeneration = 0;
static unsigned long XvResourceGeneration = 0;
@ -164,7 +163,7 @@ XvExtensionInit(void)
{
ExtensionEntry *extEntry;
if (!dixRegisterPrivateKey(&XvScreenKeyRec, PRIVATE_SCREEN, 0))
if (!dixRegisterPrivateKey(&XvScreenKeyRec, PRIVATE_SCREEN, sizeof(XvScreenPtr)))
return;
/* Look to see if any screens were initialized; if not then
@ -260,8 +259,6 @@ CreateResourceTypes(void)
int
XvScreenInit(ScreenPtr pScreen)
{
XvScreenPtr pxvs;
if (XvScreenGeneration != serverGeneration) {
if (!CreateResourceTypes()) {
ErrorF("XvScreenInit: Unable to allocate resource types\n");
@ -273,22 +270,14 @@ XvScreenInit(ScreenPtr pScreen)
XvScreenGeneration = serverGeneration;
}
if (!dixRegisterPrivateKey(&XvScreenKeyRec, PRIVATE_SCREEN, 0))
if (!dixRegisterPrivateKey(&XvScreenKeyRec, PRIVATE_SCREEN, sizeof(XvScreenPtr)))
return BadAlloc;
if (dixLookupPrivate(&pScreen->devPrivates, XvScreenKey)) {
if (dixLookupPrivate(&pScreen->devPrivates, &XvScreenKeyRec)) {
ErrorF("XvScreenInit: screen devPrivates ptr non-NULL before init\n");
}
/* ALLOCATE SCREEN PRIVATE RECORD */
pxvs = malloc(sizeof(XvScreenRec));
if (!pxvs) {
ErrorF("XvScreenInit: Unable to allocate screen private structure\n");
return BadAlloc;
}
dixSetPrivate(&pScreen->devPrivates, XvScreenKey, pxvs);
XvScreenPtr pxvs = dixLookupPrivate(&pScreen->devPrivates, &XvScreenKeyRec);
pxvs->DestroyPixmap = pScreen->DestroyPixmap;
pxvs->DestroyWindow = pScreen->DestroyWindow;
@ -304,19 +293,12 @@ XvScreenInit(ScreenPtr pScreen)
static Bool
XvCloseScreen(ScreenPtr pScreen)
{
XvScreenPtr pxvs;
pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates, XvScreenKey);
XvScreenPtr pxvs = dixLookupPrivate(&pScreen->devPrivates, &XvScreenKeyRec);
pScreen->DestroyPixmap = pxvs->DestroyPixmap;
pScreen->DestroyWindow = pxvs->DestroyWindow;
pScreen->CloseScreen = pxvs->CloseScreen;
free(pxvs);
dixSetPrivate(&pScreen->devPrivates, XvScreenKey, NULL);
return (*pScreen->CloseScreen) (pScreen);
}
@ -329,7 +311,7 @@ XvResetProc(ExtensionEntry * extEntry)
DevPrivateKey
XvGetScreenKey(void)
{
return XvScreenKey;
return &XvScreenKeyRec;
}
unsigned long
@ -342,7 +324,7 @@ static void
XvStopAdaptors(DrawablePtr pDrawable)
{
ScreenPtr pScreen = pDrawable->pScreen;
XvScreenPtr pxvs = dixLookupPrivate(&pScreen->devPrivates, XvScreenKey);
XvScreenPtr pxvs = dixLookupPrivate(&pScreen->devPrivates, &XvScreenKeyRec);
XvAdaptorPtr pa = pxvs->pAdaptors;
int na = pxvs->nAdaptors;

View File

@ -107,15 +107,13 @@ static DevPrivateKeyRec XF86XVWindowKeyRec;
#define XF86XVWindowKey (&XF86XVWindowKeyRec)
/* dixmain.c XvScreenPtr screen private */
DevPrivateKey XF86XvScreenKey;
/** xf86xv.c XF86XVScreenPtr screen private */
static DevPrivateKeyRec XF86XVScreenPrivateKey;
static unsigned long PortResource = 0;
#define GET_XV_SCREEN(pScreen) \
((XvScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XF86XvScreenKey))
((XvScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XvGetScreenKey()))
#define GET_XF86XV_SCREEN(pScreen) \
((XF86XVScreenPtr)(dixGetPrivate(&pScreen->devPrivates, &XF86XVScreenPrivateKey)))
@ -241,8 +239,6 @@ xf86XVScreenInit(ScreenPtr pScreen, XF86VideoAdaptorPtr * adaptors, int num)
if (!dixRegisterPrivateKey(&XF86XVScreenPrivateKey, PRIVATE_SCREEN, 0))
return FALSE;
XF86XvScreenKey = XvGetScreenKey();
PortResource = XvGetRTPort();
ScreenPriv = malloc(sizeof(XF86XVScreenRec));

View File

@ -148,8 +148,7 @@ xf86XvMCScreenInit(ScreenPtr pScreen,
{
XvMCAdaptorPtr pAdapt;
xf86XvMCScreenPtr pScreenPriv;
XvScreenPtr pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
XF86XvScreenKey);
XvScreenPtr pxvs = dixLookupPrivate(&pScreen->devPrivates, XvGetScreenKey());
int i, j;
if (noXvExtension)

View File

@ -34,8 +34,6 @@
/*** These are DDX layer privates ***/
extern _X_EXPORT DevPrivateKey XF86XvScreenKey;
typedef struct {
DestroyWindowProcPtr DestroyWindow;
ClipNotifyProcPtr ClipNotify;

View File

@ -124,8 +124,6 @@ typedef struct _CursorScreen {
} CursorScreenRec, *CursorScreenPtr;
#define GetCursorScreen(s) ((CursorScreenPtr)dixLookupPrivate(&(s)->devPrivates, CursorScreenPrivateKey))
#define GetCursorScreenIfSet(s) GetCursorScreen(s)
#define SetCursorScreen(s,p) dixSetPrivate(&(s)->devPrivates, CursorScreenPrivateKey, p)
#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
#define Unwrap(as,s,elt,backup) (((backup) = (s)->elt), (s)->elt = (as)->elt)
@ -197,16 +195,14 @@ static Bool
CursorCloseScreen(ScreenPtr pScreen)
{
CursorScreenPtr cs = GetCursorScreen(pScreen);
Bool ret;
_X_UNUSED CloseScreenProcPtr close_proc;
_X_UNUSED DisplayCursorProcPtr display_proc;
Unwrap(cs, pScreen, CloseScreen, close_proc);
Unwrap(cs, pScreen, DisplayCursor, display_proc);
deleteCursorHideCountsForScreen(pScreen);
ret = (*pScreen->CloseScreen) (pScreen);
free(cs);
return ret;
return pScreen->CloseScreen(pScreen);
}
#define CursorAllEvents (XFixesDisplayCursorNotifyMask)
@ -1059,20 +1055,15 @@ XFixesCursorInit(void)
else
CursorVisible = FALSE;
if (!dixRegisterPrivateKey(&CursorScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
if (!dixRegisterPrivateKey(&CursorScreenPrivateKeyRec, PRIVATE_SCREEN, sizeof(CursorScreenRec)))
return FALSE;
for (i = 0; i < screenInfo.numScreens; i++) {
ScreenPtr pScreen = screenInfo.screens[i];
CursorScreenPtr cs;
cs = (CursorScreenPtr) calloc(1, sizeof(CursorScreenRec));
if (!cs)
return FALSE;
CursorScreenPtr cs = GetCursorScreen(pScreen);
Wrap(cs, pScreen, CloseScreen, CursorCloseScreen);
Wrap(cs, pScreen, DisplayCursor, CursorDisplayCursor);
cs->pCursorHideCounts = NULL;
SetCursorScreen(pScreen, cs);
}
CursorClientType = CreateNewResourceType(CursorFreeClient,
"XFixesCursorClient");