[PATCH] EXA: Simplify exaGetPixmapFirstPixel using GetImage.

Michel Dänzer michel at daenzer.net
Sun Aug 2 07:59:58 PDT 2009


From: Michel Dänzer <daenzer at vmware.com>

---
 exa/exa_unaccel.c |   69 ++++++++++++++++++----------------------------------
 1 files changed, 24 insertions(+), 45 deletions(-)

diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index 0d53b67..f4700ad 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -492,58 +492,37 @@ ExaCheckAddTraps (PicturePtr	pPicture,
 /**
  * Gets the 0,0 pixel of a pixmap.  Used for doing solid fills of tiled pixmaps
  * that happen to be 1x1.  Pixmap must be at least 8bpp.
- *
- * XXX This really belongs in fb, so it can be aware of tiling and etc.
  */
 CARD32
 exaGetPixmapFirstPixel (PixmapPtr pPixmap)
 {
-    CARD32 pixel;
-    void *fb;
-    Bool need_finish = FALSE;
-    BoxRec box;
-    RegionRec migration;
-    ExaPixmapPriv (pPixmap);
-    Bool sys_valid = pExaPixmap->pDamage &&
-	!miPointInRegion(&pExaPixmap->validSys, 0, 0,  &box);
-    Bool damaged = pExaPixmap->pDamage &&
- 	miPointInRegion(DamageRegion(pExaPixmap->pDamage), 0, 0, &box);
-    Bool offscreen = exaPixmapIsOffscreen(pPixmap);
-
-    fb = pExaPixmap->sys_ptr;
-
-    /* Try to avoid framebuffer readbacks */
-    if ((!offscreen && !sys_valid && !damaged) ||
-	(offscreen && (!sys_valid || damaged)))
-    {
-	box.x1 = 0;
-	box.y1 = 0;
-	box.x2 = 1;
-	box.y2 = 1;
-	REGION_INIT(pScreen, &migration, &box, 1);
-
-	need_finish = TRUE;
-
-	exaPrepareAccessReg(&pPixmap->drawable, EXA_PREPARE_SRC, &migration);
-	fb = pPixmap->devPrivate.ptr;
-    }
-
     switch (pPixmap->drawable.bitsPerPixel) {
     case 32:
-	pixel = *(CARD32 *)fb;
-	break;
+	{
+	    CARD32 pixel;
+
+	    pPixmap->drawable.pScreen->GetImage(&pPixmap->drawable, 0, 0, 1, 1,
+						ZPixmap, ~0, (char*)&pixel);
+	    return pixel;
+	}
     case 16:
-	pixel = *(CARD16 *)fb;
-	break;
+	{
+	    CARD16 pixel;
+
+	    pPixmap->drawable.pScreen->GetImage(&pPixmap->drawable, 0, 0, 1, 1,
+						ZPixmap, ~0, (char*)&pixel);
+	    return pixel;
+	}
+    case 8:
+	{
+	    CARD8 pixel;
+
+	    pPixmap->drawable.pScreen->GetImage(&pPixmap->drawable, 0, 0, 1, 1,
+						ZPixmap, ~0, (char*)&pixel);
+	    return pixel;
+	}
     default:
-	pixel = *(CARD8 *)fb;
-	break;
+	FatalError("%s called for invalid bpp %d\n", __func__,
+		   pPixmap->drawable.bitsPerPixel);
     }
-
-    if (need_finish) {
-	exaFinishAccess(&pPixmap->drawable, EXA_PREPARE_SRC);
-	REGION_UNINIT(pScreen, &migration);
-    }
-
-    return pixel;
 }
-- 
1.6.3.3



More information about the xorg-devel mailing list