Use transform when computing scanout size of modes

Report transformed crtc sizes through RandR and Xinerama. Test screen size
against transformed mode sizes when configuring the Crtc.
This commit is contained in:
Keith Packard 2008-03-17 13:57:47 -07:00
parent f50349e193
commit 40f3dff6b3

View File

@ -528,30 +528,35 @@ RRCrtcGammaNotify (RRCrtcPtr crtc)
return TRUE; /* not much going on here */ return TRUE; /* not much going on here */
} }
static void
RRModeGetScanoutSize (RRModePtr mode, PictTransformPtr transform,
int *width, int *height)
{
BoxRec box;
if (mode == NULL) {
*width = 0;
*height = 0;
return;
}
box.x1 = 0;
box.y1 = 0;
box.x2 = mode->mode.width;
box.y2 = mode->mode.height;
PictureTransformBounds (&box, transform);
*width = box.x2 - box.x1;
*height = box.y2 - box.y1;
}
/** /**
* Returns the width/height that the crtc scans out from the framebuffer * Returns the width/height that the crtc scans out from the framebuffer
*/ */
void void
RRCrtcGetScanoutSize(RRCrtcPtr crtc, int *width, int *height) RRCrtcGetScanoutSize(RRCrtcPtr crtc, int *width, int *height)
{ {
if (crtc->mode == NULL) { return RRModeGetScanoutSize (crtc->mode, &crtc->transform, width, height);
*width = 0;
*height = 0;
return;
}
switch (crtc->rotation & 0xf) {
case RR_Rotate_0:
case RR_Rotate_180:
*width = crtc->mode->mode.width;
*height = crtc->mode->mode.height;
break;
case RR_Rotate_90:
case RR_Rotate_270:
*width = crtc->mode->mode.height;
*height = crtc->mode->mode.width;
break;
}
} }
/* /*
@ -1028,14 +1033,18 @@ ProcRRSetCrtcConfig (ClientPtr client)
*/ */
if (pScrPriv->rrScreenSetSize) if (pScrPriv->rrScreenSetSize)
{ {
int source_width = mode->mode.width; int source_width;
int source_height = mode->mode.height; int source_height;
PictTransform transform, inverse;
if ((rotation & 0xf) == RR_Rotate_90 || (rotation & 0xf) == RR_Rotate_270) if (!RRComputeTransform (mode, stuff->rotation,
{ stuff->x, stuff->y,
source_width = mode->mode.height; &crtc->client_pending_transform.transform,
source_height = mode->mode.width; &crtc->client_pending_transform.inverse,
} &transform, &inverse))
return BadMatch;
RRModeGetScanoutSize (mode, &transform, &source_width, &source_height);
if (stuff->x + source_width > pScreen->width) if (stuff->x + source_width > pScreen->width)
{ {
client->errorValue = stuff->x; client->errorValue = stuff->x;
@ -1246,7 +1255,6 @@ transform_filter_encode (ClientPtr client, char *output,
CARD16 *nparamsFilter, CARD16 *nparamsFilter,
RRTransformPtr transform) RRTransformPtr transform)
{ {
char *output_orig = output;
int nbytes, nparams; int nbytes, nparams;
int n; int n;
@ -1260,17 +1268,17 @@ transform_filter_encode (ClientPtr client, char *output,
*nbytesFilter = nbytes; *nbytesFilter = nbytes;
*nparamsFilter = nparams; *nparamsFilter = nparams;
memcpy (output, transform->filter->name, nbytes); memcpy (output, transform->filter->name, nbytes);
output += nbytes;
while ((nbytes & 3) != 0) while ((nbytes & 3) != 0)
*output++ = 0; output[nbytes++] = 0;
memcpy (output, transform->params, nparams * sizeof (xFixed)); memcpy (output + nbytes, transform->params, nparams * sizeof (xFixed));
if (client->swapped) { if (client->swapped) {
swaps (nbytesFilter, n); swaps (nbytesFilter, n);
swaps (nparamsFilter, n); swaps (nparamsFilter, n);
SwapLongs ((CARD32 *) output, nparams * sizeof (xFixed)); SwapLongs ((CARD32 *) (output + nbytes),
nparams * sizeof (xFixed));
} }
output += nparams * sizeof (xFixed); nbytes += nparams * sizeof (xFixed);
return output - output_orig; return nbytes;
} }
static void static void