diff options
author | Adam Jackson <ajax@redhat.com> | 2012-10-15 15:51:07 -0400 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2012-10-15 19:18:22 -0400 |
commit | fbb003e133d0180fba8d7703afac0a3d0747e167 (patch) | |
tree | d46cc3d661056cc2259689cf2786313099ceda5a | |
parent | a69429a17bf4630f6e26f61630a1c2b287202627 (diff) |
wip dix: Introduce DrawableOps for Get{Image,Spans}drawable-ops
TODO: vgaarb, xwin, rootless
Background: shatter. You want to be able to back an (XID-named)
Drawable with N other drawables. The core GC is set up well for this,
because a shatter layer can simply iterate over a list of backing
drawables, and it's easy to get scratch GCs so wrapping still works
(ie, shard rendering might actually be accelerated).
However, the pixel Get ops don't have this property, you can't restart
your descent down the GetImage wrap chain because you can't create a
"scratch screen" the way you can create a scratch GC. Since there's no
GC for GetImage or GetSpans we can simply hang their ops directly on the
Drawable. Wrapping works like GC ops (the whole vector at once) not like
screen ops (each vector individually); this is a slight semantic change,
but not effectively a functional change.
The bottom layers - fb, xnest, xwin, dmx - _are_ the implementation so
they don't need to wrap/unwrap. Everybody else grows pixmap/window
privates as needed; we could move those devPrivates directly into
DrawableRec as a further cleanup. Composite and shadow don't bother to
wrap ops for pixmaps, since their hooks have no effect for pixmaps even
before this change, and are simplified to match.
Signed-off-by: Adam Jackson <ajax@redhat.com>
43 files changed, 387 insertions, 171 deletions
diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c index 1c7197d5d..505458659 100644 --- a/Xext/panoramiX.c +++ b/Xext/panoramiX.c @@ -1195,12 +1195,12 @@ XineramaGetImageData(DrawablePtr *pDrawables, RegionUninit(&ScreenRegion); if (inOut == rgnIN) { - (*pScreen->GetImage) (pDraw, - SrcBox.x1 - pDraw->x - - screenInfo.screens[i]->x, - SrcBox.y1 - pDraw->y - - screenInfo.screens[i]->y, width, height, - format, planemask, data); + pDraw->ops->GetImage (pDraw, + SrcBox.x1 - pDraw->x - + screenInfo.screens[i]->x, + SrcBox.y1 - pDraw->y - + screenInfo.screens[i]->y, width, height, + format, planemask, data); break; } else if (inOut == rgnOUT) @@ -1232,8 +1232,8 @@ XineramaGetImageData(DrawablePtr *pDrawables, x = pbox->x1 - pDraw->x - screenInfo.screens[i]->x; y = pbox->y1 - pDraw->y - screenInfo.screens[i]->y; - (*pScreen->GetImage) (pDraw, x, y, w, h, - format, planemask, ScratchMem); + pDraw->ops->GetImage (pDraw, x, y, w, h, format, planemask, + ScratchMem); /* copy the memory over */ diff --git a/Xext/shm.c b/Xext/shm.c index 3fa04b921..84daa2775 100644 --- a/Xext/shm.c +++ b/Xext/shm.c @@ -681,21 +681,18 @@ ProcShmGetImage(ClientPtr client) /* nothing to do */ } else if (stuff->format == ZPixmap) { - (*pDraw->pScreen->GetImage) (pDraw, stuff->x, stuff->y, - stuff->width, stuff->height, - stuff->format, stuff->planeMask, - shmdesc->addr + stuff->offset); + pDraw->ops->GetImage(pDraw, stuff->x, stuff->y, stuff->width, + stuff->height, stuff->format, stuff->planeMask, + shmdesc->addr + stuff->offset); } else { length = stuff->offset; for (; plane; plane >>= 1) { if (stuff->planeMask & plane) { - (*pDraw->pScreen->GetImage) (pDraw, - stuff->x, stuff->y, - stuff->width, stuff->height, - stuff->format, plane, - shmdesc->addr + length); + pDraw->ops->GetImage(pDraw, stuff->x, stuff->y, stuff->width, + stuff->height, stuff->format, plane, + shmdesc->addr + length); length += lenPer; } } diff --git a/composite/compinit.c b/composite/compinit.c index bc1130e78..f02fdfad5 100644 --- a/composite/compinit.c +++ b/composite/compinit.c @@ -51,6 +51,7 @@ DevPrivateKeyRec CompScreenPrivateKeyRec; DevPrivateKeyRec CompWindowPrivateKeyRec; DevPrivateKeyRec CompSubwindowsPrivateKeyRec; +DevPrivateKeyRec CompDrawOpsPrivateKeyRec; static Bool compCloseScreen(ScreenPtr pScreen) @@ -77,7 +78,6 @@ compCloseScreen(ScreenPtr pScreen) pScreen->CopyWindow = cs->CopyWindow; pScreen->PositionWindow = cs->PositionWindow; - pScreen->GetImage = cs->GetImage; pScreen->SourceValidate = cs->SourceValidate; free(cs); @@ -142,15 +142,34 @@ compGetImage(DrawablePtr pDrawable, ScreenPtr pScreen = pDrawable->pScreen; CompScreenPtr cs = GetCompScreen(pScreen); - pScreen->GetImage = cs->GetImage; - if (pDrawable->type == DRAWABLE_WINDOW) - compPaintChildrenToWindow((WindowPtr) pDrawable); - (*pScreen->GetImage) (pDrawable, sx, sy, w, h, format, planemask, pdstLine); - cs->GetImage = pScreen->GetImage; - pScreen->GetImage = compGetImage; + compPaintChildrenToWindow((WindowPtr) pDrawable); + pDrawable->ops = compGetDrawableOps(pDrawable); + pDrawable->ops->GetImage(pDrawable, sx, sy, w, h, format, planemask, + pdstLine); + compSetDrawableOps(pDrawable); + pDrawable->ops = &compDrawableOps; } static void +compGetSpans(DrawablePtr pDraw, int wMax, DDXPointPtr ppt, int *pwidth, + int nspans, char *pdstStart) +{ + ScreenPtr pScreen = pDraw->pScreen; + + /* Many apps use GetImage to sync with the visable frame buffer */ + compPaintChildrenToWindow((WindowPtr) pDraw); + pDraw->ops = compGetDrawableOps(pDraw); + pDraw->ops->GetSpans(pDraw, wMax, ppt, pwidth, nspans, pdstStart); + compSetDrawableOps(pDraw); + pDraw->ops = &compDrawableOps; +} + +DrawableOps compDrawableOps = { + compGetImage, + compGetSpans, +}; + +static void compSourceValidate(DrawablePtr pDrawable, int x, int y, int width, int height, unsigned int subWindowMode) @@ -334,6 +353,8 @@ compScreenInit(ScreenPtr pScreen) return FALSE; if (!dixRegisterPrivateKey(&CompWindowPrivateKeyRec, PRIVATE_WINDOW, 0)) return FALSE; + if (!dixRegisterPrivateKey(&CompDrawOpsPrivateKeyRec, PRIVATE_WINDOW, 0)) + return FALSE; if (!dixRegisterPrivateKey(&CompSubwindowsPrivateKeyRec, PRIVATE_WINDOW, 0)) return FALSE; @@ -402,9 +423,6 @@ compScreenInit(ScreenPtr pScreen) cs->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = compCloseScreen; - cs->GetImage = pScreen->GetImage; - pScreen->GetImage = compGetImage; - cs->SourceValidate = pScreen->SourceValidate; pScreen->SourceValidate = compSourceValidate; diff --git a/composite/compint.h b/composite/compint.h index 45b5824a9..21e10bf9a 100644 --- a/composite/compint.h +++ b/composite/compint.h @@ -169,13 +169,16 @@ extern DevPrivateKeyRec CompScreenPrivateKeyRec; #define CompScreenPrivateKey (&CompScreenPrivateKeyRec) extern DevPrivateKeyRec CompWindowPrivateKeyRec; - #define CompWindowPrivateKey (&CompWindowPrivateKeyRec) extern DevPrivateKeyRec CompSubwindowsPrivateKeyRec; - #define CompSubwindowsPrivateKey (&CompSubwindowsPrivateKeyRec) +extern DevPrivateKeyRec CompDrawOpsPrivateKeyRec; +#define CompDrawOpsPrivateKey (&CompDrawOpsPrivateKeyRec) + +extern DrawableOps compDrawableOps; + #define GetCompScreen(s) ((CompScreenPtr) \ dixLookupPrivate(&(s)->devPrivates, CompScreenPrivateKey)) #define GetCompWindow(w) ((CompWindowPtr) \ @@ -329,4 +332,7 @@ compConfigNotify(WindowPtr pWin, int x, int y, int w, int h, void PanoramiXCompositeInit(void); void PanoramiXCompositeReset(void); +DrawableOps *compGetDrawableOps(DrawablePtr draw); +void compSetDrawableOps(DrawablePtr draw); + #endif /* _COMPINT_H_ */ diff --git a/composite/compwindow.c b/composite/compwindow.c index 0be7a1b34..7418cc2f2 100644 --- a/composite/compwindow.c +++ b/composite/compwindow.c @@ -537,6 +537,22 @@ compCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) compCheckTree(pWin->drawable.pScreen); } +DrawableOps * +compGetDrawableOps(DrawablePtr draw) +{ + WindowPtr win = (WindowPtr) draw; + + return dixLookupPrivate(&win->devPrivates, CompDrawOpsPrivateKey); +} + +void +compSetDrawableOps(DrawablePtr draw) +{ + WindowPtr win = (WindowPtr) draw; + + dixSetPrivate(&win->devPrivates, CompDrawOpsPrivateKey, draw->ops); +} + Bool compCreateWindow(WindowPtr pWin) { @@ -559,7 +575,9 @@ compCreateWindow(WindowPtr pWin) pWin, ccw->update); if (compImplicitRedirect(pWin, pWin->parent)) compRedirectWindow(serverClient, pWin, CompositeRedirectAutomatic); + } + compSetDrawableOps(&pWin->drawable); cs->CreateWindow = pScreen->CreateWindow; pScreen->CreateWindow = compCreateWindow; compCheckTree(pWin->drawable.pScreen); diff --git a/dix/dispatch.c b/dix/dispatch.c index 2df1a6ea5..ee7781796 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -2124,12 +2124,8 @@ DoGetImage(ClientPtr client, int format, Drawable drawable, linesDone = 0; while (height - linesDone > 0) { nlines = min(linesPerBuf, height - linesDone); - (*pDraw->pScreen->GetImage) (pDraw, - x, - y + linesDone, - width, - nlines, - format, planemask, (pointer) pBuf); + pDraw->ops->GetImage(pDraw, x, y + linesDone, width, nlines, + format, planemask, (pointer) pBuf); if (pVisibleRegion) XaceCensorImage(client, pVisibleRegion, widthBytesLine, pDraw, x, y + linesDone, width, @@ -2154,12 +2150,8 @@ DoGetImage(ClientPtr client, int format, Drawable drawable, linesDone = 0; while (height - linesDone > 0) { nlines = min(linesPerBuf, height - linesDone); - (*pDraw->pScreen->GetImage) (pDraw, - x, - y + linesDone, - width, - nlines, - format, plane, (pointer) pBuf); + pDraw->ops->GetImage(pDraw, x, y + linesDone, width, nlines, + format, plane, (pointer) pBuf); if (pVisibleRegion) XaceCensorImage(client, pVisibleRegion, widthBytesLine, @@ -2888,8 +2880,8 @@ ProcCreateCursor(ClientPtr client) return BadAlloc; } - (*src->drawable.pScreen->GetImage) ((DrawablePtr) src, 0, 0, width, height, - XYPixmap, 1, (pointer) srcbits); + src->drawable.ops->GetImage((DrawablePtr) src, 0, 0, width, height, + XYPixmap, 1, (pointer) srcbits); if (msk == (PixmapPtr) NULL) { unsigned char *bits = mskbits; @@ -2899,9 +2891,8 @@ ProcCreateCursor(ClientPtr client) else { /* zeroing the (pad) bits helps some ddx cursor handling */ memset((char *) mskbits, 0, n); - (*msk->drawable.pScreen->GetImage) ((DrawablePtr) msk, 0, 0, width, - height, XYPixmap, 1, - (pointer) mskbits); + msk->drawable.ops->GetImage((DrawablePtr) msk, 0, 0, width, height, + XYPixmap, 1,(pointer) mskbits); } cm.width = width; cm.height = height; diff --git a/dix/glyphcurs.c b/dix/glyphcurs.c index 9004cb152..2b305068c 100644 --- a/dix/glyphcurs.c +++ b/dix/glyphcurs.c @@ -58,6 +58,7 @@ SOFTWARE. #include "cursorstr.h" #include "opaque.h" #include "servermd.h" +#include "pixmapstr.h" /* get the bits out of the font in a portable way. to avoid @@ -125,8 +126,8 @@ ServerBitsFromGlyph(FontPtr pfont, unsigned ch, CursorMetricPtr cm, ValidateGC((DrawablePtr) ppix, pGC); (*pGC->ops->PolyText16) ((DrawablePtr) ppix, pGC, cm->xhot, cm->yhot, 1, (unsigned short *) char2b); - (*pScreen->GetImage) ((DrawablePtr) ppix, 0, 0, cm->width, cm->height, - XYPixmap, 1, pbits); + ppix->drawable.ops->GetImage((DrawablePtr) ppix, 0, 0, + cm->width, cm->height, XYPixmap, 1, pbits); *ppbits = (unsigned char *) pbits; FreeScratchGC(pGC); (*pScreen->DestroyPixmap) (ppix); @@ -43,6 +43,29 @@ DevPrivateKeyRec exaScreenPrivateKeyRec; static ShmFuncs exaShmFuncs = { NULL, NULL }; #endif +DrawableOps * +exaGetDrawableOps(DrawablePtr draw) +{ + if (draw->type == DRAWABLE_WINDOW) + return dixLookupPrivate(&((WindowPtr)draw)->devPrivates, + exaWindowPrivateKey); + if (draw->type == DRAWABLE_PIXMAP) + return dixLookupPrivate(&((PixmapPtr)draw)->devPrivates, + exaPixmapPrivateKey); + return NULL; +} + +void +exaSetDrawableOps(DrawablePtr draw) +{ + if (draw->type == DRAWABLE_WINDOW) + dixSetPrivate(&((WindowPtr)draw)->devPrivates, exaWindowPrivateKey, + draw->ops); + if (draw->type == DRAWABLE_PIXMAP) + dixSetPrivate(&((PixmapPtr)draw)->devPrivates, exaPixmapPrivateKey, + draw->ops); +} + /** * exaGetPixmapOffset() returns the offset (in bytes) within the framebuffer of * the beginning of the given pixmap. @@ -770,8 +793,6 @@ exaCloseScreen(ScreenPtr pScreen) unwrap(pExaScr, pScreen, WakeupHandler); unwrap(pExaScr, pScreen, CreateGC); unwrap(pExaScr, pScreen, CloseScreen); - unwrap(pExaScr, pScreen, GetImage); - unwrap(pExaScr, pScreen, GetSpans); if (pExaScr->SavedCreatePixmap) unwrap(pExaScr, pScreen, CreatePixmap); if (pExaScr->SavedDestroyPixmap) @@ -814,6 +835,24 @@ exaDriverAlloc(void) return calloc(1, sizeof(ExaDriverRec)); } +static Bool +exaCreateWindow(WindowPtr pWin) +{ + Bool ret; + ScreenPtr pScreen = pWin->drawable.pScreen; + ExaScreenPriv(pScreen); + + unwrap(pExaScr, pScreen, CreateWindow); + + ret = pScreen->CreateWindow(pWin); + + pWin->drawable.ops = &exaDrawableOps; + + wrap(pExaScr, pScreen, CreateWindow, exaCreateWindow); + + return ret; +} + /** * @param pScreen screen being initialized * @param pScreenInfo EXA driver record @@ -902,6 +941,12 @@ exaDriverInit(ScreenPtr pScreen, ExaDriverPtr pScreenInfo) return FALSE; } + if (!dixRegisterPrivateKey(&exaWindowPrivateKeyRec, PRIVATE_WINDOW, 0)) + return FALSE; + + if (!dixRegisterPrivateKey(&exaPixmapPrivateKeyRec, PRIVATE_PIXMAP, 0)) + return FALSE; + pExaScr = calloc(sizeof(ExaScreenPrivRec), 1); if (!pExaScr) { LogMessage(X_WARNING, "EXA(%d): Failed to allocate screen private\n", @@ -936,8 +981,7 @@ exaDriverInit(ScreenPtr pScreen, ExaDriverPtr pScreenInfo) wrap(pExaScr, pScreen, WakeupHandler, ExaWakeupHandler); wrap(pExaScr, pScreen, CreateGC, exaCreateGC); wrap(pExaScr, pScreen, CloseScreen, exaCloseScreen); - wrap(pExaScr, pScreen, GetImage, exaGetImage); - wrap(pExaScr, pScreen, GetSpans, ExaCheckGetSpans); + wrap(pExaScr, pScreen, CreateWindow, exaCreateWindow); wrap(pExaScr, pScreen, CopyWindow, exaCopyWindow); wrap(pExaScr, pScreen, ChangeWindowAttributes, exaChangeWindowAttributes); wrap(pExaScr, pScreen, BitmapToRegion, exaBitmapToRegion); diff --git a/exa/exa_accel.c b/exa/exa_accel.c index 0e948f414..7db5d91a5 100644 --- a/exa/exa_accel.c +++ b/exa/exa_accel.c @@ -1298,3 +1298,8 @@ exaGetImage(DrawablePtr pDrawable, int x, int y, int w, int h, fallback: ExaCheckGetImage(pDrawable, x, y, w, h, format, planeMask, d); } + +DrawableOps exaDrawableOps = { + exaGetImage, + ExaCheckGetSpans, +}; diff --git a/exa/exa_classic.c b/exa/exa_classic.c index 1fa534bc6..a9c6b523b 100644 --- a/exa/exa_classic.c +++ b/exa/exa_classic.c @@ -141,6 +141,9 @@ exaCreatePixmap_classic(ScreenPtr pScreen, int w, int h, int depth, if (pExaScr->fallback_counter) exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_AUX_DEST); + exaSetDrawableOps(&pPixmap->drawable); + pPixmap->drawable.ops = &exaDrawableOps; + return pPixmap; } diff --git a/exa/exa_driver.c b/exa/exa_driver.c index d467ca928..c716e1ca2 100644 --- a/exa/exa_driver.c +++ b/exa/exa_driver.c @@ -124,6 +124,9 @@ exaCreatePixmap_driver(ScreenPtr pScreen, int w, int h, int depth, if (pExaScr->fallback_counter) exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_AUX_DEST); + exaSetDrawableOps(&pPixmap->drawable); + pPixmap->drawable.ops = &exaDrawableOps; + return pPixmap; } diff --git a/exa/exa_mixed.c b/exa/exa_mixed.c index 0fb409102..b247ae319 100644 --- a/exa/exa_mixed.c +++ b/exa/exa_mixed.c @@ -117,6 +117,9 @@ exaCreatePixmap_mixed(ScreenPtr pScreen, int w, int h, int depth, if (pExaScr->fallback_counter) exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_AUX_DEST); + exaSetDrawableOps(&pPixmap->drawable); + pPixmap->drawable.ops = &exaDrawableOps; + return pPixmap; } diff --git a/exa/exa_priv.h b/exa/exa_priv.h index 70075786a..067013d4a 100644 --- a/exa/exa_priv.h +++ b/exa/exa_priv.h @@ -153,10 +153,9 @@ typedef struct { ScreenWakeupHandlerProcPtr SavedWakeupHandler; CreateGCProcPtr SavedCreateGC; CloseScreenProcPtr SavedCloseScreen; - GetImageProcPtr SavedGetImage; - GetSpansProcPtr SavedGetSpans; CreatePixmapProcPtr SavedCreatePixmap; DestroyPixmapProcPtr SavedDestroyPixmap; + CreateWindowProcPtr SavedCreateWindow; CopyWindowProcPtr SavedCopyWindow; ChangeWindowAttributesProcPtr SavedChangeWindowAttributes; BitmapToRegionProcPtr SavedBitmapToRegion; @@ -226,9 +225,16 @@ typedef struct { #endif extern DevPrivateKeyRec exaScreenPrivateKeyRec; - #define exaScreenPrivateKey (&exaScreenPrivateKeyRec) +extern DevPrivateKeyRec exaWindowPrivateKeyRec; +#define exaWindowPrivateKey (&exaWindowPrivateKeyRec) + +extern DevPrivateKeyRec exaPixmapPrivateKeyRec; +#define exaPixmapPrivateKey (&exaPixmapPrivateKeyRec) + +extern DrawableOps exaDrawableOps; + #define ExaGetScreenPriv(s) ((ExaScreenPrivPtr)dixGetPrivate(&(s)->devPrivates, exaScreenPrivateKey)) #define ExaScreenPriv(s) ExaScreenPrivPtr pExaScr = ExaGetScreenPriv(s) @@ -736,4 +742,10 @@ void void exaPrepareAccessReg_classic(PixmapPtr pPixmap, int index, RegionPtr pReg); +DrawableOps * +exaGetDrawableOps(DrawablePtr draw); + +void +exaSetDrawableOps(DrawablePtr draw); + #endif /* EXAPRIV_H */ diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c index 571613886..0a04f8036 100644 --- a/exa/exa_unaccel.c +++ b/exa/exa_unaccel.c @@ -405,9 +405,10 @@ ExaCheckGetImage(DrawablePtr pDrawable, int x, int y, int w, int h, EXA_FALLBACK(("from %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable))); ExaFallbackPrepareReg(pDrawable, NULL, x, y, w, h, EXA_PREPARE_SRC, FALSE); - swap(pExaScr, pScreen, GetImage); - pScreen->GetImage(pDrawable, x, y, w, h, format, planeMask, d); - swap(pExaScr, pScreen, GetImage); + pDrawable->ops = exaGetDrawableOps(pDrawable); + pDrawable->ops->GetImage(pDrawable, x, y, w, h, format, planeMask, d); + exaSetDrawableOps(pDrawable); + pDrawable->ops = &exaDrawableOps; exaFinishAccess(pDrawable, EXA_PREPARE_SRC); EXA_POST_FALLBACK(pScreen); } @@ -422,9 +423,10 @@ ExaCheckGetSpans(DrawablePtr pDrawable, EXA_PRE_FALLBACK(pScreen); EXA_FALLBACK(("from %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable))); exaPrepareAccess(pDrawable, EXA_PREPARE_SRC); - swap(pExaScr, pScreen, GetSpans); - pScreen->GetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart); - swap(pExaScr, pScreen, GetSpans); + pDrawable->ops = exaGetDrawableOps(pDrawable); + pDrawable->ops->GetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart); + exaSetDrawableOps(pDrawable); + pDrawable->ops = &exaDrawableOps; exaFinishAccess(pDrawable, EXA_PREPARE_SRC); EXA_POST_FALLBACK(pScreen); } @@ -699,16 +701,16 @@ exaGetPixmapFirstPixel(PixmapPtr pPixmap) { CARD32 pixel; - pPixmap->drawable.pScreen->GetImage(&pPixmap->drawable, 0, 0, 1, 1, - ZPixmap, ~0, (char *) &pixel); + pPixmap->drawable.ops->GetImage(&pPixmap->drawable, 0, 0, 1, 1, + ZPixmap, ~0, (char *) &pixel); return pixel; } case 16: { CARD16 pixel; - pPixmap->drawable.pScreen->GetImage(&pPixmap->drawable, 0, 0, 1, 1, - ZPixmap, ~0, (char *) &pixel); + pPixmap->drawable.ops->GetImage(&pPixmap->drawable, 0, 0, 1, 1, + ZPixmap, ~0, (char *) &pixel); return pixel; } case 8: @@ -717,8 +719,8 @@ exaGetPixmapFirstPixel(PixmapPtr pPixmap) { CARD8 pixel; - pPixmap->drawable.pScreen->GetImage(&pPixmap->drawable, 0, 0, 1, 1, - ZPixmap, ~0, (char *) &pixel); + pPixmap->drawable.ops->GetImage(&pPixmap->drawable, 0, 0, 1, 1, + ZPixmap, ~0, (char *) &pixel); return pixel; } default: @@ -625,6 +625,8 @@ typedef struct { unsigned char bpp; /* current drawable bpp */ } FbGCPrivRec, *FbGCPrivPtr; +extern DrawableOps fbDrawableOps; + #define fbGetGCPrivateKey(pGC) (&fbGetScreenPrivate((pGC)->pScreen)->gcPrivateKeyRec) #define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\ diff --git a/fb/fbpixmap.c b/fb/fbpixmap.c index fbcdca99c..4c356b666 100644 --- a/fb/fbpixmap.c +++ b/fb/fbpixmap.c @@ -80,6 +80,7 @@ fbCreatePixmapBpp(ScreenPtr pScreen, int width, int height, int depth, int bpp, #endif pPixmap->usage_hint = usage_hint; + pPixmap->drawable.ops = &fbDrawableOps; return pPixmap; } diff --git a/fb/fbscreen.c b/fb/fbscreen.c index 7c7d6560e..6e3e8e46a 100644 --- a/fb/fbscreen.c +++ b/fb/fbscreen.c @@ -26,6 +26,11 @@ #include "fb.h" +DrawableOps fbDrawableOps = { + fbGetImage, + fbGetSpans, +}; + Bool fbCloseScreen(ScreenPtr pScreen) { @@ -102,8 +107,6 @@ fbSetupScreen(ScreenPtr pScreen, pointer pbits, /* pointer to screen bitmap */ pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0; pScreen->QueryBestSize = fbQueryBestSize; /* SaveScreen */ - pScreen->GetImage = fbGetImage; - pScreen->GetSpans = fbGetSpans; pScreen->CreateWindow = fbCreateWindow; pScreen->DestroyWindow = fbDestroyWindow; pScreen->PositionWindow = fbPositionWindow; diff --git a/fb/fbwindow.c b/fb/fbwindow.c index 368c4b883..e405fc6f6 100644 --- a/fb/fbwindow.c +++ b/fb/fbwindow.c @@ -36,6 +36,7 @@ fbCreateWindow(WindowPtr pWin) if (pWin->drawable.bitsPerPixel == 32) pWin->drawable.bitsPerPixel = fbGetScreenPrivate(pWin->drawable.pScreen)->win32bpp; + pWin->drawable.ops = &fbDrawableOps; return TRUE; } diff --git a/fb/wfbrename.h b/fb/wfbrename.h index 588440c2b..289ef6072 100644 --- a/fb/wfbrename.h +++ b/fb/wfbrename.h @@ -60,6 +60,7 @@ #define fbDots24 wfbDots24 #define fbDots32 wfbDots32 #define fbDots8 wfbDots8 +#define fbDrawableOps wfbDrawableOps #define fbEvenStipple wfbEvenStipple #define fbEvenTile wfbEvenTile #define fbExpandDirectColors wfbExpandDirectColors diff --git a/glx/glxdri.c b/glx/glxdri.c index a5d87ecac..b3a5ceae1 100644 --- a/glx/glxdri.c +++ b/glx/glxdri.c @@ -475,16 +475,16 @@ __glXDRIbindTexImage(__GLXcontext * baseContext, void *data = NULL; if (!override) { + DrawablePtr draw = &pixmap->drawable; unsigned pitch = PixmapBytePad(pixmap->drawable.width, pixmap->drawable.depth); data = malloc(pitch * pixmap->drawable.height); __glXenterServer(GL_FALSE); - pScreen->GetImage(&pixmap->drawable, 0 /*pixmap->drawable.x */ , - 0 /*pixmap->drawable.y */ , - pixmap->drawable.width, - pixmap->drawable.height, ZPixmap, ~0, data); + draw->ops->GetImage(draw, 0 /* draw->x */, + 0 /* draw->.y */, + draw->width, draw->height, ZPixmap, ~0, data); __glXleaveServer(GL_FALSE); if (pixmap->drawable.depth == 24) @@ -519,16 +519,16 @@ __glXDRIbindTexImage(__GLXcontext * baseContext, CALL_PixelStorei(GET_DISPATCH(), (GL_UNPACK_SKIP_ROWS, 0)); for (i = 0; i < numRects; i++) { + DrawablePtr draw = &pixmap->drawable; unsigned pitch = PixmapBytePad(p[i].x2 - p[i].x1, pixmap->drawable.depth); void *data = malloc(pitch * (p[i].y2 - p[i].y1)); __glXenterServer(GL_FALSE); - pScreen->GetImage(&pixmap->drawable, /*pixmap->drawable.x + */ - p[i].x1, - /*pixmap->drawable.y */ +p[i].y1, - p[i].x2 - p[i].x1, - p[i].y2 - p[i].y1, ZPixmap, ~0, data); + draw->ops->GetImage(draw, /* draw->x + */ p[i].x1, + /* draw->y */ + p[i].y1, + p[i].x2 - p[i].x1, p[i].y2 - p[i].y1, + ZPixmap, ~0, data); __glXleaveServer(GL_FALSE); if (pixmap->drawable.depth == 24) diff --git a/glx/glxdriswrast.c b/glx/glxdriswrast.c index b47839868..5266d5c9b 100644 --- a/glx/glxdriswrast.c +++ b/glx/glxdriswrast.c @@ -384,9 +384,8 @@ swrastGetImage(__DRIdrawable * draw, { __GLXDRIdrawable *drawable = loaderPrivate; DrawablePtr pDraw = drawable->base.pDraw; - ScreenPtr pScreen = pDraw->pScreen; - pScreen->GetImage(pDraw, x, y, w, h, ZPixmap, ~0L, data); + pDraw->ops->GetImage(pDraw, x, y, w, h, ZPixmap, ~0L, data); } static const __DRIswrastLoaderExtension swrastLoaderExtension = { diff --git a/hw/dmx/dmx.h b/hw/dmx/dmx.h index d7c620467..4ad15ff6e 100644 --- a/hw/dmx/dmx.h +++ b/hw/dmx/dmx.h @@ -214,9 +214,6 @@ typedef struct _DMXScreenInfo { ChangeBorderWidthProcPtr ChangeBorderWidth; - GetImageProcPtr GetImage; - GetSpansProcPtr GetSpans; - CreatePixmapProcPtr CreatePixmap; DestroyPixmapProcPtr DestroyPixmap; BitmapToRegionProcPtr BitmapToRegion; diff --git a/hw/dmx/dmxgcops.c b/hw/dmx/dmxgcops.c index 19330668a..e5bbdf78d 100644 --- a/hw/dmx/dmxgcops.c +++ b/hw/dmx/dmxgcops.c @@ -635,3 +635,8 @@ dmxGetSpans(DrawablePtr pDrawable, int wMax, { /* Error -- this should never happen! */ } + +DrawableOps dmxDrawableOps = { + dmxGetImage, + dmxGetSpans, +}; diff --git a/hw/dmx/dmxpixmap.c b/hw/dmx/dmxpixmap.c index 17aca9224..54c78da78 100644 --- a/hw/dmx/dmxpixmap.c +++ b/hw/dmx/dmxpixmap.c @@ -137,6 +137,8 @@ dmxCreatePixmap(ScreenPtr pScreen, int width, int height, int depth, DMX_WRAP(CreatePixmap, dmxCreatePixmap, dmxScreen, pScreen); #endif + pPixmap->drawable.ops = &dmxDrawableOps; + return pPixmap; } diff --git a/hw/dmx/dmxpixmap.h b/hw/dmx/dmxpixmap.h index 30bb666d5..7b4d7a096 100644 --- a/hw/dmx/dmxpixmap.h +++ b/hw/dmx/dmxpixmap.h @@ -39,6 +39,8 @@ #include "pixmapstr.h" +extern DrawableOps dmxDrawableOps; + /** Pixmap private area. */ typedef struct _dmxPixPriv { Pixmap pixmap; diff --git a/hw/dmx/dmxscrinit.c b/hw/dmx/dmxscrinit.c index 849ef16a1..f306bdf27 100644 --- a/hw/dmx/dmxscrinit.c +++ b/hw/dmx/dmxscrinit.c @@ -322,10 +322,6 @@ dmxScreenInit(ScreenPtr pScreen, int argc, char *argv[]) DMX_WRAP(ChangeBorderWidth, dmxChangeBorderWidth, dmxScreen, pScreen); - /* Wrap Image functions */ - DMX_WRAP(GetImage, dmxGetImage, dmxScreen, pScreen); - DMX_WRAP(GetSpans, dmxGetSpans, dmxScreen, pScreen); - /* Wrap Pixmap functions */ DMX_WRAP(CreatePixmap, dmxCreatePixmap, dmxScreen, pScreen); DMX_WRAP(DestroyPixmap, dmxDestroyPixmap, dmxScreen, pScreen); @@ -459,9 +455,6 @@ dmxCloseScreen(ScreenPtr pScreen) DMX_UNWRAP(ChangeBorderWidth, dmxScreen, pScreen); - DMX_UNWRAP(GetImage, dmxScreen, pScreen); - DMX_UNWRAP(GetSpans, dmxScreen, pScreen); - DMX_UNWRAP(CreatePixmap, dmxScreen, pScreen); DMX_UNWRAP(DestroyPixmap, dmxScreen, pScreen); DMX_UNWRAP(BitmapToRegion, dmxScreen, pScreen); diff --git a/hw/dmx/dmxwindow.c b/hw/dmx/dmxwindow.c index 855e56b9d..1387706ec 100644 --- a/hw/dmx/dmxwindow.c +++ b/hw/dmx/dmxwindow.c @@ -374,6 +374,8 @@ dmxCreateWindow(WindowPtr pWindow) dmxSync(dmxScreen, False); } + pWindow->drawable.ops = &dmxDrawableOps; + DMX_WRAP(CreateWindow, dmxCreateWindow, dmxScreen, pScreen); return ret; diff --git a/hw/xfree86/common/xf86VGAarbiter.c b/hw/xfree86/common/xf86VGAarbiter.c index 225fff06e..e0b752a63 100644 --- a/hw/xfree86/common/xf86VGAarbiter.c +++ b/hw/xfree86/common/xf86VGAarbiter.c @@ -193,9 +193,8 @@ xf86VGAarbiterWrapFunctions(void) WRAP_SCREEN(WakeupHandler, VGAarbiterWakeupHandler); WRAP_SCREEN(BlockHandler, VGAarbiterBlockHandler); WRAP_SCREEN(CreateGC, VGAarbiterCreateGC); - WRAP_SCREEN(GetImage, VGAarbiterGetImage); - WRAP_SCREEN(GetSpans, VGAarbiterGetSpans); WRAP_SCREEN(SourceValidate, VGAarbiterSourceValidate); + // WRAP_SCREEN(CreateWindow, VGAarbiterCreateWindow); WRAP_SCREEN(CopyWindow, VGAarbiterCopyWindow); WRAP_SCREEN(ClearToBackground, VGAarbiterClearToBackground); WRAP_SCREEN(CreatePixmap, VGAarbiterCreatePixmap); @@ -235,9 +234,8 @@ VGAarbiterCloseScreen(ScreenPtr pScreen) UNWRAP_SCREEN(CreateGC); UNWRAP_SCREEN(CloseScreen); - UNWRAP_SCREEN(GetImage); - UNWRAP_SCREEN(GetSpans); UNWRAP_SCREEN(SourceValidate); + UNWRAP_SCREEN(CreateWindow); UNWRAP_SCREEN(CopyWindow); UNWRAP_SCREEN(ClearToBackground); UNWRAP_SCREEN(SaveScreen); @@ -286,6 +284,9 @@ VGAarbiterWakeupHandler(ScreenPtr pScreen, unsigned long result, SCREEN_EPILOG(WakeupHandler, VGAarbiterWakeupHandler); } +/* XXX wrap */ + +#if 0 static void VGAarbiterGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h, @@ -313,6 +314,7 @@ VGAarbiterGetSpans(DrawablePtr pDrawable, VGAPut(); SCREEN_EPILOG(GetSpans, VGAarbiterGetSpans); } +#endif static void VGAarbiterSourceValidate(DrawablePtr pDrawable, diff --git a/hw/xfree86/common/xf86VGAarbiterPriv.h b/hw/xfree86/common/xf86VGAarbiterPriv.h index ba6edfcc3..5dbc68253 100644 --- a/hw/xfree86/common/xf86VGAarbiterPriv.h +++ b/hw/xfree86/common/xf86VGAarbiterPriv.h @@ -110,9 +110,8 @@ typedef struct _VGAarbiterScreen { CloseScreenProcPtr CloseScreen; ScreenBlockHandlerProcPtr BlockHandler; ScreenWakeupHandlerProcPtr WakeupHandler; - GetImageProcPtr GetImage; - GetSpansProcPtr GetSpans; SourceValidateProcPtr SourceValidate; + CreateWindowProcPtr CreateWindow; CopyWindowProcPtr CopyWindow; ClearToBackgroundProcPtr ClearToBackground; CreatePixmapProcPtr CreatePixmap; diff --git a/hw/xnest/GCOps.c b/hw/xnest/GCOps.c index e26a1363b..0595a82a7 100644 --- a/hw/xnest/GCOps.c +++ b/hw/xnest/GCOps.c @@ -113,6 +113,11 @@ xnestGetImage(DrawablePtr pDrawable, int x, int y, int w, int h, } } +DrawableOps xnestDrawableOps = { + xnestGetImage, + xnestGetSpans, +}; + static Bool xnestBitBlitPredicate(Display * display, XEvent * event, char *args) { diff --git a/hw/xnest/GCOps.h b/hw/xnest/GCOps.h index b1cad110c..10d5c1d4a 100644 --- a/hw/xnest/GCOps.h +++ b/hw/xnest/GCOps.h @@ -15,6 +15,8 @@ is" without express or implied warranty. #ifndef XNESTGCOPS_H #define XNESTGCOPS_H +#include "pixmapstr.h" + void xnestFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nSpans, xPoint * pPoints, int *pWidths, int fSorted); void xnestSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *pSrc, @@ -65,4 +67,6 @@ void xnestPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y, void xnestPushPixels(GCPtr pGC, PixmapPtr pBitmap, DrawablePtr pDrawable, int width, int height, int x, int y); +extern DrawableOps xnestDrawableOps; + #endif /* XNESTGCOPS_H */ diff --git a/hw/xnest/Pixmap.c b/hw/xnest/Pixmap.c index 13e1610fd..79db6216a 100644 --- a/hw/xnest/Pixmap.c +++ b/hw/xnest/Pixmap.c @@ -31,6 +31,7 @@ is" without express or implied warranty. #include "Display.h" #include "Screen.h" #include "XNPixmap.h" +#include "GCOps.h" DevPrivateKeyRec xnestPixmapPrivateKeyRec; @@ -65,6 +66,8 @@ xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth, else xnestPixmapPriv(pPixmap)->pixmap = 0; + pPixmap->drawable.ops = &xnestDrawableOps; + return pPixmap; } diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c index 58b5a1199..770409ab2 100644 --- a/hw/xnest/Screen.c +++ b/hw/xnest/Screen.c @@ -261,8 +261,6 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) pScreen->QueryBestSize = xnestQueryBestSize; pScreen->SaveScreen = xnestSaveScreen; - pScreen->GetImage = xnestGetImage; - pScreen->GetSpans = xnestGetSpans; pScreen->SourceValidate = NULL; /* Window Procedures */ diff --git a/hw/xnest/Window.c b/hw/xnest/Window.c index e2b21b58e..c8f4c485a 100644 --- a/hw/xnest/Window.c +++ b/hw/xnest/Window.c @@ -38,6 +38,7 @@ is" without express or implied warranty. #include "Visual.h" #include "Events.h" #include "Args.h" +#include "GCOps.h" DevPrivateKeyRec xnestWindowPrivateKeyRec; @@ -143,6 +144,8 @@ xnestCreateWindow(WindowPtr pWin) if (!pWin->parent) /* only the root window will have the right colormap */ xnestSetInstalledColormapWindows(pWin->drawable.pScreen); + pWin->drawable.ops = &xnestDrawableOps; + return True; } diff --git a/include/pixmapstr.h b/include/pixmapstr.h index 2a1ef9b85..c306acb84 100644 --- a/include/pixmapstr.h +++ b/include/pixmapstr.h @@ -52,6 +52,22 @@ SOFTWARE. #include "privates.h" #include "damage.h" +typedef void (*GetImageProcPtr) (DrawablePtr pDrawable, + int sx, int sy, int w, int h, + unsigned int format, + unsigned long planeMask, + char *pdstLine); + +typedef void (*GetSpansProcPtr) (DrawablePtr pDrawable, + int wMax, DDXPointPtr ppt, + int *pwidt, int nspans, + char *pdstStart); + +typedef struct DrawableOps { + GetImageProcPtr GetImage; + GetSpansProcPtr GetSpans; +} DrawableOps; + typedef struct _Drawable { unsigned char type; /* DRAWABLE_<type> */ unsigned char class; /* specific to type */ @@ -64,6 +80,7 @@ typedef struct _Drawable { unsigned short height; ScreenPtr pScreen; unsigned long serialNumber; + DrawableOps *ops; } DrawableRec; /* diff --git a/include/scrnintstr.h b/include/scrnintstr.h index df7407391..47222a10b 100644 --- a/include/scrnintstr.h +++ b/include/scrnintstr.h @@ -105,22 +105,6 @@ typedef void (*QueryBestSizeProcPtr) (int /*class */ , typedef Bool (*SaveScreenProcPtr) (ScreenPtr /*pScreen */ , int /*on */ ); -typedef void (*GetImageProcPtr) (DrawablePtr /*pDrawable */ , - int /*sx */ , - int /*sy */ , - int /*w */ , - int /*h */ , - unsigned int /*format */ , - unsigned long /*planeMask */ , - char * /*pdstLine */ ); - -typedef void (*GetSpansProcPtr) (DrawablePtr /*pDrawable */ , - int /*wMax */ , - DDXPointPtr /*ppt */ , - int * /*pwidth */ , - int /*nspans */ , - char * /*pdstStart */ ); - typedef void (*SourceValidateProcPtr) (DrawablePtr /*pDrawable */ , int /*x */ , int /*y */ , @@ -388,8 +372,6 @@ typedef struct _Screen { CloseScreenProcPtr CloseScreen; QueryBestSizeProcPtr QueryBestSize; SaveScreenProcPtr SaveScreen; - GetImageProcPtr GetImage; - GetSpansProcPtr GetSpans; SourceValidateProcPtr SourceValidate; /* Window Procedures */ diff --git a/mi/mibitblt.c b/mi/mibitblt.c index b9873c16d..3dde410fe 100644 --- a/mi/mibitblt.c +++ b/mi/mibitblt.c @@ -223,9 +223,9 @@ miCopyArea(DrawablePtr pSrcDrawable, } pbits = malloc(height * PixmapBytePad(width, pSrcDrawable->depth)); if (pbits) { - (*pSrcDrawable->pScreen->GetSpans) (pSrcDrawable, width, pptFirst, - (int *) pwidthFirst, height, - (char *) pbits); + pSrcDrawable->ops->GetSpans(pSrcDrawable, width, pptFirst, + (int *) pwidthFirst, height, + (char *) pbits); ppt = pptFirst; pwidth = pwidthFirst; xMin -= (srcx - dstx); @@ -262,8 +262,7 @@ miCopyArea(DrawablePtr pSrcDrawable, * This should be replaced with something more general. mi shouldn't have to * care about such things as scanline padding et alia. */ -static -MiBits * +static MiBits * miGetPlane(DrawablePtr pDraw, int planeNum, /* number of the bitPlane */ int sx, int sy, int w, int h, MiBits * result) { @@ -314,16 +313,16 @@ miGetPlane(DrawablePtr pDraw, int planeNum, /* number of the bitPlane */ for (i = h; --i >= 0; pt.y++) { pt.x = sx; if (bitsPerPixel == 1) { - (*pDraw->pScreen->GetSpans) (pDraw, width, &pt, &width, 1, - (char *) pCharsOut); + pDraw->ops->GetSpans(pDraw, width, &pt, &width, 1, + (char *) pCharsOut); pCharsOut += widthInBytes; } else { k = 0; for (j = w; --j >= 0; pt.x++) { /* Fetch the next pixel */ - (*pDraw->pScreen->GetSpans) (pDraw, width, &pt, &width, 1, - (char *) &pixel); + pDraw->ops->GetSpans(pDraw, width, &pt, &width, 1, + (char *) &pixel); /* * Now get the bit and insert into a bitmap in XY format. */ @@ -647,15 +646,15 @@ miGetImage(DrawablePtr pDraw, int sx, int sy, int w, int h, pt.x = srcx; pt.y = srcy + i; width = w; - (*pDraw->pScreen->GetSpans) (pDraw, w, &pt, &width, 1, pDst); + pDraw->ops->GetSpans(pDraw, w, &pt, &width, 1, pDst); if (pPixmap) { pt.x = 0; pt.y = 0; width = w; (*pGC->ops->SetSpans) ((DrawablePtr) pPixmap, pGC, pDst, &pt, &width, 1, TRUE); - (*pDraw->pScreen->GetSpans) ((DrawablePtr) pPixmap, w, &pt, - &width, 1, pDst); + pDraw->ops->GetSpans((DrawablePtr) pPixmap, w, &pt, &width, 1, + pDst); } pDst += linelength; } diff --git a/mi/mipushpxl.c b/mi/mipushpxl.c index 9a78f4050..3c182c5a9 100644 --- a/mi/mipushpxl.c +++ b/mi/mipushpxl.c @@ -126,9 +126,8 @@ miPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDrawable, for (h = 0, ptThisLine.x = 0, ptThisLine.y = 0; h < dy; h++, ptThisLine.y++) { - (*pBitMap->drawable.pScreen->GetSpans) ((DrawablePtr) pBitMap, dx, - &ptThisLine, &dx, 1, - (char *) pwLineStart); + pBitMap->drawable.ops->GetSpans((DrawablePtr) pBitMap, dx, &ptThisLine, + &dx, 1, (char *) pwLineStart); pw = pwLineStart; /* Process all words which are fully in the pixmap */ diff --git a/mi/misprite.c b/mi/misprite.c index 97bbf8ef5..0b50793a4 100644 --- a/mi/misprite.c +++ b/mi/misprite.c @@ -72,11 +72,10 @@ typedef struct { typedef struct { /* screen procedures */ CloseScreenProcPtr CloseScreen; - GetImageProcPtr GetImage; - GetSpansProcPtr GetSpans; SourceValidateProcPtr SourceValidate; /* window procedures */ + CreateWindowProcPtr CreateWindow; CopyWindowProcPtr CopyWindow; /* colormap procedures */ @@ -183,8 +182,10 @@ miSpriteIsDown(miCursorInfoPtr pDevCursor) */ static DevPrivateKeyRec miSpriteScreenKeyRec; +static DevPrivateKeyRec miSpriteWindowKeyRec; #define miSpriteScreenKey (&miSpriteScreenKeyRec) +#define miSpriteWindowKey (&miSpriteWindowKeyRec) #define GetSpriteScreen(pScreen) \ (dixLookupPrivate(&(pScreen)->devPrivates, miSpriteScreenKey)) static DevPrivateKeyRec miSpriteDevPrivatesKeyRec; @@ -201,6 +202,7 @@ static void miSpriteGetSpans(DrawablePtr pDrawable, int wMax, static void miSpriteSourceValidate(DrawablePtr pDrawable, int x, int y, int width, int height, unsigned int subWindowMode); +static Bool miSpriteCreateWindow(WindowPtr pWindow); static void miSpriteCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc); static void miSpriteBlockHandler(ScreenPtr pScreen, @@ -241,6 +243,11 @@ miPointerSpriteFuncRec miSpritePointerFuncs = { miSpriteDeviceCursorCleanup, }; +static DrawableOps miSpriteDrawableOps = { + miSpriteGetImage, + miSpriteGetSpans, +}; + /* * other misc functions */ @@ -297,6 +304,9 @@ miSpriteInitialize(ScreenPtr pScreen, miPointerScreenFuncPtr screenFuncs) if (!dixRegisterPrivateKey(&miSpriteScreenKeyRec, PRIVATE_SCREEN, 0)) return FALSE; + if (!dixRegisterPrivateKey(&miSpriteWindowKeyRec, PRIVATE_WINDOW, 0)) + return FALSE; + if (!dixRegisterPrivateKey (&miSpriteDevPrivatesKeyRec, PRIVATE_DEVICE, sizeof(miCursorInfoRec))) return FALSE; @@ -318,10 +328,8 @@ miSpriteInitialize(ScreenPtr pScreen, miPointerScreenFuncPtr screenFuncs) pVisual->vid != pScreen->rootVisual; pVisual++); pScreenPriv->pVisual = pVisual; pScreenPriv->CloseScreen = pScreen->CloseScreen; - pScreenPriv->GetImage = pScreen->GetImage; - pScreenPriv->GetSpans = pScreen->GetSpans; pScreenPriv->SourceValidate = pScreen->SourceValidate; - + pScreenPriv->CreateWindow = pScreen->CreateWindow; pScreenPriv->CopyWindow = pScreen->CopyWindow; pScreenPriv->InstallColormap = pScreen->InstallColormap; @@ -346,10 +354,8 @@ miSpriteInitialize(ScreenPtr pScreen, miPointerScreenFuncPtr screenFuncs) dixSetPrivate(&pScreen->devPrivates, miSpriteScreenKey, pScreenPriv); pScreen->CloseScreen = miSpriteCloseScreen; - pScreen->GetImage = miSpriteGetImage; - pScreen->GetSpans = miSpriteGetSpans; pScreen->SourceValidate = miSpriteSourceValidate; - + pScreen->CreateWindow = miSpriteCreateWindow; pScreen->CopyWindow = miSpriteCopyWindow; pScreen->InstallColormap = miSpriteInstallColormap; pScreen->StoreColors = miSpriteStoreColors; @@ -372,9 +378,8 @@ miSpriteCloseScreen(ScreenPtr pScreen) miSpriteScreenPtr pScreenPriv = GetSpriteScreen(pScreen); pScreen->CloseScreen = pScreenPriv->CloseScreen; - pScreen->GetImage = pScreenPriv->GetImage; - pScreen->GetSpans = pScreenPriv->GetSpans; pScreen->SourceValidate = pScreenPriv->SourceValidate; + pScreen->CreateWindow = pScreenPriv->CreateWindow; pScreen->InstallColormap = pScreenPriv->InstallColormap; pScreen->StoreColors = pScreenPriv->StoreColors; @@ -385,6 +390,22 @@ miSpriteCloseScreen(ScreenPtr pScreen) return (*pScreen->CloseScreen) (pScreen); } +static DrawableOps * +miSpriteGetWrappedOps(DrawablePtr draw) +{ + WindowPtr win = (WindowPtr) draw; + + return dixLookupPrivate(&win->devPrivates, miSpriteWindowKey); +} + +static void +miSpriteSetWrappedOps(DrawablePtr draw) +{ + WindowPtr win = (WindowPtr) draw; + + dixSetPrivate(&win->devPrivates, miSpriteWindowKey, draw->ops); +} + static void miSpriteGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h, unsigned int format, unsigned long planemask, char *pdstLine) @@ -392,10 +413,8 @@ miSpriteGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h, ScreenPtr pScreen = pDrawable->pScreen; DeviceIntPtr pDev; miCursorInfoPtr pCursorInfo; - miSpriteScreenPtr pPriv = GetSpriteScreen(pScreen); - - SCREEN_PROLOGUE(pPriv, pScreen, GetImage); + pDrawable->ops = miSpriteGetWrappedOps(pDrawable); if (pDrawable->type == DRAWABLE_WINDOW) { for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { if (DevHasCursor(pDev)) { @@ -410,9 +429,11 @@ miSpriteGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h, } } - (*pScreen->GetImage) (pDrawable, sx, sy, w, h, format, planemask, pdstLine); + pDrawable->ops->GetImage(pDrawable, sx, sy, w, h, format, planemask, + pdstLine); - SCREEN_EPILOGUE(pPriv, pScreen, GetImage); + miSpriteSetWrappedOps(pDrawable); + pDrawable->ops = &miSpriteDrawableOps; } static void @@ -422,10 +443,8 @@ miSpriteGetSpans(DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, ScreenPtr pScreen = pDrawable->pScreen; DeviceIntPtr pDev; miCursorInfoPtr pCursorInfo; - miSpriteScreenPtr pPriv = GetSpriteScreen(pScreen); - - SCREEN_PROLOGUE(pPriv, pScreen, GetSpans); + pDrawable->ops = miSpriteGetWrappedOps(pDrawable); if (pDrawable->type == DRAWABLE_WINDOW) { for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { if (DevHasCursor(pDev)) { @@ -454,9 +473,10 @@ miSpriteGetSpans(DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, } } - (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart); + pDrawable->ops->GetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart); - SCREEN_EPILOGUE(pPriv, pScreen, GetSpans); + miSpriteSetWrappedOps(pDrawable); + pDrawable->ops = &miSpriteDrawableOps; } static void @@ -491,6 +511,25 @@ miSpriteSourceValidate(DrawablePtr pDrawable, int x, int y, int width, SCREEN_EPILOGUE(pPriv, pScreen, SourceValidate); } +static Bool +miSpriteCreateWindow(WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + miSpriteScreenPtr pPriv = GetSpriteScreen(pScreen); + Bool ret; + + SCREEN_PROLOGUE(pPriv, pScreen, CreateWindow); + ret = pScreen->CreateWindow(pWin); + + /* wrap in */ + miSpriteSetWrappedOps(&pWin->drawable); + pWin->drawable.ops = &miSpriteDrawableOps; + + SCREEN_EPILOGUE(pPriv, pScreen, CreateWindow); + + return ret; +} + static void miSpriteCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc) { diff --git a/miext/shadow/shadow.c b/miext/shadow/shadow.c index 2d869e54b..509f40f25 100644 --- a/miext/shadow/shadow.c +++ b/miext/shadow/shadow.c @@ -37,9 +37,14 @@ #include "shadow.h" static DevPrivateKeyRec shadowScrPrivateKeyRec; - #define shadowScrPrivateKey (&shadowScrPrivateKeyRec) +static DevPrivateKeyRec shadowWinPrivateKeyRec; +#define shadowWinPrivateKey (&shadowWinPrivateKeyRec) + +/* forward */ +static DrawableOps shadowDrawableOps; + #define wrap(priv, real, mem) {\ priv->mem = real->mem; \ real->mem = shadow##mem; \ @@ -77,20 +82,70 @@ shadowWakeupHandler(pointer data, int i, pointer LastSelectMask) { } +static DrawableOps * +shadowGetWrappedOps(DrawablePtr draw) +{ + WindowPtr win = (WindowPtr) draw; + + return dixLookupPrivate(&win->devPrivates, shadowWinPrivateKey); +} + +static void +shadowSetWrappedOps(DrawablePtr draw) +{ + WindowPtr win = (WindowPtr) draw; + + dixSetPrivate(&win->devPrivates, shadowWinPrivateKey, draw->ops); +} + static void shadowGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h, unsigned int format, unsigned long planeMask, char *pdstLine) { ScreenPtr pScreen = pDrawable->pScreen; - shadowBuf(pScreen); + /* Many apps use GetImage to sync with the visable frame buffer */ + shadowRedisplay(pScreen); + pDrawable->ops = shadowGetWrappedOps(pDrawable); + pDrawable->ops->GetImage(pDrawable, sx, sy, w, h, format, planeMask, + pdstLine); + shadowSetWrappedOps(pDrawable); + pDrawable->ops = &shadowDrawableOps; +} + +static void +shadowGetSpans(DrawablePtr pDraw, int wMax, DDXPointPtr ppt, int *pwidth, + int nspans, char *pdstStart) +{ + ScreenPtr pScreen = pDraw->pScreen; /* Many apps use GetImage to sync with the visable frame buffer */ - if (pDrawable->type == DRAWABLE_WINDOW) - shadowRedisplay(pScreen); - unwrap(pBuf, pScreen, GetImage); - pScreen->GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine); - wrap(pBuf, pScreen, GetImage); + shadowRedisplay(pScreen); + pDraw->ops = shadowGetWrappedOps(pDraw); + pDraw->ops->GetSpans(pDraw, wMax, ppt, pwidth, nspans, pdstStart); + shadowSetWrappedOps(pDraw); + pDraw->ops = &shadowDrawableOps; +} + +static DrawableOps shadowDrawableOps = { + shadowGetImage, + shadowGetSpans, +}; + +static Bool +shadowCreateWindow(WindowPtr win) +{ + Bool ret; + ScreenPtr pScreen = win->drawable.pScreen; + shadowBuf(pScreen); + + unwrap(pBuf, pScreen, CreateWindow); + ret = pScreen->CreateWindow(win); + shadowSetWrappedOps(&win->drawable); + win->drawable.ops = &shadowDrawableOps; + wrap(pBuf, pScreen, CreateWindow); + + return ret; } #define BACKWARDS_COMPATIBILITY @@ -100,7 +155,7 @@ shadowCloseScreen(ScreenPtr pScreen) { shadowBuf(pScreen); - unwrap(pBuf, pScreen, GetImage); + unwrap(pBuf, pScreen, CreateWindow); unwrap(pBuf, pScreen, CloseScreen); shadowRemove(pScreen, pBuf->pPixmap); DamageDestroy(pBuf->pDamage); @@ -141,6 +196,9 @@ shadowSetup(ScreenPtr pScreen) if (!dixRegisterPrivateKey(&shadowScrPrivateKeyRec, PRIVATE_SCREEN, 0)) return FALSE; + if (!dixRegisterPrivateKey(&shadowWinPrivateKeyRec, PRIVATE_WINDOW, 0)) + return FALSE; + if (!DamageSetup(pScreen)) return FALSE; @@ -162,7 +220,7 @@ shadowSetup(ScreenPtr pScreen) } wrap(pBuf, pScreen, CloseScreen); - wrap(pBuf, pScreen, GetImage); + wrap(pBuf, pScreen, CreateWindow); pBuf->update = 0; pBuf->window = 0; pBuf->pPixmap = 0; diff --git a/miext/shadow/shadow.h b/miext/shadow/shadow.h index 83de22ccc..675aa8767 100644 --- a/miext/shadow/shadow.h +++ b/miext/shadow/shadow.h @@ -54,7 +54,7 @@ typedef struct _shadowBuf { int randr; /* screen wrappers */ - GetImageProcPtr GetImage; + CreateWindowProcPtr CreateWindow; CloseScreenProcPtr CloseScreen; } shadowBufRec; diff --git a/render/mipict.c b/render/mipict.c index 2e64b20ff..de890d94c 100644 --- a/render/mipict.c +++ b/render/mipict.c @@ -457,14 +457,11 @@ miFillColor(CARD32 pixel, int bits) Bool miIsSolidAlpha(PicturePtr pSrc) { - ScreenPtr pScreen; char line[1]; if (!pSrc->pDrawable) return FALSE; - pScreen = pSrc->pDrawable->pScreen; - /* Alpha-only */ if (PICT_FORMAT_TYPE(pSrc->format) != PICT_TYPE_A) return FALSE; @@ -475,7 +472,8 @@ miIsSolidAlpha(PicturePtr pSrc) if (pSrc->pDrawable->width != 1 || pSrc->pDrawable->height != 1) return FALSE; line[0] = 1; - (*pScreen->GetImage) (pSrc->pDrawable, 0, 0, 1, 1, ZPixmap, ~0L, line); + pSrc->pDrawable->ops->GetImage(pSrc->pDrawable, 0, 0, 1, 1, ZPixmap, ~0L, + line); switch (pSrc->pDrawable->bitsPerPixel) { case 1: return (CARD8) line[0] == 1 || (CARD8) line[0] == 0x80; diff --git a/render/render.c b/render/render.c index 51f75ae7e..32ed71740 100644 --- a/render/render.c +++ b/render/render.c @@ -1506,9 +1506,8 @@ ProcRenderCreateCursor(ClientPtr client) } if (pSrc->format == PICT_a8r8g8b8) { - (*pScreen->GetImage) (pSrc->pDrawable, - 0, 0, width, height, ZPixmap, - 0xffffffff, (pointer) argbbits); + pSrc->pDrawable->ops->GetImage(pSrc->pDrawable, 0, 0, width, height, + ZPixmap, 0xffffffff, (pointer) argbbits); } else { PixmapPtr pPixmap; @@ -1542,9 +1541,9 @@ ProcRenderCreateCursor(ClientPtr client) (*pScreen->DestroyPixmap) (pPixmap); CompositePicture(PictOpSrc, pSrc, 0, pPicture, 0, 0, 0, 0, 0, 0, width, height); - (*pScreen->GetImage) (pPicture->pDrawable, - 0, 0, width, height, ZPixmap, - 0xffffffff, (pointer) argbbits); + pPicture->pDrawable->ops->GetImage(pPicture->pDrawable, 0, 0, + width, height, ZPixmap, + 0xffffffff, (pointer) argbbits); FreePicture(pPicture, 0); } /* |