Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
icblt.c File Reference
#include "pixman-xserver-compat.h"

Go to the source code of this file.

Defines

#define InitializeShifts(sx, dx, ls, rs)

Functions

void fbBlt (FbBits *srcLine, FbStride srcStride, int srcX, FbBits *dstLine, FbStride dstStride, int dstX, int width, int height, int alu, FbBits pm, int bpp, Bool reverse, Bool upsidedown)
static void fbBlt24Line (FbBits *src, int srcX, FbBits *dst, int dstX, int width, int alu, FbBits pm, Bool reverse)
void fbBlt24 (FbBits *srcLine, FbStride srcStride, int srcX, FbBits *dstLine, FbStride dstStride, int dstX, int width, int height, int alu, FbBits pm, Bool reverse, Bool upsidedown)
void fbBltStip (FbStip *src, FbStride srcStride, int srcX, FbStip *dst, FbStride dstStride, int dstX, int width, int height, int alu, FbBits pm, int bpp)

Define Documentation

#define InitializeShifts (   sx,
  dx,
  ls,
  rs 
)
Value:
{ \
    if (sx != dx) { \
       if (sx > dx) { \
           ls = sx - dx; \
           rs = FB_UNIT - ls; \
       } else { \
           rs = dx - sx; \
           ls = FB_UNIT - rs; \
       } \
    } \
}

Definition at line 27 of file icblt.c.


Function Documentation

void fbBlt ( FbBits srcLine,
FbStride  srcStride,
int  srcX,
FbBits dstLine,
FbStride  dstStride,
int  dstX,
int  width,
int  height,
int  alu,
FbBits  pm,
int  bpp,
Bool  reverse,
Bool  upsidedown 
)

Definition at line 40 of file icblt.c.

{
    FbBits  *src, *dst;
    int           leftShift, rightShift;
    FbBits  startmask, endmask;
    FbBits  bits, bits1;
    int           n, nmiddle;
    Bool    destInvarient;
    int           startbyte, endbyte;
    FbDeclareMergeRop ();
 
    /* are we just copying multiples of 8 bits?  if so, run, forrest, run!
       the memcpy()'s should be pluggable ala mplayer|xine - perhaps we can get
       one of the above to give up their code for us.
     */
    if((pm==FB_ALLONES) && (alu==GXcopy) && !reverse && (srcX&7)==0 && (dstX&7)==0 && (width&7)==0)
    {
              CARD8 *isrc=(CARD8 *)srcLine;
              CARD8 *idst=(CARD8 *)dstLine;
              int sstride=srcStride*sizeof(FbBits);
              int dstride=dstStride*sizeof(FbBits);
              int j;
              width>>=3;
              isrc+=(srcX>>3);
              idst+=(dstX>>3);
              if(!upsidedown)
                     for(j=0;j<height;j++)
                            memcpy(idst+j*dstride, isrc+j*sstride, width);
              else
                     for(j=(height-1);j>=0;j--)
                            memcpy(idst+j*dstride, isrc+j*sstride, width);
       
              return;
    }
    
#ifdef FB_24BIT
    if (bpp == 24 && !FbCheck24Pix (pm))
    {
       fbBlt24 (srcLine, srcStride, srcX, dstLine, dstStride, dstX,
               width, height, alu, pm, reverse, upsidedown);
       return;
    }
#endif
    FbInitializeMergeRop(alu, pm);
    destInvarient = FbDestInvarientMergeRop();
    if (upsidedown)
    {
       srcLine += (height - 1) * (srcStride);
       dstLine += (height - 1) * (dstStride);
       srcStride = -srcStride;
       dstStride = -dstStride;
    }
    FbMaskBitsBytes (dstX, width, destInvarient, startmask, startbyte,
                   nmiddle, endmask, endbyte);
    if (reverse)
    {
       srcLine += ((srcX + width - 1) >> FB_SHIFT) + 1;
       dstLine += ((dstX + width - 1) >> FB_SHIFT) + 1;
       srcX = (srcX + width - 1) & FB_MASK;
       dstX = (dstX + width - 1) & FB_MASK;
    }
    else
    {
       srcLine += srcX >> FB_SHIFT;
       dstLine += dstX >> FB_SHIFT;
       srcX &= FB_MASK;
       dstX &= FB_MASK;
    }
    if (srcX == dstX)
    {
       while (height--)
       {
           src = srcLine;
           srcLine += srcStride;
           dst = dstLine;
           dstLine += dstStride;
           if (reverse)
           {
              if (endmask)
              {
                  bits = *--src;
                  --dst;
                  FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
              }
              n = nmiddle;
              if (destInvarient)
              {
                  while (n--)
                     *--dst = FbDoDestInvarientMergeRop(*--src);
              }
              else
              {
                  while (n--)
                  {
                     bits = *--src;
                     --dst;
                     *dst = FbDoMergeRop (bits, *dst);
                  }
              }
              if (startmask)
              {
                  bits = *--src;
                  --dst;
                  FbDoLeftMaskByteMergeRop(dst, bits, startbyte, startmask);
              }
           }
           else
           {
              if (startmask)
              {
                  bits = *src++;
                  FbDoLeftMaskByteMergeRop(dst, bits, startbyte, startmask);
                  dst++;
              }
              n = nmiddle;
              if (destInvarient)
              {
#if 0
                  /*
                   * This provides some speedup on screen->screen blts
                   * over the PCI bus, usually about 10%.  But fb
                   * isn't usually used for this operation...
                   */
                  if (_ca2 + 1 == 0 && _cx2 == 0)
                  {
                     FbBits t1, t2, t3, t4;
                     while (n >= 4)
                     {
                         t1 = *src++;
                         t2 = *src++;
                         t3 = *src++;
                         t4 = *src++;
                         *dst++ = t1;
                         *dst++ = t2;
                         *dst++ = t3;
                         *dst++ = t4;
                         n -= 4;
                     }
                  }
#endif
                  while (n--)
                     *dst++ = FbDoDestInvarientMergeRop(*src++);
              }
              else
              {
                  while (n--)
                  {
                     bits = *src++;
                     *dst = FbDoMergeRop (bits, *dst);
                     dst++;
                  }
              }
              if (endmask)
              {
                  bits = *src;
                  FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
              }
           }
       }
    }
    else
    {
       if (srcX > dstX)
       {
           leftShift = srcX - dstX;
           rightShift = FB_UNIT - leftShift;
       }
       else
       {
           rightShift = dstX - srcX;
           leftShift = FB_UNIT - rightShift;
       }
       while (height--)
       {
           src = srcLine;
           srcLine += srcStride;
           dst = dstLine;
           dstLine += dstStride;
           
           bits1 = 0;
           if (reverse)
           {
              if (srcX < dstX)
                  bits1 = *--src;
              if (endmask)
              {
                  bits = FbScrRight(bits1, rightShift); 
                  if (FbScrRight(endmask, leftShift))
                  {
                     bits1 = *--src;
                     bits |= FbScrLeft(bits1, leftShift);
                  }
                  --dst;
                  FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
              }
              n = nmiddle;
              if (destInvarient)
              {
                  while (n--)
                  {
                     bits = FbScrRight(bits1, rightShift); 
                     bits1 = *--src;
                     bits |= FbScrLeft(bits1, leftShift);
                     --dst;
                     *dst = FbDoDestInvarientMergeRop(bits);
                  }
              }
              else
              {
                  while (n--)
                  {
                     bits = FbScrRight(bits1, rightShift); 
                     bits1 = *--src;
                     bits |= FbScrLeft(bits1, leftShift);
                     --dst;
                     *dst = FbDoMergeRop(bits, *dst);
                  }
              }
              if (startmask)
              {
                  bits = FbScrRight(bits1, rightShift); 
                  if (FbScrRight(startmask, leftShift))
                  {
                     bits1 = *--src;
                     bits |= FbScrLeft(bits1, leftShift);
                  }
                  --dst;
                  FbDoLeftMaskByteMergeRop (dst, bits, startbyte, startmask);
              }
           }
           else
           {
              if (srcX > dstX)
                  bits1 = *src++;
              if (startmask)
              {
                  bits = FbScrLeft(bits1, leftShift); 
                  bits1 = *src++;
                  bits |= FbScrRight(bits1, rightShift);
                  FbDoLeftMaskByteMergeRop (dst, bits, startbyte, startmask);
                  dst++;
              }
              n = nmiddle;
              if (destInvarient)
              {
                  while (n--)
                  {
                     bits = FbScrLeft(bits1, leftShift); 
                     bits1 = *src++;
                     bits |= FbScrRight(bits1, rightShift);
                     *dst = FbDoDestInvarientMergeRop(bits);
                     dst++;
                  }
              }
              else
              {
                  while (n--)
                  {
                     bits = FbScrLeft(bits1, leftShift); 
                     bits1 = *src++;
                     bits |= FbScrRight(bits1, rightShift);
                     *dst = FbDoMergeRop(bits, *dst);
                     dst++;
                  }
              }
              if (endmask)
              {
                  bits = FbScrLeft(bits1, leftShift); 
                  if (FbScrLeft(endmask, rightShift))
                  {
                     bits1 = *src;
                     bits |= FbScrRight(bits1, rightShift);
                  }
                  FbDoRightMaskByteMergeRop (dst, bits, endbyte, endmask);
              }
           }
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fbBlt24 ( FbBits srcLine,
FbStride  srcStride,
int  srcX,
FbBits dstLine,
FbStride  dstStride,
int  dstX,
int  width,
int  height,
int  alu,
FbBits  pm,
Bool  reverse,
Bool  upsidedown 
)

Definition at line 567 of file icblt.c.

{
    if (upsidedown)
    {
       srcLine += (height-1) * srcStride;
       dstLine += (height-1) * dstStride;
       srcStride = -srcStride;
       dstStride = -dstStride;
    }
    while (height--)
    {
       fbBlt24Line (srcLine, srcX, dstLine, dstX, width, alu, pm, reverse);
       srcLine += srcStride;
       dstLine += dstStride;
    }
#ifdef DEBUG_BLT24
    ErrorF ("\n");
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void fbBlt24Line ( FbBits src,
int  srcX,
FbBits dst,
int  dstX,
int  width,
int  alu,
FbBits  pm,
Bool  reverse 
) [static]

Definition at line 353 of file icblt.c.

{
#ifdef DEBUG_BLT24
    char    *origDst = (char *) dst;
    FbBits  *origLine = dst + ((dstX >> FB_SHIFT) - 1);
    int           origNlw = ((width + FB_MASK) >> FB_SHIFT) + 3;
    int           origX = dstX / 24;
#endif
    
    int           leftShift, rightShift;
    FbBits  startmask, endmask;
    int           n;
    
    FbBits  bits, bits1;
    FbBits  mask;

    int           rot;
    FbDeclareMergeRop ();
    
    FbInitializeMergeRop (alu, FB_ALLONES);
    FbMaskBits(dstX, width, startmask, n, endmask);
#ifdef DEBUG_BLT24
    ErrorF ("dstX %d width %d reverse %d\n", dstX, width, reverse);
#endif
    if (reverse)
    {
       src += ((srcX + width - 1) >> FB_SHIFT) + 1;
       dst += ((dstX + width - 1) >> FB_SHIFT) + 1;
       rot = FbFirst24Rot (((dstX + width - 8) & FB_MASK));
       rot = FbPrev24Rot(rot);
#ifdef DEBUG_BLT24
       ErrorF ("dstX + width - 8: %d rot: %d\n", (dstX + width - 8) & FB_MASK, rot);
#endif
       srcX = (srcX + width - 1) & FB_MASK;
       dstX = (dstX + width - 1) & FB_MASK;
    }
    else
    {
       src += srcX >> FB_SHIFT;
       dst += dstX >> FB_SHIFT;
       srcX &= FB_MASK;
       dstX &= FB_MASK;
       rot = FbFirst24Rot (dstX);
#ifdef DEBUG_BLT24
       ErrorF ("dstX: %d rot: %d\n", dstX, rot);
#endif
    }
    mask = FbRot24(pm,rot);
#ifdef DEBUG_BLT24
    ErrorF ("pm 0x%x mask 0x%x\n", pm, mask);
#endif
    if (srcX == dstX)
    {
       if (reverse)
       {
           if (endmask)
           {
              bits = *--src;
              --dst;
              *dst = FbDoMaskMergeRop (bits, *dst, mask & endmask);
              mask = FbPrev24Pix (mask);
           }
           while (n--)
           {
              bits = *--src;
              --dst;
              *dst = FbDoMaskMergeRop (bits, *dst, mask);
              mask = FbPrev24Pix (mask);
           }
           if (startmask)
           {
              bits = *--src;
              --dst;
              *dst = FbDoMaskMergeRop(bits, *dst, mask & startmask);
           }
       }
       else
       {
           if (startmask)
           {
              bits = *src++;
              *dst = FbDoMaskMergeRop (bits, *dst, mask & startmask);
              dst++;
              mask = FbNext24Pix(mask);
           }
           while (n--)
           {
              bits = *src++;
              *dst = FbDoMaskMergeRop (bits, *dst, mask);
              dst++;
              mask = FbNext24Pix(mask);
           }
           if (endmask)
           {
              bits = *src;
              *dst = FbDoMaskMergeRop(bits, *dst, mask & endmask);
           }
       }
    }
    else
    {
       if (srcX > dstX)
       {
           leftShift = srcX - dstX;
           rightShift = FB_UNIT - leftShift;
       }
       else
       {
           rightShift = dstX - srcX;
           leftShift = FB_UNIT - rightShift;
       }
       
       bits1 = 0;
       if (reverse)
       {
           if (srcX < dstX)
              bits1 = *--src;
           if (endmask)
           {
              bits = FbScrRight(bits1, rightShift); 
              if (FbScrRight(endmask, leftShift))
              {
                  bits1 = *--src;
                  bits |= FbScrLeft(bits1, leftShift);
              }
              --dst;
              *dst = FbDoMaskMergeRop (bits, *dst, mask & endmask);
              mask = FbPrev24Pix(mask);
           }
           while (n--)
           {
              bits = FbScrRight(bits1, rightShift); 
              bits1 = *--src;
              bits |= FbScrLeft(bits1, leftShift);
              --dst;
              *dst = FbDoMaskMergeRop(bits, *dst, mask);
              mask = FbPrev24Pix(mask);
           }
           if (startmask)
           {
              bits = FbScrRight(bits1, rightShift); 
              if (FbScrRight(startmask, leftShift))
              {
                  bits1 = *--src;
                  bits |= FbScrLeft(bits1, leftShift);
              }
              --dst;
              *dst = FbDoMaskMergeRop (bits, *dst, mask & startmask);
           }
       }
       else
       {
           if (srcX > dstX)
              bits1 = *src++;
           if (startmask)
           {
              bits = FbScrLeft(bits1, leftShift); 
              bits1 = *src++;
              bits |= FbScrRight(bits1, rightShift);
              *dst = FbDoMaskMergeRop (bits, *dst, mask & startmask);
              dst++;
              mask = FbNext24Pix(mask);
           }
           while (n--)
           {
              bits = FbScrLeft(bits1, leftShift); 
              bits1 = *src++;
              bits |= FbScrRight(bits1, rightShift);
              *dst = FbDoMaskMergeRop(bits, *dst, mask);
              dst++;
              mask = FbNext24Pix(mask);
           }
           if (endmask)
           {
              bits = FbScrLeft(bits1, leftShift); 
              if (FbScrLeft(endmask, rightShift))
              {
                  bits1 = *src;
                  bits |= FbScrRight(bits1, rightShift);
              }
              *dst = FbDoMaskMergeRop (bits, *dst, mask & endmask);
           }
       }
    }
#ifdef DEBUG_BLT24
    {
       int firstx, lastx, x;

       firstx = origX;
       if (firstx)
           firstx--;
       lastx = origX + width/24 + 1;
       for (x = firstx; x <= lastx; x++)
           ErrorF ("%06x ", getPixel (origDst, x));
       ErrorF ("\n");
       while (origNlw--)
           ErrorF ("%08x ", *origLine++);
       ErrorF ("\n");
    }
#endif
}

Here is the caller graph for this function:

void fbBltStip ( FbStip src,
FbStride  srcStride,
int  srcX,
FbStip dst,
FbStride  dstStride,
int  dstX,
int  width,
int  height,
int  alu,
FbBits  pm,
int  bpp 
)

Definition at line 875 of file icblt.c.

{
#if FB_STIP_SHIFT != FB_SHIFT
    if (FB_STIP_ODDSTRIDE(srcStride) || FB_STIP_ODDPTR(src) ||
       FB_STIP_ODDSTRIDE(dstStride) || FB_STIP_ODDPTR(dst))
    {
       FbStride    srcStrideEven, srcStrideOdd;
       FbStride    dstStrideEven, dstStrideOdd;
       int        srcXEven, srcXOdd;
       int        dstXEven, dstXOdd;
       FbBits     *s, *d;
       int        sx, dx;
       
       src += srcX >> FB_STIP_SHIFT;
       srcX &= FB_STIP_MASK;
       dst += dstX >> FB_STIP_SHIFT;
       dstX &= FB_STIP_MASK;
       
       fbSetBltOdd (src, srcStride, srcX,
                   &s,
                   &srcStrideEven, &srcStrideOdd,
                   &srcXEven, &srcXOdd);
                   
       fbSetBltOdd (dst, dstStride, dstX,
                   &d,
                   &dstStrideEven, &dstStrideOdd,
                   &dstXEven, &dstXOdd);
                   
#ifdef FB_24BIT
       if (bpp == 24 && !FbCheck24Pix (pm))
       {
           fbBltOdd24  (s, srcStrideEven, srcStrideOdd,
                      srcXEven, srcXOdd,

                      d, dstStrideEven, dstStrideOdd,
                      dstXEven, dstXOdd,

                      width, height, alu, pm);
       }
       else
#endif
       {
           fbBltOdd (s, srcStrideEven, srcStrideOdd,
                    srcXEven, srcXOdd,
    
                    d, dstStrideEven, dstStrideOdd,
                    dstXEven, dstXOdd,
    
                    width, height, alu, pm, bpp);
       }
    }
    else
#endif
    {
       fbBlt ((FbBits *) src, FbStipStrideToBitsStride (srcStride), 
              srcX, 
              (FbBits *) dst, FbStipStrideToBitsStride (dstStride), 
              dstX, 
              width, height,
              alu, pm, bpp, FALSE, FALSE);
    }
}

Here is the call graph for this function: