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

📄 ftraster.c

📁 qt-embedded-2.3.8.tar.gz源码
💻 C
📖 第 1 页 / 共 5 页
字号:
#define TRUNC( x )    ( (signed long)(x) >> ras.precision_bits )#define FRAC( x )     ( (x) & ( ras.precision - 1 ) )#define SCALED( x )   ( ( (x) << ras.scale_shift ) - ras.precision_half )  /* Note that I have moved the location of some fields in the */  /* structure to ensure that the most used variables are used */  /* at the top.  Thus, their offset can be coded with less    */  /* opcodes, and it results in a smaller executable.          */  struct  TRaster_Instance_  {    Int       precision_bits;       /* precision related variables         */    Int       precision;    Int       precision_half;    Long      precision_mask;    Int       precision_shift;    Int       precision_step;    Int       precision_jitter;    Int       scale_shift;          /* == precision_shift   for bitmaps    */                                    /* == precision_shift+1 for pixmaps    */    PLong     buff;                 /* The profiles buffer                 */    PLong     sizeBuff;             /* Render pool size                    */    PLong     maxBuff;              /* Profiles buffer size                */    PLong     top;                  /* Current cursor in buffer            */    FT_Error  error;    Int       numTurns;             /* number of Y-turns in outline        */    TPoint*   arc;                  /* current Bezier arc pointer          */    UShort    bWidth;               /* target bitmap width                 */    PByte     bTarget;              /* target bitmap buffer                */    PByte     gTarget;              /* target pixmap buffer                */    Long      lastX, lastY, minY, maxY;    UShort    num_Profs;            /* current number of profiles          */    Bool      fresh;                /* signals a fresh new profile which   */                                    /* 'start' field must be completed     */    Bool      joint;                /* signals that the last arc ended     */                                    /* exactly on a scanline.  Allows      */                                    /* removal of doublets                 */    PProfile  cProfile;             /* current profile                     */    PProfile  fProfile;             /* head of linked list of profiles     */    PProfile  gProfile;             /* contour's first profile in case     */                                    /* of impact                           */    TStates   state;                /* rendering state                     */    FT_Bitmap   target;             /* description of target bit/pixmap    */    FT_Outline  outline;    Long      traceOfs;             /* current offset in target bitmap     */    Long      traceG;               /* current offset in target pixmap     */    Short     traceIncr;            /* sweep's increment in target bitmap  */    Short     gray_min_x;           /* current min x during gray rendering */    Short     gray_max_x;           /* current max x during gray rendering */    /* dispatch variables */    Function_Sweep_Init*  Proc_Sweep_Init;    Function_Sweep_Span*  Proc_Sweep_Span;    Function_Sweep_Span*  Proc_Sweep_Drop;    Function_Sweep_Step*  Proc_Sweep_Step;    Byte      dropOutControl;       /* current drop_out control method     */    Bool      second_pass;          /* indicates wether a horizontal pass  */                                    /* should be performed to control      */                                    /* drop-out accurately when calling    */                                    /* Render_Glyph.  Note that there is   */                                    /* no horizontal pass during gray      */                                    /* rendering.                          */    TPoint    arcs[2 * MaxBezier + 1]; /* The Bezier stack                 */    TBand     band_stack[16];       /* band stack used for sub-banding     */    Int       band_top;             /* band stack top                      */    Int       count_table[256];     /* Look-up table used to quickly count */                                    /* set bits in a gray 2x2 cell         */    void*     memory;#ifdef FT_RASTER_OPTION_ANTI_ALIASING    Byte      grays[5];             /* Palette of gray levels used for     */                                    /* render.                             */    Byte      gray_lines[RASTER_GRAY_LINES];                                /* Intermediate table used to render the   */                                /* graylevels pixmaps.                     */                                /* gray_lines is a buffer holding two      */                                /* monochrome scanlines                    */    Short     gray_width;       /* width in bytes of one monochrome        */                                /* intermediate scanline of gray_lines.    */                                /* Each gray pixel takes 2 bits long there */                       /* The gray_lines must hold 2 lines, thus with size */                       /* in bytes of at least `gray_width*2'.             */#endif /* FT_RASTER_ANTI_ALIASING */#if 0    PByte       flags;              /* current flags table                 */    PUShort     outs;               /* current outlines table              */    FT_Vector*  coords;    UShort      nPoints;            /* number of points in current glyph   */    Short       nContours;          /* number of contours in current glyph */#endif  };#ifdef FT_CONFIG_OPTION_STATIC_RASTER  static TRaster_Instance  cur_ras;#define ras  cur_ras#else#define ras  (*raster)#endif /* FT_CONFIG_OPTION_STATIC_RASTER */  /*************************************************************************/  /*************************************************************************/  /**                                                                     **/  /**  PROFILES COMPUTATION                                               **/  /**                                                                     **/  /*************************************************************************/  /*************************************************************************/  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    Set_High_Precision                                                 */  /*                                                                       */  /* <Description>                                                         */  /*    Sets precision variables according to param flag.                  */  /*                                                                       */  /* <Input>                                                               */  /*    High :: Set to True for high precision (typically for ppem < 18),  */  /*            false otherwise.                                           */  /*                                                                       */  static  void  Set_High_Precision( RAS_ARGS Int  High )  {    if ( High )    {      ras.precision_bits   = 10;      ras.precision_step   = 128;      ras.precision_jitter = 24;    }    else    {      ras.precision_bits   = 6;      ras.precision_step   = 32;      ras.precision_jitter = 2;    }    FT_TRACE6(( "Set_High_Precision(%s)\n", High ? "true" : "false" ));    ras.precision       = 1L << ras.precision_bits;    ras.precision_half  = ras.precision / 2;    ras.precision_shift = ras.precision_bits - Pixel_Bits;    ras.precision_mask  = -ras.precision;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    New_Profile                                                        */  /*                                                                       */  /* <Description>                                                         */  /*    Creates a new profile in the render pool.                          */  /*                                                                       */  /* <Input>                                                               */  /*    aState :: The state/orientation of the new profile.                */  /*                                                                       */  /* <Return>                                                              */  /*   SUCCESS on success.  FAILURE in case of overflow or of incoherent   */  /*   profile.                                                            */  /*                                                                       */  static  Bool  New_Profile( RAS_ARGS TStates  aState )  {    if ( !ras.fProfile )    {      ras.cProfile  = (PProfile)ras.top;      ras.fProfile  = ras.cProfile;      ras.top      += AlignProfileSize;    }    if ( ras.top >= ras.maxBuff )    {      ras.error = Raster_Err_Overflow;      return FAILURE;    }    switch ( aState )    {    case Ascending:      ras.cProfile->flow = Flow_Up;      FT_TRACE6(( "New ascending profile = %lx\n", (long)ras.cProfile ));      break;    case Descending:      ras.cProfile->flow = Flow_Down;      FT_TRACE6(( "New descending profile = %lx\n", (long)ras.cProfile ));      break;    default:      FT_ERROR(( "New_Profile: invalid profile direction!\n" ));      ras.error = Raster_Err_Invalid;      return FAILURE;    }    ras.cProfile->start  = 0;    ras.cProfile->height = 0;    ras.cProfile->offset = ras.top;    ras.cProfile->link   = (PProfile)0;    ras.cProfile->next   = (PProfile)0;    if ( !ras.gProfile )      ras.gProfile = ras.cProfile;    ras.state = aState;    ras.fresh = TRUE;    ras.joint = FALSE;    return SUCCESS;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    End_Profile                                                        */  /*                                                                       */  /* <Description>                                                         */  /*    Finalizes the current profile.                                     */  /*                                                                       */  /* <Return>                                                              */  /*    SUCCESS on success.  FAILURE in case of overflow or incoherency.   */  /*                                                                       */  static  Bool  End_Profile( RAS_ARG )  {    Long      h;    PProfile  oldProfile;    h = ras.top - ras.cProfile->offset;    if ( h < 0 )    {      FT_ERROR(( "End_Profile: negative height encountered!\n" ));      ras.error = Raster_Err_Neg_Height;      return FAILURE;    }    if ( h > 0 )    {      FT_TRACE6(( "Ending profile %lx, start = %ld, height = %ld\n",                  (long)ras.cProfile, ras.cProfile->start, h ));      oldProfile           = ras.cProfile;      ras.cProfile->height = h;      ras.cProfile         = (PProfile)ras.top;      ras.top             += AlignProfileSize;      ras.cProfile->height = 0;      ras.cProfile->offset = ras.top;      oldProfile->next     = ras.cProfile;      ras.num_Profs++;    }    if ( ras.top >= ras.maxBuff )    {      FT_TRACE1(( "overflow in End_Profile\n" ));      ras.error = Raster_Err_Overflow;      return FAILURE;    }    ras.joint = FALSE;    return SUCCESS;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    Insert_Y_Turn                                                      */  /*                                                                       */  /* <Description>                                                         */  /*    Inserts a salient into the sorted list placed on top of the render */  /*    pool.                                                              */  /*                                                                       */  /* <Input>                                                               */  /*    New y scanline position.                                           */  /*                                                                       */  /* <Return>                                                              */  /*    SUCCESS on success.  FAILURE in case of overflow.                  */  /*                                                                       */  static  Bool  Insert_Y_Turn( RAS_ARGS Int  y )  {    PLong     y_turns;    Int       y2, n;    n       = ras.numTurns - 1;    y_turns = ras.sizeBuff - ras.numTurns;    /* look for first y value that is <= */    while ( n >= 0 && y < y_turns[n] )      n--;    /* if it is <, simply insert it, ignore if == */    if ( n >= 0 && y > y_turns[n] )      while ( n >= 0 )      {        y2 = y_turns[n];        y_turns[n] = y;        y = y2;        n--;      }    if ( n < 0 )    {      if ( ras.maxBuff <= ras.top )      {        ras.error = Raster_Err_Overflow;        return FAILURE;      }      ras.maxBuff--;      ras.numTurns++;      ras.sizeBuff[-ras.numTurns] = y;    }    return SUCCESS;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */

⌨️ 快捷键说明

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