Add very useful pixel transfer optimization

This commit is contained in:
David Reveman 2006-04-08 15:02:29 +00:00
parent 4b8e787604
commit 67538c92bf
2 changed files with 40 additions and 0 deletions

View file

@ -1,5 +1,9 @@
2006-04-08 David Reveman <davidr@novell.com>
* 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 <davidr@novell.com>

View file

@ -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);