[PATCH xserver 3/4] EXA: Glyph rects optimizations.

Michel Dänzer michel at daenzer.net
Wed May 18 08:15:35 PDT 2011


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

Mostly reducing function call argument passing overhead.

Also remove unused rect member pDst.

Signed-off-by: Michel Dänzer <daenzer at vmware.com>
---
 exa/exa_glyphs.c |   87 ++++++++++++++++++++----------------------------------
 exa/exa_priv.h   |    1 -
 2 files changed, 32 insertions(+), 56 deletions(-)

diff --git a/exa/exa_glyphs.c b/exa/exa_glyphs.c
index 66e4abf..a6b8165 100644
--- a/exa/exa_glyphs.c
+++ b/exa/exa_glyphs.c
@@ -424,21 +424,14 @@ damage:
 		    y + cache->glyphHeight);
 }
 
-static ExaGlyphCacheResult
-exaGlyphCacheBufferGlyph(ScreenPtr         pScreen,
-			 ExaGlyphCachePtr  cache,
-			 ExaGlyphBufferPtr buffer,
-			 GlyphPtr          pGlyph,
-			 PicturePtr        pSrc,
-			 PicturePtr        pDst,
-			 INT16             xSrc,
-			 INT16             ySrc,
-			 INT16             xMask,
-			 INT16             yMask,
-			 INT16             xDst,
-			 INT16             yDst)
+static _X_INLINE ExaGlyphCacheResult
+exaGlyphCacheBufferGlyph(ScreenPtr           pScreen,
+			 ExaGlyphCachePtr    cache,
+			 ExaGlyphBufferPtr   buffer,
+			 GlyphPtr            pGlyph,
+			 PicturePtr          pSrc,
+			 ExaCompositeRectPtr pRect)
 {
-    ExaCompositeRectPtr rect;
     int pos;
     int x, y;
     
@@ -504,30 +497,20 @@ exaGlyphCacheBufferGlyph(ScreenPtr         pScreen,
     }
 
     buffer->mask = cache->picture;
-	    
-    rect = &buffer->rects[buffer->count];
 
     if (pSrc)
     {
-	rect->xSrc = xSrc;
-	rect->ySrc = ySrc;
-	rect->xMask = x;
-	rect->yMask = y;
+	pRect->xMask = x;
+	pRect->yMask = y;
     }
     else
     {
-	rect->xSrc = x;
-	rect->ySrc = y;
-	rect->xMask = 0;
-	rect->yMask = 0;
+	pRect->xSrc = x;
+	pRect->ySrc = y;
+	pRect->xMask = 0;
+	pRect->yMask = 0;
     }
 
-    rect->pDst = pDst;
-    rect->xDst = xDst;
-    rect->yDst = yDst;
-    rect->width = pGlyph->info.width;
-    rect->height = pGlyph->info.height;
-
     buffer->count++;
 
     return ExaGlyphSuccess;
@@ -541,7 +524,6 @@ exaBufferGlyph(ScreenPtr         pScreen,
 	       ExaGlyphBufferPtr buffer,
 	       GlyphPtr          pGlyph,
 	       PicturePtr        pSrc,
-	       PicturePtr        pDst,
 	       INT16             xSrc,
 	       INT16             ySrc,
 	       INT16             xMask,
@@ -550,11 +532,11 @@ exaBufferGlyph(ScreenPtr         pScreen,
 	       INT16             yDst)
 {
     ExaScreenPriv(pScreen);
-    unsigned int format = (GlyphPicture(pGlyph)[pScreen->myNum])->format;
+    PicturePtr mask = GlyphPicture(pGlyph)[pScreen->myNum];
+    unsigned int format = mask->format;
     int width = pGlyph->info.width;
     int height = pGlyph->info.height;
-    ExaCompositeRectPtr rect;
-    PicturePtr mask;
+    ExaCompositeRectPtr pRect;
     int i;
 
     if (buffer->count == GLYPH_BUFFER_SIZE)
@@ -563,6 +545,16 @@ exaBufferGlyph(ScreenPtr         pScreen,
     if (PICT_FORMAT_BPP(format) == 1)
 	format = PICT_a8;
     
+    pRect = &buffer->rects[buffer->count];
+    pRect->xSrc = xSrc;
+    pRect->ySrc = ySrc;
+    pRect->xMask = xMask;
+    pRect->yMask = yMask;
+    pRect->xDst = xDst;
+    pRect->yDst = yDst;
+    pRect->width = width;
+    pRect->height = height;
+
     for (i = 0; i < EXA_NUM_GLYPH_CACHES; i++) {
 	ExaGlyphCachePtr cache = &pExaScr->glyphCaches[i];
 
@@ -570,14 +562,11 @@ exaBufferGlyph(ScreenPtr         pScreen,
 	    width <= cache->glyphWidth &&
 	    height <= cache->glyphHeight) {
 	    ExaGlyphCacheResult result = exaGlyphCacheBufferGlyph(pScreen,
-								  &pExaScr->glyphCaches[i],
+								  cache,
 								  buffer,
 								  pGlyph,
 								  pSrc,
-								  pDst,
-								  xSrc, ySrc,
-								  xMask, yMask,
-								  xDst, yDst);
+								  pRect);
 	    switch (result) {
 	    case ExaGlyphFail:
 		break;
@@ -590,22 +579,10 @@ exaBufferGlyph(ScreenPtr         pScreen,
 
     /* Couldn't find the glyph in the cache, use the glyph picture directly */
 
-    mask = GlyphPicture(pGlyph)[pScreen->myNum];
     if (buffer->mask && buffer->mask != mask)
 	return ExaGlyphNeedFlush;
-
     buffer->mask = mask;
 
-    rect = &buffer->rects[buffer->count];
-    rect->xSrc = xSrc;
-    rect->ySrc = ySrc;
-    rect->xMask = xMask;
-    rect->yMask = yMask;
-    rect->xDst = xDst;
-    rect->yDst = yDst;
-    rect->width = width;
-    rect->height = height;
-
     buffer->count++;
 
     return ExaGlyphSuccess;
@@ -805,23 +782,23 @@ exaGlyphs (CARD8 	 op,
 		/* pGlyph->info.{x,y} compensate for empty space in the glyph. */
 		if (maskFormat)
 		{
-		    if (exaBufferGlyph(pScreen, &buffer, glyph, NULL, pMask,
+		    if (exaBufferGlyph(pScreen, &buffer, glyph, NULL,
 				       0, 0, 0, 0, x - glyph->info.x, y - glyph->info.y) == ExaGlyphNeedFlush)
 		    {
 			exaGlyphsToMask(pMask, &buffer);
-			exaBufferGlyph(pScreen, &buffer, glyph, NULL, pMask,
+			exaBufferGlyph(pScreen, &buffer, glyph, NULL,
 				       0, 0, 0, 0, x - glyph->info.x, y - glyph->info.y);
 		    }
 		}
 		else
 		{
-		    if (exaBufferGlyph(pScreen, &buffer, glyph, pSrc, pDst,
+		    if (exaBufferGlyph(pScreen, &buffer, glyph, pSrc,
 				       xSrc + (x - glyph->info.x) - first_xOff, ySrc + (y - glyph->info.y) - first_yOff,
 				       0, 0, x - glyph->info.x, y - glyph->info.y)
 			== ExaGlyphNeedFlush)
 		    {
 			exaGlyphsToDst(pSrc, pDst, &buffer);
-			exaBufferGlyph(pScreen, &buffer, glyph, pSrc, pDst,
+			exaBufferGlyph(pScreen, &buffer, glyph, pSrc,
 				       xSrc + (x - glyph->info.x) - first_xOff, ySrc + (y - glyph->info.y) - first_yOff,
 				       0, 0, x - glyph->info.x, y - glyph->info.y);
 		    }
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index faed327..98d3807 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -333,7 +333,6 @@ typedef struct {
 } ExaGCPrivRec, *ExaGCPrivPtr;
 
 typedef struct {
-    PicturePtr pDst;
     INT16 xSrc;
     INT16 ySrc;
     INT16 xMask;
-- 
1.7.5.1



More information about the xorg-devel mailing list