- Add a new Render function, CopyPicture, which will update a picture with

the flagged bits from a source picture. Approved in principle by
    keithp.
- Use CopyPicture and SetTransform to update most of the backing picture's
    state in the composite wrapper. Filters are still missing.
- Don't allocate a picture private, now that we calculate clipping properly
    and don't need the serialNumber or stateChanges.
- Use the format of the source pixmap rather than generating the format
    from the window's visual.
- Wrap the rest of the Render primitives that were stubbed out before.
This commit is contained in:
Eric Anholt 2004-08-05 18:24:58 +00:00
parent 73e14bd611
commit ae1580c494
5 changed files with 200 additions and 114 deletions

View File

@ -659,6 +659,10 @@ miInitializeCompositeWrapper(ScreenPtr pScreen)
} }
if (!AllocateGCPrivate(pScreen, cwGCIndex, 0)) if (!AllocateGCPrivate(pScreen, cwGCIndex, 0))
return; return;
#ifdef RENDER
if (!AllocatePicturePrivate(pScreen, cwPictureIndex, 0))
return;
#endif
pScreenPriv = (cwScreenPtr)xalloc(sizeof(cwScreenRec)); pScreenPriv = (cwScreenPtr)xalloc(sizeof(cwScreenRec));
if (!pScreenPriv) if (!pScreenPriv)
return; return;
@ -681,13 +685,8 @@ miInitializeCompositeWrapper(ScreenPtr pScreen)
#ifdef RENDER #ifdef RENDER
if (GetPictureScreen (pScreen)) if (GetPictureScreen (pScreen))
{ cwInitializeRender(pScreen)
if (!cwInitializeRender (pScreen))
/* FIXME */;
}
#endif #endif
ErrorF("Initialized composite wrapper\n");
} }
static Bool static Bool

View File

@ -44,16 +44,8 @@ extern int cwGCIndex;
#define getCwGC(pGC) ((cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr) #define getCwGC(pGC) ((cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr)
#define setCwGC(pGC,p) ((pGC)->devPrivates[cwGCIndex].ptr = (pointer) (p)) #define setCwGC(pGC,p) ((pGC)->devPrivates[cwGCIndex].ptr = (pointer) (p))
typedef struct {
PicturePtr pBackingPicture;
unsigned long serialNumber; /* clientClip computed time */
unsigned long stateChanges; /* changes in parent picture since last copy */
} cwPictureRec, *cwPicturePtr;
extern int cwPictureIndex; extern int cwPictureIndex;
#define getCwPicture(pPicture) ((cwPicturePtr)(pPicture)->devPrivates[cwPictureIndex].ptr)
#define cwDrawableIsRedirWindow(pDraw) \ #define cwDrawableIsRedirWindow(pDraw) \
((pDraw)->type == DRAWABLE_WINDOW && \ ((pDraw)->type == DRAWABLE_WINDOW && \
((*(pDraw)->pScreen->GetWindowPixmap)((WindowPtr)(pDraw)) != \ ((*(pDraw)->pScreen->GetWindowPixmap)((WindowPtr)(pDraw)) != \
@ -142,7 +134,7 @@ cwGetBackingDrawable(DrawablePtr pDrawable, int *x_off, int *y_off);
/* cw_render.c */ /* cw_render.c */
Bool void
cwInitializeRender (ScreenPtr pScreen); cwInitializeRender (ScreenPtr pScreen);
/* cw.c */ /* cw.c */

View File

@ -31,13 +31,9 @@
PictureScreenPtr ps = GetPictureScreen (pScreen); \ PictureScreenPtr ps = GetPictureScreen (pScreen); \
cwScreenPtr pCwScreen = getCwScreen (pScreen) cwScreenPtr pCwScreen = getCwScreen (pScreen)
#define cwBackingPicture(pCwPicture, pPicture) \ #define cwPictureDecl \
((pCwPicture && pCwPicture->pBackingPicture) ? \ PicturePtr pBackingPicture = \
pCwPicture->pBackingPicture : pPicture) ((pPicture)->devPrivates[cwPictureIndex].ptr)
#define cwPictureDecl \
cwPicturePtr pCwPicture = getCwPicture(pPicture); \
PicturePtr pBackingPicture = pCwPicture ? pCwPicture->pBackingPicture : 0
#define cwSrcPictureDecl \ #define cwSrcPictureDecl \
int src_picture_x_off, src_picture_y_off; \ int src_picture_x_off, src_picture_y_off; \
@ -67,36 +63,23 @@
ps->elt = func; \ ps->elt = func; \
} }
static VisualPtr
cwFindVisualById (ScreenPtr pScreen, VisualID visual)
{
int i;
VisualPtr pVisual;
for (i = 0, pVisual = pScreen->visuals;
i < pScreen->numVisuals;
i++, pVisual++)
{
if (pVisual->vid == visual)
return pVisual;
}
return 0;
}
static PicturePtr static PicturePtr
cwCreateBackingPicture (PicturePtr pPicture) cwCreateBackingPicture (PicturePtr pPicture)
{ {
ScreenPtr pScreen = pPicture->pDrawable->pScreen; ScreenPtr pScreen = pPicture->pDrawable->pScreen;
WindowPtr pWindow = (WindowPtr) pPicture->pDrawable; WindowPtr pWindow = (WindowPtr) pPicture->pDrawable;
PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWindow); PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWindow);
VisualPtr pVisual = cwFindVisualById (pScreen, wVisual (pWindow));
PictFormatPtr pFormat = PictureMatchVisual (pScreen, pWindow->drawable.depth,
pVisual);
int error; int error;
PicturePtr pBackingPicture = CreatePicture (0, &pPixmap->drawable, pFormat, PicturePtr pBackingPicture;
0, 0, serverClient, &error);
cwPicturePtr pCwPicture = getCwPicture (pPicture);
return pCwPicture->pBackingPicture = pBackingPicture; pBackingPicture = CreatePicture (0, &pPixmap->drawable, pPicture->pFormat,
0, 0, serverClient, &error);
pPicture->devPrivates[cwPictureIndex].ptr = pBackingPicture;
CopyPicture(pPicture, (1 << (CPLastBit + 1)) - 1, pBackingPicture);
return pBackingPicture;
} }
static void static void
@ -107,7 +90,7 @@ cwDestroyBackingPicture (PicturePtr pPicture)
if (pBackingPicture) if (pBackingPicture)
{ {
FreePicture (pBackingPicture, 0); FreePicture (pBackingPicture, 0);
pCwPicture->pBackingPicture = 0; pPicture->devPrivates[cwPictureIndex].ptr = NULL;
} }
} }
@ -143,7 +126,6 @@ cwCreatePicture (PicturePtr pPicture)
cwPsDecl(pScreen); cwPsDecl(pScreen);
cwPsUnwrap (CreatePicture); cwPsUnwrap (CreatePicture);
bzero(getCwPicture(pPicture), sizeof(cwPictureRec));
ret = (*ps->CreatePicture) (pPicture); ret = (*ps->CreatePicture) (pPicture);
cwPsWrap (CreatePicture, cwCreatePicture); cwPsWrap (CreatePicture, cwCreatePicture);
return ret; return ret;
@ -180,7 +162,8 @@ cwChangePicture (PicturePtr pPicture,
} }
cwPsWrap(ChangePicture, cwChangePicture); cwPsWrap(ChangePicture, cwChangePicture);
} }
static void static void
cwValidatePicture (PicturePtr pPicture, cwValidatePicture (PicturePtr pPicture,
Mask mask) Mask mask)
@ -220,26 +203,25 @@ cwValidatePicture (PicturePtr pPicture,
} }
} }
pBackingDrawable = cwGetBackingDrawable (&pWin->drawable, &x_off, &y_off); pBackingDrawable = cwGetBackingDrawable (&pWin->drawable, &x_off,&y_off);
/* Check to see if a new composite clip must be generated */
if (pDrawable->serialNumber != pCwPicture->serialNumber || SetPictureTransform(pBackingPicture, pPicture->transform);
(mask & (CPClipXOrigin|CPClipYOrigin|CPClipMask|CPSubwindowMode))) /* XXX Set filters */
{
RegionPtr pCompositeClip;
pCompositeClip = REGION_CREATE(pScreen, NULL, 1); if (mask & (CPClipXOrigin || CPClipYOrigin)) {
/* note - CT_PIXMAP "cannot" happen because no DDX supports it*/ XID vals[2];
REGION_COPY (pScreen, pCompositeClip, pPicture->pCompositeClip);
SetPictureClipRegion (pBackingPicture, -x_off, -y_off, vals[0] = pPicture->clipOrigin.x + x_off;
pCompositeClip); vals[1] = pPicture->clipOrigin.y + y_off;
pCwPicture->serialNumber = pDrawable->serialNumber;
ChangePicture(pBackingPicture, CPClipXOrigin | CPClipYOrigin,
vals, NULL, NullClient);
mask &= ~(CPClipXOrigin | CPClipYOrigin);
} }
mask |= pCwPicture->stateChanges;
CopyPicture(pPicture, mask, pBackingPicture);
(*ps->ValidatePicture) (pBackingPicture, mask); (*ps->ValidatePicture) (pBackingPicture, mask);
pCwPicture->stateChanges = 0;
pBackingPicture->serialNumber = pBackingDrawable->serialNumber;
} }
cwPsWrap(ValidatePicture, cwValidatePicture); cwPsWrap(ValidatePicture, cwValidatePicture);
} }
@ -298,11 +280,6 @@ cwGlyphs (CARD8 op,
(*ps->Glyphs) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat, (*ps->Glyphs) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat,
xSrc + src_picture_x_off, ySrc + src_picture_y_off, xSrc + src_picture_x_off, ySrc + src_picture_y_off,
nlists, lists, glyphs); nlists, lists, glyphs);
if (nlists)
{
lists->xOff -= dst_picture_x_off;
lists->yOff -= dst_picture_y_off;
}
cwPsWrap(Glyphs, cwGlyphs); cwPsWrap(Glyphs, cwGlyphs);
} }
@ -325,11 +302,6 @@ cwCompositeRects (CARD8 op,
rects[i].y += dst_picture_y_off; rects[i].y += dst_picture_y_off;
} }
(*ps->CompositeRects) (op, pBackingDstPicture, color, nRect, rects); (*ps->CompositeRects) (op, pBackingDstPicture, color, nRect, rects);
for (i = 0; i < nRect; i++)
{
rects[i].x -= dst_picture_x_off;
rects[i].y -= dst_picture_y_off;
}
cwPsWrap(CompositeRects, cwCompositeRects); cwPsWrap(CompositeRects, cwCompositeRects);
} }
@ -350,7 +322,7 @@ cwTrapezoids (CARD8 op,
int i; int i;
cwPsUnwrap(Trapezoids); cwPsUnwrap(Trapezoids);
if (dst_picture_x_off | dst_picture_y_off) if (dst_picture_x_off || dst_picture_y_off) {
for (i = 0; i < ntrap; i++) for (i = 0; i < ntrap; i++)
{ {
traps[i].top += dst_picture_y_off << 16; traps[i].top += dst_picture_y_off << 16;
@ -364,72 +336,112 @@ cwTrapezoids (CARD8 op,
traps[i].right.p2.x += dst_picture_x_off << 16; traps[i].right.p2.x += dst_picture_x_off << 16;
traps[i].right.p2.y += dst_picture_y_off << 16; traps[i].right.p2.y += dst_picture_y_off << 16;
} }
}
(*ps->Trapezoids) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat, (*ps->Trapezoids) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat,
xSrc + src_picture_x_off, ySrc + src_picture_y_off, xSrc + src_picture_x_off, ySrc + src_picture_y_off,
ntrap, traps); ntrap, traps);
if (dst_picture_x_off | dst_picture_y_off)
for (i = 0; i < ntrap; i++)
{
traps[i].top -= dst_picture_y_off << 16;
traps[i].bottom -= dst_picture_y_off << 16;
traps[i].left.p1.x -= dst_picture_x_off << 16;
traps[i].left.p1.y -= dst_picture_y_off << 16;
traps[i].left.p2.x -= dst_picture_x_off << 16;
traps[i].left.p2.y -= dst_picture_y_off << 16;
traps[i].right.p1.x -= dst_picture_x_off << 16;
traps[i].right.p1.y -= dst_picture_y_off << 16;
traps[i].right.p2.x -= dst_picture_x_off << 16;
traps[i].right.p2.y -= dst_picture_y_off << 16;
}
cwPsWrap(Trapezoids, cwTrapezoids); cwPsWrap(Trapezoids, cwTrapezoids);
} }
static void static void
cwTriangles (CARD8 op, cwTriangles (CARD8 op,
PicturePtr pSrc, PicturePtr pSrcPicture,
PicturePtr pDst, PicturePtr pDstPicture,
PictFormatPtr maskFormat, PictFormatPtr maskFormat,
INT16 xSrc, INT16 xSrc,
INT16 ySrc, INT16 ySrc,
int ntri, int ntri,
xTriangle *tris) xTriangle *tris)
{ {
/* FIXME */ ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
cwPsDecl(pScreen);
cwSrcPictureDecl;
cwDstPictureDecl;
int i;
cwPsUnwrap(Triangles);
if (dst_picture_x_off || dst_picture_y_off) {
for (i = 0; i < ntri; i++)
{
tris[i].p1.x += dst_picture_x_off << 16;
tris[i].p1.y += dst_picture_y_off << 16;
tris[i].p2.x += dst_picture_x_off << 16;
tris[i].p2.y += dst_picture_y_off << 16;
tris[i].p3.x += dst_picture_x_off << 16;
tris[i].p3.y += dst_picture_y_off << 16;
}
}
(*ps->Triangles) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat,
xSrc + src_picture_x_off, ySrc + src_picture_y_off,
ntri, tris);
cwPsWrap(Triangles, cwTriangles);
} }
static void static void
cwTriStrip (CARD8 op, cwTriStrip (CARD8 op,
PicturePtr pSrc, PicturePtr pSrcPicture,
PicturePtr pDst, PicturePtr pDstPicture,
PictFormatPtr maskFormat, PictFormatPtr maskFormat,
INT16 xSrc, INT16 xSrc,
INT16 ySrc, INT16 ySrc,
int npoint, int npoint,
xPointFixed *points) xPointFixed *points)
{ {
/* FIXME */ ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
cwPsDecl(pScreen);
cwSrcPictureDecl;
cwDstPictureDecl;
int i;
cwPsUnwrap(TriStrip);
if (dst_picture_x_off || dst_picture_y_off) {
for (i = 0; i < npoint; i++)
{
points[i].x += dst_picture_x_off << 16;
points[i].y += dst_picture_y_off << 16;
}
}
(*ps->TriStrip) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat,
xSrc + src_picture_x_off, ySrc + src_picture_y_off,
npoint, points);
cwPsWrap(TriStrip, cwTriStrip);
} }
static void static void
cwTriFan (CARD8 op, cwTriFan (CARD8 op,
PicturePtr pSrc, PicturePtr pSrcPicture,
PicturePtr pDst, PicturePtr pDstPicture,
PictFormatPtr maskFormat, PictFormatPtr maskFormat,
INT16 xSrc, INT16 xSrc,
INT16 ySrc, INT16 ySrc,
int npoint, int npoint,
xPointFixed *points) xPointFixed *points)
{ {
/* FIXME */ ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
cwPsDecl(pScreen);
cwSrcPictureDecl;
cwDstPictureDecl;
int i;
cwPsUnwrap(TriFan);
if (dst_picture_x_off || dst_picture_y_off) {
for (i = 0; i < npoint; i++)
{
points[i].x += dst_picture_x_off << 16;
points[i].y += dst_picture_y_off << 16;
}
}
(*ps->TriFan) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat,
xSrc + src_picture_x_off, ySrc + src_picture_y_off,
npoint, points);
cwPsWrap(TriFan, cwTriFan);
} }
Bool void
cwInitializeRender (ScreenPtr pScreen) cwInitializeRender (ScreenPtr pScreen)
{ {
cwPsDecl (pScreen); cwPsDecl (pScreen);
if (!AllocatePicturePrivate (pScreen, cwPictureIndex, sizeof(cwPictureRec)))
return FALSE;
cwPsWrap(CreatePicture, cwCreatePicture); cwPsWrap(CreatePicture, cwCreatePicture);
cwPsWrap(DestroyPicture, cwDestroyPicture); cwPsWrap(DestroyPicture, cwDestroyPicture);
cwPsWrap(ChangePicture, cwChangePicture); cwPsWrap(ChangePicture, cwChangePicture);
@ -441,7 +453,6 @@ cwInitializeRender (ScreenPtr pScreen)
cwPsWrap(Triangles, cwTriangles); cwPsWrap(Triangles, cwTriangles);
cwPsWrap(TriStrip, cwTriStrip); cwPsWrap(TriStrip, cwTriStrip);
cwPsWrap(TriFan, cwTriFan); cwPsWrap(TriFan, cwTriFan);
return TRUE;
} }
#endif /* RENDER */ #endif /* RENDER */

View File

@ -1180,6 +1180,85 @@ SetPictureTransform (PicturePtr pPicture,
return Success; return Success;
} }
void
CopyPicture (PicturePtr pSrc,
Mask mask,
PicturePtr pDst)
{
PictureScreenPtr ps = GetPictureScreen(pSrc->pDrawable->pScreen);
pDst->stateChanges |= mask;
while (mask) {
Mask bit = lowbit(mask);
switch (bit)
{
case CPRepeat:
pDst->repeat = pSrc->repeat;
break;
case CPAlphaMap:
if (pSrc->alphaMap && pSrc->alphaMap->pDrawable->type == DRAWABLE_PIXMAP)
pSrc->alphaMap->refcnt++;
if (pDst->alphaMap)
FreePicture ((pointer) pDst->alphaMap, (XID) 0);
pDst->alphaMap = pSrc->alphaMap;
break;
case CPAlphaXOrigin:
pDst->alphaOrigin.x = pSrc->alphaOrigin.y;
break;
case CPAlphaYOrigin:
pDst->alphaOrigin.y = pSrc->alphaOrigin.y;
break;
case CPClipXOrigin:
pDst->clipOrigin.x = pSrc->clipOrigin.y;
break;
case CPClipYOrigin:
pDst->clipOrigin.y = pSrc->clipOrigin.y;
break;
case CPClipMask:
switch (pSrc->clientClipType) {
case CT_NONE:
(*ps->ChangePictureClip)(pDst, CT_NONE, NULL, 0);
break;
case CT_REGION:
if (!pSrc->clientClip) {
(*ps->ChangePictureClip)(pDst, CT_NONE, NULL, 0);
} else {
RegionPtr clientClip;
RegionPtr srcClientClip = (RegionPtr)pSrc->clientClip;
clientClip = REGION_CREATE(pSrc->pDrawable->pScreen,
REGION_EXTENTS(pSrc->pDrawable->pScreen, srcClientClip),
REGION_NUM_RECTS(srcClientClip));
(*ps->ChangePictureClip)(pDst, CT_REGION, clientClip, 0);
}
break;
default:
/* XXX: CT_PIXMAP unimplemented */
break;
}
break;
case CPGraphicsExposure:
pDst->graphicsExposures = pSrc->graphicsExposures;
break;
case CPPolyEdge:
pDst->polyEdge = pSrc->polyEdge;
break;
case CPPolyMode:
pDst->polyMode = pSrc->polyMode;
break;
case CPDither:
pDst->dither = pSrc->dither;
break;
case CPComponentAlpha:
pDst->componentAlpha = pSrc->componentAlpha;
break;
}
mask &= ~bit;
}
}
static void static void
ValidateOnePicture (PicturePtr pPicture) ValidateOnePicture (PicturePtr pPicture)
{ {

View File

@ -415,7 +415,12 @@ SetPictureClipRegion (PicturePtr pPicture,
int int
SetPictureTransform (PicturePtr pPicture, SetPictureTransform (PicturePtr pPicture,
PictTransform *transform); PictTransform *transform);
void
CopyPicture (PicturePtr pSrc,
Mask mask,
PicturePtr pDst);
void void
ValidatePicture(PicturePtr pPicture); ValidatePicture(PicturePtr pPicture);