summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2004-07-31 07:52:02 +0000
committerKeith Packard <keithp@keithp.com>2004-07-31 07:52:02 +0000
commitd3566e95c1b7ac00cea6797a8a7c0fc6f965f1e3 (patch)
tree6cc6827571dd422aeded1c0979fad6280e3466b8
parent6ff8c33f503b2f5097d6e21c0393d27897d93261 (diff)
Rewrite render support in composite wrapper to (almost) work. FIXME:COMPOSITEWRAP
PaintWindowBackground/CopyWindow is still broken. Remove mfb from Xvfb. Use standard visual formats so Render actually works.
-rw-r--r--hw/vfb/InitOutput.c106
-rw-r--r--miext/cw/cw.c50
-rw-r--r--miext/cw/cw.h127
-rw-r--r--miext/cw/cw_ops.c49
-rw-r--r--miext/cw/cw_render.c513
5 files changed, 554 insertions, 291 deletions
diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c
index a6aae2941..c3dd21b47 100644
--- a/hw/vfb/InitOutput.c
+++ b/hw/vfb/InitOutput.c
@@ -45,6 +45,7 @@ from The Open Group.
#include "gcstruct.h"
#include "input.h"
#include "mipointer.h"
+#include "micmap.h"
#include <sys/types.h>
#ifdef HAS_MMAP
#include <sys/mman.h>
@@ -64,7 +65,6 @@ from The Open Group.
#endif /* HAS_SHM */
#include "dix.h"
#include "miline.h"
-#include "mfb.h"
#define VFB_DEFAULT_WIDTH 1280
#define VFB_DEFAULT_HEIGHT 1024
@@ -442,60 +442,6 @@ GetTimeInMillis()
}
#endif
-
-static Bool
-vfbMultiDepthCreateGC(GCPtr pGC)
-{
- switch (vfbBitsPerPixel(pGC->depth))
- {
- case 1: return mfbCreateGC (pGC);
- case 8:
- case 16:
- case 32: return fbCreateGC (pGC);
- default: return FALSE;
- }
-}
-
-static void
-vfbMultiDepthGetSpans(
- DrawablePtr pDrawable, /* drawable from which to get bits */
- int wMax, /* largest value of all *pwidths */
- register DDXPointPtr ppt, /* points to start copying from */
- int *pwidth, /* list of number of bits to copy */
- int nspans, /* number of scanlines to copy */
- char *pdstStart) /* where to put the bits */
-{
- switch (pDrawable->bitsPerPixel) {
- case 1:
- mfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
- break;
- case 8:
- case 16:
- case 32:
- fbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
- break;
- }
- return;
-}
-
-static void
-vfbMultiDepthGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h,
- unsigned int format, unsigned long planeMask,
- char *pdstLine)
-{
- switch (pDrawable->bitsPerPixel)
- {
- case 1:
- mfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
- break;
- case 8:
- case 16:
- case 32:
- fbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
- break;
- }
-}
-
static ColormapPtr InstalledMaps[MAXSCREENS];
static int
@@ -922,39 +868,38 @@ vfbScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
pbits = vfbAllocateFramebufferMemory(pvfb);
if (!pbits) return FALSE;
- /* miSetPixmapDepths ();*/
+ miSetPixmapDepths ();
- switch (pvfb->bitsPerPixel)
- {
- case 1:
- ret = mfbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
- dpix, dpiy, pvfb->paddedWidth);
+ switch (pvfb->depth) {
+ case 15:
+ miSetVisualTypesAndMasks (15, (1 << TrueColor), 8, TrueColor,
+ 0x7c00, 0x03e0, 0x001f);
break;
- case 8:
case 16:
- case 32:
- ret = fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
- dpix, dpiy, pvfb->paddedWidth,pvfb->bitsPerPixel);
-#ifdef RENDER
- if (ret && Render)
- fbPictureInit (pScreen, 0, 0);
-#endif
+ miSetVisualTypesAndMasks (16, (1 << TrueColor), 8, TrueColor,
+ 0xf800, 0x07e0, 0x001f);
+ break;
+ case 24:
+ miSetVisualTypesAndMasks (24, (1 << TrueColor), 8, TrueColor,
+ 0xff0000, 0x00ff00, 0x0000ff);
break;
- default:
- return FALSE;
}
+
+ ret = fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
+ dpix, dpiy, pvfb->paddedWidth,pvfb->bitsPerPixel);
+#ifdef RENDER
+ if (ret && Render)
+ fbPictureInit (pScreen, 0, 0);
+#endif
if (!ret) return FALSE;
- miInitializeBackingStore(pScreen);
+ /* miInitializeBackingStore(pScreen); */
/*
* Circumvent the backing store that was just initialised. This amounts
* to a truely bizarre way of initialising SaveDoomedAreas and friends.
*/
- pScreen->CreateGC = vfbMultiDepthCreateGC;
- pScreen->GetImage = vfbMultiDepthGetImage;
- pScreen->GetSpans = vfbMultiDepthGetSpans;
pScreen->InstallColormap = vfbInstallColormap;
pScreen->UninstallColormap = vfbUninstallColormap;
@@ -970,14 +915,7 @@ vfbScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
pScreen->blackPixel = pvfb->blackPixel;
pScreen->whitePixel = pvfb->whitePixel;
- if (pvfb->bitsPerPixel == 1)
- {
- ret = mfbCreateDefColormap(pScreen);
- }
- else
- {
- ret = fbCreateDefColormap(pScreen);
- }
+ ret = fbCreateDefColormap(pScreen);
miSetZeroLineBias(pScreen, pvfb->lineBias);
@@ -1008,7 +946,7 @@ InitOutput(ScreenInfo *screenInfo, int argc, char **argv)
vfbPixmapDepths[1] = TRUE;
vfbPixmapDepths[4] = TRUE;
vfbPixmapDepths[8] = TRUE;
- vfbPixmapDepths[15] = TRUE;
+/* vfbPixmapDepths[15] = TRUE; */
vfbPixmapDepths[16] = TRUE;
vfbPixmapDepths[24] = TRUE;
vfbPixmapDepths[32] = TRUE;
diff --git a/miext/cw/cw.c b/miext/cw/cw.c
index c722bda38..8394ca8a3 100644
--- a/miext/cw/cw.c
+++ b/miext/cw/cw.c
@@ -40,6 +40,9 @@
int cwGCIndex;
int cwScreenIndex;
+#ifdef RENDER
+int cwPictureIndex;
+#endif
static unsigned long cwGeneration = 0;
extern GCOps cwGCOps;
@@ -96,22 +99,10 @@ static GCFuncs cwCheapGCFuncs = {
cwCheapCopyClip,
};
-static __inline__ Bool
-DrawableIsRedirWindow(DrawablePtr pDrawable)
-{
- if (pDrawable->type != DRAWABLE_WINDOW)
- return FALSE;
- if (!((WindowPtr)pDrawable)->redirectDraw)
- return FALSE;
-
- ErrorF("yes!\n");
- return TRUE;
-}
-
DrawablePtr
cwGetBackingDrawable(DrawablePtr pDrawable, int *x_off, int *y_off)
{
- if (DrawableIsRedirWindow(pDrawable)) {
+ if (cwDrawableIsRedirWindow(pDrawable)) {
WindowPtr pWin = (WindowPtr)pDrawable;
PixmapPtr pPixmap = (*pDrawable->pScreen->GetWindowPixmap)(pWin);
*x_off = -pPixmap->screen_x;
@@ -154,22 +145,21 @@ cwCreateGCPrivate(GCPtr pGC, DrawablePtr pDrawable)
pPriv->wrapFuncs = pGC->funcs;
pGC->funcs = &cwGCFuncs;
pGC->ops = &cwGCOps;
- pGC->devPrivates[cwGCIndex].ptr = (pointer)pPriv;
+ setCwGC (pGC, pPriv);
return TRUE;
}
static void
cwDestroyGCPrivate(GCPtr pGC)
{
- cwGCRec *pPriv;
+ cwGCPtr pPriv;
- pPriv = (cwGCRec *)pGC->devPrivates[cwGCIndex].ptr;
- pGC->devPrivates[cwGCIndex].ptr = (pointer)pPriv->wrapFuncs;
+ pPriv = (cwGCPtr) getCwGC (pGC);
pGC->funcs = &cwCheapGCFuncs;
pGC->ops = pPriv->wrapOps;
if (pPriv->pBackingGC)
FreeGC(pPriv->pBackingGC, (XID)0);
- pGC->devPrivates[cwGCIndex].ptr = pPriv->wrapFuncs;
+ setCwGC (pGC, pPriv->wrapFuncs);
xfree((pointer)pPriv);
}
@@ -193,12 +183,12 @@ cwValidateGC(GCPtr pGC, unsigned long stateChanges, DrawablePtr pDrawable)
DrawablePtr pBackingDrawable;
int x_off, y_off;
- pPriv = (cwGCPtr)pGC->devPrivates[cwGCIndex].ptr;
+ pPriv = (cwGCPtr) getCwGC (pGC);
FUNC_PROLOGUE(pGC, pPriv);
if (pDrawable->serialNumber != pPriv->serialNumber &&
- !DrawableIsRedirWindow(pDrawable))
+ !cwDrawableIsRedirWindow(pDrawable))
{
/* The drawable is no longer a window with backing store, so kill the
* private and go back to cheap functions.
@@ -350,7 +340,7 @@ cwCheapValidateGC(GCPtr pGC, unsigned long stateChanges, DrawablePtr pDrawable)
* re-wrap on return.
*/
if (pDrawable->type == DRAWABLE_WINDOW &&
- DrawableIsRedirWindow(pDrawable) &&
+cwDrawableIsRedirWindow(pDrawable) &&
cwCreateGCPrivate(pGC, pDrawable))
{
(*pGC->funcs->ValidateGC)(pGC, stateChanges, pDrawable);
@@ -511,9 +501,6 @@ void
miInitializeCompositeWrapper(ScreenPtr pScreen)
{
cwScreenPtr pScreenPriv;
-#ifdef RENDER
- PictureScreenPtr ps = GetPictureScreen(pScreen);
-#endif
if (cwGeneration != serverGeneration)
{
@@ -521,6 +508,9 @@ miInitializeCompositeWrapper(ScreenPtr pScreen)
if (cwScreenIndex < 0)
return;
cwGCIndex = AllocateGCPrivateIndex();
+#ifdef RENDER
+ cwPictureIndex = AllocatePicturePrivateIndex();
+#endif
cwGeneration = serverGeneration;
}
if (!AllocateGCPrivate(pScreen, cwGCIndex, 0))
@@ -539,19 +529,17 @@ miInitializeCompositeWrapper(ScreenPtr pScreen)
pScreen->GetSpans = cwGetSpans;
pScreen->CreateGC = cwCreateGC;
+ pScreen->devPrivates[cwScreenIndex].ptr = (pointer)pScreenPriv;
+
#ifdef RENDER
- if (ps)
+ if (GetPictureScreen (pScreen))
{
- pScreenPriv->Composite = ps->Composite;
- ps->Composite = cwComposite;
- pScreenPriv->Glyphs = ps->Glyphs;
- ps->Glyphs = cwGlyphs;
+ if (!cwInitializeRender (pScreen))
+ /* FIXME */;
}
#endif
ErrorF("Initialized composite wrapper\n");
-
- pScreen->devPrivates[cwScreenIndex].ptr = (pointer)pScreenPriv;
}
static Bool
diff --git a/miext/cw/cw.h b/miext/cw/cw.h
index c4089b497..33e62f039 100644
--- a/miext/cw/cw.h
+++ b/miext/cw/cw.h
@@ -40,6 +40,25 @@ typedef struct {
GCFuncs *wrapFuncs; /* wrapped funcs */
} cwGCRec, *cwGCPtr;
+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 gc since last copy */
+} cwPictureRec, *cwPicturePtr;
+
+extern int cwPictureIndex;
+
+#define getCwPicture(pPicture) ((cwPicturePtr)(pPicture)->devPrivates[cwPictureIndex].ptr)
+#define setCwPicture(pPicture,p) ((pPicture)->devPrivates[cwPictureIndex].ptr = (pointer) (p))
+
+#define cwDrawableIsRedirWindow(pDraw) ((pDraw)->type == DRAWABLE_WINDOW && \
+ ((WindowPtr)(pDraw))->redirectDraw)
+
typedef struct {
/*
* screen func wrappers
@@ -48,42 +67,98 @@ typedef struct {
GetImageProcPtr GetImage;
GetSpansProcPtr GetSpans;
CreateGCProcPtr CreateGC;
+
+ DestroyWindowProcPtr DestroyWindow;
+
+ StoreColorsProcPtr StoreColors;
+
+ InitIndexedProcPtr InitIndexed;
+ CloseIndexedProcPtr CloseIndexed;
+ UpdateIndexedProcPtr UpdateIndexed;
+
#ifdef RENDER
- CompositeProcPtr Composite;
- GlyphsProcPtr Glyphs;
+ CreatePictureProcPtr CreatePicture;
+ DestroyPictureProcPtr DestroyPicture;
+ ChangePictureClipProcPtr ChangePictureClip;
+ DestroyPictureClipProcPtr DestroyPictureClip;
+
+ ChangePictureProcPtr ChangePicture;
+ ValidatePictureProcPtr ValidatePicture;
+
+ CompositeProcPtr Composite;
+ GlyphsProcPtr Glyphs;
+ CompositeRectsProcPtr CompositeRects;
+
+ TrapezoidsProcPtr Trapezoids;
+ TrianglesProcPtr Triangles;
+ TriStripProcPtr TriStrip;
+ TriFanProcPtr TriFan;
+
+ RasterizeTrapezoidProcPtr RasterizeTrapezoid;
+#if 0
+ AddTrapsProcPtr AddTraps;
+#endif
#endif
} cwScreenRec, *cwScreenPtr;
+extern int cwScreenIndex;
+
+#define getCwScreen(pScreen) ((cwScreenPtr)(pScreen)->devPrivates[cwScreenIndex].ptr)
+#define setCwScreen(pScreen,p) ((cwScreenPtr)(pScreen)->devPrivates[cwScreenIndex].ptr = (p))
+
+#define CW_COPY_OFFSET_XYPOINTS(ppt_trans, ppt, npt) do { \
+ short *_origpt = (short *)(ppt); \
+ short *_transpt = (short *)(ppt_trans); \
+ int _i; \
+ for (_i = 0; _i < npt; _i++) { \
+ *_transpt++ = *_origpt++ + dst_off_x; \
+ *_transpt++ = *_origpt++ + dst_off_y; \
+ } \
+} while (0)
+
+#define CW_COPY_OFFSET_RECTS(prect_trans, prect, nrect) do { \
+ short *_origpt = (short *)(prect); \
+ short *_transpt = (short *)(prect_trans); \
+ int _i; \
+ for (_i = 0; _i < nrect; _i++) { \
+ *_transpt++ = *_origpt++ + dst_off_x; \
+ *_transpt++ = *_origpt++ + dst_off_y; \
+ _transpt += 2; \
+ _origpt += 2; \
+ } \
+} while (0)
+
+#define CW_COPY_OFFSET_ARCS(parc_trans, parc, narc) do { \
+ short *_origpt = (short *)(parc); \
+ short *_transpt = (short *)(parc_trans); \
+ int _i; \
+ for (_i = 0; _i < narc; _i++) { \
+ *_transpt++ = *_origpt++ + dst_off_x; \
+ *_transpt++ = *_origpt++ + dst_off_y; \
+ _transpt += 4; \
+ _origpt += 4; \
+ } \
+} while (0)
+
+#define CW_COPY_OFFSET_XY_DST(bx, by, x, y) do { \
+ bx = x + dst_off_x; \
+ by = y + dst_off_y; \
+} while (0)
+
+#define CW_COPY_OFFSET_XY_SRC(bx, by, x, y) do { \
+ bx = x + src_off_x; \
+ by = y + src_off_y; \
+} while (0)
+
/* cw.c */
DrawablePtr
cwGetBackingDrawable(DrawablePtr pDrawable, int *x_off, int *y_off);
/* cw_render.c */
-void
-cwComposite(CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst,
- CARD16 width,
- CARD16 height);
-
-void
-cwGlyphs(CARD8 op,
- PicturePtr pSrc,
- PicturePtr pDst,
- PictFormatPtr maskFormat,
- INT16 xSrc,
- INT16 ySrc,
- int nlist,
- GlyphListPtr list,
- GlyphPtr *glyphs);
+Bool
+cwInitializeRender (ScreenPtr pScreen);
+/* cw.c */
void
miInitializeCompositeWrapper(ScreenPtr pScreen);
diff --git a/miext/cw/cw_ops.c b/miext/cw/cw_ops.c
index b1b5633f1..879bfb04d 100644
--- a/miext/cw/cw_ops.c
+++ b/miext/cw/cw_ops.c
@@ -25,7 +25,7 @@
#include "cw.h"
#define SETUP_BACKING_DST(_pDst, _pGC) \
- cwGCPtr pGCPrivate = (cwGCPtr)(_pGC)->devPrivates[cwGCIndex].ptr; \
+ cwGCPtr pGCPrivate = getCwGC (_pGC); \
GCFuncs *oldFuncs = (_pGC)->funcs; \
GCPtr pBackingGC = pGCPrivate->pBackingGC; \
int dst_off_x, dst_off_y; \
@@ -37,50 +37,6 @@
DrawablePtr pBackingSrc = cwGetBackingDrawable(pSrc, &src_off_x, \
&src_off_y)
-#define CW_COPY_OFFSET_XYPOINTS(ppt_trans, ppt, npt) do { \
- short *_origpt = (short *)(ppt); \
- short *_transpt = (short *)(ppt_trans); \
- int _i; \
- for (_i = 0; _i < npt; _i++) { \
- *_transpt++ = *_origpt++ + dst_off_x; \
- *_transpt++ = *_origpt++ + dst_off_y; \
- } \
-} while (0)
-
-#define CW_COPY_OFFSET_RECTS(prect_trans, prect, nrect) do { \
- short *_origpt = (short *)(prect); \
- short *_transpt = (short *)(prect_trans); \
- int _i; \
- for (_i = 0; _i < nrect; _i++) { \
- *_transpt++ = *_origpt++ + dst_off_x; \
- *_transpt++ = *_origpt++ + dst_off_y; \
- _transpt += 2; \
- _origpt += 2; \
- } \
-} while (0)
-
-#define CW_COPY_OFFSET_ARCS(parc_trans, parc, narc) do { \
- short *_origpt = (short *)(parc); \
- short *_transpt = (short *)(parc_trans); \
- int _i; \
- for (_i = 0; _i < narc; _i++) { \
- *_transpt++ = *_origpt++ + dst_off_x; \
- *_transpt++ = *_origpt++ + dst_off_y; \
- _transpt += 4; \
- _origpt += 4; \
- } \
-} while (0)
-
-#define CW_COPY_OFFSET_XY_DST(bx, by, x, y) do { \
- bx = x + dst_off_x; \
- by = y + dst_off_y; \
-} while (0)
-
-#define CW_COPY_OFFSET_XY_SRC(bx, by, x, y) do { \
- bx = x + src_off_x; \
- by = y + src_off_y; \
-} while (0)
-
#define PROLOGUE(pGC) do { \
pGC->ops = pGCPrivate->wrapOps;\
pGC->funcs = pGCPrivate->wrapFuncs; \
@@ -92,9 +48,6 @@
(pGC)->funcs = oldFuncs; \
} while (0)
-extern int cwGCIndex;
-
-
/*
* GC ops -- wrap each GC operation with our own function
*/
diff --git a/miext/cw/cw_render.c b/miext/cw/cw_render.c
index a78d0ab67..4f8bed8e4 100644
--- a/miext/cw/cw_render.c
+++ b/miext/cw/cw_render.c
@@ -27,112 +27,421 @@
#ifdef RENDER
-extern int cwScreenIndex;
-
-void
-cwComposite(CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst,
- CARD16 width,
- CARD16 height)
-{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
- cwScreenPtr pScreenPriv =
- (cwScreenPtr)pScreen->devPrivates[cwScreenIndex].ptr;
- DrawablePtr pSrcDraw, pMaskDraw = NULL, pDstDraw;
- DrawablePtr pBackSrcDraw, pBackMaskDraw, pBackDstDraw;
- int src_off_x, src_off_y, mask_off_x, mask_off_y, dst_off_x, dst_off_y;
-
- pSrcDraw = pSrc->pDrawable;
- pBackSrcDraw = cwGetBackingDrawable(pSrcDraw, &src_off_x, &src_off_y);
- xSrc += src_off_x;
- ySrc += src_off_y;
- pSrc->pDrawable = pBackSrcDraw;
-
- pDstDraw = pDst->pDrawable;
- pBackDstDraw = cwGetBackingDrawable(pDstDraw, &dst_off_x, &dst_off_y);
- xDst += dst_off_x;
- yDst += dst_off_y;
- pDst->pDrawable = pBackDstDraw;
-
- if (pMask) {
- pMaskDraw = pMask->pDrawable;
- pBackMaskDraw = cwGetBackingDrawable(pMaskDraw, &mask_off_x,
- &mask_off_y);
- xMask += mask_off_x;
- yMask += mask_off_y;
- pMask->pDrawable = pBackMaskDraw;
+#define cwPsDecl(pScreen) \
+ 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 cwSrcPictureDecl \
+ int src_picture_x_off, src_picture_y_off; \
+ PicturePtr pBackingSrcPicture = cwGetBackingPicture(pSrcPicture, \
+ &src_picture_x_off,\
+ &src_picture_y_off)
+
+#define cwDstPictureDecl \
+ int dst_picture_x_off, dst_picture_y_off; \
+ PicturePtr pBackingDstPicture = cwGetBackingPicture(pDstPicture, \
+ &dst_picture_x_off,\
+ &dst_picture_y_off)
+
+#define cwMskPictureDecl \
+ int msk_picture_x_off = 0, msk_picture_y_off = 0; \
+ PicturePtr pBackingMskPicture = (!pMskPicture ? 0 : \
+ cwGetBackingPicture(pMskPicture, \
+ &msk_picture_x_off,\
+ &msk_picture_y_off))
+
+#define cwPsUnwrap(elt) { \
+ ps->elt = pCwScreen->elt; \
+}
+
+#define cwPsWrap(elt,func) { \
+ pCwScreen->elt = ps->elt; \
+ 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);
+
+ return pCwPicture->pBackingPicture = pBackingPicture;
+}
+
+static void
+cwDestroyBackingPicture (PicturePtr pPicture)
+{
+ cwPictureDecl;
- ps->Composite = pScreenPriv->Composite;
- (*ps->Composite)(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
- xDst, yDst, width, height);
- ps->Composite = cwComposite;
-
- pSrc->pDrawable = pSrcDraw;
- pDst->pDrawable = pDstDraw;
- if (pMask)
- pMask->pDrawable = pMaskDraw;
-}
-void
-cwGlyphs(CARD8 op,
- PicturePtr pSrc,
- PicturePtr pDst,
- PictFormatPtr maskFormat,
- INT16 xSrc,
- INT16 ySrc,
- int nlist,
- GlyphListPtr list,
- GlyphPtr *glyphs)
-{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
- cwScreenPtr pScreenPriv =
- (cwScreenPtr)pScreen->devPrivates[cwScreenIndex].ptr;
- DrawablePtr pSrcDraw, pDstDraw;
- DrawablePtr pBackSrcDraw, pBackDstDraw;
- int src_off_x, src_off_y, dst_off_x, dst_off_y;
- GlyphListPtr oldList;
-
- pDstDraw = pDst->pDrawable;
- pBackDstDraw = cwGetBackingDrawable(pDstDraw, &dst_off_x, &dst_off_y);
- if (dst_off_x != 0 || dst_off_y != 0) {
- int i;
-
- oldList = list;
- list = ALLOCATE_LOCAL(nlist * sizeof(GlyphListRec));
- if (list == NULL)
- return;
- memcpy(list, oldList, nlist * sizeof(GlyphListRec));
- for (i = 0; i < nlist; i++) {
- list[i].xOff += dst_off_x;
- list[i].yOff += dst_off_y;
+ if (pBackingPicture)
+ {
+ FreePicture (pBackingPicture, 0);
+ pCwPicture->pBackingPicture = 0;
+ }
+}
+
+static PicturePtr
+cwGetBackingPicture (PicturePtr pPicture, int *x_off, int *y_off)
+{
+ cwPictureDecl;
+
+ if (pBackingPicture)
+ {
+ DrawablePtr pDrawable = pPicture->pDrawable;
+ ScreenPtr pScreen = pDrawable->pScreen;
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+
+ *x_off = -pPixmap->screen_x;
+ *y_off = -pPixmap->screen_y;
+
+ return pBackingPicture;
+ }
+ else
+ {
+ *x_off = *y_off = 0;
+ return pPicture;
+ }
+}
+
+static int
+cwCreatePicture (PicturePtr pPicture)
+{
+ int ret;
+ ScreenPtr pScreen = pPicture->pDrawable->pScreen;
+ cwPsDecl(pScreen);
+
+ cwPsUnwrap (CreatePicture);
+ setCwPicture(pPicture, 0);
+ ret = (*ps->CreatePicture) (pPicture);
+ cwPsWrap (CreatePicture, cwCreatePicture);
+ return ret;
+}
+
+static void
+cwDestroyPicture (PicturePtr pPicture)
+{
+ ScreenPtr pScreen = pPicture->pDrawable->pScreen;
+ cwPsDecl(pScreen);
+
+ cwPsUnwrap(DestroyPicture);
+ cwDestroyBackingPicture (pPicture);
+ (*ps->DestroyPicture) (pPicture);
+ cwPsWrap(DestroyPicture, cwDestroyPicture);
+}
+
+static void
+cwChangePicture (PicturePtr pPicture,
+ Mask mask)
+{
+ ScreenPtr pScreen = pPicture->pDrawable->pScreen;
+ cwPsDecl(pScreen);
+ cwPictureDecl;
+
+ cwPsUnwrap(ChangePicture);
+ if (pBackingPicture)
+ {
+ (*ps->ChangePicture) (pBackingPicture, mask);
+ }
+ else
+ {
+ (*ps->ChangePicture) (pPicture, mask);
+ }
+ cwPsWrap(ChangePicture, cwChangePicture);
+}
+
+static void
+cwValidatePicture (PicturePtr pPicture,
+ Mask mask)
+{
+ ScreenPtr pScreen = pPicture->pDrawable->pScreen;
+ cwPsDecl(pScreen);
+ cwPictureDecl;
+
+ cwPsUnwrap(ValidatePicture);
+ (*ps->ValidatePicture) (pPicture, mask);
+ if (!cwDrawableIsRedirWindow (pPicture->pDrawable))
+ {
+ if (pBackingPicture)
+ cwDestroyBackingPicture (pPicture);
+ }
+ else
+ {
+ DrawablePtr pDrawable = pPicture->pDrawable;
+ WindowPtr pWin = (WindowPtr) (pDrawable);
+ DrawablePtr pBackingDrawable;
+ int x_off, y_off;
+
+ if (pBackingPicture && pBackingPicture->pDrawable !=
+ &(*pScreen->GetWindowPixmap) ((WindowPtr) pPicture->pDrawable)->drawable)
+ {
+ cwDestroyBackingPicture (pPicture);
+ pBackingPicture = 0;
+ }
+
+ if (!pBackingPicture)
+ {
+ pBackingPicture = cwCreateBackingPicture (pPicture);
+ if (!pBackingPicture)
+ {
+ cwPsWrap(ValidatePicture, cwValidatePicture);
+ return;
+ }
+ }
+
+ pBackingDrawable = cwGetBackingDrawable (&pWin->drawable, &x_off, &y_off);
+
+ /* Check to see if a new composite clip must be generated */
+
+ 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;
}
+ mask |= pCwPicture->stateChanges;
+ (*ps->ValidatePicture) (pBackingPicture, mask);
+ pCwPicture->stateChanges = 0;
+ pBackingPicture->serialNumber = pBackingDrawable->serialNumber;
+ }
+ cwPsWrap(ValidatePicture, cwValidatePicture);
+}
+
+static void
+cwComposite (CARD8 op,
+ PicturePtr pSrcPicture,
+ PicturePtr pMskPicture,
+ PicturePtr pDstPicture,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMsk,
+ INT16 yMsk,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
+ cwPsDecl(pScreen);
+ cwSrcPictureDecl;
+ cwMskPictureDecl;
+ cwDstPictureDecl;
+
+ cwPsUnwrap(Composite);
+ (*ps->Composite) (op, pBackingSrcPicture, pBackingMskPicture, pBackingDstPicture,
+ xSrc + src_picture_x_off, ySrc + src_picture_y_off,
+ xMsk + msk_picture_x_off, yMsk + msk_picture_y_off,
+ xDst + dst_picture_x_off, yDst + dst_picture_y_off,
+ width, height);
+ cwPsWrap(Composite, cwComposite);
+}
+
+static void
+cwGlyphs (CARD8 op,
+ PicturePtr pSrcPicture,
+ PicturePtr pDstPicture,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int nlists,
+ GlyphListPtr lists,
+ GlyphPtr *glyphs)
+{
+ ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
+ cwPsDecl(pScreen);
+ cwSrcPictureDecl;
+ cwDstPictureDecl;
+
+ cwPsUnwrap(Glyphs);
+ if (nlists)
+ {
+ lists->xOff += dst_picture_x_off;
+ lists->yOff += dst_picture_y_off;
+ }
+ (*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);
+}
+
+static void
+cwCompositeRects (CARD8 op,
+ PicturePtr pDstPicture,
+ xRenderColor *color,
+ int nRect,
+ xRectangle *rects)
+{
+ ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
+ cwPsDecl(pScreen);
+ cwDstPictureDecl;
+ int i;
+
+ cwPsUnwrap(CompositeRects);
+ for (i = 0; i < nRect; i++)
+ {
+ rects[i].x += dst_picture_x_off;
+ rects[i].y += dst_picture_y_off;
}
- pDst->pDrawable = pBackDstDraw;
-
- pSrcDraw = pSrc->pDrawable;
- pBackSrcDraw = cwGetBackingDrawable(pSrcDraw, &src_off_x, &src_off_y);
- xSrc += src_off_x;
- ySrc += src_off_y;
- pSrc->pDrawable = pBackSrcDraw;
-
- ps->Glyphs = pScreenPriv->Glyphs;
- (*ps->Glyphs)(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
- ps->Glyphs = cwGlyphs;
-
- pSrc->pDrawable = pSrcDraw;
- pDst->pDrawable = pDstDraw;
- if (dst_off_x != 0 || dst_off_y != 0)
- DEALLOCATE_LOCAL(list);
+ (*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);
+}
+
+static void
+cwTrapezoids (CARD8 op,
+ PicturePtr pSrcPicture,
+ PicturePtr pDstPicture,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int ntrap,
+ xTrapezoid *traps)
+{
+ ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
+ cwPsDecl(pScreen);
+ cwSrcPictureDecl;
+ cwDstPictureDecl;
+ int i;
+
+ cwPsUnwrap(Trapezoids);
+ 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;
+ }
+ (*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,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int ntri,
+ xTriangle *tris)
+{
+ /* FIXME */
+}
+
+static void
+cwTriStrip (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoint,
+ xPointFixed *points)
+{
+ /* FIXME */
+}
+
+static void
+cwTriFan (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoint,
+ xPointFixed *points)
+{
+ /* FIXME */
+}
+
+Bool
+cwInitializeRender (ScreenPtr pScreen)
+{
+ cwPsDecl (pScreen);
+
+ if (!AllocatePicturePrivate (pScreen, cwPictureIndex, 0))
+ return FALSE;
+ cwPsWrap(CreatePicture, cwCreatePicture);
+ cwPsWrap(DestroyPicture, cwDestroyPicture);
+ cwPsWrap(ChangePicture, cwChangePicture);
+ cwPsWrap(ValidatePicture, cwValidatePicture);
+ cwPsWrap(Composite, cwComposite);
+ cwPsWrap(Glyphs, cwGlyphs);
+ cwPsWrap(CompositeRects, cwCompositeRects);
+ cwPsWrap(Trapezoids, cwTrapezoids);
+ cwPsWrap(Triangles, cwTriangles);
+ cwPsWrap(TriStrip, cwTriStrip);
+ cwPsWrap(TriFan, cwTriFan);
+ return TRUE;
}
#endif /* RENDER */