(submit/cleanup-xv-dispatch) Xext: xv: untwist Xinerama handling

The current way of switching between Xinerama and single-screen handlers
is quite complicated and needs call vector tables that are changed on
the fly, which in turn makes dispatching more complicated.

Reworking this into a simple and straight code flow, where individual request
procs just look at a flag to decide whether to call the Xinerama or single
screen version.

This isn't just much easier to understand (and debug), but also removes the need
or the call vectors, thus allowing further simplification of the dispatcher.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-07-08 19:12:06 +02:00
parent 2fdfe57bc3
commit 0b39afbb00
3 changed files with 92 additions and 37 deletions

View File

@ -453,7 +453,7 @@ ProcXvQueryEncodings(ClientPtr client)
} }
static int static int
ProcXvPutVideo(ClientPtr client) SingleXvPutVideo(ClientPtr client)
{ {
DrawablePtr pDraw; DrawablePtr pDraw;
XvPortPtr pPort; XvPortPtr pPort;
@ -482,8 +482,20 @@ ProcXvPutVideo(ClientPtr client)
stuff->drw_w, stuff->drw_h); stuff->drw_w, stuff->drw_h);
} }
static int XineramaXvPutVideo(ClientPtr client);
static int static int
ProcXvPutStill(ClientPtr client) ProcXvPutVideo(ClientPtr client)
{
#ifdef PANORAMIX
if (xvUseXinerama)
return XineramaXvPutVideo(client);
#endif
return SingleXvPutVideo(client);
}
static int
SingleXvPutStill(ClientPtr client)
{ {
DrawablePtr pDraw; DrawablePtr pDraw;
XvPortPtr pPort; XvPortPtr pPort;
@ -512,6 +524,18 @@ ProcXvPutStill(ClientPtr client)
stuff->drw_w, stuff->drw_h); stuff->drw_w, stuff->drw_h);
} }
static int XineramaXvPutStill(ClientPtr client);
static int
ProcXvPutStill(ClientPtr client)
{
#ifdef PANORAMIX
if (xvUseXinerama)
return XineramaXvPutStill(client);
#endif
return SingleXvPutStill(client);
}
static int static int
ProcXvGetVideo(ClientPtr client) ProcXvGetVideo(ClientPtr client)
{ {
@ -643,7 +667,7 @@ ProcXvUngrabPort(ClientPtr client)
} }
static int static int
ProcXvStopVideo(ClientPtr client) SingleXvStopVideo(ClientPtr client)
{ {
int ret; int ret;
DrawablePtr pDraw; DrawablePtr pDraw;
@ -661,8 +685,20 @@ ProcXvStopVideo(ClientPtr client)
return XvdiStopVideo(client, pPort, pDraw); return XvdiStopVideo(client, pPort, pDraw);
} }
static int XineramaXvStopVideo(ClientPtr client);
static int static int
ProcXvSetPortAttribute(ClientPtr client) ProcXvStopVideo(ClientPtr client)
{
#ifdef PANORAMIX
if (xvUseXinerama)
return XineramaXvStopVideo(client);
#endif
return SingleXvStopVideo(client);
}
static int
SingleXvSetPortAttribute(ClientPtr client)
{ {
int status; int status;
XvPortPtr pPort; XvPortPtr pPort;
@ -688,6 +724,18 @@ ProcXvSetPortAttribute(ClientPtr client)
return status; return status;
} }
static int XineramaXvSetPortAttribute(ClientPtr client);
static int
ProcXvSetPortAttribute(ClientPtr client)
{
#ifdef PANORAMIX
if (xvUseXinerama)
return XineramaXvSetPortAttribute(client);
#endif
return SingleXvSetPortAttribute(client);
}
static int static int
ProcXvGetPortAttribute(ClientPtr client) ProcXvGetPortAttribute(ClientPtr client)
{ {
@ -797,7 +845,7 @@ ProcXvQueryPortAttributes(ClientPtr client)
} }
static int static int
ProcXvPutImage(ClientPtr client) SingleXvPutImage(ClientPtr client)
{ {
DrawablePtr pDraw; DrawablePtr pDraw;
XvPortPtr pPort; XvPortPtr pPort;
@ -853,10 +901,23 @@ ProcXvPutImage(ClientPtr client)
stuff->width, stuff->height); stuff->width, stuff->height);
} }
static int
XineramaXvPutImage(ClientPtr client);
static int
ProcXvPutImage(ClientPtr client)
{
#ifdef PANORAMIX
if (xvUseXinerama)
return XineramaXvPutImage(client);
#endif
return SingleXvPutImage(client);
}
#ifdef MITSHM #ifdef MITSHM
static int static int
ProcXvShmPutImage(ClientPtr client) SingleXvShmPutImage(ClientPtr client)
{ {
ShmDescPtr shmdesc; ShmDescPtr shmdesc;
DrawablePtr pDraw; DrawablePtr pDraw;
@ -929,13 +990,24 @@ ProcXvShmPutImage(ClientPtr client)
return status; return status;
} }
#else /* !MITSHM */
static int XineramaXvShmPutImage(ClientPtr client);
#endif /* MITSHM */
static int static int
ProcXvShmPutImage(ClientPtr client) ProcXvShmPutImage(ClientPtr client)
{ {
return BadImplementation; #ifdef MITSHM
} #ifdef PANORAMIX
if (xvUseXinerama)
return XineramaXvShmPutImage(client);
#endif #endif
return SingleXvShmPutImage(client);
#else
return BadImplementation;
#endif
}
#ifdef XvMCExtension #ifdef XvMCExtension
#include "xvmcext.h" #include "xvmcext.h"
@ -1412,7 +1484,7 @@ XineramaXvStopVideo(ClientPtr client)
if (port->info[i].id) { if (port->info[i].id) {
stuff->drawable = draw->info[i].id; stuff->drawable = draw->info[i].id;
stuff->port = port->info[i].id; stuff->port = port->info[i].id;
result = ProcXvStopVideo(client); result = SingleXvStopVideo(client);
} }
} }
@ -1436,7 +1508,7 @@ XineramaXvSetPortAttribute(ClientPtr client)
FOR_NSCREENS_BACKWARD(i) { FOR_NSCREENS_BACKWARD(i) {
if (port->info[i].id) { if (port->info[i].id) {
stuff->port = port->info[i].id; stuff->port = port->info[i].id;
result = ProcXvSetPortAttribute(client); result = SingleXvSetPortAttribute(client);
} }
} }
return result; return result;
@ -1489,7 +1561,7 @@ XineramaXvShmPutImage(ClientPtr client)
} }
stuff->send_event = (send_event && !i) ? 1 : 0; stuff->send_event = (send_event && !i) ? 1 : 0;
result = ProcXvShmPutImage(client); result = SingleXvShmPutImage(client);
} }
} }
return result; return result;
@ -1540,7 +1612,7 @@ XineramaXvPutImage(ClientPtr client)
stuff->drw_y -= screenInfo.screens[i]->y; stuff->drw_y -= screenInfo.screens[i]->y;
} }
result = ProcXvPutImage(client); result = SingleXvPutImage(client);
} }
} }
return result; return result;
@ -1588,7 +1660,7 @@ XineramaXvPutVideo(ClientPtr client)
stuff->drw_y -= screenInfo.screens[i]->y; stuff->drw_y -= screenInfo.screens[i]->y;
} }
result = ProcXvPutVideo(client); result = SingleXvPutVideo(client);
} }
} }
return result; return result;
@ -1636,7 +1708,7 @@ XineramaXvPutStill(ClientPtr client)
stuff->drw_y -= screenInfo.screens[i]->y; stuff->drw_y -= screenInfo.screens[i]->y;
} }
result = ProcXvPutStill(client); result = SingleXvPutStill(client);
} }
} }
return result; return result;
@ -1743,25 +1815,6 @@ XineramifyXv(void)
} }
} }
/* munge the dispatch vector */ xvUseXinerama = 1;
XvProcVector[xv_PutVideo] = XineramaXvPutVideo;
XvProcVector[xv_PutStill] = XineramaXvPutStill;
XvProcVector[xv_StopVideo] = XineramaXvStopVideo;
XvProcVector[xv_SetPortAttribute] = XineramaXvSetPortAttribute;
XvProcVector[xv_PutImage] = XineramaXvPutImage;
XvProcVector[xv_ShmPutImage] = XineramaXvShmPutImage;
} }
#endif /* PANORAMIX */ #endif /* PANORAMIX */
void
XvResetProcVector(void)
{
#ifdef PANORAMIX
XvProcVector[xv_PutVideo] = ProcXvPutVideo;
XvProcVector[xv_PutStill] = ProcXvPutStill;
XvProcVector[xv_StopVideo] = ProcXvStopVideo;
XvProcVector[xv_SetPortAttribute] = ProcXvSetPortAttribute;
XvProcVector[xv_PutImage] = ProcXvPutImage;
XvProcVector[xv_ShmPutImage] = ProcXvShmPutImage;
#endif
}

View File

@ -1,2 +1,2 @@
extern void XineramifyXv(void); extern void XineramifyXv(void);
extern void XvResetProcVector(void); extern int xvUseXinerama;

View File

@ -130,6 +130,8 @@ int XvReqCode;
static int XvEventBase; static int XvEventBase;
int XvErrorBase; int XvErrorBase;
int xvUseXinerama = 0;
RESTYPE XvRTPort; RESTYPE XvRTPort;
static RESTYPE XvRTEncoding; static RESTYPE XvRTEncoding;
static RESTYPE XvRTGrab; static RESTYPE XvRTGrab;
@ -325,7 +327,7 @@ XvCloseScreen(ScreenPtr pScreen)
static void static void
XvResetProc(ExtensionEntry * extEntry) XvResetProc(ExtensionEntry * extEntry)
{ {
XvResetProcVector(); xvUseXinerama = 0;
} }
DevPrivateKey DevPrivateKey