2003-11-14 17:48:57 +01:00
|
|
|
|
2005-07-03 09:02:09 +02:00
|
|
|
#ifdef HAVE_XORG_CONFIG_H
|
|
|
|
#include <xorg-config.h>
|
|
|
|
#endif
|
|
|
|
|
2005-07-03 10:53:54 +02:00
|
|
|
#include "misc.h"
|
2003-11-14 17:48:57 +01:00
|
|
|
#include "xf86.h"
|
|
|
|
#include "xf86_OSproc.h"
|
|
|
|
|
2005-04-20 14:25:48 +02:00
|
|
|
#include <X11/X.h>
|
2003-11-14 17:48:57 +01:00
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "pixmapstr.h"
|
|
|
|
#include "windowstr.h"
|
|
|
|
#include "xf86str.h"
|
|
|
|
#include "mi.h"
|
|
|
|
#include "miline.h"
|
|
|
|
#include "xaa.h"
|
|
|
|
#include "xaalocal.h"
|
|
|
|
#include "xaawrap.h"
|
|
|
|
#include "xf86fbman.h"
|
|
|
|
#include "servermd.h"
|
2008-10-26 11:20:33 +01:00
|
|
|
#ifdef COMPOSITE
|
|
|
|
#include "cw.h"
|
|
|
|
#endif
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
#define MAX_PREALLOC_MEM 65536 /* MUST be >= 1024 */
|
|
|
|
|
|
|
|
#define MIN_OFFPIX_SIZE (320*200)
|
|
|
|
|
|
|
|
static Bool XAACloseScreen(int i, ScreenPtr pScreen);
|
|
|
|
static void XAAGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h,
|
|
|
|
unsigned int format, unsigned long planemask,
|
|
|
|
char *pdstLine);
|
|
|
|
static void XAAGetSpans(DrawablePtr pDrawable, int wMax, DDXPointPtr ppt,
|
|
|
|
int *pwidth, int nspans, char *pdstStart);
|
2007-10-31 22:15:35 +01:00
|
|
|
static PixmapPtr XAACreatePixmap(ScreenPtr pScreen, int w, int h, int depth,
|
2011-03-18 07:48:52 +01:00
|
|
|
unsigned usage_hint);
|
2003-11-14 17:48:57 +01:00
|
|
|
static Bool XAADestroyPixmap(PixmapPtr pPixmap);
|
|
|
|
static Bool XAAEnterVT (int index, int flags);
|
|
|
|
static void XAALeaveVT (int index, int flags);
|
|
|
|
static int XAASetDGAMode(int index, int num, DGADevicePtr devRet);
|
|
|
|
static void XAAEnableDisableFBAccess (int index, Bool enable);
|
|
|
|
static Bool XAAChangeWindowAttributes (WindowPtr pWin, unsigned long mask);
|
|
|
|
|
2010-04-27 02:22:21 +02:00
|
|
|
static DevPrivateKeyRec XAAScreenKeyRec;
|
|
|
|
#define XAAScreenKey (&XAAScreenKeyRec)
|
|
|
|
static DevPrivateKeyRec XAAGCKeyRec;
|
|
|
|
#define XAAGCKey (&XAAGCKeyRec)
|
|
|
|
static DevPrivateKeyRec XAAPixmapKeyRec;
|
|
|
|
#define XAAPixmapKey (&XAAPixmapKeyRec)
|
2004-07-30 22:30:57 +02:00
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
DevPrivateKey XAAGetScreenKey(void) {
|
2007-08-28 15:28:25 +02:00
|
|
|
return XAAScreenKey;
|
2004-07-30 22:30:57 +02:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
DevPrivateKey XAAGetGCKey(void) {
|
2007-08-28 15:28:25 +02:00
|
|
|
return XAAGCKey;
|
2004-07-30 22:30:57 +02:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
DevPrivateKey XAAGetPixmapKey(void) {
|
2007-08-28 15:28:25 +02:00
|
|
|
return XAAPixmapKey;
|
2004-07-30 22:30:57 +02:00
|
|
|
}
|
|
|
|
|
2003-11-14 17:48:57 +01:00
|
|
|
/* temp kludge */
|
|
|
|
static Bool SwitchedOut = FALSE;
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
XAAInfoRecPtr
|
2009-01-11 08:33:18 +01:00
|
|
|
XAACreateInfoRec(void)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
|
|
|
XAAInfoRecPtr infoRec;
|
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
infoRec = calloc(1, sizeof(XAAInfoRec));
|
2003-11-14 17:48:57 +01:00
|
|
|
if(infoRec)
|
|
|
|
infoRec->CachePixelGranularity = -1;
|
|
|
|
|
|
|
|
return infoRec;
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2003-11-14 17:48:57 +01:00
|
|
|
XAADestroyInfoRec(XAAInfoRecPtr infoRec)
|
|
|
|
{
|
|
|
|
if(!infoRec) return;
|
|
|
|
|
|
|
|
if(infoRec->ClosePixmapCache)
|
|
|
|
(*infoRec->ClosePixmapCache)(infoRec->pScrn->pScreen);
|
|
|
|
|
2010-06-06 10:28:30 +02:00
|
|
|
free(infoRec->PreAllocMem);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2010-06-06 10:28:30 +02:00
|
|
|
free(infoRec->PixmapCachePrivate);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
free(infoRec);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2003-11-14 17:48:57 +01:00
|
|
|
XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
|
|
|
|
{
|
|
|
|
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
|
|
|
|
XAAScreenPtr pScreenPriv;
|
|
|
|
int i;
|
|
|
|
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
|
|
|
|
|
|
|
|
/* Return successfully if no acceleration wanted */
|
|
|
|
if (!infoRec)
|
|
|
|
return TRUE;
|
|
|
|
|
2010-04-27 02:22:21 +02:00
|
|
|
if (!dixRegisterPrivateKey(&XAAGCKeyRec, PRIVATE_GC, sizeof(XAAGCRec)))
|
2003-11-14 17:48:57 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2010-04-27 02:22:21 +02:00
|
|
|
if (!dixRegisterPrivateKey(&XAAPixmapKeyRec, PRIVATE_PIXMAP, sizeof(XAAPixmapRec)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!dixRegisterPrivateKey(&XAAScreenKeyRec, PRIVATE_SCREEN, 0))
|
2003-11-14 17:48:57 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
if (!(pScreenPriv = malloc(sizeof(XAAScreenRec))))
|
2003-11-14 17:48:57 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2007-08-28 15:28:25 +02:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, XAAScreenKey, pScreenPriv);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
if(!xf86FBManagerRunning(pScreen))
|
|
|
|
infoRec->Flags &= ~(PIXMAP_CACHE | OFFSCREEN_PIXMAPS);
|
|
|
|
if(!(infoRec->Flags & LINEAR_FRAMEBUFFER))
|
|
|
|
infoRec->Flags &= ~OFFSCREEN_PIXMAPS;
|
|
|
|
|
|
|
|
if(!infoRec->FullPlanemask) { /* for backwards compatibility */
|
|
|
|
infoRec->FullPlanemask = (1 << pScrn->depth) - 1;
|
|
|
|
infoRec->FullPlanemasks[pScrn->depth - 1] = infoRec->FullPlanemask;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i = 0; i < 32; i++) {
|
|
|
|
if(!infoRec->FullPlanemasks[i]) /* keep any set by caller */
|
|
|
|
infoRec->FullPlanemasks[i] = (1 << (i+1)) - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!XAAInitAccel(pScreen, infoRec)) return FALSE;
|
|
|
|
pScreenPriv->AccelInfoRec = infoRec;
|
|
|
|
infoRec->ScratchGC.pScreen = pScreen;
|
|
|
|
|
|
|
|
|
|
|
|
if(!infoRec->GetImage)
|
|
|
|
infoRec->GetImage = XAAGetImage;
|
|
|
|
if(!infoRec->GetSpans)
|
|
|
|
infoRec->GetSpans = XAAGetSpans;
|
|
|
|
if(!infoRec->CopyWindow)
|
|
|
|
infoRec->CopyWindow = XAACopyWindow;
|
|
|
|
|
|
|
|
pScreenPriv->CreateGC = pScreen->CreateGC;
|
|
|
|
pScreen->CreateGC = XAACreateGC;
|
|
|
|
pScreenPriv->CloseScreen = pScreen->CloseScreen;
|
|
|
|
pScreen->CloseScreen = XAACloseScreen;
|
|
|
|
pScreenPriv->GetImage = pScreen->GetImage;
|
|
|
|
pScreen->GetImage = infoRec->GetImage;
|
|
|
|
pScreenPriv->GetSpans = pScreen->GetSpans;
|
|
|
|
pScreen->GetSpans = infoRec->GetSpans;
|
|
|
|
pScreenPriv->CopyWindow = pScreen->CopyWindow;
|
|
|
|
pScreen->CopyWindow = infoRec->CopyWindow;
|
|
|
|
pScreenPriv->CreatePixmap = pScreen->CreatePixmap;
|
|
|
|
pScreen->CreatePixmap = XAACreatePixmap;
|
|
|
|
pScreenPriv->DestroyPixmap = pScreen->DestroyPixmap;
|
|
|
|
pScreen->DestroyPixmap = XAADestroyPixmap;
|
|
|
|
pScreenPriv->ChangeWindowAttributes = pScreen->ChangeWindowAttributes;
|
|
|
|
pScreen->ChangeWindowAttributes = XAAChangeWindowAttributes;
|
|
|
|
|
|
|
|
pScreenPriv->EnterVT = pScrn->EnterVT;
|
|
|
|
pScrn->EnterVT = XAAEnterVT;
|
|
|
|
pScreenPriv->LeaveVT = pScrn->LeaveVT;
|
|
|
|
pScrn->LeaveVT = XAALeaveVT;
|
|
|
|
pScreenPriv->SetDGAMode = pScrn->SetDGAMode;
|
|
|
|
pScrn->SetDGAMode = XAASetDGAMode;
|
|
|
|
pScreenPriv->EnableDisableFBAccess = pScrn->EnableDisableFBAccess;
|
|
|
|
pScrn->EnableDisableFBAccess = XAAEnableDisableFBAccess;
|
|
|
|
|
|
|
|
pScreenPriv->WindowExposures = pScreen->WindowExposures;
|
|
|
|
if (ps)
|
|
|
|
{
|
|
|
|
pScreenPriv->Composite = ps->Composite;
|
|
|
|
ps->Composite = XAAComposite;
|
|
|
|
pScreenPriv->Glyphs = ps->Glyphs;
|
|
|
|
ps->Glyphs = XAAGlyphs;
|
|
|
|
}
|
|
|
|
if(pScrn->overlayFlags & OVERLAY_8_32_PLANAR)
|
|
|
|
XAASetupOverlay8_32Planar(pScreen);
|
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
infoRec->PreAllocMem = malloc(MAX_PREALLOC_MEM);
|
2003-11-14 17:48:57 +01:00
|
|
|
if(infoRec->PreAllocMem)
|
|
|
|
infoRec->PreAllocSize = MAX_PREALLOC_MEM;
|
|
|
|
|
|
|
|
if(infoRec->Flags & PIXMAP_CACHE)
|
|
|
|
xf86RegisterFreeBoxCallback(pScreen, infoRec->InitPixmapCache,
|
|
|
|
(pointer)infoRec);
|
|
|
|
|
|
|
|
if(infoRec->Flags & MICROSOFT_ZERO_LINE_BIAS)
|
|
|
|
miSetZeroLineBias(pScreen, OCTANT1 | OCTANT2 | OCTANT3 | OCTANT4);
|
|
|
|
|
2007-03-28 02:31:28 +02:00
|
|
|
#ifdef COMPOSITE
|
|
|
|
/* Initialize the composite wrapper. This needs to happen after the
|
|
|
|
* wrapping above (so it comes before us), but before all other extensions,
|
|
|
|
* so it doesn't confuse them. (particularly damage).
|
|
|
|
*/
|
|
|
|
miInitializeCompositeWrapper(pScreen);
|
|
|
|
#endif
|
|
|
|
|
2003-11-14 17:48:57 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
XAACloseScreen (int i, ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
|
|
|
|
XAAScreenPtr pScreenPriv =
|
2007-08-28 15:28:25 +02:00
|
|
|
(XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
pScrn->EnterVT = pScreenPriv->EnterVT;
|
|
|
|
pScrn->LeaveVT = pScreenPriv->LeaveVT;
|
|
|
|
pScrn->EnableDisableFBAccess = pScreenPriv->EnableDisableFBAccess;
|
|
|
|
|
|
|
|
pScreen->CreateGC = pScreenPriv->CreateGC;
|
|
|
|
pScreen->CloseScreen = pScreenPriv->CloseScreen;
|
|
|
|
pScreen->GetImage = pScreenPriv->GetImage;
|
|
|
|
pScreen->GetSpans = pScreenPriv->GetSpans;
|
|
|
|
pScreen->CopyWindow = pScreenPriv->CopyWindow;
|
|
|
|
pScreen->WindowExposures = pScreenPriv->WindowExposures;
|
|
|
|
pScreen->CreatePixmap = pScreenPriv->CreatePixmap;
|
|
|
|
pScreen->DestroyPixmap = pScreenPriv->DestroyPixmap;
|
|
|
|
pScreen->ChangeWindowAttributes = pScreenPriv->ChangeWindowAttributes;
|
|
|
|
|
|
|
|
/* We leave it up to the client to free the XAAInfoRec */
|
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
free((pointer) pScreenPriv);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
return (*pScreen->CloseScreen) (i, pScreen);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
XAAGetImage (
|
|
|
|
DrawablePtr pDraw,
|
|
|
|
int sx, int sy, int w, int h,
|
|
|
|
unsigned int format,
|
|
|
|
unsigned long planemask,
|
|
|
|
char *pdstLine
|
|
|
|
)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pDraw->pScreen;
|
|
|
|
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
|
|
|
|
ScrnInfoPtr pScrn = infoRec->pScrn;
|
|
|
|
|
|
|
|
if(pScrn->vtSema &&
|
|
|
|
((pDraw->type == DRAWABLE_WINDOW) || IS_OFFSCREEN_PIXMAP(pDraw)))
|
|
|
|
{
|
|
|
|
if(infoRec->ReadPixmap && (format == ZPixmap) &&
|
|
|
|
((planemask & infoRec->FullPlanemasks[pDraw->depth - 1]) ==
|
|
|
|
infoRec->FullPlanemasks[pDraw->depth - 1]) &&
|
|
|
|
(pDraw->bitsPerPixel == BitsPerPixel(pDraw->depth)))
|
|
|
|
{
|
|
|
|
(*infoRec->ReadPixmap)(pScrn,
|
|
|
|
sx + pDraw->x, sy + pDraw->y, w, h,
|
|
|
|
(unsigned char *)pdstLine,
|
|
|
|
PixmapBytePad(w, pDraw->depth),
|
|
|
|
pDraw->bitsPerPixel, pDraw->depth);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
SYNC_CHECK(pDraw);
|
|
|
|
}
|
|
|
|
|
|
|
|
XAA_SCREEN_PROLOGUE (pScreen, GetImage);
|
|
|
|
(*pScreen->GetImage) (pDraw, sx, sy, w, h, format, planemask, pdstLine);
|
|
|
|
XAA_SCREEN_EPILOGUE (pScreen, GetImage, XAAGetImage);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
XAAGetSpans (
|
|
|
|
DrawablePtr pDraw,
|
|
|
|
int wMax,
|
|
|
|
DDXPointPtr ppt,
|
|
|
|
int *pwidth,
|
|
|
|
int nspans,
|
|
|
|
char *pdstStart
|
|
|
|
)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pDraw->pScreen;
|
|
|
|
XAA_SCREEN_PROLOGUE (pScreen, GetSpans);
|
|
|
|
if(xf86Screens[pScreen->myNum]->vtSema &&
|
|
|
|
((pDraw->type == DRAWABLE_WINDOW) || IS_OFFSCREEN_PIXMAP(pDraw))) {
|
|
|
|
SYNC_CHECK(pDraw);
|
|
|
|
}
|
|
|
|
(*pScreen->GetSpans) (pDraw, wMax, ppt, pwidth, nspans, pdstStart);
|
|
|
|
XAA_SCREEN_EPILOGUE (pScreen, GetSpans, XAAGetSpans);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
XAAPixmapBPP (ScreenPtr pScreen, int depth)
|
|
|
|
{
|
|
|
|
PixmapPtr pPix;
|
|
|
|
int bpp;
|
|
|
|
DestroyPixmapProcPtr destroyPixmap;
|
|
|
|
|
|
|
|
XAA_SCREEN_PROLOGUE (pScreen, CreatePixmap);
|
2007-10-31 22:15:35 +01:00
|
|
|
pPix = (*pScreen->CreatePixmap) (pScreen, 1, 1, depth,
|
|
|
|
CREATE_PIXMAP_USAGE_SCRATCH);
|
2003-11-14 17:48:57 +01:00
|
|
|
XAA_SCREEN_EPILOGUE (pScreen, CreatePixmap, XAACreatePixmap);
|
|
|
|
if (!pPix)
|
|
|
|
return 0;
|
|
|
|
bpp = pPix->drawable.bitsPerPixel;
|
|
|
|
destroyPixmap = pScreen->DestroyPixmap;
|
|
|
|
XAA_SCREEN_PROLOGUE (pScreen, DestroyPixmap);
|
|
|
|
(*pScreen->DestroyPixmap) (pPix);
|
|
|
|
XAA_SCREEN_EPILOGUE (pScreen, DestroyPixmap, destroyPixmap);
|
|
|
|
return bpp;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
XAAInitializeOffscreenDepths (ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
|
|
|
|
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
|
|
|
|
int d, dep;
|
|
|
|
|
|
|
|
infoRec->offscreenDepthsInitialized = TRUE;
|
|
|
|
infoRec->offscreenDepths = 0;
|
|
|
|
if (infoRec->Flags & OFFSCREEN_PIXMAPS) {
|
|
|
|
for (d = 0; d < pScreen->numDepths; d++) {
|
|
|
|
dep = pScreen->allowedDepths[d].depth;
|
|
|
|
if (XAAPixmapBPP (pScreen, dep) == pScrn->bitsPerPixel)
|
|
|
|
infoRec->offscreenDepths |= (1 << (dep - 1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static PixmapPtr
|
2011-03-18 07:48:52 +01:00
|
|
|
XAACreatePixmap(ScreenPtr pScreen, int w, int h, int depth, unsigned usage_hint)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
|
|
|
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
|
|
|
|
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
|
|
|
|
XAAPixmapPtr pPriv;
|
|
|
|
PixmapPtr pPix = NULL;
|
|
|
|
int size = w * h;
|
2005-09-13 03:33:19 +02:00
|
|
|
|
|
|
|
if (w > 32767 || h > 32767)
|
|
|
|
return NullPixmap;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
if (!infoRec->offscreenDepthsInitialized)
|
|
|
|
XAAInitializeOffscreenDepths (pScreen);
|
|
|
|
|
2008-05-06 23:52:37 +02:00
|
|
|
if(pScrn->vtSema &&
|
2011-03-18 07:48:52 +01:00
|
|
|
(usage_hint != CREATE_PIXMAP_USAGE_GLYPH_PICTURE) &&
|
2008-05-06 23:52:37 +02:00
|
|
|
(infoRec->offscreenDepths & (1 << (depth - 1))) &&
|
2003-11-14 17:48:57 +01:00
|
|
|
(size >= MIN_OFFPIX_SIZE) && !SwitchedOut &&
|
|
|
|
(!infoRec->maxOffPixWidth || (w <= infoRec->maxOffPixWidth)) &&
|
|
|
|
(!infoRec->maxOffPixHeight || (h <= infoRec->maxOffPixHeight)) )
|
|
|
|
{
|
|
|
|
PixmapLinkPtr pLink;
|
|
|
|
PixmapPtr pScreenPix;
|
|
|
|
FBAreaPtr area;
|
|
|
|
int gran = 0;
|
|
|
|
|
|
|
|
switch(pScrn->bitsPerPixel) {
|
|
|
|
case 24:
|
|
|
|
case 8: gran = 4; break;
|
|
|
|
case 16: gran = 2; break;
|
|
|
|
case 32: gran = 1; break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(BITMAP_SCANLINE_PAD == 64)
|
|
|
|
gran *= 2;
|
|
|
|
|
|
|
|
if(!(area = xf86AllocateOffscreenArea(pScreen, w, h, gran, 0,
|
|
|
|
XAARemoveAreaCallback, NULL))) {
|
|
|
|
goto BAILOUT;
|
|
|
|
}
|
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
if(!(pLink = malloc(sizeof(PixmapLink)))) {
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86FreeOffscreenArea(area);
|
|
|
|
goto BAILOUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
XAA_SCREEN_PROLOGUE (pScreen, CreatePixmap);
|
2011-03-18 07:48:52 +01:00
|
|
|
pPix = (*pScreen->CreatePixmap) (pScreen, 0, 0, depth, usage_hint);
|
2003-11-14 17:48:57 +01:00
|
|
|
XAA_SCREEN_EPILOGUE (pScreen, CreatePixmap, XAACreatePixmap);
|
|
|
|
|
|
|
|
if (!pPix) {
|
2010-05-05 20:44:06 +02:00
|
|
|
free(pLink);
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86FreeOffscreenArea(area);
|
|
|
|
goto BAILOUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
pScreenPix = (*pScreen->GetScreenPixmap)(pScreen);
|
|
|
|
|
|
|
|
pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
|
|
|
|
pPix->drawable.x = area->box.x1;
|
|
|
|
pPix->drawable.y = area->box.y1;
|
|
|
|
pPix->drawable.width = w;
|
|
|
|
pPix->drawable.height = h;
|
|
|
|
pPix->drawable.bitsPerPixel = pScrn->bitsPerPixel;
|
|
|
|
pPix->devKind = pScreenPix->devKind;
|
|
|
|
pPix->devPrivate.ptr = pScreenPix->devPrivate.ptr;
|
|
|
|
area->devPrivate.ptr = pPix;
|
|
|
|
|
|
|
|
pPriv->flags = OFFSCREEN;
|
|
|
|
pPriv->offscreenArea = area;
|
|
|
|
pPriv->freeData = FALSE;
|
|
|
|
|
|
|
|
pLink->next = infoRec->OffscreenPixmaps;
|
|
|
|
pLink->pPix = pPix;
|
|
|
|
infoRec->OffscreenPixmaps = pLink;
|
|
|
|
return pPix;
|
|
|
|
}
|
|
|
|
BAILOUT:
|
|
|
|
XAA_SCREEN_PROLOGUE (pScreen, CreatePixmap);
|
2011-03-18 07:48:52 +01:00
|
|
|
pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth, usage_hint);
|
2003-11-14 17:48:57 +01:00
|
|
|
XAA_SCREEN_EPILOGUE (pScreen, CreatePixmap, XAACreatePixmap);
|
|
|
|
|
|
|
|
if(pPix) {
|
|
|
|
pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
|
|
|
|
pPriv->flags = 0;
|
|
|
|
pPriv->offscreenArea = NULL;
|
|
|
|
pPriv->freeData = FALSE;
|
|
|
|
if(!w || !h) /* either scratch or shared memory */
|
|
|
|
pPriv->flags |= SHARED_PIXMAP;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pPix;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
XAADestroyPixmap(PixmapPtr pPix)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pPix->drawable.pScreen;
|
|
|
|
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
|
|
|
|
XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
|
|
|
|
Bool ret;
|
|
|
|
|
|
|
|
if(pPix->refcnt == 1) {
|
|
|
|
if(pPriv->flags & OFFSCREEN) {
|
|
|
|
if(pPriv->flags & DGA_PIXMAP)
|
2010-05-05 20:44:06 +02:00
|
|
|
free(pPriv->offscreenArea);
|
2003-11-14 17:48:57 +01:00
|
|
|
else {
|
|
|
|
FBAreaPtr area = pPriv->offscreenArea;
|
|
|
|
PixmapLinkPtr pLink = infoRec->OffscreenPixmaps;
|
|
|
|
PixmapLinkPtr prev = NULL;
|
|
|
|
|
|
|
|
while(pLink->pPix != pPix) {
|
|
|
|
prev = pLink;
|
|
|
|
pLink = pLink->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(prev) prev->next = pLink->next;
|
|
|
|
else infoRec->OffscreenPixmaps = pLink->next;
|
|
|
|
|
|
|
|
if(!area) area = pLink->area;
|
|
|
|
|
|
|
|
xf86FreeOffscreenArea(area);
|
|
|
|
pPriv->offscreenArea = NULL;
|
2010-05-05 20:44:06 +02:00
|
|
|
free(pLink);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pPriv->freeData) { /* pixmaps that were once in video ram */
|
2010-05-05 20:44:06 +02:00
|
|
|
free(pPix->devPrivate.ptr);
|
2003-11-14 17:48:57 +01:00
|
|
|
pPix->devPrivate.ptr = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
XAA_SCREEN_PROLOGUE (pScreen, DestroyPixmap);
|
|
|
|
ret = (*pScreen->DestroyPixmap) (pPix);
|
|
|
|
XAA_SCREEN_EPILOGUE (pScreen, DestroyPixmap, XAADestroyPixmap);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
XAAChangeWindowAttributes (WindowPtr pWin, unsigned long mask)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pWin->drawable.pScreen;
|
|
|
|
Bool ret;
|
|
|
|
|
|
|
|
XAA_SCREEN_PROLOGUE (pScreen, ChangeWindowAttributes);
|
|
|
|
ret = (*pScreen->ChangeWindowAttributes) (pWin, mask);
|
|
|
|
XAA_SCREEN_EPILOGUE (pScreen, ChangeWindowAttributes, XAAChangeWindowAttributes);
|
|
|
|
|
|
|
|
/* we have to assume that shared memory pixmaps are dirty
|
|
|
|
because we can't wrap operations on them */
|
|
|
|
|
|
|
|
if((mask & CWBackPixmap) && (pWin->backgroundState == BackgroundPixmap) &&
|
|
|
|
PIXMAP_IS_SHARED(pWin->background.pixmap))
|
|
|
|
{
|
|
|
|
XAAPixmapPtr pPixPriv = XAA_GET_PIXMAP_PRIVATE(pWin->background.pixmap);
|
|
|
|
pPixPriv->flags |= DIRTY;
|
|
|
|
}
|
|
|
|
if((mask & CWBorderPixmap) && !(pWin->borderIsPixel) &&
|
|
|
|
PIXMAP_IS_SHARED(pWin->border.pixmap))
|
|
|
|
{
|
|
|
|
XAAPixmapPtr pPixPriv = XAA_GET_PIXMAP_PRIVATE(pWin->border.pixmap);
|
|
|
|
pPixPriv->flags |= DIRTY;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* These two aren't really needed for anything */
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
XAAEnterVT(int index, int flags)
|
|
|
|
{
|
2010-07-13 01:01:34 +02:00
|
|
|
ScrnInfoPtr pScrn = xf86Screens[index];
|
|
|
|
Bool ret;
|
2003-11-14 17:48:57 +01:00
|
|
|
ScreenPtr pScreen = screenInfo.screens[index];
|
|
|
|
XAAScreenPtr pScreenPriv =
|
2007-08-28 15:28:25 +02:00
|
|
|
(XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2010-07-13 01:01:34 +02:00
|
|
|
pScrn->EnterVT = pScreenPriv->EnterVT;
|
|
|
|
ret = ((*pScreenPriv->EnterVT)(index, flags));
|
|
|
|
pScreenPriv->EnterVT = pScrn->EnterVT;
|
|
|
|
pScrn->EnterVT = XAAEnterVT;
|
|
|
|
return ret;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
XAALeaveVT(int index, int flags)
|
|
|
|
{
|
2010-07-13 01:01:34 +02:00
|
|
|
ScrnInfoPtr pScrn = xf86Screens[index];
|
2003-11-14 17:48:57 +01:00
|
|
|
ScreenPtr pScreen = screenInfo.screens[index];
|
|
|
|
XAAScreenPtr pScreenPriv =
|
2007-08-28 15:28:25 +02:00
|
|
|
(XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
|
2003-11-14 17:48:57 +01:00
|
|
|
XAAInfoRecPtr infoRec = pScreenPriv->AccelInfoRec;
|
|
|
|
|
|
|
|
if(infoRec->NeedToSync) {
|
|
|
|
(*infoRec->Sync)(infoRec->pScrn);
|
|
|
|
infoRec->NeedToSync = FALSE;
|
|
|
|
}
|
|
|
|
|
2010-07-13 01:01:34 +02:00
|
|
|
pScrn->LeaveVT = pScreenPriv->LeaveVT;
|
2003-11-14 17:48:57 +01:00
|
|
|
(*pScreenPriv->LeaveVT)(index, flags);
|
2010-07-13 01:01:34 +02:00
|
|
|
pScreenPriv->LeaveVT = pScrn->LeaveVT;
|
|
|
|
pScrn->LeaveVT = XAALeaveVT;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
Bool UsingPixmapCache;
|
|
|
|
Bool CanDoColor8x8;
|
|
|
|
Bool CanDoMono8x8;
|
|
|
|
} SavedCacheState, *SavedCacheStatePtr;
|
|
|
|
|
|
|
|
static int
|
|
|
|
XAASetDGAMode(int index, int num, DGADevicePtr devRet)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen = screenInfo.screens[index];
|
|
|
|
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
|
|
|
|
XAAScreenPtr pScreenPriv =
|
2007-08-28 15:28:25 +02:00
|
|
|
(XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
|
2003-11-14 17:48:57 +01:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!num && infoRec->dgaSaves) { /* restore old pixmap cache state */
|
|
|
|
SavedCacheStatePtr state = (SavedCacheStatePtr)infoRec->dgaSaves;
|
|
|
|
|
|
|
|
infoRec->UsingPixmapCache = state->UsingPixmapCache;
|
|
|
|
infoRec->CanDoColor8x8 = state->CanDoColor8x8;
|
|
|
|
infoRec->CanDoMono8x8 = state->CanDoMono8x8;
|
2010-05-05 20:44:06 +02:00
|
|
|
free(infoRec->dgaSaves);
|
2003-11-14 17:48:57 +01:00
|
|
|
infoRec->dgaSaves = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = (*pScreenPriv->SetDGAMode)(index, num, devRet);
|
|
|
|
if(ret != Success) return ret;
|
|
|
|
|
|
|
|
if(num && devRet->pPix) { /* accelerate this pixmap */
|
|
|
|
XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE(devRet->pPix);
|
|
|
|
FBAreaPtr area;
|
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
if((area = malloc(sizeof(FBArea)))) {
|
2003-11-14 17:48:57 +01:00
|
|
|
area->pScreen = pScreen;
|
|
|
|
area->box.x1 = 0;
|
|
|
|
area->box.x2 = 0;
|
|
|
|
area->box.y1 = devRet->mode->pixmapWidth;
|
|
|
|
area->box.y2 = devRet->mode->pixmapHeight;
|
|
|
|
area->granularity = 0;
|
|
|
|
area->MoveAreaCallback = 0;
|
|
|
|
area->RemoveAreaCallback = 0;
|
|
|
|
area->devPrivate.ptr = 0;
|
|
|
|
|
|
|
|
pixPriv->flags |= OFFSCREEN | DGA_PIXMAP;
|
|
|
|
pixPriv->offscreenArea = area;
|
|
|
|
|
|
|
|
if(!infoRec->dgaSaves) { /* save pixmap cache state */
|
2010-05-05 20:44:06 +02:00
|
|
|
SavedCacheStatePtr state = malloc(sizeof(SavedCacheState));
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
state->UsingPixmapCache = infoRec->UsingPixmapCache;
|
|
|
|
state->CanDoColor8x8 = infoRec->CanDoColor8x8;
|
|
|
|
state->CanDoMono8x8 = infoRec->CanDoMono8x8;
|
|
|
|
infoRec->dgaSaves = (char*)state;
|
|
|
|
|
|
|
|
infoRec->UsingPixmapCache = FALSE;
|
|
|
|
if(infoRec->PixmapCacheFlags & CACHE_MONO_8x8)
|
|
|
|
infoRec->CanDoMono8x8 = FALSE;
|
|
|
|
if(infoRec->PixmapCacheFlags & CACHE_COLOR_8x8)
|
|
|
|
infoRec->CanDoColor8x8 = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
XAAEnableDisableFBAccess (int index, Bool enable)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen = screenInfo.screens[index];
|
|
|
|
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
|
|
|
|
XAAScreenPtr pScreenPriv =
|
2007-08-28 15:28:25 +02:00
|
|
|
(XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
if(!enable) {
|
|
|
|
if((infoRec->Flags & OFFSCREEN_PIXMAPS) && (infoRec->OffscreenPixmaps))
|
|
|
|
XAAMoveOutOffscreenPixmaps(pScreen);
|
|
|
|
if(infoRec->Flags & PIXMAP_CACHE)
|
|
|
|
XAAInvalidatePixmapCache(pScreen);
|
|
|
|
SwitchedOut = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
(*pScreenPriv->EnableDisableFBAccess)(index, enable);
|
|
|
|
|
|
|
|
if(enable) {
|
|
|
|
if((infoRec->Flags & OFFSCREEN_PIXMAPS) && (infoRec->OffscreenPixmaps))
|
|
|
|
XAAMoveInOffscreenPixmaps(pScreen);
|
|
|
|
SwitchedOut = FALSE;
|
|
|
|
}
|
|
|
|
}
|