Back to index

scribus-ng  1.3.4.dfsg+svn20071115
Classes | Typedefs | Functions
art_rgb_svp.c File Reference
#include "scconfig.h"
#include "art_rgb_svp.h"
#include <libart_lgpl/art_svp.h>
#include <libart_lgpl/art_svp_render_aa.h>
#include "art_rgb.h"

Go to the source code of this file.

Classes

struct  _ArtRgbSVPData
struct  _ArtRgbSVPAlphaData

Typedefs

typedef struct _ArtRgbSVPData
typedef struct _ArtRgbSVPAlphaData

Functions

static void art_rgb_svp_callback_ (void *callback_data, int y, int start, ArtSVPRenderAAStep *steps, int n_steps)
void art_rgb_svp_aa_ (const ArtSVP *svp, int x0, int y0, int x1, int y1, art_u32 fg_color, art_u32 bg_color, art_u8 *buf, int rowstride, ArtAlphaGamma *alphagamma)
 art_rgb_svp_aa: Render sorted vector path into RGB buffer.
static void art_rgb_svp_alpha_callback_ (void *callback_data, int y, int start, ArtSVPRenderAAStep *steps, int n_steps)
static void art_rgb_svp_alpha_opaque_callback_ (void *callback_data, int y, int start, ArtSVPRenderAAStep *steps, int n_steps)
void art_rgb_svp_alpha_ (const ArtSVP *svp, int x0, int y0, int x1, int y1, art_u32 rgb, int alpha, art_u8 *buf, int rowstride, ArtAlphaGamma *alphagamma)
 art_rgb_svp_alpha: Alpha-composite sorted vector path over RGB buffer.

Class Documentation

struct _ArtRgbSVPData

Definition at line 33 of file art_rgb_svp.c.

Class Members
art_u8 * buf
art_u32 rgbtab
int rowstride
int x0
int x1
struct _ArtRgbSVPAlphaData

Definition at line 40 of file art_rgb_svp.c.

Class Members
art_u8 alpha
int alphatab
art_u8 b
art_u8 * buf
art_u8 g
art_u8 r
art_u32 rgb
int rowstride
int x0
int x1

Typedef Documentation

typedef struct _ArtRgbSVPAlphaData

Definition at line 31 of file art_rgb_svp.c.

typedef struct _ArtRgbSVPData

Definition at line 30 of file art_rgb_svp.c.


Function Documentation

void art_rgb_svp_aa_ ( const ArtSVP *  svp,
int  x0,
int  y0,
int  x1,
int  y1,
art_u32  fg_color,
art_u32  bg_color,
art_u8 *  buf,
int  rowstride,
ArtAlphaGamma *  alphagamma 
)

art_rgb_svp_aa: Render sorted vector path into RGB buffer.

: The source sorted vector path. : Left coordinate of destination rectangle. : Top coordinate of destination rectangle. : Right coordinate of destination rectangle. : Bottom coordinate of destination rectangle. : Foreground color in 0xRRGGBB format. : Background color in 0xRRGGBB format. : Destination RGB buffer. : Rowstride of buffer. : #ArtAlphaGamma for gamma-correcting the rendering.

Renders the shape specified with into the RGB buffer. - specifies the width, and - specifies the height, of the rectangle rendered. The new pixels are stored starting at the first byte of . Thus, the and parameters specify an offset within , and may be tweaked as a way of doing integer-pixel translations without fiddling with itself.

The and arguments specify the opaque colors to be used for rendering. For pixels of entirely 0 winding-number, is used. For pixels of entirely 1 winding number, is used. In between, the color is interpolated based on the fraction of the pixel with a winding number of 1. If is NULL, then linear interpolation (in pixel counts) is the default. Otherwise, the interpolation is as specified by .

Definition at line 141 of file art_rgb_svp.c.

