From 8c73c1c880214dba26f9d42204f199478d8afde7 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 20 Sep 2012 14:04:56 +1000 Subject: impedance: add drawable->pixmap lookup --- dix/impedance.c | 79 +++++++++++++++++++++++++++++------------------------ dix/pixmap.c | 29 ++++++++++++++++++++ exa/exa.c | 5 +--- include/impedance.h | 10 ------- include/pixmap.h | 2 ++ render/impedpict.c | 31 +++++++++++---------- 6 files changed, 92 insertions(+), 64 deletions(-) diff --git a/dix/impedance.c b/dix/impedance.c index 3712875d0..78edb38e6 100644 --- a/dix/impedance.c +++ b/dix/impedance.c @@ -55,7 +55,7 @@ impedGetWinPrivateKey (void) void impedValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable) { - PixmapPtr pPixmap = GetDrawablePixmap(pDrawable); + PixmapPtr pPixmap = GetDrawablePixmap(pDrawable->pScreen, pDrawable); GCPtr pDrvGC; int i; int x_off = 0, y_off = 0; @@ -248,7 +248,7 @@ impedFillSpans (DrawablePtr pDrawable, { int i; int x_off, y_off; - PixmapPtr pPixmap = GetDrawablePixmap(pDrawable); + PixmapPtr pPixmap = GetDrawablePixmap(pDrawable->pScreen, pDrawable); impedGetDrawableDeltas(pDrawable, pPixmap, &x_off, &y_off); for (i = 0; i < nInit; i++) { pptInit[i].x += x_off; @@ -274,7 +274,7 @@ impedSetSpans (DrawablePtr pDrawable, { int i; int x_off, y_off; - PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable); + PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable->pScreen, pDrawable); impedGetDrawableDeltas(pDrawable, pPixmap, &x_off, &y_off); for (i = 0; i < nspans; i++) { @@ -305,7 +305,7 @@ impedPutImage (DrawablePtr pDrawable, char *pImage) { int x_off, y_off; - PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable); + PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable->pScreen, pDrawable); impedGetDrawableDeltas(pDrawable, pPixmap, &x_off, &y_off); x += x_off; @@ -326,7 +326,7 @@ impedPolyPoint (DrawablePtr pDrawable, xPoint *pptInit) { int i; - PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable); + PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable->pScreen, pDrawable); int x_off, y_off; xPoint *origPts; @@ -358,7 +358,7 @@ impedPolyLines (DrawablePtr pDrawable, DDXPointPtr ppt) { int i; - PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable); + PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable->pScreen, pDrawable); int x_off, y_off; DDXPointPtr ppt_orig; impedGetDrawableDeltas(pDrawable, pPixmap, &x_off, &y_off); @@ -392,7 +392,7 @@ impedPolySegment (DrawablePtr pDrawable, xSegment *pSegs) { int i; - PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable); + PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable->pScreen, pDrawable); int x_off, y_off; xSegment *pSegs_orig; @@ -420,7 +420,7 @@ static void impedPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nrects, xRectangle *pRects) { int i; - PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable); + PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable->pScreen, pDrawable); int x_off, y_off; xRectangle *orig_pRects; @@ -445,7 +445,7 @@ static void impedPolyArc (DrawablePtr pDrawable, xArc *parcs) { int i; - PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable); + PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable->pScreen, pDrawable); int x_off, y_off; xArc *orig_arcs; impedGetDrawableDeltas(pDrawable, pPixmap, &x_off, &y_off); @@ -470,7 +470,7 @@ static void impedFillPolygon( DrawablePtr pDrawable, GCPtr pGC, int count, DDXPointPtr pPts) { int i; - PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable); + PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable->pScreen, pDrawable); int x_off, y_off; DDXPointPtr orig_pts; impedGetDrawableDeltas(pDrawable, pPixmap, &x_off, &y_off); @@ -497,7 +497,7 @@ static void impedPolyFillRect(DrawablePtr pDrawable, xRectangle *prectInit) { int i; - PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable); + PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable->pScreen, pDrawable); int x_off, y_off; xRectangle *orig_prect; @@ -521,7 +521,7 @@ static void impedPolyFillRect(DrawablePtr pDrawable, static void impedPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs) { int i; - PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable); + PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable->pScreen, pDrawable); int x_off, y_off; xArc *orig_arcs; @@ -546,7 +546,7 @@ static int impedPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, char *chars) { int i, ret = 0; - PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable); + PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable->pScreen, pDrawable); int x_off, y_off; GCPtr pDrvGC; impedGetDrawableDeltas(pDrawable, pPixmap, &x_off, &y_off); @@ -563,7 +563,7 @@ impedPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, unsig { int ret = 0; int i; - PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable); + PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable->pScreen, pDrawable); int x_off, y_off; GCPtr pDrvGC; @@ -581,7 +581,7 @@ impedPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, unsig static void impedImageText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, char *chars) { - PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable); + PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable->pScreen, pDrawable); int x_off, y_off; impedGetDrawableDeltas(pDrawable, pPixmap, &x_off, &y_off); @@ -592,7 +592,7 @@ impedImageText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, char static void impedImageText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, unsigned short *chars) { - PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable); + PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable->pScreen, pDrawable); int x_off, y_off; impedGetDrawableDeltas(pDrawable, pPixmap, &x_off, &y_off); @@ -609,7 +609,7 @@ impedPolyGlyphBlt (DrawablePtr pDrawable, pointer pglyphBase) { int x_off, y_off; - PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable); + PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable->pScreen, pDrawable); impedGetDrawableDeltas(pDrawable, pPixmap, &x_off, &y_off); x += x_off; @@ -630,7 +630,7 @@ impedImageGlyphBlt (DrawablePtr pDrawable, pointer pglyphBase) { int x_off, y_off; - PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable); + PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable->pScreen, pDrawable); impedGetDrawableDeltas(pDrawable, pPixmap, &x_off, &y_off); x += x_off; @@ -656,9 +656,9 @@ impedCopyNtoN (DrawablePtr pSrcDrawable, miCopyProc copy; int src_x_off, src_y_off; int dst_x_off, dst_y_off; - PixmapPtr pSrcPixmap = (PixmapPtr)GetDrawablePixmap(pSrcDrawable); - PixmapPtr pDstPixmap = (PixmapPtr)GetDrawablePixmap(pDstDrawable); - int i; + PixmapPtr pSrcPixmap = (PixmapPtr)GetDrawablePixmap(pSrcDrawable->pScreen, pSrcDrawable); + PixmapPtr pDstPixmap = (PixmapPtr)GetDrawablePixmap(pDstDrawable->pScreen, pDstDrawable); + int i = 0; GCPtr pDrvGC = NULL; impedGetCompositeDeltas(pSrcDrawable, pSrcPixmap, &src_x_off, &src_y_off); @@ -678,19 +678,26 @@ impedCopyNtoN (DrawablePtr pSrcDrawable, } } - for (i = 0; i < pSrcDrawable->pScreen->num_gpu; i++) { - copy = pSrcDrawable->pScreen->gpu[i]->GetCopyAreaFunction(&pSrcPixmap->gpu[i]->drawable, &pDstPixmap->gpu[i]->drawable); + i = 0; + /* convert to GPU pixmaps */ + if (!pSrcPixmap->drawable.pScreen->isGPU) { + pSrcPixmap = &pSrcPixmap->gpu[i]->drawable; + } - if (pGC) { - pDrvGC = pGC->gpu[i]; - } - - copy(&pSrcPixmap->gpu[i]->drawable, - &pDstPixmap->gpu[i]->drawable, - pDrvGC, pbox, nbox, dx, dy, reverse, - upsidedown, bitplane, closure); + if (!pDstPixmap->drawable.pScreen->isGPU) { + pDstPixmap = &pDstPixmap->gpu[i]->drawable; } + copy = pSrcPixmap->drawable.pScreen->GetCopyAreaFunction(&pSrcPixmap->drawable, &pDstPixmap->drawable); + + if (pGC) { + pDrvGC = pGC->gpu[i]; + } + + copy(&pSrcPixmap->drawable, + &pDstPixmap->drawable, + pDrvGC, pbox, nbox, dx, dy, reverse, + upsidedown, bitplane, closure); } static RegionPtr @@ -769,8 +776,8 @@ impedCopyPlane (DrawablePtr pSrcDrawable, // drvCopyProc copy; PixmapPtr pSrcPixmap, pDstPixmap; - pSrcPixmap = GetDrawablePixmap(pSrcDrawable); - pDstPixmap = GetDrawablePixmap(pDstDrawable); + pSrcPixmap = GetDrawablePixmap(pSrcDrawable->pScreen, pSrcDrawable); + pDstPixmap = GetDrawablePixmap(pSrcDrawable->pScreen, pDstDrawable); #if 0 copy = imped_src_screen->gpu[0]->GetCopyPlaneFunction(imped_src_pixmap->gpu[0], @@ -804,7 +811,7 @@ impedPushPixels (GCPtr pGC, int yOrg) { int x_off, y_off; - PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable); + PixmapPtr pPixmap = (PixmapPtr)GetDrawablePixmap(pDrawable->pScreen, pDrawable); impedGetDrawableDeltas(pDrawable, pPixmap, &x_off, &y_off); xOrg += x_off; @@ -991,7 +998,7 @@ impedGetImage (DrawablePtr pDrawable, { ScreenPtr pScreen = pDrawable->pScreen; RegionRec img_region; - PixmapPtr pPixmap = GetDrawablePixmap(pDrawable); + PixmapPtr pPixmap = GetDrawablePixmap(pDrawable->pScreen, pDrawable); int x_off, y_off; if (!impedDrawableEnabled(pDrawable)) @@ -1038,6 +1045,8 @@ impedCreatePixmap (ScreenPtr pScreen, int width, int height, int depth, pPixmap->drawable.height = height; pPixmap->devKind = (width * (BitsPerPixel(depth)/8)); pPixmap->refcnt = 1; + pPixmap->gpu[0] = NULL; + pPixmap->master_pixmap = NULL; #ifdef COMPOSITE pPixmap->screen_x = 0; diff --git a/dix/pixmap.c b/dix/pixmap.c index 241881262..43af9354f 100644 --- a/dix/pixmap.c +++ b/dix/pixmap.c @@ -268,3 +268,32 @@ Bool PixmapSyncDirtyHelper(PixmapDirtyUpdatePtr dirty, RegionPtr dirty_region) pScreen->SourceValidate = SourceValidate; return TRUE; } + +PixmapPtr GetDrawablePixmap(ScreenPtr pScreen, DrawablePtr drawable) +{ + int i; + if (pScreen == drawable->pScreen) { + if (drawable->type == DRAWABLE_PIXMAP) + return (PixmapPtr)drawable; + else + return pScreen->GetWindowPixmap((WindowPtr)drawable); + } + + /* the screen asking for drawable pixmap must be a GPU screen */ + assert(pScreen->isGPU); + /* must be the current master also */ + assert(pScreen->current_master == drawable->pScreen); + + for (i = 0; i < drawable->pScreen->num_gpu; i++) + if (drawable->pScreen->gpu[i] == pScreen) + break; + + if (i == drawable->pScreen->num_gpu) + return NULL; + + if (drawable->type == DRAWABLE_PIXMAP) { + return ((PixmapPtr)drawable)->gpu[i]; + } else { + return (drawable->pScreen->GetWindowPixmap((WindowPtr)drawable)->gpu[i]); + } +} diff --git a/exa/exa.c b/exa/exa.c index b83ba2a3d..3d6fd6303 100644 --- a/exa/exa.c +++ b/exa/exa.c @@ -111,10 +111,7 @@ exaGetPixmapSize(PixmapPtr pPix) PixmapPtr exaGetDrawablePixmap(DrawablePtr pDrawable) { - if (pDrawable->type == DRAWABLE_WINDOW) - return pDrawable->pScreen->GetWindowPixmap((WindowPtr) pDrawable); - else - return (PixmapPtr) pDrawable; + return GetDrawablePixmap(pDrawable->pScreen, pDrawable); } /** diff --git a/include/impedance.h b/include/impedance.h index 95c587212..8b9507b11 100644 --- a/include/impedance.h +++ b/include/impedance.h @@ -17,16 +17,6 @@ static inline void impedGetDrawableDeltas(DrawablePtr pDrawable, PixmapPtr pPixm #endif } -static inline PixmapPtr GetDrawablePixmap(DrawablePtr drawable) -{ - if (drawable->type == DRAWABLE_PIXMAP) - return (PixmapPtr)drawable; - else { - struct _Window *pWin = (struct _Window *)drawable; - return drawable->pScreen->GetWindowPixmap(pWin); - } -} - /* only used for CopyNtoN */ static inline void impedGetCompositeDeltas(DrawablePtr pDrawable, PixmapPtr pPixmap, int *x_off, int *y_off) diff --git a/include/pixmap.h b/include/pixmap.h index 921a94d1e..c293eca00 100644 --- a/include/pixmap.h +++ b/include/pixmap.h @@ -128,4 +128,6 @@ PixmapStopDirtyTracking(PixmapPtr src, PixmapPtr slave_dst); extern _X_EXPORT Bool PixmapSyncDirtyHelper(PixmapDirtyUpdatePtr dirty, RegionPtr dirty_region); +extern _X_EXPORT PixmapPtr +GetDrawablePixmap(ScreenPtr pScreen, DrawablePtr drawable); #endif /* PIXMAP_H */ diff --git a/render/impedpict.c b/render/impedpict.c index e0132dde5..d4efd87bd 100644 --- a/render/impedpict.c +++ b/render/impedpict.c @@ -33,13 +33,13 @@ impedComposite (CARD8 op, int i; if (pSrc->pDrawable) { - pSrcPixmap = GetDrawablePixmap(pSrc->pDrawable); + pSrcPixmap = GetDrawablePixmap(pScreen, pSrc->pDrawable); } if (pMask) { - pMaskPixmap = GetDrawablePixmap(pMask->pDrawable); + pMaskPixmap = GetDrawablePixmap(pScreen, pMask->pDrawable); } - pDstPixmap = GetDrawablePixmap(pDst->pDrawable); + pDstPixmap = GetDrawablePixmap(pScreen, pDst->pDrawable); miCompositeSourceValidate (pSrc); if (pMask) @@ -94,7 +94,7 @@ impedRasterizeTrapezoid (PicturePtr pPicture, int y_off) { ScreenPtr pScreen = pPicture->pDrawable->pScreen; - PixmapPtr pPixmap = GetDrawablePixmap(pPicture->pDrawable); + PixmapPtr pPixmap = GetDrawablePixmap(pScreen, pPicture->pDrawable); PicturePtr pDrvPicture; PictureScreenPtr drv_ps; int i; @@ -116,8 +116,8 @@ impedAddTraps (PicturePtr pPicture, xTrap *traps) { PictureScreenPtr drv_ps; - PixmapPtr pPixmap = GetDrawablePixmap(pPicture->pDrawable); ScreenPtr pScreen = pPicture->pDrawable->pScreen; + PixmapPtr pPixmap = GetDrawablePixmap(pScreen, pPicture->pDrawable); PicturePtr pDrvPicture; int i; for (i = 0; i < pScreen->num_gpu; i++) { @@ -150,14 +150,14 @@ impedTrapezoids (CARD8 op, miCompositeSourceValidate (pSrc); if (pSrc) { if (pSrc->pDrawable) { - pSrcPixmap = GetDrawablePixmap(pSrc->pDrawable); + pSrcPixmap = GetDrawablePixmap(pScreen, pSrc->pDrawable); impedGetDrawableDeltas(pSrc->pDrawable, pSrcPixmap, &x_off, &y_off); xSrc += x_off; ySrc += y_off; } } - pDstPixmap = GetDrawablePixmap(pDst->pDrawable); + pDstPixmap = GetDrawablePixmap(pScreen, pDst->pDrawable); impedGetDrawableDeltas(pDst->pDrawable, pDstPixmap, &x_off, &y_off); if (x_off || y_off) { for (i = 0; i < ntrap; i++) { @@ -209,8 +209,8 @@ impedAddTriangles (PicturePtr pPicture, xTriangle *tris) { int x_off, y_off; - PixmapPtr pPixmap = GetDrawablePixmap(pPicture->pDrawable); ScreenPtr pScreen = pPicture->pDrawable->pScreen; + PixmapPtr pPixmap = GetDrawablePixmap(pScreen, pPicture->pDrawable); int i; impedGetDrawableDeltas(pPicture->pDrawable, pPixmap, &x_off, &y_off); @@ -245,12 +245,12 @@ impedTriangles (CARD8 op, miCompositeSourceValidate (pSrc); - pSrcPixmap = GetDrawablePixmap(pSrc->pDrawable); + pSrcPixmap = GetDrawablePixmap(pScreen, pSrc->pDrawable); impedGetDrawableDeltas(pSrc->pDrawable, pSrcPixmap, &x_off, &y_off); xSrc += x_off; ySrc += y_off; - pDstPixmap = GetDrawablePixmap(pDst->pDrawable); + pDstPixmap = GetDrawablePixmap(pScreen, pDst->pDrawable); impedGetDrawableDeltas(pDst->pDrawable, pDstPixmap, &x_off, &y_off); if (x_off || y_off) { for (i = 0; i < ntris; i++) { @@ -299,13 +299,13 @@ impedGlyphs(CARD8 op, ScreenPtr pScreen = pDst->pDrawable->pScreen; if (pSrc->pDrawable) { - pSrcPixmap = GetDrawablePixmap(pSrc->pDrawable); + pSrcPixmap = GetDrawablePixmap(pScreen, pSrc->pDrawable); impedGetDrawableDeltas(pSrc->pDrawable, pSrcPixmap, &x_off, &y_off); xSrc += x_off; ySrc += y_off; } - pDstPixmap = GetDrawablePixmap(pDst->pDrawable); + pDstPixmap = GetDrawablePixmap(pScreen, pDst->pDrawable); impedGetDrawableDeltas(pDst->pDrawable, pDstPixmap, &x_off, &y_off); for (i = 0; i < pScreen->num_gpu; i++) { @@ -413,7 +413,7 @@ impedCreatePicture (PicturePtr pPicture) ps = GetPictureScreen(pPicture->pDrawable->pScreen); - pPixmap = GetDrawablePixmap(pPicture->pDrawable); + pPixmap = GetDrawablePixmap(pScreen, pPicture->pDrawable); xorg_list_add(&pPicture->member, &pScreen->picture_list); @@ -468,7 +468,7 @@ impedValidatePicture(PicturePtr pPicture, Mask mask) pScreen = pPicture->pDrawable->pScreen; #ifdef COMPOSITE if (pPicture->pCompositeClip && pPicture->pDrawable->type == DRAWABLE_WINDOW) { - PixmapPtr pPixmap = GetDrawablePixmap(pPicture->pDrawable); + PixmapPtr pPixmap = GetDrawablePixmap(pScreen, pPicture->pDrawable); x_off = -pPixmap->screen_x; y_off = -pPixmap->screen_y; RegionTranslate(pPicture->pCompositeClip, x_off, y_off); @@ -530,10 +530,11 @@ impedPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats) void impedPictureDuplicate(PicturePtr pPicture, int new_gpu_index) { + ScreenPtr pScreen = pPicture->pDrawable->pScreen; PixmapPtr pPixmap; int error; - pPixmap = GetDrawablePixmap(pPicture->pDrawable); + pPixmap = GetDrawablePixmap(pScreen, pPicture->pDrawable); pPicture->gpu[new_gpu_index] = CreatePicture(0, &pPixmap->gpu[new_gpu_index]->drawable, pPicture->pFormat, 0, 0, serverClient, &error); } -- cgit v1.2.3