GLX improvements and remove use of pbuffers for offscreen rendering in Xgl

This commit is contained in:
David Reveman 2005-06-07 08:53:40 +00:00
parent 8237b31f60
commit d146c41882
12 changed files with 2615 additions and 1344 deletions

View File

@ -14,7 +14,6 @@ libxgl_a_SOURCES = \
xglparse.c \
xglscreen.c \
xglarea.c \
xgloffscreen.c \
xglgeometry.c \
xglpixmap.c \
xglsync.c \

View File

@ -437,7 +437,11 @@ xglxScreenInit (int index,
return FALSE;
}
XSelectInput (xdisplay, pScreenPriv->win, ExposureMask);
XSelectInput (xdisplay, pScreenPriv->win,
ButtonPressMask | ButtonReleaseMask |
KeyPressMask | KeyReleaseMask | EnterWindowMask |
PointerMotionMask | ExposureMask);
XMapWindow (xdisplay, pScreenPriv->win);
if (xglScreenInfo.fullscreen)
@ -517,11 +521,6 @@ xglxScreenInit (int index,
while (XNextEvent (xdisplay, &xevent))
if (xevent.type == Expose)
break;
XSelectInput (xdisplay, pScreenPriv->win,
ButtonPressMask | ButtonReleaseMask |
KeyPressMask | KeyReleaseMask | EnterWindowMask |
PointerMotionMask);
return TRUE;
}
@ -580,20 +579,81 @@ InitOutput (ScreenInfo *pScreenInfo,
AddScreen (xglxScreenInit, argc, argv);
}
static Bool
xglxExposurePredicate (Display *xdisplay,
XEvent *xevent,
char *args)
{
return (xevent->type == Expose);
}
static Bool
xglxNotExposurePredicate (Display *xdisplay,
XEvent *xevent,
char *args)
{
return (xevent->type != Expose);
}
static int
xglxWindowExposures (WindowPtr pWin,
pointer pReg)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
RegionRec ClipList;
if (HasBorder (pWin))
{
REGION_INIT (pScreen, &ClipList, NullBox, 0);
REGION_SUBTRACT (pScreen, &ClipList, &pWin->borderClip,
&pWin->winSize);
REGION_INTERSECT (pScreen, &ClipList, &ClipList, (RegionPtr) pReg);
(*pScreen->PaintWindowBorder) (pWin, &ClipList, PW_BORDER);
REGION_UNINIT (pScreen, &ClipList);
}
REGION_INIT (pScreen, &ClipList, NullBox, 0);
REGION_INTERSECT (pScreen, &ClipList, &pWin->clipList, (RegionPtr) pReg);
(*pScreen->WindowExposures) (pWin, &ClipList, NullRegion);
REGION_UNINIT (pScreen, &ClipList);
return WT_WALKCHILDREN;
}
static void
xglxBlockHandler (pointer blockData,
OSTimePtr pTimeout,
pointer pReadMask)
{
XEvent X;
RegionRec region;
BoxRec box;
XGL_SCREEN_PRIV (currentScreen);
while (XCheckIfEvent (xdisplay, &X, xglxExposurePredicate, NULL))
{
ScreenPtr pScreen = currentScreen;
box.x1 = X.xexpose.x;
box.y1 = X.xexpose.y;
box.x2 = box.x1 + X.xexpose.width;
box.y2 = box.y1 + X.xexpose.height;
REGION_INIT (currentScreen, &region, &box, 1);
WalkTree (pScreen, xglxWindowExposures, &region);
REGION_UNINIT (pScreen, &region);
}
if (!xglSyncSurface (&pScreenPriv->pScreenPixmap->drawable))
FatalError (XGL_SW_FAILURE_STRING);
glitz_surface_flush (pScreenPriv->surface);
glitz_drawable_finish (pScreenPriv->drawable);
glitz_drawable_flush (pScreenPriv->drawable);
XSync (xdisplay, FALSE);
XFlush (xdisplay);
}
static void
@ -605,9 +665,8 @@ xglxWakeupHandler (pointer blockData,
XEvent X;
xEvent x;
while (XPending (xdisplay)) {
XNextEvent (xdisplay, &X);
while (XCheckIfEvent (xdisplay, &X, xglxNotExposurePredicate, NULL))
{
switch (X.type) {
case KeyPress:
x.u.u.type = KeyPress;

View File

@ -89,9 +89,6 @@ typedef struct _xglPixmapFormat {
extern xglVisualPtr xglVisuals;
extern int nxglVisuals;
extern xglVisualPtr xglPbufferVisuals;
extern int nxglPbufferVisuals;
#define xglAreaAvailable 0
#define xglAreaDivided 1
#define xglAreaOccupied 2
@ -201,25 +198,15 @@ extern int xglGlyphPrivateIndex;
#endif
#define XGL_MAX_OFFSCREEN_AREAS 8
typedef struct _xglOffscreen {
xglRootAreaRec rootArea;
glitz_drawable_t *drawable;
glitz_drawable_format_t *format;
glitz_drawable_buffer_t buffer;
} xglOffscreenRec, *xglOffscreenPtr;
typedef struct _xglScreen {
xglVisualPtr pVisual;
xglPixmapFormatRec pixmapFormats[33];
glitz_drawable_t *drawable;
glitz_surface_t *surface;
glitz_surface_t *backSurface;
glitz_surface_t *solid;
PixmapPtr pScreenPixmap;
unsigned long features;
xglOffscreenRec pOffscreen[XGL_MAX_OFFSCREEN_AREAS];
int nOffscreen;
int geometryUsage;
int geometryDataType;
Bool yInverted;
@ -264,7 +251,11 @@ typedef struct _xglScreen {
#endif
BSFuncRec BackingStoreFuncs;
#ifdef GLXEXT
DestroyWindowProcPtr DestroyWindow;
#endif
} xglScreenRec, *xglScreenPtr;
extern int xglScreenPrivateIndex;
@ -342,8 +333,6 @@ typedef struct _xglPixmap {
glitz_surface_t *surface;
glitz_buffer_t *buffer;
int target;
xglAreaPtr pArea;
int score;
Bool acceleratedTile;
pointer bits;
int stride;
@ -437,23 +426,6 @@ extern int xglWinPrivateIndex;
(((pBox)->x2 - (pBox)->x1) > 0 && \
((pBox)->y2 - (pBox)->y1) > 0)
#define XGL_MAX_PIXMAP_SCORE 32768
#define XGL_MIN_PIXMAP_SCORE -32768
#define XGL_INCREMENT_PIXMAP_SCORE(pPixmapPriv, incr) \
{ \
(pPixmapPriv)->score += (incr); \
if ((pPixmapPriv)->score > XGL_MAX_PIXMAP_SCORE) \
(pPixmapPriv)->score = XGL_MAX_PIXMAP_SCORE; \
}
#define XGL_DECREMENT_PIXMAP_SCORE(pPixmapPriv, decr) \
{ \
(pPixmapPriv)->score -= (decr); \
if ((pPixmapPriv)->score < XGL_MIN_PIXMAP_SCORE) \
(pPixmapPriv)->score = XGL_MIN_PIXMAP_SCORE; \
}
/* xglinput.c */
@ -574,23 +546,6 @@ xglFindArea (xglAreaPtr pArea,
pointer closure);
/* xgloffscreen.c */
Bool
xglInitOffscreen (ScreenPtr pScreen,
xglScreenInfoPtr pScreenInfo);
void
xglFiniOffscreen (ScreenPtr pScreen);
Bool
xglFindOffscreenArea (ScreenPtr pScreen,
PixmapPtr pPixmap);
void
xglLeaveOffscreenArea (PixmapPtr pPixmap);
/* xglgeometry.c */
#define GEOMETRY_DATA_TYPE_SHORT 0

View File

@ -38,9 +38,6 @@ xglCopy (DrawablePtr pSrc,
int srcXoff, srcYoff;
int dstXoff, dstYoff;
XGL_SCREEN_PRIV (pDst->pScreen);
XGL_DRAWABLE_PIXMAP_PRIV (pSrc);
if (!nBox)
return TRUE;
@ -53,10 +50,6 @@ xglCopy (DrawablePtr pSrc,
XGL_GET_DRAWABLE (pSrc, src, srcXoff, srcYoff);
XGL_GET_DRAWABLE (pDst, dst, dstXoff, dstYoff);
/* blit to screen */
if (dst == pScreenPriv->surface)
XGL_INCREMENT_PIXMAP_SCORE (pPixmapPriv, 5000);
glitz_surface_set_clip_region (dst,
dstXoff, dstYoff,
(glitz_box_t *) pBox, nBox);

View File

@ -45,6 +45,9 @@ xglGetImage (DrawablePtr pDrawable,
/* Many apps use GetImage to sync with the visable frame buffer */
if (pDrawable->type == DRAWABLE_WINDOW)
{
if (!xglSyncSurface (&pScreenPriv->pScreenPixmap->drawable))
FatalError (XGL_SW_FAILURE_STRING);
glitz_surface_flush (pScreenPriv->surface);
glitz_drawable_finish (pScreenPriv->drawable);
}

File diff suppressed because it is too large Load Diff

View File

@ -1145,8 +1145,6 @@ xglGlyphs (CARD8 op,
if (pMask)
{
xglLeaveOffscreenArea ((PixmapPtr) pMask->pDrawable);
CompositePicture (op,
pSrc,
pMask,

View File

@ -33,7 +33,7 @@
#include <X11/XF86keysym.h>
#endif
#define NUM_BUTTONS 5
#define NUM_BUTTONS 7
int
xglMouseProc (DeviceIntPtr pDevice,

View File

@ -101,8 +101,6 @@ xglPixmapSurfaceInit (PixmapPtr pPixmap,
XGL_PIXMAP_PRIV (pPixmap);
pPixmapPriv->surface = NULL;
pPixmapPriv->pArea = NULL;
pPixmapPriv->score = 0;
pPixmapPriv->acceleratedTile = FALSE;
pPixmapPriv->pictureMask = ~0;
pPixmapPriv->target = xglPixmapTargetNo;
@ -211,9 +209,6 @@ xglFiniPixmap (PixmapPtr pPixmap)
{
XGL_PIXMAP_PRIV (pPixmap);
if (pPixmapPriv->pArea)
xglWithdrawArea (pPixmapPriv->pArea);
if (pPixmap->devPrivate.ptr)
{
if (pPixmapPriv->buffer)
@ -316,9 +311,6 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
pPixmap->drawable.width != oldWidth ||
pPixmap->drawable.height != oldHeight)
{
if (pPixmapPriv->pArea)
xglWithdrawArea (pPixmapPriv->pArea);
if (pPixmapPriv->surface)
glitz_surface_destroy (pPixmapPriv->surface);
@ -372,11 +364,6 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
REGION_INIT (pPixmap->drawable.pScreen, pRegion,
&pPixmapPriv->bitBox, 1);
}
/*
* We probably don't want accelerated drawing to this pixmap.
*/
pPixmapPriv->score = XGL_MIN_PIXMAP_SCORE;
}
/*

View File

@ -159,9 +159,6 @@ xglScreenInit (ScreenPtr pScreen,
depth = pScreenPriv->pVisual->pPixel->depth;
bpp = pScreenPriv->pVisual->pPixel->masks.bpp;
if (!xglInitOffscreen (pScreen, pScreenInfo))
return FALSE;
xglInitPixmapFormats (pScreen);
if (!pScreenPriv->pixmapFormats[depth].format)
return FALSE;
@ -189,6 +186,8 @@ xglScreenInit (ScreenPtr pScreen,
GLITZ_DRAWABLE_BUFFER_FRONT_COLOR,
0, 0);
pScreenPriv->backSurface = NULL;
if (monitorResolution == 0)
monitorResolution = XGL_DEFAULT_DPI;
@ -365,7 +364,7 @@ xglCloseScreen (int index,
{
XGL_SCREEN_PRIV (pScreen);
XGL_PIXMAP_PRIV (pScreenPriv->pScreenPixmap);
#ifdef RENDER
int i;
@ -386,11 +385,12 @@ xglCloseScreen (int index,
if (pScreenPriv->solid)
glitz_surface_destroy (pScreenPriv->solid);
if (pScreenPriv->backSurface)
glitz_surface_destroy (pScreenPriv->backSurface);
if (pScreenPriv->surface)
glitz_surface_destroy (pScreenPriv->surface);
xglFiniOffscreen (pScreen);
GEOMETRY_UNINIT (&pScreenPriv->scratchGeometry);
XGL_SCREEN_UNWRAP (CloseScreen);

View File

@ -73,8 +73,6 @@ xglSyncBits (DrawablePtr pDrawable,
XGL_DRAWABLE_PIXMAP (pDrawable);
XGL_PIXMAP_PRIV (pPixmap);
XGL_DECREMENT_PIXMAP_SCORE (pPixmapPriv, 20);
if (pPixmapPriv->allBits)
return xglMapPixmapBits (pPixmap);
@ -295,22 +293,12 @@ xglPrepareTarget (DrawablePtr pDrawable)
switch (pPixmapPriv->target) {
case xglPixmapTargetNo:
case xglPixmapTargetOut:
break;
case xglPixmapTargetIn:
XGL_INCREMENT_PIXMAP_SCORE (pPixmapPriv, 10);
if (xglSyncSurface (pDrawable))
return TRUE;
break;
case xglPixmapTargetOut:
XGL_INCREMENT_PIXMAP_SCORE (pPixmapPriv, 10);
if (pPixmapPriv->lock)
return FALSE;
if (xglFindOffscreenArea (pDrawable->pScreen, pPixmap))
return TRUE;
break;
}
return FALSE;

View File

@ -375,8 +375,6 @@ xglTrapezoids (CARD8 op,
if (pMask)
{
xglLeaveOffscreenArea ((PixmapPtr) pMask->pDrawable);
CompositePicture (op, pSrc, pMask, pDst,
extents.x1 + xSrc - xDst,
extents.y1 + ySrc - yDst,