{
  ArtRgbSVPData data;

  int r_fg, g_fg, b_fg;
  int r_bg, g_bg, b_bg;
  int r, g, b;
  int dr, dg, db;
  int i;

  if (alphagamma == NULL)
    {
      r_fg = fg_color >> 16;
      g_fg = (fg_color >> 8) & 0xff;
      b_fg = fg_color & 0xff;

      r_bg = bg_color >> 16;
      g_bg = (bg_color >> 8) & 0xff;
      b_bg = bg_color & 0xff;

      r = (r_bg << 16) + 0x8000;
      g = (g_bg << 16) + 0x8000;
      b = (b_bg << 16) + 0x8000;
      dr = ((r_fg - r_bg) << 16) / 255;
      dg = ((g_fg - g_bg) << 16) / 255;
      db = ((b_fg - b_bg) << 16) / 255;

      for (i = 0; i < 256; i++)
       {
         data.rgbtab[i] = (r & 0xff0000) | ((g & 0xff0000) >> 8) | (b >> 16);
         r += dr;
         g += dg;
         b += db;
       }
    }
  else
    {
      int *table;
      art_u8 *invtab;

      table = alphagamma->table;

      r_fg = table[fg_color >> 16];
      g_fg = table[(fg_color >> 8) & 0xff];
      b_fg = table[fg_color & 0xff];

      r_bg = table[bg_color >> 16];
      g_bg = table[(bg_color >> 8) & 0xff];
      b_bg = table[bg_color & 0xff];

      r = (r_bg << 16) + 0x8000;
      g = (g_bg << 16) + 0x8000;
      b = (b_bg << 16) + 0x8000;
      dr = ((r_fg - r_bg) << 16) / 255;
      dg = ((g_fg - g_bg) << 16) / 255;
      db = ((b_fg - b_bg) << 16) / 255;

      invtab = alphagamma->invtable;
      for (i = 0; i < 256; i++)
       {
         data.rgbtab[i] = (invtab[r >> 16] << 16) |
           (invtab[g >> 16] << 8) |
           invtab[b >> 16];
         r += dr;
         g += dg;
         b += db;
       }
    }
  data.buf = buf;
  data.rowstride = rowstride;
  data.x0 = x0;
  data.x1 = x1;
  art_svp_render_aa (svp, x0, y0, x1, y1, art_rgb_svp_callback_, &data);
}

Here is the call graph for this function:

void art_rgb_svp_alpha_ ( const ArtSVP *  svp,
int  x0,
int  y0,
int  x1,
int  y1,
art_u32  rgb,
int  alpha,
art_u8 *  buf,
int  rowstride,
ArtAlphaGamma *  alphagamma 
)

art_rgb_svp_alpha: Alpha-composite sorted vector path over RGB buffer.

: The source sorted vector path. : Left coordinate of destination rectangle. : Top coordinate of destination rectangle. : Right coordinate of destination rectangle. : Bottom coordinate of destination rectangle. : Color in 0xRRGGBBAA format. : Destination RGB buffer. : Rowstride of buffer. : #ArtAlphaGamma for gamma-correcting the compositing.

Renders the shape specified with over the RGB buffer. - specifies the width, and - specifies the height, of the rectangle rendered. The new pixels are stored starting at the first byte of . Thus, the and parameters specify an offset within , and may be tweaked as a way of doing integer-pixel translations without fiddling with itself.

The argument specifies the color for the rendering. Pixels of entirely 0 winding number are left untouched. Pixels of entirely 1 winding number have the color composited over them (ie, are replaced by the red, green, blue components of if the alpha component is 0xff). Pixels of intermediate coverage are interpolated according to the rule in , or default to linear if is NULL.

Definition at line 420 of file art_rgb_svp.c.

