2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
Copyright (C) 1999. The XFree86 Project Inc.
|
2014-09-27 11:52:59 -06:00
|
|
|
Copyright 2014 Red Hat, Inc.
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
Written by Mark Vojkovich (mvojkovi@ucsd.edu)
|
|
|
|
Pre-fb-write callbacks and RENDER support - Nolan Leake (nolan@vmware.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_XORG_CONFIG_H
|
|
|
|
#include <xorg-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xproto.h>
|
|
|
|
#include "misc.h"
|
|
|
|
#include "pixmapstr.h"
|
|
|
|
#include "input.h"
|
|
|
|
#include <X11/fonts/font.h>
|
|
|
|
#include "mi.h"
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "windowstr.h"
|
|
|
|
#include "gcstruct.h"
|
|
|
|
#include "dixfontstr.h"
|
|
|
|
#include <X11/fonts/fontstruct.h>
|
|
|
|
#include "xf86.h"
|
|
|
|
#include "xf86str.h"
|
|
|
|
#include "shadowfb.h"
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
#include "picturestr.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
static Bool ShadowCloseScreen(ScreenPtr pScreen);
|
2014-09-27 11:52:59 -06:00
|
|
|
static Bool ShadowCreateRootWindow(WindowPtr pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
typedef struct {
|
2012-06-10 07:21:05 -06:00
|
|
|
ScrnInfoPtr pScrn;
|
|
|
|
RefreshAreaFuncPtr preRefresh;
|
|
|
|
RefreshAreaFuncPtr postRefresh;
|
|
|
|
CloseScreenProcPtr CloseScreen;
|
2014-09-27 11:52:59 -06:00
|
|
|
CreateWindowProcPtr CreateWindow;
|
2006-11-26 11:13:41 -07:00
|
|
|
} ShadowScreenRec, *ShadowScreenPtr;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
static DevPrivateKeyRec ShadowScreenKeyRec;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static ShadowScreenPtr
|
|
|
|
shadowfbGetScreenPrivate(ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
return dixLookupPrivate(&(pScreen)->devPrivates, &ShadowScreenKeyRec);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
ShadowFBInit2(ScreenPtr pScreen,
|
|
|
|
RefreshAreaFuncPtr preRefreshArea,
|
|
|
|
RefreshAreaFuncPtr postRefreshArea)
|
|
|
|
{
|
2013-06-07 11:28:45 -06:00
|
|
|
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
ShadowScreenPtr pPriv;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!preRefreshArea && !postRefreshArea)
|
|
|
|
return FALSE;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
if (!dixRegisterPrivateKey(&ShadowScreenKeyRec, PRIVATE_SCREEN, 0))
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2010-12-05 08:36:02 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(pPriv = (ShadowScreenPtr) malloc(sizeof(ShadowScreenRec))))
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, &ShadowScreenKeyRec, pPriv);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pPriv->pScrn = pScrn;
|
|
|
|
pPriv->preRefresh = preRefreshArea;
|
|
|
|
pPriv->postRefresh = postRefreshArea;
|
|
|
|
|
|
|
|
pPriv->CloseScreen = pScreen->CloseScreen;
|
2014-09-27 11:52:59 -06:00
|
|
|
pPriv->CreateWindow = pScreen->CreateWindow;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pScreen->CloseScreen = ShadowCloseScreen;
|
2014-09-27 11:52:59 -06:00
|
|
|
pScreen->CreateWindow = ShadowCreateRootWindow;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
ShadowFBInit(ScreenPtr pScreen, RefreshAreaFuncPtr refreshArea)
|
|
|
|
{
|
2006-11-26 11:13:41 -07:00
|
|
|
return ShadowFBInit2(pScreen, NULL, refreshArea);
|
|
|
|
}
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
/*
|
|
|
|
* Note that we don't do DamageEmpty, or indeed look at the region inside the
|
|
|
|
* DamagePtr at all. This is an optimization, believe it or not. The
|
|
|
|
* incoming RegionPtr is the new damage, and if we were to empty the region
|
|
|
|
* miext/damage would just have to waste time reallocating and re-unioning
|
|
|
|
* it every time, whereas if we leave it around the union gets fast-pathed
|
|
|
|
* away.
|
|
|
|
*/
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
2014-09-27 11:52:59 -06:00
|
|
|
shadowfbReportPre(DamagePtr damage, RegionPtr reg, void *closure)
|
2012-06-10 07:21:05 -06:00
|
|
|
{
|
2014-09-27 11:52:59 -06:00
|
|
|
ShadowScreenPtr pPriv = closure;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
if (!pPriv->pScrn->vtSema)
|
|
|
|
return;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
pPriv->preRefresh(pPriv->pScrn, RegionNumRects(reg), RegionRects(reg));
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-27 11:52:59 -06:00
|
|
|
shadowfbReportPost(DamagePtr damage, RegionPtr reg, void *closure)
|
2012-06-10 07:21:05 -06:00
|
|
|
{
|
2014-09-27 11:52:59 -06:00
|
|
|
ShadowScreenPtr pPriv = closure;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
if (!pPriv->pScrn->vtSema)
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
pPriv->postRefresh(pPriv->pScrn, RegionNumRects(reg), RegionRects(reg));
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2014-09-27 11:52:59 -06:00
|
|
|
ShadowCreateRootWindow(WindowPtr pWin)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool ret;
|
2014-09-27 11:52:59 -06:00
|
|
|
ScreenPtr pScreen = pWin->drawable.pScreen;
|
|
|
|
ShadowScreenPtr pPriv = shadowfbGetScreenPrivate(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
/* paranoia */
|
|
|
|
if (pWin != pScreen->root)
|
|
|
|
ErrorF("ShadowCreateRootWindow called unexpectedly\n");
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
/* call down, but don't hook ourselves back in; we know the first time
|
|
|
|
* we're called it's for the root window.
|
|
|
|
*/
|
|
|
|
pScreen->CreateWindow = pPriv->CreateWindow;
|
|
|
|
ret = pScreen->CreateWindow(pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
/* this might look like it leaks, but the damage code reaps listeners
|
|
|
|
* when their drawable disappears.
|
|
|
|
*/
|
|
|
|
if (ret) {
|
|
|
|
DamagePtr damage;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
if (pPriv->preRefresh) {
|
|
|
|
damage = DamageCreate(shadowfbReportPre, NULL,
|
|
|
|
DamageReportRawRegion,
|
|
|
|
TRUE, pScreen, pPriv);
|
|
|
|
DamageRegister(&pWin->drawable, damage);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
if (pPriv->postRefresh) {
|
|
|
|
damage = DamageCreate(shadowfbReportPost, NULL,
|
|
|
|
DamageReportRawRegion,
|
|
|
|
TRUE, pScreen, pPriv);
|
|
|
|
DamageSetReportAfterOp(damage, TRUE);
|
|
|
|
DamageRegister(&pWin->drawable, damage);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static Bool
|
|
|
|
ShadowCloseScreen(ScreenPtr pScreen)
|
2012-06-10 07:21:05 -06:00
|
|
|
{
|
2014-09-27 11:52:59 -06:00
|
|
|
ShadowScreenPtr pPriv = shadowfbGetScreenPrivate(pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
pScreen->CloseScreen = pPriv->CloseScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
free(pPriv);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
return (*pScreen->CloseScreen) (pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|