2007-11-24 10:55:21 -07:00
|
|
|
/*
|
|
|
|
* Copyright © 2006 Keith Packard
|
2011-11-05 07:32:40 -06:00
|
|
|
* Copyright 2010 Red Hat, Inc
|
2007-11-24 10:55:21 -07:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
* the above copyright notice appear in all copies and that both that copyright
|
|
|
|
* notice and this permission notice appear in supporting documentation, and
|
|
|
|
* that the name of the copyright holders not be used in advertising or
|
|
|
|
* publicity pertaining to distribution of the software without specific,
|
|
|
|
* written prior permission. The copyright holders make no representations
|
|
|
|
* about the suitability of this software for any purpose. It is provided "as
|
|
|
|
* is" without express or implied warranty.
|
|
|
|
*
|
|
|
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
|
|
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
|
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
|
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
|
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
|
|
|
* OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "randrstr.h"
|
|
|
|
#include "swaprep.h"
|
2011-11-05 07:32:40 -06:00
|
|
|
#include "mipointer.h"
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
RESTYPE RRCrtcType;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Notify the CRTC of some change
|
|
|
|
*/
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcChanged(RRCrtcPtr crtc, Bool layoutChanged)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = crtc->pScreen;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
crtc->changed = TRUE;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pScreen) {
|
|
|
|
rrScrPriv(pScreen);
|
|
|
|
|
2013-12-28 07:40:01 -07:00
|
|
|
RRSetChanged(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
/*
|
|
|
|
* Send ConfigureNotify on any layout change
|
|
|
|
*/
|
|
|
|
if (layoutChanged)
|
|
|
|
pScrPriv->layoutChanged = TRUE;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a CRTC
|
|
|
|
*/
|
|
|
|
RRCrtcPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcCreate(ScreenPtr pScreen, void *devPrivate)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcPtr crtc;
|
|
|
|
RRCrtcPtr *crtcs;
|
|
|
|
rrScrPrivPtr pScrPriv;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
if (!RRInit())
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
pScrPriv = rrGetScrPriv(pScreen);
|
|
|
|
|
|
|
|
/* make space for the crtc pointer */
|
|
|
|
if (pScrPriv->numCrtcs)
|
2012-06-10 07:21:05 -06:00
|
|
|
crtcs = realloc(pScrPriv->crtcs,
|
|
|
|
(pScrPriv->numCrtcs + 1) * sizeof(RRCrtcPtr));
|
2007-11-24 10:55:21 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
crtcs = malloc(sizeof(RRCrtcPtr));
|
2007-11-24 10:55:21 -07:00
|
|
|
if (!crtcs)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2007-11-24 10:55:21 -07:00
|
|
|
pScrPriv->crtcs = crtcs;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
crtc = calloc(1, sizeof(RRCrtcRec));
|
2007-11-24 10:55:21 -07:00
|
|
|
if (!crtc)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
|
|
|
crtc->id = FakeClientID(0);
|
2007-11-24 10:55:21 -07:00
|
|
|
crtc->pScreen = pScreen;
|
|
|
|
crtc->mode = NULL;
|
|
|
|
crtc->x = 0;
|
|
|
|
crtc->y = 0;
|
|
|
|
crtc->rotation = RR_Rotate_0;
|
|
|
|
crtc->rotations = RR_Rotate_0;
|
|
|
|
crtc->outputs = NULL;
|
|
|
|
crtc->numOutputs = 0;
|
|
|
|
crtc->gammaSize = 0;
|
|
|
|
crtc->gammaRed = crtc->gammaBlue = crtc->gammaGreen = NULL;
|
|
|
|
crtc->changed = FALSE;
|
|
|
|
crtc->devPrivate = devPrivate;
|
2012-06-10 07:21:05 -06:00
|
|
|
RRTransformInit(&crtc->client_pending_transform);
|
|
|
|
RRTransformInit(&crtc->client_current_transform);
|
|
|
|
pixman_transform_init_identity(&crtc->transform);
|
|
|
|
pixman_f_transform_init_identity(&crtc->f_transform);
|
|
|
|
pixman_f_transform_init_identity(&crtc->f_inverse);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!AddResource(crtc->id, RRCrtcType, (pointer) crtc))
|
|
|
|
return NULL;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
/* attach the screen and crtc together */
|
|
|
|
crtc->pScreen = pScreen;
|
|
|
|
pScrPriv->crtcs[pScrPriv->numCrtcs++] = crtc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2013-12-28 07:40:01 -07:00
|
|
|
RRResourcesChanged(pScreen);
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
return crtc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the allowed rotations on a CRTC
|
|
|
|
*/
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcSetRotations(RRCrtcPtr crtc, Rotation rotations)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
|
|
|
crtc->rotations = rotations;
|
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
/*
|
|
|
|
* Set whether transforms are allowed on a CRTC
|
|
|
|
*/
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcSetTransformSupport(RRCrtcPtr crtc, Bool transforms)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
|
|
|
crtc->transforms = transforms;
|
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
/*
|
|
|
|
* Notify the extension that the Crtc has been reconfigured,
|
|
|
|
* the driver calls this whenever it has updated the mode
|
|
|
|
*/
|
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcNotify(RRCrtcPtr crtc,
|
|
|
|
RRModePtr mode,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
Rotation rotation,
|
|
|
|
RRTransformPtr transform, int numOutputs, RROutputPtr * outputs)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int i, j;
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
/*
|
|
|
|
* Check to see if any of the new outputs were
|
|
|
|
* not in the old list and mark them as changed
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < numOutputs; i++) {
|
|
|
|
for (j = 0; j < crtc->numOutputs; j++)
|
|
|
|
if (outputs[i] == crtc->outputs[j])
|
|
|
|
break;
|
|
|
|
if (j == crtc->numOutputs) {
|
|
|
|
outputs[i]->crtc = crtc;
|
|
|
|
RROutputChanged(outputs[i], FALSE);
|
|
|
|
RRCrtcChanged(crtc, FALSE);
|
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Check to see if any of the old outputs are
|
|
|
|
* not in the new list and mark them as changed
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
for (j = 0; j < crtc->numOutputs; j++) {
|
|
|
|
for (i = 0; i < numOutputs; i++)
|
|
|
|
if (outputs[i] == crtc->outputs[j])
|
|
|
|
break;
|
|
|
|
if (i == numOutputs) {
|
|
|
|
if (crtc->outputs[j]->crtc == crtc)
|
|
|
|
crtc->outputs[j]->crtc = NULL;
|
|
|
|
RROutputChanged(crtc->outputs[j], FALSE);
|
|
|
|
RRCrtcChanged(crtc, FALSE);
|
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Reallocate the crtc output array if necessary
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
if (numOutputs != crtc->numOutputs) {
|
|
|
|
RROutputPtr *newoutputs;
|
|
|
|
|
|
|
|
if (numOutputs) {
|
|
|
|
if (crtc->numOutputs)
|
|
|
|
newoutputs = realloc(crtc->outputs,
|
|
|
|
numOutputs * sizeof(RROutputPtr));
|
|
|
|
else
|
|
|
|
newoutputs = malloc(numOutputs * sizeof(RROutputPtr));
|
|
|
|
if (!newoutputs)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
free(crtc->outputs);
|
|
|
|
newoutputs = NULL;
|
|
|
|
}
|
|
|
|
crtc->outputs = newoutputs;
|
|
|
|
crtc->numOutputs = numOutputs;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Copy the new list of outputs into the crtc
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
memcpy(crtc->outputs, outputs, numOutputs * sizeof(RROutputPtr));
|
2007-11-24 10:55:21 -07:00
|
|
|
/*
|
|
|
|
* Update remaining crtc fields
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
if (mode != crtc->mode) {
|
|
|
|
if (crtc->mode)
|
|
|
|
RRModeDestroy(crtc->mode);
|
|
|
|
crtc->mode = mode;
|
|
|
|
if (mode != NULL)
|
|
|
|
mode->refcnt++;
|
|
|
|
RRCrtcChanged(crtc, TRUE);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (x != crtc->x) {
|
|
|
|
crtc->x = x;
|
|
|
|
RRCrtcChanged(crtc, TRUE);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (y != crtc->y) {
|
|
|
|
crtc->y = y;
|
|
|
|
RRCrtcChanged(crtc, TRUE);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (rotation != crtc->rotation) {
|
|
|
|
crtc->rotation = rotation;
|
|
|
|
RRCrtcChanged(crtc, TRUE);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!RRTransformEqual(transform, &crtc->client_current_transform)) {
|
|
|
|
RRTransformCopy(&crtc->client_current_transform, transform);
|
|
|
|
RRCrtcChanged(crtc, TRUE);
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (crtc->changed && mode) {
|
|
|
|
RRTransformCompute(x, y,
|
|
|
|
mode->mode.width, mode->mode.height,
|
|
|
|
rotation,
|
|
|
|
&crtc->client_current_transform,
|
|
|
|
&crtc->transform, &crtc->f_transform,
|
|
|
|
&crtc->f_inverse);
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
RRDeliverCrtcEvent(ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pWin->drawable.pScreen;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
rrScrPriv(pScreen);
|
|
|
|
RRModePtr mode = crtc->mode;
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
xRRCrtcChangeNotifyEvent ce = {
|
|
|
|
.type = RRNotify + RREventBase,
|
|
|
|
.subCode = RRNotify_CrtcChange,
|
|
|
|
.timestamp = pScrPriv->lastSetTime.milliseconds,
|
|
|
|
.window = pWin->drawable.id,
|
|
|
|
.crtc = crtc->id,
|
|
|
|
.mode = mode ? mode->mode.id : None,
|
|
|
|
.rotation = crtc->rotation,
|
|
|
|
.x = mode ? crtc->x : 0,
|
|
|
|
.y = mode ? crtc->y : 0,
|
|
|
|
.width = mode ? mode->mode.width : 0,
|
|
|
|
.height = mode ? mode->mode.height : 0
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteEventsToClient(client, 1, (xEvent *) &ce);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcPendingProperties(RRCrtcPtr crtc)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = crtc->pScreen;
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
rrScrPriv(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
int o;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (o = 0; o < pScrPriv->numOutputs; o++) {
|
|
|
|
RROutputPtr output = pScrPriv->outputs[o];
|
|
|
|
|
|
|
|
if (output->crtc == crtc && output->pendingProperties)
|
|
|
|
return TRUE;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
static void
|
|
|
|
crtc_bounds(RRCrtcPtr crtc, int *left, int *right, int *top, int *bottom)
|
|
|
|
{
|
|
|
|
*left = crtc->x;
|
|
|
|
*top = crtc->y;
|
|
|
|
|
|
|
|
switch (crtc->rotation) {
|
|
|
|
case RR_Rotate_0:
|
|
|
|
case RR_Rotate_180:
|
|
|
|
default:
|
2012-06-10 07:21:05 -06:00
|
|
|
*right = crtc->x + crtc->mode->mode.width;
|
|
|
|
*bottom = crtc->y + crtc->mode->mode.height;
|
|
|
|
return;
|
2011-11-05 07:32:40 -06:00
|
|
|
case RR_Rotate_90:
|
|
|
|
case RR_Rotate_270:
|
2012-06-10 07:21:05 -06:00
|
|
|
*right = crtc->x + crtc->mode->mode.height;
|
|
|
|
*bottom = crtc->y + crtc->mode->mode.width;
|
|
|
|
return;
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* overlapping counts as adjacent */
|
|
|
|
static Bool
|
|
|
|
crtcs_adjacent(const RRCrtcPtr a, const RRCrtcPtr b)
|
|
|
|
{
|
|
|
|
/* left, right, top, bottom... */
|
|
|
|
int al, ar, at, ab;
|
|
|
|
int bl, br, bt, bb;
|
2012-06-10 07:21:05 -06:00
|
|
|
int cl, cr, ct, cb; /* the overlap, if any */
|
2011-11-05 07:32:40 -06:00
|
|
|
|
|
|
|
crtc_bounds(a, &al, &ar, &at, &ab);
|
|
|
|
crtc_bounds(b, &bl, &br, &bt, &bb);
|
|
|
|
|
|
|
|
cl = max(al, bl);
|
|
|
|
cr = min(ar, br);
|
|
|
|
ct = max(at, bt);
|
|
|
|
cb = min(ab, bb);
|
|
|
|
|
|
|
|
return (cl <= cr) && (ct <= cb);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Depth-first search and mark all CRTCs reachable from cur */
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
mark_crtcs(rrScrPrivPtr pScrPriv, int *reachable, int cur)
|
2011-11-05 07:32:40 -06:00
|
|
|
{
|
|
|
|
int i;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
reachable[cur] = TRUE;
|
|
|
|
for (i = 0; i < pScrPriv->numCrtcs; ++i) {
|
|
|
|
if (reachable[i] || !pScrPriv->crtcs[i]->mode)
|
|
|
|
continue;
|
|
|
|
if (crtcs_adjacent(pScrPriv->crtcs[cur], pScrPriv->crtcs[i]))
|
|
|
|
mark_crtcs(pScrPriv, reachable, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
RRComputeContiguity(ScreenPtr pScreen)
|
2011-11-05 07:32:40 -06:00
|
|
|
{
|
|
|
|
rrScrPriv(pScreen);
|
|
|
|
Bool discontiguous = TRUE;
|
|
|
|
int i, n = pScrPriv->numCrtcs;
|
|
|
|
|
|
|
|
int *reachable = calloc(n, sizeof(int));
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
if (!reachable)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* Find first enabled CRTC and start search for reachable CRTCs from it */
|
|
|
|
for (i = 0; i < n; ++i) {
|
|
|
|
if (pScrPriv->crtcs[i]->mode) {
|
|
|
|
mark_crtcs(pScrPriv, reachable, i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check that all enabled CRTCs were marked as reachable */
|
|
|
|
for (i = 0; i < n; ++i)
|
|
|
|
if (pScrPriv->crtcs[i]->mode && !reachable[i])
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
discontiguous = FALSE;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
out:
|
2011-11-05 07:32:40 -06:00
|
|
|
free(reachable);
|
|
|
|
pScrPriv->discontiguous = discontiguous;
|
|
|
|
}
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
void
|
|
|
|
RRCrtcDetachScanoutPixmap(RRCrtcPtr crtc)
|
|
|
|
{
|
|
|
|
ScreenPtr master = crtc->pScreen->current_master;
|
|
|
|
PixmapPtr mscreenpix;
|
|
|
|
rrScrPriv(crtc->pScreen);
|
|
|
|
|
|
|
|
mscreenpix = master->GetScreenPixmap(master);
|
|
|
|
|
2014-05-02 13:27:46 -06:00
|
|
|
pScrPriv->rrCrtcSetScanoutPixmap(crtc, NULL);
|
2013-06-07 11:28:45 -06:00
|
|
|
if (crtc->scanout_pixmap) {
|
|
|
|
master->StopPixmapTracking(mscreenpix, crtc->scanout_pixmap);
|
|
|
|
/*
|
|
|
|
* Unref the pixmap twice: once for the original reference, and once
|
|
|
|
* for the reference implicitly added by PixmapShareToSlave.
|
|
|
|
*/
|
|
|
|
master->DestroyPixmap(crtc->scanout_pixmap->master_pixmap);
|
|
|
|
master->DestroyPixmap(crtc->scanout_pixmap->master_pixmap);
|
|
|
|
crtc->pScreen->DestroyPixmap(crtc->scanout_pixmap);
|
|
|
|
}
|
|
|
|
crtc->scanout_pixmap = NULL;
|
|
|
|
RRCrtcChanged(crtc, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
rrCreateSharedPixmap(RRCrtcPtr crtc, int width, int height,
|
|
|
|
int x, int y)
|
|
|
|
{
|
|
|
|
PixmapPtr mpix, spix;
|
|
|
|
ScreenPtr master = crtc->pScreen->current_master;
|
|
|
|
Bool ret;
|
|
|
|
int depth;
|
|
|
|
PixmapPtr mscreenpix;
|
|
|
|
PixmapPtr protopix = crtc->pScreen->current_master->GetScreenPixmap(crtc->pScreen->current_master);
|
|
|
|
rrScrPriv(crtc->pScreen);
|
|
|
|
|
|
|
|
/* create a pixmap on the master screen,
|
|
|
|
then get a shared handle for it
|
|
|
|
create a shared pixmap on the slave screen using the handle
|
|
|
|
set the master screen to do dirty updates to the shared pixmap
|
|
|
|
from the screen pixmap.
|
|
|
|
set slave screen to scanout shared linear pixmap
|
|
|
|
*/
|
|
|
|
|
|
|
|
mscreenpix = master->GetScreenPixmap(master);
|
|
|
|
depth = protopix->drawable.depth;
|
|
|
|
|
|
|
|
if (crtc->scanout_pixmap)
|
|
|
|
RRCrtcDetachScanoutPixmap(crtc);
|
|
|
|
|
|
|
|
if (width == 0 && height == 0) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
mpix = master->CreatePixmap(master, width, height, depth,
|
|
|
|
CREATE_PIXMAP_USAGE_SHARED);
|
|
|
|
if (!mpix)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
spix = PixmapShareToSlave(mpix, crtc->pScreen);
|
|
|
|
if (spix == NULL) {
|
|
|
|
master->DestroyPixmap(mpix);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = pScrPriv->rrCrtcSetScanoutPixmap(crtc, spix);
|
|
|
|
if (ret == FALSE) {
|
|
|
|
ErrorF("failed to set shadow slave pixmap\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
crtc->scanout_pixmap = spix;
|
|
|
|
|
|
|
|
master->StartPixmapTracking(mscreenpix, spix, x, y);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
rrCheckPixmapBounding(ScreenPtr pScreen,
|
|
|
|
RRCrtcPtr rr_crtc, int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
RegionRec root_pixmap_region, total_region, new_crtc_region;
|
2014-05-02 13:27:46 -06:00
|
|
|
int c;
|
2013-06-07 11:28:45 -06:00
|
|
|
BoxRec newbox;
|
|
|
|
BoxPtr newsize;
|
|
|
|
ScreenPtr slave;
|
|
|
|
int new_width, new_height;
|
|
|
|
PixmapPtr screen_pixmap = pScreen->GetScreenPixmap(pScreen);
|
|
|
|
rrScrPriv(pScreen);
|
|
|
|
|
|
|
|
PixmapRegionInit(&root_pixmap_region, screen_pixmap);
|
|
|
|
RegionInit(&total_region, NULL, 0);
|
|
|
|
|
|
|
|
/* have to iterate all the crtcs of the attached gpu masters
|
|
|
|
and all their output slaves */
|
|
|
|
for (c = 0; c < pScrPriv->numCrtcs; c++) {
|
|
|
|
if (pScrPriv->crtcs[c] == rr_crtc) {
|
|
|
|
newbox.x1 = x;
|
|
|
|
newbox.x2 = x + w;
|
|
|
|
newbox.y1 = y;
|
|
|
|
newbox.y2 = y + h;
|
|
|
|
} else {
|
|
|
|
if (!pScrPriv->crtcs[c]->mode)
|
|
|
|
continue;
|
|
|
|
newbox.x1 = pScrPriv->crtcs[c]->x;
|
|
|
|
newbox.x2 = pScrPriv->crtcs[c]->x + pScrPriv->crtcs[c]->mode->mode.width;
|
|
|
|
newbox.y1 = pScrPriv->crtcs[c]->y;
|
|
|
|
newbox.y2 = pScrPriv->crtcs[c]->y + pScrPriv->crtcs[c]->mode->mode.height;
|
|
|
|
}
|
|
|
|
RegionInit(&new_crtc_region, &newbox, 1);
|
|
|
|
RegionUnion(&total_region, &total_region, &new_crtc_region);
|
|
|
|
}
|
|
|
|
|
|
|
|
xorg_list_for_each_entry(slave, &pScreen->output_slave_list, output_head) {
|
|
|
|
rrScrPriv(slave);
|
|
|
|
for (c = 0; c < pScrPriv->numCrtcs; c++)
|
|
|
|
if (pScrPriv->crtcs[c] == rr_crtc) {
|
|
|
|
newbox.x1 = x;
|
|
|
|
newbox.x2 = x + w;
|
|
|
|
newbox.y1 = y;
|
|
|
|
newbox.y2 = y + h;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!pScrPriv->crtcs[c]->mode)
|
|
|
|
continue;
|
|
|
|
newbox.x1 = pScrPriv->crtcs[c]->x;
|
|
|
|
newbox.x2 = pScrPriv->crtcs[c]->x + pScrPriv->crtcs[c]->mode->mode.width;
|
|
|
|
newbox.y1 = pScrPriv->crtcs[c]->y;
|
|
|
|
newbox.y2 = pScrPriv->crtcs[c]->y + pScrPriv->crtcs[c]->mode->mode.height;
|
|
|
|
}
|
|
|
|
RegionInit(&new_crtc_region, &newbox, 1);
|
|
|
|
RegionUnion(&total_region, &total_region, &new_crtc_region);
|
|
|
|
}
|
|
|
|
|
|
|
|
newsize = RegionExtents(&total_region);
|
|
|
|
new_width = newsize->x2 - newsize->x1;
|
|
|
|
new_height = newsize->y2 - newsize->y1;
|
|
|
|
|
|
|
|
if (new_width == screen_pixmap->drawable.width &&
|
|
|
|
new_height == screen_pixmap->drawable.height) {
|
|
|
|
ErrorF("adjust shatters %d %d\n", newsize->x1, newsize->x2);
|
|
|
|
} else {
|
|
|
|
rrScrPriv(pScreen);
|
2014-05-02 13:27:46 -06:00
|
|
|
pScrPriv->rrScreenSetSize(pScreen, new_width, new_height, 0, 0);
|
2013-06-07 11:28:45 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* set shatters TODO */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
/*
|
|
|
|
* Request that the Crtc be reconfigured
|
|
|
|
*/
|
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcSet(RRCrtcPtr crtc,
|
|
|
|
RRModePtr mode,
|
|
|
|
int x,
|
|
|
|
int y, Rotation rotation, int numOutputs, RROutputPtr * outputs)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = crtc->pScreen;
|
|
|
|
Bool ret = FALSE;
|
|
|
|
Bool recompute = TRUE;
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
rrScrPriv(pScreen);
|
|
|
|
|
|
|
|
/* See if nothing changed */
|
|
|
|
if (crtc->mode == mode &&
|
2012-06-10 07:21:05 -06:00
|
|
|
crtc->x == x &&
|
|
|
|
crtc->y == y &&
|
|
|
|
crtc->rotation == rotation &&
|
|
|
|
crtc->numOutputs == numOutputs &&
|
|
|
|
!memcmp(crtc->outputs, outputs, numOutputs * sizeof(RROutputPtr)) &&
|
|
|
|
!RRCrtcPendingProperties(crtc) && !RRCrtcPendingTransform(crtc)) {
|
|
|
|
recompute = FALSE;
|
|
|
|
ret = TRUE;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
2013-06-07 11:28:45 -06:00
|
|
|
if (pScreen->isGPU) {
|
|
|
|
ScreenPtr master = pScreen->current_master;
|
|
|
|
int width = 0, height = 0;
|
|
|
|
|
|
|
|
if (mode) {
|
|
|
|
width = mode->mode.width;
|
|
|
|
height = mode->mode.height;
|
|
|
|
}
|
|
|
|
ErrorF("have a master to look out for\n");
|
|
|
|
ret = rrCheckPixmapBounding(master, crtc,
|
|
|
|
x, y, width, height);
|
|
|
|
if (!ret)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (pScreen->current_master) {
|
|
|
|
ret = rrCreateSharedPixmap(crtc, width, height, x, y);
|
|
|
|
ErrorF("need to create shared pixmap %d", ret);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
#if RANDR_12_INTERFACE
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pScrPriv->rrCrtcSet) {
|
|
|
|
ret = (*pScrPriv->rrCrtcSet) (pScreen, crtc, mode, x, y,
|
|
|
|
rotation, numOutputs, outputs);
|
|
|
|
}
|
|
|
|
else
|
2007-11-24 10:55:21 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
#if RANDR_10_INTERFACE
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pScrPriv->rrSetConfig) {
|
|
|
|
RRScreenSize size;
|
|
|
|
RRScreenRate rate;
|
|
|
|
|
|
|
|
if (!mode) {
|
|
|
|
RRCrtcNotify(crtc, NULL, x, y, rotation, NULL, 0, NULL);
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
size.width = mode->mode.width;
|
|
|
|
size.height = mode->mode.height;
|
|
|
|
if (outputs[0]->mmWidth && outputs[0]->mmHeight) {
|
|
|
|
size.mmWidth = outputs[0]->mmWidth;
|
|
|
|
size.mmHeight = outputs[0]->mmHeight;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
size.mmWidth = pScreen->mmWidth;
|
|
|
|
size.mmHeight = pScreen->mmHeight;
|
|
|
|
}
|
|
|
|
size.nRates = 1;
|
|
|
|
rate.rate = RRVerticalRefresh(&mode->mode);
|
|
|
|
size.pRates = &rate;
|
|
|
|
ret =
|
|
|
|
(*pScrPriv->rrSetConfig) (pScreen, rotation, rate.rate,
|
|
|
|
&size);
|
|
|
|
/*
|
|
|
|
* Old 1.0 interface tied screen size to mode size
|
|
|
|
*/
|
|
|
|
if (ret) {
|
|
|
|
RRCrtcNotify(crtc, mode, x, y, rotation, NULL, 1,
|
|
|
|
outputs);
|
|
|
|
RRScreenSizeNotify(pScreen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
if (ret) {
|
|
|
|
int o;
|
|
|
|
|
|
|
|
RRTellChanged(pScreen);
|
|
|
|
|
|
|
|
for (o = 0; o < numOutputs; o++)
|
|
|
|
RRPostPendingProperties(outputs[o]);
|
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2011-11-05 07:32:40 -06:00
|
|
|
|
|
|
|
if (recompute)
|
2012-06-10 07:21:05 -06:00
|
|
|
RRComputeContiguity(pScreen);
|
2011-11-05 07:32:40 -06:00
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
/*
|
|
|
|
* Return crtc transform
|
|
|
|
*/
|
|
|
|
RRTransformPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcGetTransform(RRCrtcPtr crtc)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
RRTransformPtr transform = &crtc->client_pending_transform;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pixman_transform_is_identity(&transform->transform))
|
|
|
|
return NULL;
|
2009-09-06 13:44:18 -06:00
|
|
|
return transform;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check whether the pending and current transforms are the same
|
|
|
|
*/
|
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcPendingTransform(RRCrtcPtr crtc)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
return memcmp(&crtc->client_current_transform.transform,
|
|
|
|
&crtc->client_pending_transform.transform,
|
|
|
|
sizeof(PictTransform)) != 0;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
/*
|
|
|
|
* Destroy a Crtc at shutdown
|
|
|
|
*/
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcDestroy(RRCrtcPtr crtc)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeResource(crtc->id, 0);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcDestroyResource(pointer value, XID pid)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcPtr crtc = (RRCrtcPtr) value;
|
|
|
|
ScreenPtr pScreen = crtc->pScreen;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pScreen) {
|
|
|
|
rrScrPriv(pScreen);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < pScrPriv->numCrtcs; i++) {
|
|
|
|
if (pScrPriv->crtcs[i] == crtc) {
|
|
|
|
memmove(pScrPriv->crtcs + i, pScrPriv->crtcs + i + 1,
|
|
|
|
(pScrPriv->numCrtcs - (i + 1)) * sizeof(RRCrtcPtr));
|
|
|
|
--pScrPriv->numCrtcs;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-12-28 07:40:01 -07:00
|
|
|
|
|
|
|
RRResourcesChanged(pScreen);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
|
|
|
|
if (crtc->scanout_pixmap)
|
|
|
|
RRCrtcDetachScanoutPixmap(crtc);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(crtc->gammaRed);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (crtc->mode)
|
2012-06-10 07:21:05 -06:00
|
|
|
RRModeDestroy(crtc->mode);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(crtc);
|
2007-11-24 10:55:21 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Request that the Crtc gamma be changed
|
|
|
|
*/
|
|
|
|
|
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcGammaSet(RRCrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool ret = TRUE;
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
#if RANDR_12_INTERFACE
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = crtc->pScreen;
|
2007-11-24 10:55:21 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
memcpy(crtc->gammaRed, red, crtc->gammaSize * sizeof(CARD16));
|
|
|
|
memcpy(crtc->gammaGreen, green, crtc->gammaSize * sizeof(CARD16));
|
|
|
|
memcpy(crtc->gammaBlue, blue, crtc->gammaSize * sizeof(CARD16));
|
2007-11-24 10:55:21 -07:00
|
|
|
#if RANDR_12_INTERFACE
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pScreen) {
|
|
|
|
rrScrPriv(pScreen);
|
|
|
|
if (pScrPriv->rrCrtcSetGamma)
|
|
|
|
ret = (*pScrPriv->rrCrtcSetGamma) (pScreen, crtc);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
/*
|
|
|
|
* Request current gamma back from the DDX (if possible).
|
|
|
|
* This includes gamma size.
|
|
|
|
*/
|
|
|
|
Bool
|
|
|
|
RRCrtcGammaGet(RRCrtcPtr crtc)
|
|
|
|
{
|
|
|
|
Bool ret = TRUE;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
#if RANDR_12_INTERFACE
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPtr pScreen = crtc->pScreen;
|
2010-07-27 13:02:24 -06:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if RANDR_12_INTERFACE
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pScreen) {
|
2010-07-27 13:02:24 -06:00
|
|
|
rrScrPriv(pScreen);
|
|
|
|
if (pScrPriv->rrCrtcGetGamma)
|
|
|
|
ret = (*pScrPriv->rrCrtcGetGamma) (pScreen, crtc);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
/*
|
|
|
|
* Notify the extension that the Crtc gamma has been changed
|
|
|
|
* The driver calls this whenever it has changed the gamma values
|
|
|
|
* in the RRCrtcRec
|
|
|
|
*/
|
|
|
|
|
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcGammaNotify(RRCrtcPtr crtc)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE; /* not much going on here */
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
RRModeGetScanoutSize(RRModePtr mode, PictTransformPtr transform,
|
|
|
|
int *width, int *height)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
BoxRec box;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
if (mode == NULL) {
|
2012-06-10 07:21:05 -06:00
|
|
|
*width = 0;
|
|
|
|
*height = 0;
|
|
|
|
return;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
box.x1 = 0;
|
|
|
|
box.y1 = 0;
|
|
|
|
box.x2 = mode->mode.width;
|
|
|
|
box.y2 = mode->mode.height;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pixman_transform_bounds(transform, &box);
|
2009-09-06 13:44:18 -06:00
|
|
|
*width = box.x2 - box.x1;
|
|
|
|
*height = box.y2 - box.y1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the width/height that the crtc scans out from the framebuffer
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
RRCrtcGetScanoutSize(RRCrtcPtr crtc, int *width, int *height)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
RRModeGetScanoutSize(crtc->mode, &crtc->transform, width, height);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the size of the gamma table at server startup time
|
|
|
|
*/
|
|
|
|
|
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcGammaSetSize(RRCrtcPtr crtc, int size)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
CARD16 *gamma;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
if (size == crtc->gammaSize)
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE;
|
|
|
|
if (size) {
|
|
|
|
gamma = malloc(size * 3 * sizeof(CARD16));
|
|
|
|
if (!gamma)
|
|
|
|
return FALSE;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
gamma = NULL;
|
2010-12-05 08:36:02 -07:00
|
|
|
free(crtc->gammaRed);
|
2007-11-24 10:55:21 -07:00
|
|
|
crtc->gammaRed = gamma;
|
|
|
|
crtc->gammaGreen = gamma + size;
|
2012-06-10 07:21:05 -06:00
|
|
|
crtc->gammaBlue = gamma + size * 2;
|
2007-11-24 10:55:21 -07:00
|
|
|
crtc->gammaSize = size;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
/*
|
|
|
|
* Set the pending CRTC transformation
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcTransformSet(RRCrtcPtr crtc,
|
|
|
|
PictTransformPtr transform,
|
|
|
|
struct pixman_f_transform *f_transform,
|
|
|
|
struct pixman_f_transform *f_inverse,
|
|
|
|
char *filter_name,
|
|
|
|
int filter_len, xFixed * params, int nparams)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
PictFilterPtr filter = NULL;
|
|
|
|
int width = 0, height = 0;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
if (!crtc->transforms)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadValue;
|
|
|
|
|
|
|
|
if (filter_len) {
|
|
|
|
filter = PictureFindFilter(crtc->pScreen, filter_name, filter_len);
|
|
|
|
if (!filter)
|
|
|
|
return BadName;
|
|
|
|
if (filter->ValidateParams) {
|
|
|
|
if (!filter->ValidateParams(crtc->pScreen, filter->id,
|
|
|
|
params, nparams, &width, &height))
|
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
width = filter->width;
|
|
|
|
height = filter->height;
|
|
|
|
}
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
if (nparams)
|
|
|
|
return BadMatch;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!RRTransformSetFilter(&crtc->client_pending_transform,
|
|
|
|
filter, params, nparams, width, height))
|
|
|
|
return BadAlloc;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
crtc->client_pending_transform.transform = *transform;
|
|
|
|
crtc->client_pending_transform.f_transform = *f_transform;
|
|
|
|
crtc->client_pending_transform.f_inverse = *f_inverse;
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
/*
|
|
|
|
* Initialize crtc type
|
|
|
|
*/
|
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcInit(void)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcType = CreateNewResourceType(RRCrtcDestroyResource, "CRTC");
|
2007-11-24 10:55:21 -07:00
|
|
|
if (!RRCrtcType)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
/*
|
|
|
|
* Initialize crtc type error value
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
RRCrtcInitErrorValue(void)
|
|
|
|
{
|
|
|
|
SetResourceTypeErrorValue(RRCrtcType, RRErrorBase + BadRRCrtc);
|
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcRRGetCrtcInfo(ClientPtr client)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
|
|
|
REQUEST(xRRGetCrtcInfoReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
xRRGetCrtcInfoReply rep;
|
|
|
|
RRCrtcPtr crtc;
|
|
|
|
CARD8 *extra;
|
|
|
|
unsigned long extraLen;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
rrScrPrivPtr pScrPriv;
|
|
|
|
RRModePtr mode;
|
|
|
|
RROutput *outputs;
|
|
|
|
RROutput *possible;
|
|
|
|
int i, j, k;
|
|
|
|
int width, height;
|
|
|
|
BoxRec panned_area;
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq);
|
2010-07-27 13:02:24 -06:00
|
|
|
VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
/* All crtcs must be associated with screens before client
|
|
|
|
* requests are processed
|
|
|
|
*/
|
|
|
|
pScreen = crtc->pScreen;
|
|
|
|
pScrPriv = rrGetScrPriv(pScreen);
|
|
|
|
|
|
|
|
mode = crtc->mode;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
rep = (xRRGetCrtcInfoReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.status = RRSetConfigSuccess,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.timestamp = pScrPriv->lastSetTime.milliseconds
|
|
|
|
};
|
2009-09-06 13:44:18 -06:00
|
|
|
if (pScrPriv->rrGetPanning &&
|
2012-06-10 07:21:05 -06:00
|
|
|
pScrPriv->rrGetPanning(pScreen, crtc, &panned_area, NULL, NULL) &&
|
|
|
|
(panned_area.x2 > panned_area.x1) && (panned_area.y2 > panned_area.y1))
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.x = panned_area.x1;
|
|
|
|
rep.y = panned_area.y1;
|
|
|
|
rep.width = panned_area.x2 - panned_area.x1;
|
|
|
|
rep.height = panned_area.y2 - panned_area.y1;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
RRCrtcGetScanoutSize(crtc, &width, &height);
|
|
|
|
rep.x = crtc->x;
|
|
|
|
rep.y = crtc->y;
|
|
|
|
rep.width = width;
|
|
|
|
rep.height = height;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
rep.mode = mode ? mode->mode.id : 0;
|
|
|
|
rep.rotation = crtc->rotation;
|
|
|
|
rep.rotations = crtc->rotations;
|
|
|
|
rep.nOutput = crtc->numOutputs;
|
|
|
|
k = 0;
|
|
|
|
for (i = 0; i < pScrPriv->numOutputs; i++)
|
2012-06-10 07:21:05 -06:00
|
|
|
for (j = 0; j < pScrPriv->outputs[i]->numCrtcs; j++)
|
|
|
|
if (pScrPriv->outputs[i]->crtcs[j] == crtc)
|
|
|
|
k++;
|
2007-11-24 10:55:21 -07:00
|
|
|
rep.nPossibleOutput = k;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
rep.length = rep.nOutput + rep.nPossibleOutput;
|
|
|
|
|
|
|
|
extraLen = rep.length << 2;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (extraLen) {
|
|
|
|
extra = malloc(extraLen);
|
|
|
|
if (!extra)
|
|
|
|
return BadAlloc;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
extra = NULL;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
outputs = (RROutput *) extra;
|
|
|
|
possible = (RROutput *) (outputs + rep.nOutput);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
for (i = 0; i < crtc->numOutputs; i++) {
|
|
|
|
outputs[i] = crtc->outputs[i]->id;
|
|
|
|
if (client->swapped)
|
|
|
|
swapl(&outputs[i]);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
k = 0;
|
|
|
|
for (i = 0; i < pScrPriv->numOutputs; i++)
|
2012-06-10 07:21:05 -06:00
|
|
|
for (j = 0; j < pScrPriv->outputs[i]->numCrtcs; j++)
|
|
|
|
if (pScrPriv->outputs[i]->crtcs[j] == crtc) {
|
|
|
|
possible[k] = pScrPriv->outputs[i]->id;
|
|
|
|
if (client->swapped)
|
|
|
|
swapl(&possible[k]);
|
|
|
|
k++;
|
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swapl(&rep.timestamp);
|
|
|
|
swaps(&rep.x);
|
|
|
|
swaps(&rep.y);
|
|
|
|
swaps(&rep.width);
|
|
|
|
swaps(&rep.height);
|
|
|
|
swapl(&rep.mode);
|
|
|
|
swaps(&rep.rotation);
|
|
|
|
swaps(&rep.rotations);
|
|
|
|
swaps(&rep.nOutput);
|
|
|
|
swaps(&rep.nPossibleOutput);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xRRGetCrtcInfoReply), &rep);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (extraLen) {
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, extraLen, extra);
|
2012-06-10 07:21:05 -06:00
|
|
|
free(extra);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcRRSetCrtcConfig(ClientPtr client)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
|
|
|
REQUEST(xRRSetCrtcConfigReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
xRRSetCrtcConfigReply rep;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
rrScrPrivPtr pScrPriv;
|
|
|
|
RRCrtcPtr crtc;
|
|
|
|
RRModePtr mode;
|
|
|
|
int numOutputs;
|
|
|
|
RROutputPtr *outputs = NULL;
|
|
|
|
RROutput *outputIds;
|
|
|
|
TimeStamp time;
|
|
|
|
Rotation rotation;
|
2013-06-07 11:28:45 -06:00
|
|
|
int ret, i, j;
|
|
|
|
CARD8 status;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
numOutputs = (stuff->length - bytes_to_int32(SIZEOF(xRRSetCrtcConfigReq)));
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
VERIFY_RR_CRTC(stuff->crtc, crtc, DixSetAttrAccess);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->mode == None) {
|
|
|
|
mode = NULL;
|
|
|
|
if (numOutputs > 0)
|
|
|
|
return BadMatch;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
VERIFY_RR_MODE(stuff->mode, mode, DixSetAttrAccess);
|
|
|
|
if (numOutputs == 0)
|
|
|
|
return BadMatch;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (numOutputs) {
|
|
|
|
outputs = malloc(numOutputs * sizeof(RROutputPtr));
|
|
|
|
if (!outputs)
|
|
|
|
return BadAlloc;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
outputs = NULL;
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
outputIds = (RROutput *) (stuff + 1);
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < numOutputs; i++) {
|
2013-06-07 11:28:45 -06:00
|
|
|
ret = dixLookupResourceByType((pointer *) (outputs + i), outputIds[i],
|
2012-06-10 07:21:05 -06:00
|
|
|
RROutputType, client, DixSetAttrAccess);
|
2013-06-07 11:28:45 -06:00
|
|
|
if (ret != Success) {
|
2012-06-10 07:21:05 -06:00
|
|
|
free(outputs);
|
2013-06-07 11:28:45 -06:00
|
|
|
return ret;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
/* validate crtc for this output */
|
|
|
|
for (j = 0; j < outputs[i]->numCrtcs; j++)
|
|
|
|
if (outputs[i]->crtcs[j] == crtc)
|
|
|
|
break;
|
|
|
|
if (j == outputs[i]->numCrtcs) {
|
|
|
|
free(outputs);
|
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
/* validate mode for this output */
|
|
|
|
for (j = 0; j < outputs[i]->numModes + outputs[i]->numUserModes; j++) {
|
|
|
|
RRModePtr m = (j < outputs[i]->numModes ?
|
|
|
|
outputs[i]->modes[j] :
|
|
|
|
outputs[i]->userModes[j - outputs[i]->numModes]);
|
|
|
|
if (m == mode)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (j == outputs[i]->numModes + outputs[i]->numUserModes) {
|
|
|
|
free(outputs);
|
|
|
|
return BadMatch;
|
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
/* validate clones */
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < numOutputs; i++) {
|
|
|
|
for (j = 0; j < numOutputs; j++) {
|
|
|
|
int k;
|
|
|
|
|
|
|
|
if (i == j)
|
|
|
|
continue;
|
|
|
|
for (k = 0; k < outputs[i]->numClones; k++) {
|
|
|
|
if (outputs[i]->clones[k] == outputs[j])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (k == outputs[i]->numClones) {
|
|
|
|
free(outputs);
|
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
pScreen = crtc->pScreen;
|
|
|
|
pScrPriv = rrGetScrPriv(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
time = ClientTimeToServerTime(stuff->timestamp);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
if (!pScrPriv) {
|
|
|
|
time = currentTime;
|
2013-06-07 11:28:45 -06:00
|
|
|
status = RRSetConfigFailed;
|
2012-06-10 07:21:05 -06:00
|
|
|
goto sendReply;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
/*
|
|
|
|
* Validate requested rotation
|
|
|
|
*/
|
|
|
|
rotation = (Rotation) stuff->rotation;
|
|
|
|
|
|
|
|
/* test the rotation bits only! */
|
|
|
|
switch (rotation & 0xf) {
|
|
|
|
case RR_Rotate_0:
|
|
|
|
case RR_Rotate_90:
|
|
|
|
case RR_Rotate_180:
|
|
|
|
case RR_Rotate_270:
|
2012-06-10 07:21:05 -06:00
|
|
|
break;
|
2007-11-24 10:55:21 -07:00
|
|
|
default:
|
2012-06-10 07:21:05 -06:00
|
|
|
/*
|
|
|
|
* Invalid rotation
|
|
|
|
*/
|
|
|
|
client->errorValue = stuff->rotation;
|
|
|
|
free(outputs);
|
|
|
|
return BadValue;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (mode) {
|
|
|
|
if ((~crtc->rotations) & rotation) {
|
|
|
|
/*
|
|
|
|
* requested rotation or reflection not supported by screen
|
|
|
|
*/
|
|
|
|
client->errorValue = stuff->rotation;
|
|
|
|
free(outputs);
|
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
#ifdef RANDR_12_INTERFACE
|
2012-06-10 07:21:05 -06:00
|
|
|
/*
|
|
|
|
* Check screen size bounds if the DDX provides a 1.2 interface
|
|
|
|
* for setting screen size. Else, assume the CrtcSet sets
|
|
|
|
* the size along with the mode. If the driver supports transforms,
|
|
|
|
* then it must allow crtcs to display a subset of the screen, so
|
|
|
|
* only do this check for drivers without transform support.
|
|
|
|
*/
|
|
|
|
if (pScrPriv->rrScreenSetSize && !crtc->transforms) {
|
|
|
|
int source_width;
|
|
|
|
int source_height;
|
|
|
|
PictTransform transform;
|
|
|
|
struct pixman_f_transform f_transform, f_inverse;
|
2013-06-07 11:28:45 -06:00
|
|
|
int width, height;
|
|
|
|
|
|
|
|
if (pScreen->isGPU) {
|
|
|
|
width = pScreen->current_master->width;
|
|
|
|
height = pScreen->current_master->height;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
width = pScreen->width;
|
|
|
|
height = pScreen->height;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
RRTransformCompute(stuff->x, stuff->y,
|
|
|
|
mode->mode.width, mode->mode.height,
|
|
|
|
rotation,
|
|
|
|
&crtc->client_pending_transform,
|
|
|
|
&transform, &f_transform, &f_inverse);
|
|
|
|
|
|
|
|
RRModeGetScanoutSize(mode, &transform, &source_width,
|
|
|
|
&source_height);
|
2013-06-07 11:28:45 -06:00
|
|
|
if (stuff->x + source_width > width) {
|
2012-06-10 07:21:05 -06:00
|
|
|
client->errorValue = stuff->x;
|
|
|
|
free(outputs);
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
if (stuff->y + source_height > height) {
|
2012-06-10 07:21:05 -06:00
|
|
|
client->errorValue = stuff->y;
|
|
|
|
free(outputs);
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
#endif
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
if (!RRCrtcSet(crtc, mode, stuff->x, stuff->y,
|
|
|
|
rotation, numOutputs, outputs)) {
|
2013-06-07 11:28:45 -06:00
|
|
|
status = RRSetConfigFailed;
|
2012-06-10 07:21:05 -06:00
|
|
|
goto sendReply;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
status = RRSetConfigSuccess;
|
2009-09-06 13:44:18 -06:00
|
|
|
pScrPriv->lastSetTime = time;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
sendReply:
|
2010-12-05 08:36:02 -07:00
|
|
|
free(outputs);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
rep = (xRRSetCrtcConfigReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.status = status,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.newTimestamp = pScrPriv->lastSetTime.milliseconds
|
|
|
|
};
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (client->swapped) {
|
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swapl(&rep.newTimestamp);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xRRSetCrtcConfigReply), &rep);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcRRGetPanning(ClientPtr client)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
|
|
|
REQUEST(xRRGetPanningReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
xRRGetPanningReply rep;
|
|
|
|
RRCrtcPtr crtc;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
rrScrPrivPtr pScrPriv;
|
|
|
|
BoxRec total;
|
|
|
|
BoxRec tracking;
|
|
|
|
INT16 border[4];
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
REQUEST_SIZE_MATCH(xRRGetPanningReq);
|
2010-07-27 13:02:24 -06:00
|
|
|
VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
/* All crtcs must be associated with screens before client
|
|
|
|
* requests are processed
|
|
|
|
*/
|
|
|
|
pScreen = crtc->pScreen;
|
|
|
|
pScrPriv = rrGetScrPriv(pScreen);
|
|
|
|
|
|
|
|
if (!pScrPriv)
|
2012-06-10 07:21:05 -06:00
|
|
|
return RRErrorBase + BadRRCrtc;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
rep = (xRRGetPanningReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.status = RRSetConfigSuccess,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 1,
|
|
|
|
.timestamp = pScrPriv->lastSetTime.milliseconds
|
|
|
|
};
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
if (pScrPriv->rrGetPanning &&
|
2012-06-10 07:21:05 -06:00
|
|
|
pScrPriv->rrGetPanning(pScreen, crtc, &total, &tracking, border)) {
|
|
|
|
rep.left = total.x1;
|
|
|
|
rep.top = total.y1;
|
|
|
|
rep.width = total.x2 - total.x1;
|
|
|
|
rep.height = total.y2 - total.y1;
|
|
|
|
rep.track_left = tracking.x1;
|
|
|
|
rep.track_top = tracking.y1;
|
|
|
|
rep.track_width = tracking.x2 - tracking.x1;
|
|
|
|
rep.track_height = tracking.y2 - tracking.y1;
|
|
|
|
rep.border_left = border[0];
|
|
|
|
rep.border_top = border[1];
|
|
|
|
rep.border_right = border[2];
|
|
|
|
rep.border_bottom = border[3];
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swapl(&rep.timestamp);
|
|
|
|
swaps(&rep.left);
|
|
|
|
swaps(&rep.top);
|
|
|
|
swaps(&rep.width);
|
|
|
|
swaps(&rep.height);
|
|
|
|
swaps(&rep.track_left);
|
|
|
|
swaps(&rep.track_top);
|
|
|
|
swaps(&rep.track_width);
|
|
|
|
swaps(&rep.track_height);
|
|
|
|
swaps(&rep.border_left);
|
|
|
|
swaps(&rep.border_top);
|
|
|
|
swaps(&rep.border_right);
|
|
|
|
swaps(&rep.border_bottom);
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xRRGetPanningReply), &rep);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcRRSetPanning(ClientPtr client)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
|
|
|
REQUEST(xRRSetPanningReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
xRRSetPanningReply rep;
|
|
|
|
RRCrtcPtr crtc;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
rrScrPrivPtr pScrPriv;
|
|
|
|
TimeStamp time;
|
|
|
|
BoxRec total;
|
|
|
|
BoxRec tracking;
|
|
|
|
INT16 border[4];
|
2013-06-07 11:28:45 -06:00
|
|
|
CARD8 status;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
REQUEST_SIZE_MATCH(xRRSetPanningReq);
|
2010-07-27 13:02:24 -06:00
|
|
|
VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
/* All crtcs must be associated with screens before client
|
|
|
|
* requests are processed
|
|
|
|
*/
|
|
|
|
pScreen = crtc->pScreen;
|
|
|
|
pScrPriv = rrGetScrPriv(pScreen);
|
|
|
|
|
|
|
|
if (!pScrPriv) {
|
2012-06-10 07:21:05 -06:00
|
|
|
time = currentTime;
|
2013-06-07 11:28:45 -06:00
|
|
|
status = RRSetConfigFailed;
|
2012-06-10 07:21:05 -06:00
|
|
|
goto sendReply;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
time = ClientTimeToServerTime(stuff->timestamp);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
if (!pScrPriv->rrGetPanning)
|
2012-06-10 07:21:05 -06:00
|
|
|
return RRErrorBase + BadRRCrtc;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
total.x1 = stuff->left;
|
|
|
|
total.y1 = stuff->top;
|
|
|
|
total.x2 = total.x1 + stuff->width;
|
|
|
|
total.y2 = total.y1 + stuff->height;
|
2009-09-06 13:44:18 -06:00
|
|
|
tracking.x1 = stuff->track_left;
|
|
|
|
tracking.y1 = stuff->track_top;
|
|
|
|
tracking.x2 = tracking.x1 + stuff->track_width;
|
|
|
|
tracking.y2 = tracking.y1 + stuff->track_height;
|
2012-06-10 07:21:05 -06:00
|
|
|
border[0] = stuff->border_left;
|
|
|
|
border[1] = stuff->border_top;
|
|
|
|
border[2] = stuff->border_right;
|
|
|
|
border[3] = stuff->border_bottom;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!pScrPriv->rrSetPanning(pScreen, crtc, &total, &tracking, border))
|
|
|
|
return BadMatch;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
pScrPriv->lastSetTime = time;
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
status = RRSetConfigSuccess;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
sendReply:
|
2013-06-07 11:28:45 -06:00
|
|
|
rep = (xRRSetPanningReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.status = status,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.newTimestamp = pScrPriv->lastSetTime.milliseconds
|
|
|
|
};
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swapl(&rep.newTimestamp);
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xRRSetPanningReply), &rep);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcRRGetCrtcGammaSize(ClientPtr client)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
|
|
|
REQUEST(xRRGetCrtcGammaSizeReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
xRRGetCrtcGammaSizeReply reply;
|
|
|
|
RRCrtcPtr crtc;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq);
|
2010-07-27 13:02:24 -06:00
|
|
|
VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
|
|
|
|
|
|
|
|
/* Gamma retrieval failed, any better error? */
|
|
|
|
if (!RRCrtcGammaGet(crtc))
|
|
|
|
return RRErrorBase + BadRRCrtc;
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
reply = (xRRGetCrtcGammaSizeReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.size = crtc->gammaSize
|
|
|
|
};
|
2007-11-24 10:55:21 -07:00
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&reply.sequenceNumber);
|
|
|
|
swapl(&reply.length);
|
|
|
|
swaps(&reply.size);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xRRGetCrtcGammaSizeReply), &reply);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcRRGetCrtcGamma(ClientPtr client)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
|
|
|
REQUEST(xRRGetCrtcGammaReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
xRRGetCrtcGammaReply reply;
|
|
|
|
RRCrtcPtr crtc;
|
|
|
|
unsigned long len;
|
|
|
|
char *extra = NULL;
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq);
|
2010-07-27 13:02:24 -06:00
|
|
|
VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
|
|
|
|
|
|
|
|
/* Gamma retrieval failed, any better error? */
|
|
|
|
if (!RRCrtcGammaGet(crtc))
|
|
|
|
return RRErrorBase + BadRRCrtc;
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
len = crtc->gammaSize * 3 * 2;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
if (crtc->gammaSize) {
|
2012-06-10 07:21:05 -06:00
|
|
|
extra = malloc(len);
|
|
|
|
if (!extra)
|
|
|
|
return BadAlloc;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
reply = (xRRGetCrtcGammaReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = bytes_to_int32(len),
|
|
|
|
.size = crtc->gammaSize
|
|
|
|
};
|
2007-11-24 10:55:21 -07:00
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&reply.sequenceNumber);
|
|
|
|
swapl(&reply.length);
|
|
|
|
swaps(&reply.size);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xRRGetCrtcGammaReply), &reply);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (crtc->gammaSize) {
|
|
|
|
memcpy(extra, crtc->gammaRed, len);
|
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap16Write;
|
|
|
|
WriteSwappedDataToClient(client, len, extra);
|
|
|
|
free(extra);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcRRSetCrtcGamma(ClientPtr client)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
|
|
|
REQUEST(xRRSetCrtcGammaReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcPtr crtc;
|
|
|
|
unsigned long len;
|
|
|
|
CARD16 *red, *green, *blue;
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
REQUEST_AT_LEAST_SIZE(xRRSetCrtcGammaReq);
|
2010-07-27 13:02:24 -06:00
|
|
|
VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
len = client->req_len - bytes_to_int32(sizeof(xRRSetCrtcGammaReq));
|
2007-11-24 10:55:21 -07:00
|
|
|
if (len < (stuff->size * 3 + 1) >> 1)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadLength;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
if (stuff->size != crtc->gammaSize)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadMatch;
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
red = (CARD16 *) (stuff + 1);
|
|
|
|
green = red + crtc->gammaSize;
|
|
|
|
blue = green + crtc->gammaSize;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
RRCrtcGammaSet(crtc, red, green, blue);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
/* Version 1.3 additions */
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcRRSetCrtcTransform(ClientPtr client)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
|
|
|
REQUEST(xRRSetCrtcTransformReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcPtr crtc;
|
|
|
|
PictTransform transform;
|
2009-09-06 13:44:18 -06:00
|
|
|
struct pixman_f_transform f_transform, f_inverse;
|
2012-06-10 07:21:05 -06:00
|
|
|
char *filter;
|
|
|
|
int nbytes;
|
|
|
|
xFixed *params;
|
|
|
|
int nparams;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xRRSetCrtcTransformReq);
|
2010-07-27 13:02:24 -06:00
|
|
|
VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
PictTransform_from_xRenderTransform(&transform, &stuff->transform);
|
|
|
|
pixman_f_transform_from_pixman_transform(&f_transform, &transform);
|
|
|
|
if (!pixman_f_transform_invert(&f_inverse, &f_transform))
|
|
|
|
return BadMatch;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
filter = (char *) (stuff + 1);
|
|
|
|
nbytes = stuff->nbytesFilter;
|
2010-07-27 13:02:24 -06:00
|
|
|
params = (xFixed *) (filter + pad_to_int32(nbytes));
|
2009-09-06 13:44:18 -06:00
|
|
|
nparams = ((xFixed *) stuff + client->req_len) - params;
|
|
|
|
if (nparams < 0)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadLength;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return RRCrtcTransformSet(crtc, &transform, &f_transform, &f_inverse,
|
|
|
|
filter, nbytes, params, nparams);
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#define CrtcTransformExtra (SIZEOF(xRRGetCrtcTransformReply) - 32)
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
transform_filter_length(RRTransformPtr transform)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int nbytes, nparams;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
if (transform->filter == NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return 0;
|
|
|
|
nbytes = strlen(transform->filter->name);
|
2009-09-06 13:44:18 -06:00
|
|
|
nparams = transform->nparams;
|
2012-06-10 07:21:05 -06:00
|
|
|
return pad_to_int32(nbytes) + (nparams * sizeof(xFixed));
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
transform_filter_encode(ClientPtr client, char *output,
|
|
|
|
CARD16 *nbytesFilter,
|
|
|
|
CARD16 *nparamsFilter, RRTransformPtr transform)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int nbytes, nparams;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
if (transform->filter == NULL) {
|
2012-06-10 07:21:05 -06:00
|
|
|
*nbytesFilter = 0;
|
|
|
|
*nparamsFilter = 0;
|
|
|
|
return 0;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
nbytes = strlen(transform->filter->name);
|
2009-09-06 13:44:18 -06:00
|
|
|
nparams = transform->nparams;
|
|
|
|
*nbytesFilter = nbytes;
|
|
|
|
*nparamsFilter = nparams;
|
2012-06-10 07:21:05 -06:00
|
|
|
memcpy(output, transform->filter->name, nbytes);
|
2009-09-06 13:44:18 -06:00
|
|
|
while ((nbytes & 3) != 0)
|
2012-06-10 07:21:05 -06:00
|
|
|
output[nbytes++] = 0;
|
|
|
|
memcpy(output + nbytes, transform->params, nparams * sizeof(xFixed));
|
2009-09-06 13:44:18 -06:00
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(nbytesFilter);
|
|
|
|
swaps(nparamsFilter);
|
|
|
|
SwapLongs((CARD32 *) (output + nbytes), nparams);
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
nbytes += nparams * sizeof(xFixed);
|
2009-09-06 13:44:18 -06:00
|
|
|
return nbytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
transform_encode(ClientPtr client, xRenderTransform * wire,
|
|
|
|
PictTransform * pict)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xRenderTransform_from_PictTransform(wire, pict);
|
2009-09-06 13:44:18 -06:00
|
|
|
if (client->swapped)
|
2012-06-10 07:21:05 -06:00
|
|
|
SwapLongs((CARD32 *) wire, bytes_to_int32(sizeof(xRenderTransform)));
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcRRGetCrtcTransform(ClientPtr client)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
|
|
|
REQUEST(xRRGetCrtcTransformReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
xRRGetCrtcTransformReply *reply;
|
|
|
|
RRCrtcPtr crtc;
|
|
|
|
int nextra;
|
|
|
|
RRTransformPtr current, pending;
|
|
|
|
char *extra;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST_SIZE_MATCH(xRRGetCrtcTransformReq);
|
2010-07-27 13:02:24 -06:00
|
|
|
VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
pending = &crtc->client_pending_transform;
|
|
|
|
current = &crtc->client_current_transform;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
nextra = (transform_filter_length(pending) +
|
|
|
|
transform_filter_length(current));
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
reply = calloc(1, sizeof(xRRGetCrtcTransformReply) + nextra);
|
2009-09-06 13:44:18 -06:00
|
|
|
if (!reply)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadAlloc;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
extra = (char *) (reply + 1);
|
|
|
|
reply->type = X_Reply;
|
|
|
|
reply->sequenceNumber = client->sequence;
|
2010-07-27 13:02:24 -06:00
|
|
|
reply->length = bytes_to_int32(CrtcTransformExtra + nextra);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
reply->hasTransforms = crtc->transforms;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
transform_encode(client, &reply->pendingTransform, &pending->transform);
|
|
|
|
extra += transform_filter_encode(client, extra,
|
|
|
|
&reply->pendingNbytesFilter,
|
|
|
|
&reply->pendingNparamsFilter, pending);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
transform_encode(client, &reply->currentTransform, ¤t->transform);
|
|
|
|
extra += transform_filter_encode(client, extra,
|
|
|
|
&reply->currentNbytesFilter,
|
|
|
|
&reply->currentNparamsFilter, current);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&reply->sequenceNumber);
|
|
|
|
swapl(&reply->length);
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xRRGetCrtcTransformReply) + nextra, reply);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(reply);
|
|
|
|
return Success;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
2011-11-05 07:32:40 -06:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
static Bool check_all_screen_crtcs(ScreenPtr pScreen, int *x, int *y)
|
2011-11-05 07:32:40 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
rrScrPriv(pScreen);
|
2011-11-05 07:32:40 -06:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < pScrPriv->numCrtcs; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcPtr crtc = pScrPriv->crtcs[i];
|
2011-11-05 07:32:40 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
int left, right, top, bottom;
|
2011-11-05 07:32:40 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!crtc->mode)
|
|
|
|
continue;
|
2011-11-05 07:32:40 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
crtc_bounds(crtc, &left, &right, &top, &bottom);
|
2011-11-05 07:32:40 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((*x >= left) && (*x < right) && (*y >= top) && (*y < bottom))
|
2013-06-07 11:28:45 -06:00
|
|
|
return TRUE;
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool constrain_all_screen_crtcs(DeviceIntPtr pDev, ScreenPtr pScreen, int *x, int *y)
|
|
|
|
{
|
|
|
|
rrScrPriv(pScreen);
|
|
|
|
int i;
|
2011-11-05 07:32:40 -06:00
|
|
|
|
|
|
|
/* if we're trying to escape, clamp to the CRTC we're coming from */
|
|
|
|
for (i = 0; i < pScrPriv->numCrtcs; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
RRCrtcPtr crtc = pScrPriv->crtcs[i];
|
|
|
|
int nx, ny;
|
|
|
|
int left, right, top, bottom;
|
|
|
|
|
|
|
|
if (!crtc->mode)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
crtc_bounds(crtc, &left, &right, &top, &bottom);
|
|
|
|
miPointerGetPosition(pDev, &nx, &ny);
|
|
|
|
|
|
|
|
if ((nx >= left) && (nx < right) && (ny >= top) && (ny < bottom)) {
|
|
|
|
if (*x < left)
|
|
|
|
*x = left;
|
|
|
|
if (*x >= right)
|
|
|
|
*x = right - 1;
|
|
|
|
if (*y < top)
|
|
|
|
*y = top;
|
|
|
|
if (*y >= bottom)
|
|
|
|
*y = bottom - 1;
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x,
|
|
|
|
int *y)
|
|
|
|
{
|
|
|
|
rrScrPriv(pScreen);
|
|
|
|
Bool ret;
|
|
|
|
ScreenPtr slave;
|
|
|
|
|
|
|
|
/* intentional dead space -> let it float */
|
|
|
|
if (pScrPriv->discontiguous)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* if we're moving inside a crtc, we're fine */
|
|
|
|
ret = check_all_screen_crtcs(pScreen, x, y);
|
|
|
|
if (ret == TRUE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
xorg_list_for_each_entry(slave, &pScreen->output_slave_list, output_head) {
|
|
|
|
ret = check_all_screen_crtcs(slave, x, y);
|
|
|
|
if (ret == TRUE)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2013-06-07 11:28:45 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* if we're trying to escape, clamp to the CRTC we're coming from */
|
|
|
|
ret = constrain_all_screen_crtcs(pDev, pScreen, x, y);
|
|
|
|
if (ret == TRUE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
xorg_list_for_each_entry(slave, &pScreen->output_slave_list, output_head) {
|
|
|
|
ret = constrain_all_screen_crtcs(pDev, slave, x, y);
|
|
|
|
if (ret == TRUE)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
|
|
|
RRReplaceScanoutPixmap(DrawablePtr pDrawable, PixmapPtr pPixmap, Bool enable)
|
|
|
|
{
|
|
|
|
rrScrPriv(pDrawable->pScreen);
|
|
|
|
int i;
|
|
|
|
Bool size_fits = FALSE;
|
|
|
|
Bool changed = FALSE;
|
|
|
|
Bool ret = TRUE;
|
|
|
|
|
|
|
|
for (i = 0; i < pScrPriv->numCrtcs; i++) {
|
|
|
|
RRCrtcPtr crtc = pScrPriv->crtcs[i];
|
|
|
|
|
|
|
|
if (!crtc->mode && enable)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
changed = FALSE;
|
|
|
|
if (crtc->mode && crtc->x == pDrawable->x &&
|
|
|
|
crtc->y == pDrawable->y &&
|
|
|
|
crtc->mode->mode.width == pDrawable->width &&
|
|
|
|
crtc->mode->mode.height == pDrawable->height)
|
|
|
|
size_fits = TRUE;
|
|
|
|
|
|
|
|
/* is the pixmap already set? */
|
|
|
|
if (crtc->scanout_pixmap == pPixmap) {
|
|
|
|
/* if its a disable then don't care about size */
|
|
|
|
if (enable == FALSE) {
|
|
|
|
/* set scanout to NULL */
|
|
|
|
crtc->scanout_pixmap = NULL;
|
|
|
|
changed = TRUE;
|
|
|
|
} else {
|
|
|
|
/* if the size fits then we are already setup */
|
|
|
|
if (size_fits)
|
|
|
|
return TRUE;
|
|
|
|
/* if the size no longer fits then drop off */
|
|
|
|
crtc->scanout_pixmap = NULL;
|
|
|
|
changed = TRUE;
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!size_fits)
|
|
|
|
return FALSE;
|
|
|
|
if (enable) {
|
|
|
|
crtc->scanout_pixmap = pPixmap;
|
|
|
|
pScrPriv->rrCrtcSetScanoutPixmap(crtc, pPixmap);
|
|
|
|
changed = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed && pScrPriv->rrCrtcSet) {
|
|
|
|
pScrPriv->rrCrtcSetScanoutPixmap(crtc, crtc->scanout_pixmap);
|
|
|
|
|
|
|
|
(*pScrPriv->rrCrtcSet) (pDrawable->pScreen, crtc, crtc->mode, crtc->x, crtc->y,
|
|
|
|
crtc->rotation, crtc->numOutputs, crtc->outputs);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
return ret;
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|