⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ftraster.c

📁 qt-embedded-2.3.8.tar.gz源码
💻 C
📖 第 1 页 / 共 5 页
字号:
  /*    Finalize_Profile_Table                                             */  /*                                                                       */  /* <Description>                                                         */  /*    Adjusts all links in the profiles list.                            */  /*                                                                       */  /* <Return>                                                              */  /*    SUCCESS on success.  FAILURE in case of overflow.                  */  /*                                                                       */  static  Bool  Finalize_Profile_Table( RAS_ARG )  {    Int       bottom, top;    UShort    n;    PProfile  p;    n = ras.num_Profs;    if ( n > 1 )    {      p = ras.fProfile;      while ( n > 0 )      {        if ( n > 1 )          p->link = (PProfile)( p->offset + p->height );        else          p->link = NULL;        switch ( p->flow )        {        case Flow_Down:          bottom     = p->start - p->height+1;          top        = p->start;          p->start   = bottom;          p->offset += p->height - 1;          break;        case Flow_Up:        default:          bottom = p->start;          top    = p->start + p->height - 1;        }        if ( Insert_Y_Turn( RAS_VARS bottom )   ||             Insert_Y_Turn( RAS_VARS top + 1 )  )          return FAILURE;        p = p->link;        n--;      }    }    else      ras.fProfile = NULL;    return SUCCESS;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    Split_Conic                                                        */  /*                                                                       */  /* <Description>                                                         */  /*    Subdivides one conic Bezier into two joint sub-arcs in the Bezier  */  /*    stack.                                                             */  /*                                                                       */  /* <Input>                                                               */  /*    None (subdivided Bezier is taken from the top of the stack).       */  /*                                                                       */  /* <Note>                                                                */  /*    This routine is the `beef' of this component.  It is  _the_ inner  */  /*    loop that should be optimized to hell to get the best performance. */  /*                                                                       */  static  void  Split_Conic( TPoint*  base )  {    Long  a, b;    base[4].x = base[2].x;    b = base[1].x;    a = base[3].x = ( base[2].x + b ) / 2;    b = base[1].x = ( base[0].x + b ) / 2;    base[2].x = ( a + b ) / 2;    base[4].y = base[2].y;    b = base[1].y;    a = base[3].y = ( base[2].y + b ) / 2;    b = base[1].y = ( base[0].y + b ) / 2;    base[2].y = ( a + b ) / 2;    /* hand optimized.  gcc doesn't seem to be too good at common      */    /* expression substitution and instruction scheduling ;-)          */  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    Split_Cubic                                                        */  /*                                                                       */  /* <Description>                                                         */  /*    Subdivides a third-order Bezier arc into two joint sub-arcs in the */  /*    Bezier stack.                                                      */  /*                                                                       */  /* <Note>                                                                */  /*    This routine is the `beef' of the component.  It is one of _the_   */  /*    inner loops that should be optimized like hell to get the best     */  /*    performance.                                                       */  /*                                                                       */  static  void  Split_Cubic( TPoint*  base )  {    Long  a, b, c, d;    base[6].x = base[3].x;    c = base[1].x;    d = base[2].x;    base[1].x = a = ( base[0].x + c + 1 ) >> 1;    base[5].x = b = ( base[3].x + d + 1 ) >> 1;    c = ( c + d + 1 ) >> 1;    base[2].x = a = ( a + c + 1 ) >> 1;    base[4].x = b = ( b + c + 1 ) >> 1;    base[3].x = ( a + b + 1 ) >> 1;    base[6].y = base[3].y;    c = base[1].y;    d = base[2].y;    base[1].y = a = ( base[0].y + c + 1 ) >> 1;    base[5].y = b = ( base[3].y + d + 1 ) >> 1;    c = ( c + d + 1 ) >> 1;    base[2].y = a = ( a + c + 1 ) >> 1;    base[4].y = b = ( b + c + 1 ) >> 1;    base[3].y = ( a + b + 1 ) >> 1;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    Line_Up                                                            */  /*                                                                       */  /* <Description>                                                         */  /*    Computes the x-coordinates of an ascending line segment and stores */  /*    them in the render pool.                                           */  /*                                                                       */  /* <Input>                                                               */  /*    x1   :: The x-coordinate of the segment's start point.             */  /*                                                                       */  /*    y1   :: The y-coordinate of the segment's start point.             */  /*                                                                       */  /*    x2   :: The x-coordinate of the segment's end point.               */  /*                                                                       */  /*    y2   :: The y-coordinate of the segment's end point.               */  /*                                                                       */  /*    miny :: A lower vertical clipping bound value.                     */  /*                                                                       */  /*    maxy :: An upper vertical clipping bound value.                    */  /*                                                                       */  /* <Return>                                                              */  /*    SUCCESS on success, FAILURE on render pool overflow.               */  /*                                                                       */  static  Bool  Line_Up( RAS_ARGS Long  x1,                          Long  y1,                          Long  x2,                          Long  y2,                          Long  miny,                          Long  maxy )  {    Long   Dx, Dy;    Int    e1, e2, f1, f2, size;     /* XXX: is `Short' sufficient? */    Long   Ix, Rx, Ax;    PLong  top;    Dx = x2 - x1;    Dy = y2 - y1;    if ( Dy <= 0 || y2 < miny || y1 > maxy )      return SUCCESS;    if ( y1 < miny )    {      /* Take care: miny-y1 can be a very large value; we use     */      /*            a slow MulDiv function to avoid clipping bugs */      x1 += SMulDiv( Dx, miny - y1, Dy );      e1  = TRUNC( miny );      f1  = 0;    }    else    {      e1 = TRUNC( y1 );      f1 = FRAC( y1 );    }    if ( y2 > maxy )    {      /* x2 += FMulDiv( Dx, maxy - y2, Dy );  UNNECESSARY */      e2  = TRUNC( maxy );      f2  = 0;    }    else    {      e2 = TRUNC( y2 );      f2 = FRAC( y2 );    }    if ( f1 > 0 )    {      if ( e1 == e2 )        return SUCCESS;      else      {        x1 += FMulDiv( Dx, ras.precision - f1, Dy );        e1 += 1;      }    }    else      if ( ras.joint )      {        ras.top--;        ras.joint = FALSE;      }    ras.joint = ( f2 == 0 );    if ( ras.fresh )    {      ras.cProfile->start = e1;      ras.fresh           = FALSE;    }    size = e2 - e1 + 1;    if ( ras.top + size >= ras.maxBuff )    {      ras.error = Raster_Err_Overflow;      return FAILURE;    }    if ( Dx > 0 )    {      Ix = ( ras.precision * Dx ) / Dy;      Rx = ( ras.precision * Dx ) % Dy;      Dx = 1;    }    else    {      Ix = -( ( ras.precision * -Dx ) / Dy );      Rx =    ( ras.precision * -Dx ) % Dy;      Dx = -1;    }    Ax  = -Dy;    top = ras.top;    while ( size > 0 )    {      *top++ = x1;      x1 += Ix;      Ax += Rx;      if ( Ax >= 0 )      {        Ax -= Dy;        x1 += Dx;      }      size--;    }    ras.top = top;    return SUCCESS;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    Line_Down                                                          */  /*                                                                       */  /* <Description>                                                         */  /*    Computes the x-coordinates of an descending line segment and       */  /*    stores them in the render pool.                                    */  /*                                                                       */  /* <Input>                                                               */  /*    x1   :: The x-coordinate of the segment's start point.             */  /*                                                                       */  /*    y1   :: The y-coordinate of the segment's start point.             */  /*                                                                       */  /*    x2   :: The x-coordinate of the segment's end point.               */  /*                                                                       */  /*    y2   :: The y-coordinate of the segment's end point.               */  /*                                                                       */  /*    miny :: A lower vertical clipping bound value.                     */  /*                                                                       */  /*    maxy :: An upper vertical clipping bound value.                    */  /*                                                                       */  /* <Return>                                                              */  /*    SUCCESS on success, FAILURE on render pool overflow.               */  /*                                                                       */  static  Bool  Line_Down( RAS_ARGS Long  x1,                            Long  y1,                            Long  x2,                            Long  y2,                            Long  miny,                            Long  maxy )  {    Bool  result, fresh;    fresh  = ras.fresh;    result = Line_Up( RAS_VARS x1, -y1, x2, -y2, -maxy, -miny );    if ( fresh && !ras.fresh )      ras.cProfile->start = -ras.cProfile->start;    return result;  }  /* A function type describing the functions used to split Bezier arcs */  typedef void  (*TSplitter)( TPoint*  base );  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    Bezier_Up                                                          */  /*                                                                       */  /* <Description>                                                         */  /*    Computes the x-coordinates of an ascending Bezier arc and stores   */  /*    them in the render pool.                                           */  /*                                                                       */  /* <Input>                                                               */  /*    degree   :: The degree of the Bezier arc (either 2 or 3).          */  /*                                                                       */  /*    splitter :: The function to split Bezier arcs.                     */  /*                                                                       */  /*    miny     :: A lower vertical clipping bound value.                 */  /*                                                                       */  /*    maxy     :: An upper vertical clipping bound value.                */  /*                                                                       */  /* <Return>                                                              */  /*    SUCCESS on success, FAILURE on render pool overflow.               */  /*                                                                       */  static  Bool  Bezier_Up( RAS_ARGS Int        degree,                            TSplitter  splitter,                            Long       miny,                            Long       maxy )  {    Long   y1, y2, e, e2, e0;    Short  f1;    TPoint*  arc;    TPoint*  start_arc;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -