From 67538c92bfef9fd2f3fc13be67a1636eb52aa438 Mon Sep 17 00:00:00 2001 From: David Reveman Date: Sat, 8 Apr 2006 15:02:29 +0000 Subject: [PATCH] Add very useful pixel transfer optimization --- ChangeLog | 4 ++++ hw/xgl/xglsync.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/ChangeLog b/ChangeLog index 95c81ae08..fa562b4ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2006-04-08 David Reveman + * hw/xgl/xglsync.c (xglSyncSurface): Add very useful optimization + for which avoids which makes pixels transfers much more efficient in + some cases. + * hw/xgl/Makefile.am (Xgl_DEPENDENCIES): Add libxgl.a. 2006-04-07 David Reveman diff --git a/hw/xgl/xglsync.c b/hw/xgl/xglsync.c index 6b5c00b57..a05ad24b6 100644 --- a/hw/xgl/xglsync.c +++ b/hw/xgl/xglsync.c @@ -236,6 +236,42 @@ xglSyncSurface (DrawablePtr pDrawable) format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN; } + /* If all bits are up to date we can avoid transferring a large set + of boxes by transferring the extents box instead. */ + if (pPixmapPriv->allBits && nBox != 1) + { + /* This many boxes. It is likely more efficient to always transfer + the extents box instead. */ + if (nBox > 64) + { + pBox = pExt; + nBox = 1; + } + else + { + int i, w, e, r = 0; + + for (i = 0; i < nBox; i++) + r += (pBox[i].x2 - pBox[i].x1) * (pBox[i].y2 - pBox[i].y1); + + e = (pExt->x2 - pExt->x1) * (pExt->y2 - pExt->y1); + w = e - r; + + /* r, is the area of all boxes. e, is the are for the + extents. w, is the area that doesn't need to be + transferred. + + If w per box is less than 2 times the area of all + boxes, transferring the extents has been proved more + efficient. */ + if ((w / nBox) < (r << 1)) + { + pBox = pExt; + nBox = 1; + } + } + } + glitz_surface_set_clip_region (pPixmapPriv->surface, 0, 0, (glitz_box_t *) pBox, nBox);