Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
fbedge.c File Reference
#include <string.h>
#include "pixman-xserver-compat.h"
#include "fbedgeimp.h"

Go to the source code of this file.

Defines

#define N_BITS   4
#define rasterizeEdges   fbRasterizeEdges4
#define Shift4(o)   ((o) << 2)
#define Get4(x, o)   (((x) >> Shift4(o)) & 0xf)
#define Put4(x, o, v)   (((x) & ~(0xf << Shift4(o))) | (((v) & 0xf) << Shift4(o)))
#define DefineAlpha(line, x)
#define StepAlpha   ((__ap += __ao), (__ao ^= 1))
#define AddAlpha(a)
#define N_BITS   1
#define rasterizeEdges   fbRasterizeEdges1

Functions

static INLINE CARD8 clip255 (int x)
static INLINE void add_saturate_8 (CARD8 *buf, int value, int length)
static void fbRasterizeEdges8 (FbBits *buf, int width, int stride, RenderEdge *l, RenderEdge *r, xFixed t, xFixed b)
void fbRasterizeEdges (FbBits *buf, int bpp, int width, int stride, RenderEdge *l, RenderEdge *r, xFixed t, xFixed b)

Define Documentation

#define AddAlpha (   a)
Value:
{                                         \
    CARD8   __o = *__ap;                                \
    CARD8   __a = (a) + Get4(__o, __ao);                \
    *__ap = Put4 (__o, __ao, __a | (0 - ((__a) >> 4)));        \
}

Definition at line 52 of file fbedge.c.

#define DefineAlpha (   line,
  x 
)
Value:
CARD8   *__ap = (CARD8 *) line + ((x) >> 1); \
    int           __ao = (x) & 1

Definition at line 46 of file fbedge.c.

#define Get4 (   x,
  o 
)    (((x) >> Shift4(o)) & 0xf)

Definition at line 43 of file fbedge.c.

#define N_BITS   4

Definition at line 71 of file fbedge.c.

#define N_BITS   1

Definition at line 71 of file fbedge.c.

#define Put4 (   x,
  o,
  v 
)    (((x) & ~(0xf << Shift4(o))) | (((v) & 0xf) << Shift4(o)))

Definition at line 44 of file fbedge.c.

#define rasterizeEdges   fbRasterizeEdges4

Definition at line 72 of file fbedge.c.

#define rasterizeEdges   fbRasterizeEdges1

Definition at line 72 of file fbedge.c.

#define Shift4 (   o)    ((o) << 2)

Definition at line 38 of file fbedge.c.

#define StepAlpha   ((__ap += __ao), (__ao ^= 1))

Definition at line 50 of file fbedge.c.


Function Documentation

static INLINE void add_saturate_8 ( CARD8 buf,
int  value,
int  length 
) [static]

Definition at line 91 of file fbedge.c.

{
    while (length--)
    {
        *buf = clip255 (*buf + value);
        buf++;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static INLINE CARD8 clip255 ( int  x) [static]

Definition at line 84 of file fbedge.c.

{
    if (x > 255) return 255;
    return x;
}

Here is the caller graph for this function:

void fbRasterizeEdges ( FbBits buf,
int  bpp,
int  width,
int  stride,
RenderEdge l,
RenderEdge r,
xFixed  t,
xFixed  b 
)

Definition at line 282 of file fbedge.c.

{
    switch (bpp) {
    case 1:
       fbRasterizeEdges1 (buf, width, stride, l, r, t, b);
       break;
    case 4:
       fbRasterizeEdges4 (buf, width, stride, l, r, t, b);
       break;
    case 8:
       fbRasterizeEdges8 (buf, width, stride, l, r, t, b);
       break;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void fbRasterizeEdges8 ( FbBits buf,
int  width,
int  stride,
RenderEdge l,
RenderEdge r,
xFixed  t,
xFixed  b 
) [static]

Definition at line 112 of file fbedge.c.

{
    xFixed  y = t;
    FbBits  *line;
    int fill_start = -1, fill_end = -1;
    int fill_size = 0;

    line = buf + xFixedToInt (y) * stride;

    for (;;)
    {
        CARD8 *ap = (CARD8 *) line;
       xFixed lx, rx;
       int    lxi, rxi;
       
       /* clip X */
       lx = l->x;
       if (lx < 0)
           lx = 0;
       rx = r->x;
       if (xFixedToInt (rx) >= width)
           rx = IntToxFixed (width);
       
       /* Skip empty (or backwards) sections */
       if (rx > lx)
       {
            int lxs, rxs;

           /* Find pixel bounds for span. */
           lxi = xFixedToInt (lx);
           rxi = xFixedToInt (rx);

            /* Sample coverage for edge pixels */
            lxs = RenderSamplesX (lx, 8);
            rxs = RenderSamplesX (rx, 8);

            /* Add coverage across row */
            if (lxi == rxi)
            {
                ap[lxi] = clip255 (ap[lxi] + rxs - lxs);
            }
            else
            {
                ap[lxi] = clip255 (ap[lxi] + N_X_FRAC(8) - lxs);

                /* Move forward so that lxi/rxi is the pixel span */
                lxi++;

                /* Don't bother trying to optimize the fill unless
                 * the span is longer than 4 pixels. */
                if (rxi - lxi > 4)
                {
                    if (fill_start < 0)
                    {
                        fill_start = lxi;
                        fill_end = rxi;
                        fill_size++;
                    }
                    else
                    {
                        if (lxi >= fill_end || rxi < fill_start)
                        {
                            /* We're beyond what we saved, just fill it */
                            add_saturate_8 (ap + fill_start,
                                            fill_size * N_X_FRAC(8),
                                            fill_end - fill_start);
                            fill_start = lxi;
                            fill_end = rxi;
                            fill_size = 1;
                        }
                        else
                        {
                            /* Update fill_start */
                            if (lxi > fill_start)
                            {
                                add_saturate_8 (ap + fill_start,
                                                fill_size * N_X_FRAC(8),
                                                lxi - fill_start);
                                fill_start = lxi;
                            }
                            else if (lxi < fill_start)
                            {
                                add_saturate_8 (ap + lxi, N_X_FRAC(8),
                                                fill_start - lxi);
                            }

                            /* Update fill_end */
                            if (rxi < fill_end)
                            {
                                add_saturate_8 (ap + rxi,
                                                fill_size * N_X_FRAC(8),
                                                fill_end - rxi);
                                fill_end = rxi;
                            }
                            else if (fill_end < rxi)
                            {
                                add_saturate_8 (ap + fill_end,
                                                N_X_FRAC(8),
                                                rxi - fill_end);
                            }
                            fill_size++;
                        }
                    }
                }
                else
                {
                    add_saturate_8 (ap + lxi, N_X_FRAC(8), rxi - lxi);
                }

                /* Do not add in a 0 alpha here. This check is
                 * necessary to avoid a buffer overrun, (when rx
                 * is exactly on a pixel boundary). */
                if (rxs)
                    ap[rxi] = clip255 (ap[rxi] + rxs);
            }
       }

       if (y == b) {
            /* We're done, make sure we clean up any remaining fill. */
            if (fill_start != fill_end) {
                if (fill_size == N_Y_FRAC(8))
                {
                    memset (ap + fill_start, 0xff, fill_end - fill_start);
                }
                else
                {
                    add_saturate_8 (ap + fill_start, fill_size * N_X_FRAC(8),
                                    fill_end - fill_start);
                }
            }
           break;
        }

       if (xFixedFrac (y) != Y_FRAC_LAST(8))
       {
           RenderEdgeStepSmall (l);
           RenderEdgeStepSmall (r);
           y += STEP_Y_SMALL(8);
       }
       else
       {
           RenderEdgeStepBig (l);
           RenderEdgeStepBig (r);
           y += STEP_Y_BIG(8);
            if (fill_start != fill_end)
            {
                if (fill_size == N_Y_FRAC(8))
                {
                    memset (ap + fill_start, 0xff, fill_end - fill_start);
                }
                else
                {
                    add_saturate_8 (ap + fill_start, fill_size * N_X_FRAC(8),
                                    fill_end - fill_start);
                }
                fill_start = fill_end = -1;
                fill_size = 0;
            }
           line += stride;
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function: