[xserver-commit] xserver/fb fbblt.c,1.9,1.10 fbpict.c,1.22,1.23
Jaymz Julian
xserver-commit@pdx.freedesktop.org
Sat, 20 Dec 2003 06:36:43 -0800
Committed by: jaymz
Update of /cvs/xserver/xserver/fb
In directory pdx:/tmp/cvs-serv22511/fb
Modified Files:
fbblt.c fbpict.c
Log Message:
Add a special case to the fbBlt for the very common case of just blitting
directly (GXcopy) and not applying any ops. Profiles show this to be
significnatly faster, although I'd like to one day change it to be able
to choose the fastest memcpy() for this system ala xine when it benchmarks
on startup (does it still do that?), but i'm reluctant to do that right now,
since it means that it can't be inlined, and there'd be a function call
per line... eew! (the correct solution is probably 5 blitters or something,
heh)
Index: fbblt.c
===================================================================
RCS file: /cvs/xserver/xserver/fb/fbblt.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- fbblt.c 11 Sep 2003 05:12:50 -0000 1.9
+++ fbblt.c 20 Dec 2003 14:36:41 -0000 1.10
@@ -40,6 +40,7 @@
} \
}
+
void
fbBlt (FbBits *srcLine,
FbStride srcStride,
@@ -66,6 +67,23 @@
int n, nmiddle;
Bool destInvarient;
int startbyte, endbyte;
+
+ if((pm==FB_ALLONES) && (alu==GXcopy) && !reverse && !upsidedown)
+ {
+ CARD8 *isrc=(CARD8 *)srcLine;
+ CARD8 *idst=(CARD8 *)dstLine;
+ width>>=3;
+ int sstride=srcStride*sizeof(FbBits);
+ int dstride=dstStride*sizeof(FbBits);
+ isrc+=(srcX>>3);
+ idst+=(dstX>>3);
+ int j;
+ for(j=0;j<height;j++)
+ memcpy(idst+j*dstride, isrc+j*sstride, width);
+
+ return;
+ }
+
FbDeclareMergeRop ();
#ifdef FB_24BIT
Index: fbpict.c
===================================================================
RCS file: /cvs/xserver/xserver/fb/fbpict.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- fbpict.c 19 Dec 2003 13:08:01 -0000 1.22
+++ fbpict.c 20 Dec 2003 14:36:41 -0000 1.23
@@ -1131,7 +1131,7 @@
// are xSrc and xDst at the same alignment? if not, we need to be complicated :)
//if(0==0)
- if( (((xSrc*3)&3)!=((xDst*3)&3)) || (srcStride&3)!=0 || (dstStride&3)!=0)
+ if( (((xSrc*3)&3)!=((xDst*3)&3)) || ((srcStride&3)!=(dstStride&3)))
{
while (height--)
{
@@ -1283,32 +1283,40 @@
{
FbBits *dst;
FbBits *src;
- FbStride dstStride, srcStride;
- int srcXoff, srcYoff;
- int dstXoff, dstYoff;
- int srcBpp;
- int dstBpp;
+ CARD8 *isrc;
+ CARD8 *idst;
+ int dstStride, srcStride;
+ int srcXoff, srcYoff;
+ int dstXoff, dstYoff;
+ int srcBpp;
+ int dstBpp;
// these need to be signed now!
- int iwidth=width;
- int iheight=height;
- Bool reverse = FALSE;
- Bool upsidedown = FALSE;
+ int iwidth=width;
+ int iheight=height;
+ int bytesPerPixel;
int initialWidth=width;
int initialX=xDst;
- // FIXME: this is possibly the worst piece of code I've ever written.
- // My main objection to it, is that it is incrfedibly slow in a few cases, due to the
- // call-per-repeat structure of it - the *correct* solution is to implement
- // repeat into fbBlt(), but that's a nontrivial job, and it's far more
- // important to get the "requireRepeat" stuff implented functionally
- // first, *then* make it fast.
+ // FIXME: this is possibly the second worst piece of code I've ever written.
+ // (the worst being the previous imlementation of this)
// -- jj
+
Bool srcRepeat=pSrc->repeat;
CARD32 srcHeight=pSrc->pDrawable->height;
CARD32 srcWidth=pSrc->pDrawable->width;
fbGetDrawable(pSrc->pDrawable,src,srcStride,srcBpp,srcXoff,srcYoff);
fbGetDrawable(pDst->pDrawable,dst,dstStride,dstBpp,dstXoff,dstYoff);
+
+ src+=(srcXoff+(srcYoff*srcStride));
+ dst+=(dstXoff+(dstYoff*dstStride));
+
+ isrc=(CARD8 *)src;
+ idst=(CARD8 *)dst;
+
+ bytesPerPixel=(srcBpp>>3);
+ srcStride*=sizeof(FbBits);
+ dstStride*=sizeof(FbBits);
if(srcRepeat)
{
@@ -1326,26 +1334,14 @@
while(iwidth>0)
{
int wwidth=iwidth;
+ int j;
if(wwidth>(srcWidth-xSrc))
wwidth=(srcWidth-xSrc);
- fbBlt (src + (ySrc + srcYoff) * srcStride,
- srcStride,
- (xSrc + srcXoff) * srcBpp,
-
- dst + (yDst + dstYoff) * dstStride,
- dstStride,
- (xDst + dstXoff) * dstBpp,
-
- (wwidth) * dstBpp,
- (wheight),
-
- GXcopy,
- FB_ALLONES,
- dstBpp,
-
- reverse,
- upsidedown);
+ for(j=0;j<wheight;j++)
+ memcpy( idst + (yDst + j) * dstStride + ((xDst * bytesPerPixel)),
+ isrc + (ySrc + j) * srcStride + ((xSrc * bytesPerPixel)),
+ (wwidth*bytesPerPixel));
if(!srcRepeat)
iwidth=0;
else