dix/randr: add a hook into screen to replace scanout pixmap
For DRI2 in some offload cases we need to set a new pixmap on the crtc, this hook allows dri2 to call into randr to do the necessary work to set a pixmap as the scanout pixmap for the crtc the drawable is currently on. This is really only to be used for unredirected full screen apps in composited environments. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
parent
e2fd447e76
commit
c41922940a
|
@ -351,6 +351,8 @@ typedef Bool (*StartPixmapTrackingProcPtr)(PixmapPtr, PixmapPtr,
|
||||||
|
|
||||||
typedef Bool (*StopPixmapTrackingProcPtr)(PixmapPtr, PixmapPtr);
|
typedef Bool (*StopPixmapTrackingProcPtr)(PixmapPtr, PixmapPtr);
|
||||||
|
|
||||||
|
typedef Bool (*ReplaceScanoutPixmapProcPtr)(DrawablePtr, PixmapPtr, Bool);
|
||||||
|
|
||||||
typedef struct _Screen {
|
typedef struct _Screen {
|
||||||
int myNum; /* index of this instance in Screens[] */
|
int myNum; /* index of this instance in Screens[] */
|
||||||
ATOM id;
|
ATOM id;
|
||||||
|
@ -510,6 +512,7 @@ typedef struct _Screen {
|
||||||
struct xorg_list offload_slave_list;
|
struct xorg_list offload_slave_list;
|
||||||
struct xorg_list offload_head;
|
struct xorg_list offload_head;
|
||||||
|
|
||||||
|
ReplaceScanoutPixmapProcPtr ReplaceScanoutPixmap;
|
||||||
} ScreenRec;
|
} ScreenRec;
|
||||||
|
|
||||||
static inline RegionPtr
|
static inline RegionPtr
|
||||||
|
|
|
@ -324,7 +324,7 @@ RRScreenInit(ScreenPtr pScreen)
|
||||||
wrap(pScrPriv, pScreen, CloseScreen, RRCloseScreen);
|
wrap(pScrPriv, pScreen, CloseScreen, RRCloseScreen);
|
||||||
|
|
||||||
pScreen->ConstrainCursorHarder = RRConstrainCursorHarder;
|
pScreen->ConstrainCursorHarder = RRConstrainCursorHarder;
|
||||||
|
pScreen->ReplaceScanoutPixmap = RRReplaceScanoutPixmap;
|
||||||
pScrPriv->numOutputs = 0;
|
pScrPriv->numOutputs = 0;
|
||||||
pScrPriv->outputs = NULL;
|
pScrPriv->outputs = NULL;
|
||||||
pScrPriv->numCrtcs = 0;
|
pScrPriv->numCrtcs = 0;
|
||||||
|
|
|
@ -673,6 +673,9 @@ extern _X_EXPORT void
|
||||||
extern _X_EXPORT void
|
extern _X_EXPORT void
|
||||||
RRCrtcDetachScanoutPixmap(RRCrtcPtr crtc);
|
RRCrtcDetachScanoutPixmap(RRCrtcPtr crtc);
|
||||||
|
|
||||||
|
extern _X_EXPORT Bool
|
||||||
|
RRReplaceScanoutPixmap(DrawablePtr pDrawable, PixmapPtr pPixmap, Bool enable);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Crtc dispatch
|
* Crtc dispatch
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1641,3 +1641,61 @@ RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x,
|
||||||
return;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue