Commit d3566e95 authored by Keith Packard's avatar Keith Packard
Browse files

Rewrite render support in composite wrapper to (almost) work. FIXME:

    PaintWindowBackground/CopyWindow is still broken.
Remove mfb from Xvfb. Use standard visual formats so Render actually works.
parent 6ff8c33f
......@@ -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;
......
......@@ -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
......
......@@ -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);
......@@ -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
*/
......
......@@ -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,