Add GLX code to Xgl

This commit is contained in:
David Reveman 2005-04-13 14:27:47 +00:00
parent ddfa6f00da
commit e40db7f26a
9 changed files with 1724 additions and 168 deletions

View File

@ -351,6 +351,7 @@ typedef struct _xglPixmap {
Bool allBits;
unsigned long pictureMask;
xglGeometryPtr pGeometry;
int lock;
} xglPixmapRec, *xglPixmapPtr;
extern int xglPixmapPrivateIndex;
@ -1313,6 +1314,9 @@ xglUpdatePicture (PicturePtr pPicture);
Bool
xglPictureInit (ScreenPtr pScreen);
void
xglPictureClipExtents (PicturePtr pPicture,
BoxPtr extents);
/* xglglyph.c */
@ -1365,4 +1369,11 @@ xglAddTraps (PicturePtr pDst,
#endif
#ifdef GLXEXT
Bool
xglInitVisualConfigs (ScreenPtr pScreen);
#endif
#endif /* _XGL_H_ */

1506
hw/xgl/xglglx.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -837,7 +837,8 @@ xglCachedGlyphs (CARD8 op,
}
static Bool
xglGlyphExtents (int nlist,
xglGlyphExtents (PicturePtr pDst,
int nlist,
GlyphListPtr list,
GlyphPtr *glyphs,
BoxPtr extents)
@ -941,6 +942,8 @@ xglGlyphExtents (int nlist,
}
}
xglPictureClipExtents (pDst, extents);
return overlap;
}
@ -981,20 +984,26 @@ xglGlyphs (CARD8 op,
BoxRec extents;
xglGlyphOpRec glyphOp;
int xDst = list->xOff, yDst = list->yOff;
int overlap;
int target;
XGL_DRAWABLE_PIXMAP_PRIV (pDst->pDrawable);
overlap = xglGlyphExtents (pDst, nlist, list, glyphs, &extents);
if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1)
return;
target = xglPrepareTarget (pDst->pDrawable);
if (op != PictOpAdd && maskFormat &&
(xglGlyphExtents (nlist, list, glyphs, &extents) || op != PictOpOver ||
(overlap || op != PictOpOver ||
xglGlyphListFormatId (list, nlist) != maskFormat->id))
{
PixmapPtr pPixmap;
xglPixmapPtr pPixmapPriv;
CARD32 componentAlpha;
GCPtr pGC;
xRectangle rect;
int error;
if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1)
return;
PixmapPtr pPixmap;
CARD32 componentAlpha;
GCPtr pGC;
xRectangle rect;
int error;
rect.x = 0;
rect.y = 0;
@ -1012,7 +1021,17 @@ xglGlyphs (CARD8 op,
maskFormat, CPComponentAlpha, &componentAlpha,
serverClient, &error);
if (!pMask)
{
(*pScreen->DestroyPixmap) (pPixmap);
return;
}
/* make sure destination drawable is locked */
pPixmapPriv->lock++;
/* lock mask if we are not doing accelerated drawing to destination */
if (!target)
XGL_GET_PIXMAP_PRIV (pPixmap)->lock = 1;
ValidatePicture (pMask);
pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
@ -1020,14 +1039,9 @@ xglGlyphs (CARD8 op,
(*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &rect);
FreeScratchGC (pGC);
/* all will be damaged */
pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap);
pPixmapPriv->damageBox.x1 = 0;
pPixmapPriv->damageBox.y1 = 0;
pPixmapPriv->damageBox.x2 = pMask->pDrawable->width;
pPixmapPriv->damageBox.y2 = pMask->pDrawable->height;
(*pScreen->DestroyPixmap) (pPixmap);
target = xglPrepareTarget (pMask->pDrawable);
glyphOp.xOff = -extents.x1;
glyphOp.yOff = -extents.y1;
@ -1036,6 +1050,9 @@ xglGlyphs (CARD8 op,
}
else
{
/* make sure destination drawable is locked */
pPixmapPriv->lock++;
glyphOp.xOff = 0;
glyphOp.yOff = 0;
pSrcPicture = pSrc;
@ -1043,11 +1060,7 @@ xglGlyphs (CARD8 op,
}
glyphOp.ppGlyphs = glyphs;
if (xglPrepareTarget (pDstPicture->pDrawable))
glyphOp.noCache = FALSE;
else
glyphOp.noCache = TRUE;
glyphOp.noCache = !target;
while (nlist--)
{
@ -1097,6 +1110,10 @@ xglGlyphs (CARD8 op,
FreePicture ((pointer) pMask, (XID) 0);
}
/* release destination drawable lock */
pPixmapPriv->lock--;
}
#endif

View File

@ -90,6 +90,9 @@ xglOffscreenCompareScore (xglAreaPtr pArea,
if (s1 > s2)
XGL_DECREMENT_PIXMAP_SCORE (pPixmapPriv, 10);
if (pPixmapPriv->lock)
return 1;
return s1 - s2;
}

View File

@ -464,4 +464,41 @@ xglPictureInit (ScreenPtr pScreen)
return TRUE;
}
void
xglPictureClipExtents (PicturePtr pPicture,
BoxPtr extents)
{
if (pPicture->clientClipType != CT_NONE)
{
BoxPtr clip = REGION_EXTENTS (pPicture->pDrawable->pScreen,
(RegionPtr) pPicture->clientClip);
if (extents->x1 < pPicture->clipOrigin.x + clip->x1)
extents->x1 = pPicture->clipOrigin.x + clip->x1;
if (extents->y1 < pPicture->clipOrigin.y + clip->y1)
extents->y1 = pPicture->clipOrigin.y + clip->y1;
if (extents->x2 > pPicture->clipOrigin.x + clip->x2)
extents->x2 = pPicture->clipOrigin.x + clip->x2;
if (extents->y2 > pPicture->clipOrigin.y + clip->y2)
extents->y2 = pPicture->clipOrigin.y + clip->y2;
}
else
{
if (extents->x1 < 0)
extents->x1 = 0;
if (extents->y1 < 0)
extents->y1 = 0;
if (extents->x2 > pPicture->pDrawable->width)
extents->x2 = pPicture->pDrawable->width;
if (extents->y2 > pPicture->pDrawable->height)
extents->y2 = pPicture->pDrawable->height;
}
}
#endif

View File

@ -106,6 +106,7 @@ xglPixmapSurfaceInit (PixmapPtr pPixmap,
pPixmapPriv->acceleratedTile = FALSE;
pPixmapPriv->pictureMask = ~0;
pPixmapPriv->target = xglPixmapTargetNo;
pPixmapPriv->lock = 0;
if (pPixmapPriv->format)
{
@ -209,7 +210,7 @@ void
xglFiniPixmap (PixmapPtr pPixmap)
{
XGL_PIXMAP_PRIV (pPixmap);
if (pPixmapPriv->pArea)
xglWithdrawArea (pPixmapPriv->pArea);

View File

@ -35,6 +35,9 @@ static ShmFuncs shmFuncs = { NULL, xglShmPutImage };
#ifdef RENDER
#include "glyphstr.h"
#endif
#ifdef COMPOSITE
#include "compint.h"
#endif
int xglScreenGeneration = -1;
int xglScreenPrivateIndex;
@ -135,7 +138,7 @@ xglScreenInit (ScreenPtr pScreen,
xglScreenInfoPtr pScreenInfo)
{
xglScreenPtr pScreenPriv;
int depth;
int depth, bpp;
#ifdef RENDER
PictureScreenPtr pPictureScreen;
@ -154,6 +157,7 @@ xglScreenInit (ScreenPtr pScreen,
glitz_drawable_get_features (pScreenInfo->drawable);
depth = pScreenPriv->pVisual->pPixel->depth;
bpp = pScreenPriv->pVisual->pPixel->masks.bpp;
if (!xglInitOffscreen (pScreen, pScreenInfo))
return FALSE;
@ -190,8 +194,7 @@ xglScreenInit (ScreenPtr pScreen,
if (!fbSetupScreen (pScreen, NULL,
pScreenInfo->width, pScreenInfo->height,
monitorResolution, monitorResolution,
pScreenInfo->width,
pScreenPriv->pVisual->pPixel->masks.bpp))
pScreenInfo->width, bpp))
return FALSE;
pScreen->SaveScreen = xglSaveScreen;
@ -202,8 +205,7 @@ xglScreenInit (ScreenPtr pScreen,
if (!fbFinishScreenInit (pScreen, NULL,
pScreenInfo->width, pScreenInfo->height,
monitorResolution, monitorResolution,
pScreenInfo->width,
pScreenPriv->pVisual->pPixel->masks.bpp))
pScreenInfo->width, bpp))
return FALSE;
#ifdef MITSHM
@ -267,6 +269,19 @@ xglScreenInit (ScreenPtr pScreen,
XGL_SCREEN_WRAP (BackingStoreFuncs.SaveAreas, xglSaveAreas);
XGL_SCREEN_WRAP (BackingStoreFuncs.RestoreAreas, xglRestoreAreas);
if (!fbCreateDefColormap (pScreen))
return FALSE;
#ifdef COMPOSITE
if (!compScreenInit (pScreen))
return FALSE;
#endif
#ifdef GLXEXT
if (!xglInitVisualConfigs (pScreen))
return FALSE;
#endif
/* Damage is required */
DamageSetup (pScreen);
@ -288,13 +303,6 @@ xglFinishScreenInit (ScreenPtr pScreen)
XGL_SCREEN_PRIV (pScreen);
/* Do we want to use BackingStore?
miInitializeBackingStore (pScreen);
*/
if (!fbCreateDefColormap (pScreen))
return FALSE;
pScreenPriv->solid =
glitz_surface_create (pScreenPriv->drawable,
pScreenPriv->pixmapFormats[32].format,

View File

@ -304,6 +304,9 @@ xglPrepareTarget (DrawablePtr pDrawable)
break;
case xglPixmapTargetOut:
XGL_INCREMENT_PIXMAP_SCORE (pPixmapPriv, 10);
if (pPixmapPriv->lock)
return FALSE;
if (xglFindOffscreenArea (pDrawable->pScreen, pPixmap))
return TRUE;

View File

@ -40,64 +40,6 @@
/* just a guess */
#define SMOOTH_TRAPS_ESTIMATE_RECTS(nTrap) (30 * nTrap)
static PicturePtr
xglCreateMaskPicture (ScreenPtr pScreen,
PicturePtr pDst,
PictFormatPtr pPictFormat,
CARD16 width,
CARD16 height,
Bool accelerate)
{
PixmapPtr pPixmap;
PicturePtr pPicture;
GCPtr pGC;
int error;
xRectangle rect;
if (width > 32767 || height > 32767)
return 0;
pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
pPictFormat->depth);
if (!pPixmap)
return 0;
if (!accelerate)
{
XGL_PIXMAP_PRIV (pPixmap);
if (!xglAllocatePixmapBits (pPixmap, XGL_PIXMAP_USAGE_HINT_DEFAULT))
{
(*pScreen->DestroyPixmap) (pPixmap);
return 0;
}
pPixmapPriv->target = xglPixmapTargetNo;
}
pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
if (!pGC)
{
(*pScreen->DestroyPixmap) (pPixmap);
return 0;
}
rect.x = 0;
rect.y = 0;
rect.width = width;
rect.height = height;
ValidateGC (&pPixmap->drawable, pGC);
(*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &rect);
FreeScratchGC (pGC);
pPicture = CreatePicture (0, &pPixmap->drawable, pPictFormat,
0, 0, serverClient, &error);
(*pScreen->DestroyPixmap) (pPixmap);
return pPicture;
}
#define LINE_FIXED_X(l, _y, v) \
dx = (l)->p2.x - (l)->p1.x; \
ex = (xFixed_32_32) ((_y) - (l)->p1.y) * dx; \
@ -111,9 +53,10 @@ xglCreateMaskPicture (ScreenPtr pScreen,
(v) = (l)->p1.x + (xFixed) ((ex + (dy - 1)) / dy)
static Bool
xglTrapezoidBounds (int ntrap,
xTrapezoid *traps,
BoxPtr box)
xglTrapezoidExtents (PicturePtr pDst,
int ntrap,
xTrapezoid *traps,
BoxPtr extents)
{
Bool x_overlap, overlap = FALSE;
xFixed dx, dy, top, bottom;
@ -121,24 +64,24 @@ xglTrapezoidBounds (int ntrap,
if (!ntrap)
{
box->x1 = MAXSHORT;
box->x2 = MINSHORT;
box->y1 = MAXSHORT;
box->y2 = MINSHORT;
extents->x1 = MAXSHORT;
extents->x2 = MINSHORT;
extents->y1 = MAXSHORT;
extents->y2 = MINSHORT;
return FALSE;
}
box->y1 = xFixedToInt (traps->top);
box->y2 = xFixedToInt (xFixedCeil (traps->bottom));
extents->y1 = xFixedToInt (traps->top);
extents->y2 = xFixedToInt (xFixedCeil (traps->bottom));
LINE_FIXED_X (&traps->left, traps->top, top);
LINE_FIXED_X (&traps->left, traps->bottom, bottom);
box->x1 = xFixedToInt (MIN (top, bottom));
extents->x1 = xFixedToInt (MIN (top, bottom));
LINE_FIXED_X_CEIL (&traps->right, traps->top, top);
LINE_FIXED_X_CEIL (&traps->right, traps->bottom, bottom);
box->x2 = xFixedToInt (xFixedCeil (MAX (top, bottom)));
extents->x2 = xFixedToInt (xFixedCeil (MAX (top, bottom)));
ntrap--;
traps++;
@ -162,35 +105,37 @@ xglTrapezoidBounds (int ntrap,
x2 = xFixedToInt (xFixedCeil (MAX (top, bottom)));
x_overlap = FALSE;
if (x1 >= box->x2)
box->x2 = x2;
else if (x2 <= box->x1)
box->x1 = x1;
if (x1 >= extents->x2)
extents->x2 = x2;
else if (x2 <= extents->x1)
extents->x1 = x1;
else
{
x_overlap = TRUE;
if (x1 < box->x1)
box->x1 = x1;
if (x2 > box->x2)
box->x2 = x2;
if (x1 < extents->x1)
extents->x1 = x1;
if (x2 > extents->x2)
extents->x2 = x2;
}
if (y1 >= box->y2)
box->y2 = y2;
else if (y2 <= box->y1)
box->y1 = y1;
if (y1 >= extents->y2)
extents->y2 = y2;
else if (y2 <= extents->y1)
extents->y1 = y1;
else
{
if (y1 < box->y1)
box->y1 = y1;
if (y2 > box->y2)
box->y2 = y2;
if (y1 < extents->y1)
extents->y1 = y1;
if (y2 > extents->y2)
extents->y2 = y2;
if (x_overlap)
overlap = TRUE;
}
}
xglPictureClipExtents (pDst, extents);
return overlap;
}
@ -211,24 +156,30 @@ xglTrapezoids (CARD8 op,
unsigned int polyEdge = pDst->polyEdge;
INT16 xDst, yDst;
INT16 xOff, yOff;
BoxRec bounds;
BoxRec extents;
Bool overlap;
Bool target;
XGL_SCREEN_PRIV (pScreen);
XGL_DRAWABLE_PIXMAP_PRIV (pDst->pDrawable);
xDst = traps[0].left.p1.x >> 16;
yDst = traps[0].left.p1.y >> 16;
overlap = xglTrapezoidBounds (nTrap, traps, &bounds);
if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
overlap = xglTrapezoidExtents (pDst, nTrap, traps, &extents);
if (extents.y1 >= extents.y2 || extents.x1 >= extents.x2)
return;
target = xglPrepareTarget (pDst->pDrawable);
if (nTrap > 1 && op != PictOpAdd && maskFormat &&
(overlap || op != PictOpOver))
{
xglPixmapPtr pPixmapPriv;
int width, height;
Bool accelerate;
PixmapPtr pPixmap;
GCPtr pGC;
xRectangle rect;
int error;
int area;
if (!pScreenPriv->pSolidAlpha)
{
@ -237,39 +188,53 @@ xglTrapezoids (CARD8 op,
return;
}
accelerate = TRUE;
width = bounds.x2 - bounds.x1;
height = bounds.y2 - bounds.y1;
if (maskFormat->depth > 1)
{
/* Avoid acceleration if the estimated amount of vertex data
is likely to exceed the size of the mask. */
if ((SMOOTH_TRAPS_ESTIMATE_RECTS (nTrap) * 4) > (width * height))
accelerate = FALSE;
} else
accelerate = FALSE;
rect.x = 0;
rect.y = 0;
rect.width = extents.x2 - extents.x1;
rect.height = extents.y2 - extents.y1;
pMask = xglCreateMaskPicture (pScreen, pDst, maskFormat,
width, height, accelerate);
if (!pMask)
pPixmap = (*pScreen->CreatePixmap) (pScreen,
rect.width, rect.height,
maskFormat->depth);
if (!pPixmap)
return;
pMask = CreatePicture (0, &pPixmap->drawable, maskFormat,
0, 0, serverClient, &error);
if (!pMask)
{
(*pScreen->DestroyPixmap) (pPixmap);
return;
}
/* make sure destination drawable is locked */
pPixmapPriv->lock++;
/* lock mask if we are not doing accelerated drawing to destination */
area = rect.width * rect.height;
if (!target || (SMOOTH_TRAPS_ESTIMATE_RECTS (nTrap) * 4) > area)
XGL_GET_PIXMAP_PRIV (pPixmap)->lock = 1;
ValidatePicture (pMask);
pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
ValidateGC (&pPixmap->drawable, pGC);
(*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &rect);
FreeScratchGC (pGC);
/* all will be damaged */
pPixmapPriv = XGL_GET_DRAWABLE_PIXMAP_PRIV (pMask->pDrawable);
pPixmapPriv->damageBox.x1 = 0;
pPixmapPriv->damageBox.y1 = 0;
pPixmapPriv->damageBox.x2 = pMask->pDrawable->width;
pPixmapPriv->damageBox.y2 = pMask->pDrawable->height;
(*pScreen->DestroyPixmap) (pPixmap);
xOff = -bounds.x1;
yOff = -bounds.y1;
target = xglPrepareTarget (pMask->pDrawable);
xOff = -extents.x1;
yOff = -extents.y1;
pSrcPicture = pScreenPriv->pSolidAlpha;
pDstPicture = pMask;
}
else
{
/* make sure destination drawable is locked */
pPixmapPriv->lock++;
if (maskFormat)
{
if (maskFormat->depth == 1)
@ -284,7 +249,7 @@ xglTrapezoids (CARD8 op,
pDstPicture = pDst;
}
if (xglPrepareTarget (pDstPicture->pDrawable))
if (target)
{
if (maskFormat || polyEdge == PolyEdgeSmooth)
{
@ -309,7 +274,8 @@ xglTrapezoids (CARD8 op,
{
if (pMask)
FreePicture (pMask, 0);
pPixmapPriv->lock--;
return;
}
@ -337,7 +303,8 @@ xglTrapezoids (CARD8 op,
{
if (pMask)
FreePicture (pMask, 0);
pPixmapPriv->lock--;
return;
}
@ -354,13 +321,13 @@ xglTrapezoids (CARD8 op,
pSrcPicture,
NULL,
pDstPicture,
bounds.x1 + xOff + xSrc - xDst,
bounds.y1 + yOff + ySrc - yDst,
extents.x1 + xOff + xSrc - xDst,
extents.y1 + yOff + ySrc - yDst,
0, 0,
pDstPicture->pDrawable->x + bounds.x1 + xOff,
pDstPicture->pDrawable->y + bounds.y1 + yOff,
bounds.x2 - bounds.x1,
bounds.y2 - bounds.y1,
pDstPicture->pDrawable->x + extents.x1 + xOff,
pDstPicture->pDrawable->y + extents.y1 + yOff,
extents.x2 - extents.x1,
extents.y2 - extents.y1,
pGeometry,
mask))
{
@ -370,7 +337,7 @@ xglTrapezoids (CARD8 op,
{
RegionRec region;
REGION_INIT (pScreen, &region, &bounds, 1);
REGION_INIT (pScreen, &region, &extents, 1);
REGION_TRANSLATE (pScreen, &region,
pDst->pDrawable->x, pDst->pDrawable->y);
@ -385,10 +352,10 @@ xglTrapezoids (CARD8 op,
{
XGL_DRAWABLE_PIXMAP_PRIV (pDstPicture->pDrawable);
pPixmapPriv->damageBox.x1 = bounds.x1 + xOff;
pPixmapPriv->damageBox.y1 = bounds.y1 + yOff;
pPixmapPriv->damageBox.x2 = bounds.x2 + xOff;
pPixmapPriv->damageBox.y2 = bounds.y2 + yOff;
pPixmapPriv->damageBox.x1 = extents.x1 + xOff;
pPixmapPriv->damageBox.y1 = extents.y1 + yOff;
pPixmapPriv->damageBox.x2 = extents.x2 + xOff;
pPixmapPriv->damageBox.y2 = extents.y2 + yOff;
xglSyncDamageBoxBits (pDstPicture->pDrawable);
@ -411,15 +378,18 @@ xglTrapezoids (CARD8 op,
xglLeaveOffscreenArea ((PixmapPtr) pMask->pDrawable);
CompositePicture (op, pSrc, pMask, pDst,
bounds.x1 + xSrc - xDst,
bounds.y1 + ySrc - yDst,
extents.x1 + xSrc - xDst,
extents.y1 + ySrc - yDst,
0, 0,
bounds.x1, bounds.y1,
bounds.x2 - bounds.x1,
bounds.y2 - bounds.y1);
extents.x1, extents.y1,
extents.x2 - extents.x1,
extents.y2 - extents.y1);
FreePicture (pMask, 0);
}
/* release destination drawable lock */
pPixmapPriv->lock--;
}
void