{
  ArtRgbSVPAlphaData data;
  int r, g, b;
  int i;
  int a, da;

#ifdef WORDS_BIGENDIAN
  r = (rgb >> 8)  & 0xff;
  g = (rgb >> 16) & 0xff;
  b = (rgb >> 24) & 0xff;
#else
  r = (rgb >> 16) & 0xff;
  g = (rgb >> 8) & 0xff;
  b = rgb & 0xff;
#endif

  data.r = r;
  data.g = g;
  data.b = b;
  data.alpha = alpha;
  data.rgb = rgb;

  a = 0x8000;
  da = (alpha * 66051 + 0x80) >> 8; /* 66051 equals 2 ^ 32 / (255 * 255) */

  for (i = 0; i < 256; i++)
    {
      data.alphatab[i] = a >> 16;
      a += da;
    }

  data.buf = buf;
  data.rowstride = rowstride;
  data.x0 = x0;
  data.x1 = x1;
  if (alpha == 255)
    art_svp_render_aa (svp, x0, y0, x1, y1, art_rgb_svp_alpha_opaque_callback_,
                     &data);
  else
    art_svp_render_aa (svp, x0, y0, x1, y1, art_rgb_svp_alpha_callback_, &data);
}

Here is the call graph for this function:

static void art_rgb_svp_alpha_callback_ ( void *  callback_data,
int  y,
int  start,
ArtSVPRenderAAStep *  steps,
int  n_steps 
) [static]

Definition at line 221 of file art_rgb_svp.c.

{
  ArtRgbSVPAlphaData *data = (ArtRgbSVPAlphaData *)callback_data;
  art_u8 *linebuf;
  int run_x0, run_x1;
  art_u32 running_sum = start;
  int x0, x1;
  int k;
  art_u8 r, g, b;
  int *alphatab;
  int alpha;

  linebuf = data->buf;
  x0 = data->x0;
  x1 = data->x1;

  r = data->r;
  g = data->g;
  b = data->b;
  alphatab = data->alphatab;

  if (n_steps > 0)
    {
      run_x1 = steps[0].x;
      if (run_x1 > x0)
       {
         alpha = (running_sum >> 16) & 0xff;
         if (alpha)
           art_rgb_run_alpha_ (linebuf,
                            r, g, b, alphatab[alpha],
                            run_x1 - x0);
       }

      for (k = 0; k < n_steps - 1; k++)
       {
         running_sum += steps[k].delta;
         run_x0 = run_x1;
         run_x1 = steps[k + 1].x;
         if (run_x1 > run_x0)
           {
             alpha = (running_sum >> 16) & 0xff;
             if (alpha)
              art_rgb_run_alpha_ (linebuf + (run_x0 - x0) * 4,
                               r, g, b, alphatab[alpha],
                               run_x1 - run_x0);
           }
       }
      running_sum += steps[k].delta;
      if (x1 > run_x1)
       {
         alpha = (running_sum >> 16) & 0xff;
         if (alpha)
           art_rgb_run_alpha_ (linebuf + (run_x1 - x0) * 4,
                            r, g, b, alphatab[alpha],
                            x1 - run_x1);
       }
    }
  else
    {
      alpha = (running_sum >> 16) & 0xff;
      if (alpha)
       art_rgb_run_alpha_ (linebuf,
                        r, g, b, alphatab[alpha],
                        x1 - x0);
    }

  data->buf += data->rowstride;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void art_rgb_svp_alpha_opaque_callback_ ( void *  callback_data,
int  y,
int  start,
ArtSVPRenderAAStep *  steps,
int  n_steps 
) [static]

Definition at line 292 of file art_rgb_svp.c.

{
  ArtRgbSVPAlphaData *data = (ArtRgbSVPAlphaData *)callback_data;
  art_u8 *linebuf;
  int run_x0, run_x1;
  art_u32 running_sum = start;
  int x0, x1;
  int k;
  art_u8 r, g, b;
  art_u32 rgb;
  int *alphatab;
  int alpha;

  linebuf = data->buf;
  x0 = data->x0;
  x1 = data->x1;

  r = data->r;
  g = data->g;
  b = data->b;
  rgb = data->rgb;
  alphatab = data->alphatab;

  if (n_steps > 0)
    {
      run_x1 = steps[0].x;
      if (run_x1 > x0)
       {
         alpha = running_sum >> 16;
         if (alpha)
           {
             if (alpha >= 255)
              art_rgb_fill_run_ (linebuf,
                              rgb,
                              run_x1 - x0);
             else
              art_rgb_run_alpha_ (linebuf,
                               r, g, b, alphatab[alpha],
                               run_x1 - x0);
           }
       }

      for (k = 0; k < n_steps - 1; k++)
       {
         running_sum += steps[k].delta;
         run_x0 = run_x1;
         run_x1 = steps[k + 1].x;
         if (run_x1 > run_x0)
           {
             alpha = running_sum >> 16;
             if (alpha)
              {
                if (alpha >= 255)
                  art_rgb_fill_run_ (linebuf + (run_x0 - x0) * 4,
                                  rgb,
                                  run_x1 - run_x0);
                else
                  art_rgb_run_alpha_ (linebuf + (run_x0 - x0) * 4,
                                   r, g, b, alphatab[alpha],
                                   run_x1 - run_x0);
              }
           }
       }
      running_sum += steps[k].delta;
      if (x1 > run_x1)
       {
         alpha = running_sum >> 16;
         if (alpha)
           {
             if (alpha >= 255)
              art_rgb_fill_run_ (linebuf + (run_x1 - x0) * 4,
                              rgb,
                              x1 - run_x1);
             else
              art_rgb_run_alpha_ (linebuf + (run_x1 - x0) * 4,
                               r, g, b, alphatab[alpha],
                               x1 - run_x1);
           }
       }
    }
  else
    {
      alpha = running_sum >> 16;
      if (alpha)
       {
         if (alpha >= 255)
           art_rgb_fill_run_ (linebuf,
                           rgb,
                           x1 - x0);
         else
           art_rgb_run_alpha_ (linebuf,
                            r, g, b, alphatab[alpha],
                            x1 - x0);
       }
    }
  data->buf += data->rowstride;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void art_rgb_svp_callback_ ( void *  callback_data,
int  y,
int  start,
ArtSVPRenderAAStep *  steps,
int  n_steps 
) [static]

Definition at line 50 of file art_rgb_svp.c.

{
  ArtRgbSVPData *data = (ArtRgbSVPData *)callback_data;
  art_u8 *linebuf;
  int run_x0, run_x1;
  art_u32 running_sum = start;
  art_u32 rgb;
  int x0, x1;
  int k;

  linebuf = data->buf;
  x0 = data->x0;
  x1 = data->x1;

  if (n_steps > 0)
    {
      run_x1 = steps[0].x;
      if (run_x1 > x0)
       {
         rgb = data->rgbtab[(running_sum >> 16) & 0xff];
/*       art_rgb_fill_run (linebuf,
                         rgb >> 16, (rgb >> 8) & 0xff, rgb & 0xff,
                         run_x1 - x0);*/
       }

      for (k = 0; k < n_steps - 1; k++)
       {
         running_sum += steps[k].delta;
         run_x0 = run_x1;
         run_x1 = steps[k + 1].x;
         if (run_x1 > run_x0)
           {
             rgb = data->rgbtab[(running_sum >> 16) & 0xff];
/*           art_rgb_fill_run (linebuf + (run_x0 - x0) * 3,
                            rgb >> 16, (rgb >> 8) & 0xff, rgb & 0xff,
                            run_x1 - run_x0);*/
           }
       }
      running_sum += steps[k].delta;
      if (x1 > run_x1)
       {
         rgb = data->rgbtab[(running_sum >> 16) & 0xff];
/*       art_rgb_fill_run (linebuf + (run_x1 - x0) * 3,
                         rgb >> 16, (rgb >> 8) & 0xff, rgb & 0xff,
                         x1 - run_x1);*/
       }
    }
  else
    {
      rgb = data->rgbtab[(running_sum >> 16) & 0xff];
/*      art_rgb_fill_run (linebuf,
                     rgb >> 16, (rgb >> 8) & 0xff, rgb & 0xff,
                     x1 - x0);*/
    }

  data->buf += data->rowstride;
}

Here is the caller graph for this function: