summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <anholt@freebsd.org>2004-08-05 18:24:58 +0000
committerEric Anholt <anholt@freebsd.org>2004-08-05 18:24:58 +0000
commitae1580c494fde2b56f9faa40f7ebcf637728efc8 (patch)
tree0798058dcd39a70c33663f38f140eeafcb6c8ff6
parent73e14bd611fa7eac649a2b4c7964959d9eae887b (diff)
- 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.
-rw-r--r--miext/cw/cw.c11
-rw-r--r--miext/cw/cw.h10
-rw-r--r--miext/cw/cw_render.c209
-rw-r--r--render/picture.c79
-rw-r--r--render/picturestr.h7
5 files changed, 201 insertions, 115 deletions
diff --git a/miext/cw/cw.c b/miext/cw/cw.c
index a99dd0e0a..e0b7467ed 100644
--- a/miext/cw/cw.c
+++ b/miext/cw/cw.c
@@ -659,6 +659,10 @@ miInitializeCompositeWrapper(ScreenPtr pScreen)
}
if (!AllocateGCPrivate(pScreen, cwGCIndex, 0))
return;
+#ifdef RENDER
+ if (!AllocatePicturePrivate(pScreen, cwPictureIndex, 0))
+ return;
+#endif
pScreenPriv = (cwScreenPtr)xalloc(sizeof(cwScreenRec));
if (!pScreenPriv)
return;
@@ -681,13 +685,8 @@ miInitializeCompositeWrapper(ScreenPtr pScreen)
#ifdef RENDER
if (GetPictureScreen (pScreen))
- {
- if (!cwInitializeRender (pScreen))
- /* FIXME */;
- }
+ cwInitializeRender(pScreen)
#endif
-
- ErrorF("Initialized composite wrapper\n");
}
static Bool
diff --git a/miext/cw/cw.h b/miext/cw/cw.h
index 014cfd4bb..0fb626d11 100644
--- a/miext/cw/cw.h
+++ b/miext/cw/cw.h
@@ -44,16 +44,8 @@ extern int cwGCIndex;
#define getCwGC(pGC) ((cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr)
#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;
-#define getCwPicture(pPicture) ((cwPicturePtr)(pPicture)->devPrivates[cwPictureIndex].ptr)
-
#define cwDrawableIsRedirWindow(pDraw) \
((pDraw)->type == DRAWABLE_WINDOW && \
((*(pDraw)->pScreen->GetWindowPixmap)((WindowPtr)(pDraw)) != \
@@ -142,7 +134,7 @@ cwGetBackingDrawable(DrawablePtr pDrawable, int *x_off, int *y_off);
/* cw_render.c */
-Bool
+void
cwInitializeRender (ScreenPtr pScreen);
/* cw.c */
diff --git a/miext/cw/cw_render.c b/miext/cw/cw_render.c
index 7d28b7b34..2db90b759 100644
--- a/miext/cw/cw_render.c
+++ b/miext/cw/cw_render.c
@@ -31,13 +31,9 @@
PictureScreenPtr ps = GetPictureScreen (pScreen); \
cwScreenPtr pCwScreen = getCwScreen (pScreen)
-#define cwBackingPicture(pCwPicture, pPicture) \
- ((pCwPicture && pCwPicture->pBackingPicture) ? \
- pCwPicture->pBackingPicture : pPicture)
-
-#define cwPictureDecl \
- cwPicturePtr pCwPicture = getCwPicture(pPicture); \
- PicturePtr pBackingPicture = pCwPicture ? pCwPicture->pBackingPicture : 0
+#define cwPictureDecl \
+ PicturePtr pBackingPicture = \
+ ((pPicture)->devPrivates[cwPictureIndex].ptr)
#define cwSrcPictureDecl \
int src_picture_x_off, src_picture_y_off; \
@@ -67,36 +63,23 @@
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
cwCreateBackingPicture (PicturePtr pPicture)
{
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
WindowPtr pWindow = (WindowPtr) pPicture->pDrawable;
PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWindow);
- VisualPtr pVisual = cwFindVisualById (pScreen, wVisual (pWindow));
- PictFormatPtr pFormat = PictureMatchVisual (pScreen, pWindow->drawable.depth,
- pVisual);
int error;
- PicturePtr pBackingPicture = CreatePicture (0, &pPixmap->drawable, pFormat,
- 0, 0, serverClient, &error);
- cwPicturePtr pCwPicture = getCwPicture (pPicture);
+ PicturePtr pBackingPicture;
+
+ pBackingPicture = CreatePicture (0, &pPixmap->drawable, pPicture->pFormat,
+ 0, 0, serverClient, &error);
+
+ pPicture->devPrivates[cwPictureIndex].ptr = pBackingPicture;
- return pCwPicture->pBackingPicture = pBackingPicture;
+ CopyPicture(pPicture, (1 << (CPLastBit + 1)) - 1, pBackingPicture);
+
+ return pBackingPicture;
}
static void
@@ -107,7 +90,7 @@ cwDestroyBackingPicture (PicturePtr pPicture)
if (pBackingPicture)
{
FreePicture (pBackingPicture, 0);
- pCwPicture->pBackingPicture = 0;
+ pPicture->devPrivates[cwPictureIndex].ptr = NULL;
}
}
@@ -143,7 +126,6 @@ cwCreatePicture (PicturePtr pPicture)
cwPsDecl(pScreen);
cwPsUnwrap (CreatePicture);
- bzero(getCwPicture(pPicture), sizeof(cwPictureRec));
ret = (*ps->CreatePicture) (pPicture);
cwPsWrap (CreatePicture, cwCreatePicture);
return ret;
@@ -180,7 +162,8 @@ cwChangePicture (PicturePtr pPicture,
}
cwPsWrap(ChangePicture, cwChangePicture);
}
-
+
+
static void
cwValidatePicture (PicturePtr pPicture,
Mask mask)
@@ -220,26 +203,25 @@ cwValidatePicture (PicturePtr pPicture,
}
}
- pBackingDrawable = cwGetBackingDrawable (&pWin->drawable, &x_off, &y_off);
-
- /* Check to see if a new composite clip must be generated */
+ pBackingDrawable = cwGetBackingDrawable (&pWin->drawable, &x_off,&y_off);
- if (pDrawable->serialNumber != pCwPicture->serialNumber ||
- (mask & (CPClipXOrigin|CPClipYOrigin|CPClipMask|CPSubwindowMode)))
- {
- RegionPtr pCompositeClip;
-
- pCompositeClip = REGION_CREATE(pScreen, NULL, 1);
- /* note - CT_PIXMAP "cannot" happen because no DDX supports it*/
- REGION_COPY (pScreen, pCompositeClip, pPicture->pCompositeClip);
- SetPictureClipRegion (pBackingPicture, -x_off, -y_off,
- pCompositeClip);
- pCwPicture->serialNumber = pDrawable->serialNumber;
+ SetPictureTransform(pBackingPicture, pPicture->transform);
+ /* XXX Set filters */
+
+ if (mask & (CPClipXOrigin || CPClipYOrigin)) {
+ XID vals[2];
+
+ vals[0] = pPicture->clipOrigin.x + x_off;
+ vals[1] = pPicture->clipOrigin.y + y_off;
+
+ ChangePicture(pBackingPicture, CPClipXOrigin | CPClipYOrigin,
+ vals, NULL, NullClient);
+ mask &= ~(CPClipXOrigin | CPClipYOrigin);
}
- mask |= pCwPicture->stateChanges;
+
+ CopyPicture(pPicture, mask, pBackingPicture);
+
(*ps->ValidatePicture) (pBackingPicture, mask);
- pCwPicture->stateChanges = 0;
- pBackingPicture->serialNumber = pBackingDrawable->serialNumber;
}
cwPsWrap(ValidatePicture, cwValidatePicture);
}
@@ -298,11 +280,6 @@ cwGlyphs (CARD8 op,
(*ps->Glyphs) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat,
xSrc + src_picture_x_off, ySrc + src_picture_y_off,
nlists, lists, glyphs);
- if (nlists)
- {
- lists->xOff -= dst_picture_x_off;
- lists->yOff -= dst_picture_y_off;
- }
cwPsWrap(Glyphs, cwGlyphs);
}
@@ -325,11 +302,6 @@ cwCompositeRects (CARD8 op,
rects[i].y += dst_picture_y_off;
}
(*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);
}
@@ -350,7 +322,7 @@ cwTrapezoids (CARD8 op,
int i;
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++)
{
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.y += dst_picture_y_off << 16;
}
+ }
(*ps->Trapezoids) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat,
xSrc + src_picture_x_off, ySrc + src_picture_y_off,
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);
}
static void
cwTriangles (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pDst,
+ PicturePtr pSrcPicture,
+ PicturePtr pDstPicture,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
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
cwTriStrip (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pDst,
- PictFormatPtr maskFormat,
- INT16 xSrc,
- INT16 ySrc,
- int npoint,
- xPointFixed *points)
+ PicturePtr pSrcPicture,
+ PicturePtr pDstPicture,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoint,
+ 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
-cwTriFan (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pDst,
- PictFormatPtr maskFormat,
- INT16 xSrc,
- INT16 ySrc,
- int npoint,
- xPointFixed *points)
+cwTriFan (CARD8 op,
+ PicturePtr pSrcPicture,
+ PicturePtr pDstPicture,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoint,
+ 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)
{
cwPsDecl (pScreen);
- if (!AllocatePicturePrivate (pScreen, cwPictureIndex, sizeof(cwPictureRec)))
- return FALSE;
cwPsWrap(CreatePicture, cwCreatePicture);
cwPsWrap(DestroyPicture, cwDestroyPicture);
cwPsWrap(ChangePicture, cwChangePicture);
@@ -441,7 +453,6 @@ cwInitializeRender (ScreenPtr pScreen)
cwPsWrap(Triangles, cwTriangles);
cwPsWrap(TriStrip, cwTriStrip);
cwPsWrap(TriFan, cwTriFan);
- return TRUE;
}
#endif /* RENDER */
diff --git a/render/picture.c b/render/picture.c
index 6ab0d943c..77593db52 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -1180,6 +1180,85 @@ SetPictureTransform (PicturePtr pPicture,
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
ValidateOnePicture (PicturePtr pPicture)
{
diff --git a/render/picturestr.h b/render/picturestr.h
index 23bab63dc..70881fc78 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -415,7 +415,12 @@ SetPictureClipRegion (PicturePtr pPicture,
int
SetPictureTransform (PicturePtr pPicture,
PictTransform *transform);
-
+
+void
+CopyPicture (PicturePtr pSrc,
+ Mask mask,
+ PicturePtr pDst);
+
void
ValidatePicture(PicturePtr pPicture);