Simplify XineramifyXv.
The structure of the adaptor-matching algorithm was obscured by trying to use "continue" and "break" as the only control-flow primitives. It's a lot more clear if you add "return" to that set. Signed-off-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
parent
3f63db8919
commit
22c4300ee2
149
Xext/xvdisp.c
149
Xext/xvdisp.c
|
@ -1850,110 +1850,91 @@ XineramaXvPutStill(ClientPtr client)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Bool
|
||||||
|
isImageAdaptor(XvAdaptorPtr pAdapt)
|
||||||
|
{
|
||||||
|
return (pAdapt->type & XvImageMask) && (pAdapt->nImages > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Bool
|
||||||
|
hasOverlay(XvAdaptorPtr pAdapt)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i = 0; i < pAdapt->nAttributes; i++)
|
||||||
|
if(!strcmp(pAdapt->pAttributes[i].name, "XV_COLORKEY"))
|
||||||
|
return TRUE;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static XvAdaptorPtr
|
||||||
|
matchAdaptor(ScreenPtr pScreen, XvAdaptorPtr refAdapt, Bool isOverlay)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
XvScreenPtr xvsp = dixLookupPrivate(&pScreen->devPrivates, XvGetScreenKey());
|
||||||
|
/* Do not try to go on if xv is not supported on this screen */
|
||||||
|
if(xvsp == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* if the adaptor has the same name it's a perfect match */
|
||||||
|
for(i = 0; i < xvsp->nAdaptors; i++) {
|
||||||
|
XvAdaptorPtr pAdapt = xvsp->pAdaptors + i;
|
||||||
|
if(!strcmp(refAdapt->name, pAdapt->name))
|
||||||
|
return pAdapt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* otherwise we only look for XvImage adaptors */
|
||||||
|
if(!isImageAdaptor(refAdapt))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* prefer overlay/overlay non-overlay/non-overlay pairing */
|
||||||
|
for(i = 0; i < xvsp->nAdaptors; i++) {
|
||||||
|
XvAdaptorPtr pAdapt = xvsp->pAdaptors + i;
|
||||||
|
if(isImageAdaptor(pAdapt) && isOverlay == hasOverlay(pAdapt))
|
||||||
|
return pAdapt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* but we'll take any XvImage pairing if we can get it */
|
||||||
|
for(i = 0; i < xvsp->nAdaptors; i++) {
|
||||||
|
XvAdaptorPtr pAdapt = xvsp->pAdaptors + i;
|
||||||
|
if(isImageAdaptor(pAdapt))
|
||||||
|
return pAdapt;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void XineramifyXv(void)
|
void XineramifyXv(void)
|
||||||
{
|
{
|
||||||
ScreenPtr pScreen, screen0 = screenInfo.screens[0];
|
XvScreenPtr xvsp0 = dixLookupPrivate(&screenInfo.screens[0]->devPrivates, XvGetScreenKey());
|
||||||
XvScreenPtr xvsp0 = (XvScreenPtr)dixLookupPrivate(&screen0->devPrivates,
|
|
||||||
XvGetScreenKey());
|
|
||||||
XvAdaptorPtr refAdapt, pAdapt;
|
|
||||||
XvAttributePtr pAttr;
|
|
||||||
XvScreenPtr xvsp;
|
|
||||||
Bool isOverlay, hasOverlay;
|
|
||||||
PanoramiXRes *port;
|
|
||||||
XvAdaptorPtr MatchingAdaptors[MAXSCREENS];
|
XvAdaptorPtr MatchingAdaptors[MAXSCREENS];
|
||||||
int i, j, k, l;
|
int i, j, k;
|
||||||
|
|
||||||
XvXRTPort = CreateNewResourceType(XineramaDeleteResource, "XvXRTPort");
|
XvXRTPort = CreateNewResourceType(XineramaDeleteResource, "XvXRTPort");
|
||||||
|
|
||||||
if (!xvsp0 || !XvXRTPort) return;
|
if (!xvsp0 || !XvXRTPort) return;
|
||||||
|
|
||||||
for(i = 0; i < xvsp0->nAdaptors; i++) {
|
for(i = 0; i < xvsp0->nAdaptors; i++) {
|
||||||
refAdapt = xvsp0->pAdaptors + i;
|
Bool isOverlay;
|
||||||
|
XvAdaptorPtr refAdapt = xvsp0->pAdaptors + i;
|
||||||
bzero(MatchingAdaptors, sizeof(XvAdaptorPtr) * MAXSCREENS);
|
|
||||||
|
|
||||||
MatchingAdaptors[0] = refAdapt;
|
|
||||||
|
|
||||||
if(!(refAdapt->type & XvInputMask)) continue;
|
if(!(refAdapt->type & XvInputMask)) continue;
|
||||||
|
|
||||||
isOverlay = FALSE;
|
MatchingAdaptors[0] = refAdapt;
|
||||||
for(j = 0; j < refAdapt->nAttributes; j++) {
|
isOverlay = hasOverlay(refAdapt);
|
||||||
pAttr = refAdapt->pAttributes + j;
|
for(j = 1; j < PanoramiXNumScreens; j++)
|
||||||
if(!strcmp(pAttr->name, "XV_COLORKEY")) {
|
MatchingAdaptors[j] = matchAdaptor(screenInfo.screens[j], refAdapt, isOverlay);
|
||||||
isOverlay = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(j = 1; j < PanoramiXNumScreens; j++) {
|
|
||||||
pScreen = screenInfo.screens[j];
|
|
||||||
xvsp = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
||||||
XvGetScreenKey());
|
|
||||||
/* Do not try to go on if xv is not supported on this screen */
|
|
||||||
if (xvsp==NULL) continue ;
|
|
||||||
|
|
||||||
/* if the adaptor has the same name it's a perfect match */
|
|
||||||
for(k = 0; k < xvsp->nAdaptors; k++) {
|
|
||||||
pAdapt = xvsp->pAdaptors + k;
|
|
||||||
if(!strcmp(refAdapt->name, pAdapt->name)) {
|
|
||||||
MatchingAdaptors[j] = pAdapt;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(MatchingAdaptors[j]) continue; /* found it */
|
|
||||||
|
|
||||||
/* otherwise we only look for XvImage adaptors */
|
|
||||||
if(!(refAdapt->type & XvImageMask)) continue;
|
|
||||||
if(refAdapt->nImages <= 0) continue;
|
|
||||||
|
|
||||||
/* prefer overlay/overlay non-overlay/non-overlay pairing */
|
|
||||||
for(k = 0; k < xvsp->nAdaptors; k++) {
|
|
||||||
pAdapt = xvsp->pAdaptors + k;
|
|
||||||
if((pAdapt->type & XvImageMask) && (pAdapt->nImages > 0)) {
|
|
||||||
hasOverlay = FALSE;
|
|
||||||
for(l = 0; l < pAdapt->nAttributes; l++) {
|
|
||||||
if(!strcmp(pAdapt->pAttributes[l].name, "XV_COLORKEY")) {
|
|
||||||
hasOverlay = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(isOverlay && hasOverlay) {
|
|
||||||
MatchingAdaptors[j] = pAdapt;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if(!isOverlay && !hasOverlay) {
|
|
||||||
MatchingAdaptors[j] = pAdapt;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(MatchingAdaptors[j]) continue; /* found it */
|
|
||||||
|
|
||||||
/* but we'll take any XvImage pairing if we can get it */
|
|
||||||
|
|
||||||
for(k = 0; k < xvsp->nAdaptors; k++) {
|
|
||||||
pAdapt = xvsp->pAdaptors + k;
|
|
||||||
if((pAdapt->type & XvImageMask) && (pAdapt->nImages > 0)) {
|
|
||||||
MatchingAdaptors[j] = pAdapt;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now create a resource for each port */
|
/* now create a resource for each port */
|
||||||
for(j = 0; j < refAdapt->nPorts; j++) {
|
for(j = 0; j < refAdapt->nPorts; j++) {
|
||||||
if(!(port = xalloc(sizeof(PanoramiXRes))))
|
PanoramiXRes *port = xalloc(sizeof(PanoramiXRes));
|
||||||
|
if(!port)
|
||||||
break;
|
break;
|
||||||
port->info[0].id = MatchingAdaptors[0]->base_id + j;
|
|
||||||
AddResource(port->info[0].id, XvXRTPort, port);
|
|
||||||
|
|
||||||
for(k = 1; k < PanoramiXNumScreens; k++) {
|
for(k = 0; k < PanoramiXNumScreens; k++) {
|
||||||
if(MatchingAdaptors[k] && (MatchingAdaptors[k]->nPorts > j))
|
if(MatchingAdaptors[k] && (MatchingAdaptors[k]->nPorts > j))
|
||||||
port->info[k].id = MatchingAdaptors[k]->base_id + j;
|
port->info[k].id = MatchingAdaptors[k]->base_id + j;
|
||||||
else
|
else
|
||||||
port->info[k].id = 0;
|
port->info[k].id = 0;
|
||||||
}
|
}
|
||||||
|
AddResource(port->info[0].id, XvXRTPort, port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue