Back to index

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

Go to the source code of this file.

Defines

#define LoadBits
#define LaneCases1(n, a)   case n: (void)FbLaneCase(n,a); break
#define LaneCases2(n, a)   LaneCases1(n,a); LaneCases1(n+1,a)
#define LaneCases4(n, a)   LaneCases2(n,a); LaneCases2(n+2,a)
#define LaneCases8(n, a)   LaneCases4(n,a); LaneCases4(n+4,a)
#define LaneCases16(n, a)   LaneCases8(n,a); LaneCases8(n+8,a)
#define LaneCases32(n, a)   LaneCases16(n,a); LaneCases16(n+16,a)
#define LaneCases64(n, a)   LaneCases32(n,a); LaneCases32(n+32,a)
#define LaneCases128(n, a)   LaneCases64(n,a); LaneCases64(n+64,a)
#define LaneCases256(n, a)   LaneCases128(n,a); LaneCases128(n+128,a)
#define LaneCases(a)   LaneCases16(0,a)
#define Mask24Pos(x, r)   ((x)*24-((r) ? 24 - (r) : 0))
#define Mask24Neg(x, r)   (Mask24Pos(x,r) < 0 ? -Mask24Pos(x,r) : 0)
#define Mask24Check(x, r)
#define Mask24(x, r)
#define SelMask24(b, n, r)   ((((b) >> n) & 1) * Mask24(n,r))
#define C2_24(b, r)
#define FbStip24Len   2
#define FbStip24New(rot)   (1 + (rot == 8))
#define FbMergeStip24Bits(left, right, new)   (FbStipLeft (left, new) | FbStipRight ((right), (FbStip24Len - (new))))
#define FbMergePartStip24Bits(left, right, llen, rlen)   (left | FbStipRight(right, llen))
#define fbFirstStipBits(len, stip)
#define fbInitStipBits(offset, len, stip)
#define fbNextStipBits(rot, stip)

Functions

static const uint8_tfbLaneTable (int bpp)
void fbBltOne (FbStip *src, FbStride srcStride, int srcX, FbBits *dst, FbStride dstStride, int dstX, int dstBpp, int width, int height, FbBits fgand, FbBits fgxor, FbBits bgand, FbBits bgxor)
void fbBltOne24 (FbStip *srcLine, FbStride srcStride, int srcX, FbBits *dst, FbStride dstStride, int dstX, int dstBpp, int width, int height, FbBits fgand, FbBits fgxor, FbBits bgand, FbBits bgxor)

Variables

static uint8_t const fb8Lane [16]
static uint8_t const fb16Lane [16]
static uint8_t const fb32Lane [16]
static const FbBits fbStipple24Bits [3][1<< FbStip24Len]

Define Documentation

#define C2_24 (   b,
  r 
)
Value:
(SelMask24(b,0,r) | \
     SelMask24(b,1,r))

Definition at line 485 of file icbltone.c.

#define fbFirstStipBits (   len,
  stip 
)
Value:
{\
    int       __len = (len); \
    if (len <= remain) { \
       stip = FbLeftStipBits(bits, len); \
    } else { \
       stip = FbLeftStipBits(bits, remain); \
       bits = *src++; \
       __len = (len) - remain; \
       stip = FbMergePartStip24Bits(stip, FbLeftStipBits(bits, __len), \
                                 remain, __len); \
       remain = FB_STIP_UNIT; \
    } \
    bits = FbStipLeft (bits, __len); \
    remain -= __len; \
}

Definition at line 530 of file icbltone.c.

#define fbInitStipBits (   offset,
  len,
  stip 
)
Value:
{\
    bits = FbStipLeft (*src++,offset); \
    remain = FB_STIP_UNIT - offset; \
    fbFirstStipBits(len,stip); \
    stip = FbMergeStip24Bits (0, stip, len); \
}

Definition at line 546 of file icbltone.c.

#define FbMergePartStip24Bits (   left,
  right,
  llen,
  rlen 
)    (left | FbStipRight(right, llen))

Definition at line 517 of file icbltone.c.

#define FbMergeStip24Bits (   left,
  right,
  new 
)    (FbStipLeft (left, new) | FbStipRight ((right), (FbStip24Len - (new))))

Definition at line 514 of file icbltone.c.

#define fbNextStipBits (   rot,
  stip 
)
Value:
{\
    int           __new = FbStip24New(rot); \
    FbStip  __right; \
    fbFirstStipBits(__new, __right); \
    stip = FbMergeStip24Bits (stip, __right, __new); \
    rot = FbNext24Rot (rot); \
}

Definition at line 553 of file icbltone.c.

Definition at line 489 of file icbltone.c.

#define FbStip24New (   rot)    (1 + (rot == 8))

Definition at line 493 of file icbltone.c.

#define LaneCases (   a)    LaneCases16(0,a)

Definition at line 75 of file icbltone.c.

#define LaneCases1 (   n,
  a 
)    case n: (void)FbLaneCase(n,a); break

Definition at line 60 of file icbltone.c.

#define LaneCases128 (   n,
  a 
)    LaneCases64(n,a); LaneCases64(n+64,a)

Definition at line 67 of file icbltone.c.

#define LaneCases16 (   n,
  a 
)    LaneCases8(n,a); LaneCases8(n+8,a)

Definition at line 64 of file icbltone.c.

#define LaneCases2 (   n,
  a 
)    LaneCases1(n,a); LaneCases1(n+1,a)

Definition at line 61 of file icbltone.c.

#define LaneCases256 (   n,
  a 
)    LaneCases128(n,a); LaneCases128(n+128,a)

Definition at line 68 of file icbltone.c.

#define LaneCases32 (   n,
  a 
)    LaneCases16(n,a); LaneCases16(n+16,a)

Definition at line 65 of file icbltone.c.

#define LaneCases4 (   n,
  a 
)    LaneCases2(n,a); LaneCases2(n+2,a)

Definition at line 62 of file icbltone.c.

#define LaneCases64 (   n,
  a 
)    LaneCases32(n,a); LaneCases32(n+32,a)

Definition at line 66 of file icbltone.c.

#define LaneCases8 (   n,
  a 
)    LaneCases4(n,a); LaneCases4(n+4,a)

Definition at line 63 of file icbltone.c.

Value:
{\
    if (leftShift) { \
       bitsRight = *src++; \
       bits = (FbStipLeft (bitsLeft, leftShift) | \
              FbStipRight(bitsRight, rightShift)); \
       bitsLeft = bitsRight; \
    } else \
       bits = *src++; \
}

Definition at line 48 of file icbltone.c.

#define Mask24 (   x,
  r 
)
Value:
(Mask24Pos(x,r) < FB_UNIT ? \
                   (Mask24Pos(x,r) < 0 ? \
                    0xffffff >> Mask24Neg (x,r) : \
                    0xffffff << Mask24Check(x,r)) : 0)

Definition at line 437 of file icbltone.c.

#define Mask24Check (   x,
  r 
)
Value:
(Mask24Pos(x,r) < 0 ? 0 : \
                          Mask24Pos(x,r) >= FB_UNIT ? 0 : Mask24Pos(x,r))

Definition at line 434 of file icbltone.c.

#define Mask24Neg (   x,
  r 
)    (Mask24Pos(x,r) < 0 ? -Mask24Pos(x,r) : 0)

Definition at line 433 of file icbltone.c.

#define Mask24Pos (   x,
  r 
)    ((x)*24-((r) ? 24 - (r) : 0))

Definition at line 430 of file icbltone.c.

#define SelMask24 (   b,
  n,
  r 
)    ((((b) >> n) & 1) * Mask24(n,r))

Definition at line 442 of file icbltone.c.


Function Documentation

void fbBltOne ( FbStip src,
FbStride  srcStride,
int  srcX,
FbBits dst,
FbStride  dstStride,
int  dstX,
int  dstBpp,
int  width,
int  height,
FbBits  fgand,
FbBits  fgxor,
FbBits  bgand,
FbBits  bgxor 
)

Definition at line 138 of file icbltone.c.

{
    const FbBits    *fbBits;
    int                  pixelsPerDst;           /* dst pixels per FbBits */
    int                  unitsPerSrc;            /* src patterns per FbStip */
    int                  leftShift, rightShift;  /* align source with dest */
    FbBits        startmask, endmask;            /* dest scanline masks */
    FbStip        bits=0, bitsLeft, bitsRight;/* source bits */
    FbStip        left;
    FbBits        mask;
    int                  nDst;                   /* dest longwords (w.o. end) */
    int                  w;
    int                  n, nmiddle;
    int                  dstS;                   /* stipple-relative dst X coordinate */
    Bool          copy;                   /* accelerate dest-invariant */
    Bool          transparent;            /* accelerate 0 nop */
    int                  srcinc;                 /* source units consumed */
    Bool          endNeedsLoad = FALSE;   /* need load for endmask */
#ifndef FBNOPIXADDR
    const CARD8          *fbLane;
#endif
    int                  startbyte, endbyte;

#ifdef FB_24BIT
    if (dstBpp == 24)
    {
       fbBltOne24 (src, srcStride, srcX,
                  dst, dstStride, dstX, dstBpp,
                  width, height,
                  fgand, fgxor, bgand, bgxor);
       return;
    }
#endif
    
    /*
     * Number of destination units in FbBits == number of stipple pixels
     * used each time
     */
    pixelsPerDst = FB_UNIT / dstBpp;

    /*
     * Number of source stipple patterns in FbStip 
     */
    unitsPerSrc = FB_STIP_UNIT / pixelsPerDst;
    
    copy = FALSE;
    transparent = FALSE;
    if (bgand == 0 && fgand == 0)
       copy = TRUE;
    else if (bgand == FB_ALLONES && bgxor == 0)
       transparent = TRUE;

    /*
     * Adjust source and dest to nearest FbBits boundary
     */
    src += srcX >> FB_STIP_SHIFT;
    dst += dstX >> FB_SHIFT;
    srcX &= FB_STIP_MASK;
    dstX &= FB_MASK;

    FbMaskBitsBytes(dstX, width, copy, 
                  startmask, startbyte, nmiddle, endmask, endbyte);

    /*
     * Compute effective dest alignment requirement for
     * source -- must align source to dest unit boundary
     */
    dstS = dstX / dstBpp;
    /*
     * Compute shift constants for effective alignement
     */
    if (srcX >= dstS)
    {
       leftShift = srcX - dstS;
       rightShift = FB_STIP_UNIT - leftShift;
    }
    else
    {
       rightShift = dstS - srcX;
       leftShift = FB_STIP_UNIT - rightShift;
    }
    /*
     * Get pointer to stipple mask array for this depth
     */
    fbBits = NULL;   /* unused */
    if (pixelsPerDst <= 8)
       fbBits = fbStippleTable(pixelsPerDst);
#ifndef FBNOPIXADDR
    fbLane = NULL;
    if (transparent && fgand == 0 && dstBpp >= 8)
       fbLane = fbLaneTable(dstBpp);
#endif
    
    /*
     * Compute total number of destination words written, but 
     * don't count endmask 
     */
    nDst = nmiddle;
    if (startmask)
       nDst++;
    
    dstStride -= nDst;

    /*
     * Compute total number of source words consumed
     */
    
    srcinc = (nDst + unitsPerSrc - 1) / unitsPerSrc;
    
    if (srcX > dstS)
       srcinc++;
    if (endmask)
    {
       endNeedsLoad = nDst % unitsPerSrc == 0;
       if (endNeedsLoad)
           srcinc++;
    }

    srcStride -= srcinc;
    
    /*
     * Copy rectangle
     */
    while (height--)
    {
       w = nDst;         /* total units across scanline */
       n = unitsPerSrc;    /* units avail in single stipple */
       if (n > w)
           n = w;
       
       bitsLeft = 0;
       if (srcX > dstS)
           bitsLeft = *src++;
       if (n)
       {
           /*
            * Load first set of stipple bits
            */
           LoadBits;

           /*
            * Consume stipple bits for startmask
            */
           if (startmask)
           {
#if FB_UNIT > 32
              if (pixelsPerDst == 16)
                  mask = FbStipple16Bits(FbLeftStipBits(bits,16));
              else
#endif
                  mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
#ifndef FBNOPIXADDR         
              if (fbLane)
              {
                  fbTransparentSpan (dst, mask & startmask, fgxor, 1);
              }
              else
#endif
              {
                  if (mask || !transparent)
                     FbDoLeftMaskByteStippleRRop (dst, mask,
                                               fgand, fgxor, bgand, bgxor,
                                               startbyte, startmask);
              }
              bits = FbStipLeft (bits, pixelsPerDst);
              dst++;
              n--;
              w--;
           }
           /*
            * Consume stipple bits across scanline
            */
           for (;;)
           {
              w -= n;
              if (copy)
              {
                  while (n--)
                  {
#if FB_UNIT > 32
                     if (pixelsPerDst == 16)
                         mask = FbStipple16Bits(FbLeftStipBits(bits,16));
                     else
#endif
                         mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
                     *dst = FbOpaqueStipple (mask, fgxor, bgxor);
                     dst++;
                     bits = FbStipLeft(bits, pixelsPerDst);
                  }
              }
              else
              {
#ifndef FBNOPIXADDR
                  if (fbLane)
                  {
                     while (bits && n)
                     {
                         switch (fbLane[FbLeftStipBits(bits,pixelsPerDst)]) {
                            LaneCases((CARD8 *) dst);
                         }
                         bits = FbStipLeft(bits,pixelsPerDst);
                         dst++;
                         n--;
                     }
                     dst += n;
                  }
                  else
#endif
                  {
                     while (n--)
                     {
                         left = FbLeftStipBits(bits,pixelsPerDst);
                         if (left || !transparent)
                         {
                            mask = fbBits[left];
                            *dst = FbStippleRRop (*dst, mask,
                                                fgand, fgxor, bgand, bgxor);
                         }
                         dst++;
                         bits = FbStipLeft(bits, pixelsPerDst);
                     }
                  }
              }
              if (!w)
                  break;
              /*
               * Load another set and reset number of available units
               */
              LoadBits;
              n = unitsPerSrc;
              if (n > w)
                  n = w;
           }
       }
       /*
        * Consume stipple bits for endmask
        */
       if (endmask)
       {
           if (endNeedsLoad)
           {
              LoadBits;
           }
#if FB_UNIT > 32
           if (pixelsPerDst == 16)
              mask = FbStipple16Bits(FbLeftStipBits(bits,16));
           else
#endif
              mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
#ifndef FBNOPIXADDR
           if (fbLane)
           {
              fbTransparentSpan (dst, mask & endmask, fgxor, 1);
           }
           else
#endif
           {
              if (mask || !transparent)
                  FbDoRightMaskByteStippleRRop (dst, mask, 
                                            fgand, fgxor, bgand, bgxor,
                                            endbyte, endmask);
           }
       }
       dst += dstStride;
       src += srcStride;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fbBltOne24 ( FbStip srcLine,
FbStride  srcStride,
int  srcX,
FbBits dst,
FbStride  dstStride,
int  dstX,
int  dstBpp,
int  width,
int  height,
FbBits  fgand,
FbBits  fgxor,
FbBits  bgand,
FbBits  bgxor 
)

Definition at line 571 of file icbltone.c.

{
    FbStip    *src;
    FbBits    leftMask, rightMask, mask;
    int              nlMiddle, nl;
    FbStip    stip, bits;
    int              remain;
    int              dstS;
    int              firstlen;
    int              rot0, rot;
    int              nDst;
    
    srcLine += srcX >> FB_STIP_SHIFT;
    dst += dstX >> FB_SHIFT;
    srcX &= FB_STIP_MASK;
    dstX &= FB_MASK;
    rot0 = FbFirst24Rot (dstX);
    
    FbMaskBits (dstX, width, leftMask, nlMiddle, rightMask);
    
    dstS = (dstX + 23) / 24;
    firstlen = FbStip24Len - dstS;
    
    nDst = nlMiddle;
    if (leftMask)
       nDst++;
    dstStride -= nDst;
    
    /* opaque copy */
    if (bgand == 0 && fgand == 0)
    {
       while (height--)
       {
           rot = rot0;
           src = srcLine;
           srcLine += srcStride;
           fbInitStipBits (srcX,firstlen, stip);
           if (leftMask)
           {
              mask = fbStipple24Bits[rot >> 3][stip];
              *dst = (*dst & ~leftMask) | (FbOpaqueStipple (mask,
                                                       FbRot24(fgxor, rot),
                                                       FbRot24(bgxor, rot))
                                        & leftMask);
              dst++;
              fbNextStipBits(rot,stip);
           }
           nl = nlMiddle;
           while (nl--)
           {
              mask = fbStipple24Bits[rot>>3][stip];
              *dst = FbOpaqueStipple (mask, 
                                   FbRot24(fgxor, rot),
                                   FbRot24(bgxor, rot));
              dst++;
              fbNextStipBits(rot,stip);
           }
           if (rightMask)
           {
              mask = fbStipple24Bits[rot >> 3][stip];
              *dst = (*dst & ~rightMask) | (FbOpaqueStipple (mask,
                                                        FbRot24(fgxor, rot),
                                                        FbRot24(bgxor, rot))
                                         & rightMask);
           }
           dst += dstStride;
           src += srcStride;
       }
    }
    /* transparent copy */
    else if (bgand == FB_ALLONES && bgxor == 0 && fgand == 0)
    {
       while (height--)
       {
           rot = rot0;
           src = srcLine;
           srcLine += srcStride;
           fbInitStipBits (srcX, firstlen, stip);
           if (leftMask)
           {
              if (stip)
              {
                  mask = fbStipple24Bits[rot >> 3][stip] & leftMask;
                  *dst = (*dst & ~mask) | (FbRot24(fgxor, rot) & mask);
              }
              dst++;
              fbNextStipBits (rot, stip);
           }
           nl = nlMiddle;
           while (nl--)
           {
              if (stip)
              {
                  mask = fbStipple24Bits[rot>>3][stip];
                  *dst = (*dst & ~mask) | (FbRot24(fgxor,rot) & mask);
              }
              dst++;
              fbNextStipBits (rot, stip);
           }
           if (rightMask)
           {
              if (stip)
              {
                  mask = fbStipple24Bits[rot >> 3][stip] & rightMask;
                  *dst = (*dst & ~mask) | (FbRot24(fgxor, rot) & mask);
              }
           }
           dst += dstStride;
       }
    }
    else
    {
       while (height--)
       {
           rot = rot0;
           src = srcLine;
           srcLine += srcStride;
           fbInitStipBits (srcX, firstlen, stip);
           if (leftMask)
           {
              mask = fbStipple24Bits[rot >> 3][stip];
              *dst = FbStippleRRopMask (*dst, mask,
                                     FbRot24(fgand, rot),
                                     FbRot24(fgxor, rot),
                                     FbRot24(bgand, rot),
                                     FbRot24(bgxor, rot),
                                     leftMask);
              dst++;
              fbNextStipBits(rot,stip);
           }
           nl = nlMiddle;
           while (nl--)
           {
              mask = fbStipple24Bits[rot >> 3][stip];
              *dst = FbStippleRRop (*dst, mask,
                                  FbRot24(fgand, rot),
                                  FbRot24(fgxor, rot),
                                  FbRot24(bgand, rot),
                                  FbRot24(bgxor, rot));
              dst++;
              fbNextStipBits(rot,stip);
           }
           if (rightMask)
           {
              mask = fbStipple24Bits[rot >> 3][stip];
              *dst = FbStippleRRopMask (*dst, mask,
                                     FbRot24(fgand, rot),
                                     FbRot24(fgxor, rot),
                                     FbRot24(bgand, rot),
                                     FbRot24(bgxor, rot),
                                     rightMask);
           }
           dst += dstStride;
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static const uint8_t* fbLaneTable ( int  bpp) [static]

Definition at line 123 of file icbltone.c.

{
    switch (bpp) {
    case 8:
       return fb8Lane;
    case 16:
       return fb16Lane;
    case 32:
       return fb32Lane;
    }
    return NULL;
}

Here is the caller graph for this function:


Variable Documentation

uint8_t const fb16Lane[16] [static]
Initial value:
 {
    0, 3, 12, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
}

Definition at line 113 of file icbltone.c.

uint8_t const fb32Lane[16] [static]
Initial value:
 {
    0, 15,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
}

Definition at line 117 of file icbltone.c.

uint8_t const fb8Lane[16] [static]
Initial value:
 {
    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
}

Definition at line 109 of file icbltone.c.

Initial value:
 {
    
    {
       C2_24( 0, 0), C2_24 ( 1, 0), C2_24 ( 2, 0), C2_24 ( 3, 0),
    },
    
    {
       C2_24( 0, 8), C2_24 ( 1, 8), C2_24 ( 2, 8), C2_24 ( 3, 8),
    },
    
    {
       C2_24( 0,16), C2_24 ( 1,16), C2_24 ( 2,16), C2_24 ( 3,16),
    }
}

Definition at line 496 of file icbltone.c.