misc/libfreetype/src/raster/ftraster.c
author koda
Mon, 25 Apr 2011 01:46:54 +0200
changeset 5172 88f2e05288ba
permissions -rw-r--r--
aaand let's add freetype as well while we are at it other smaller changes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     1
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     2
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     3
/*  ftraster.c                                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
/*    The FreeType glyph rasterizer (body).                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
/*  Copyright 1996-2001, 2002, 2003, 2005, 2007, 2008, 2009, 2010, 2011 by */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*  This file is part of the FreeType project, and may only be used,       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  modified, and distributed under the terms of the FreeType project      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
/*  this file you indicate that you have read the license and              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
  /* This file can be compiled without the rest of the FreeType engine, by */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
  /* defining the _STANDALONE_ macro when compiling it.  You also need to  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
  /* put the files `ftimage.h' and `ftmisc.h' into the $(incdir)           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
  /* directory.  Typically, you should do something like                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
  /* - copy `src/raster/ftraster.c' (this file) to your current directory  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
  /* - copy `include/freetype/ftimage.h' and `src/raster/ftmisc.h'         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
  /*   to your current directory                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
  /* - compile `ftraster' with the _STANDALONE_ macro defined, as in       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
  /*     cc -c -D_STANDALONE_ ftraster.c                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
  /* The renderer can be initialized with a call to                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
  /* `ft_standard_raster.raster_new'; a bitmap can be generated            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
  /* with a call to `ft_standard_raster.raster_render'.                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
  /* See the comments and documentation in the file `ftimage.h' for more   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
  /* details on how the raster works.                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
  /* This is a rewrite of the FreeType 1.x scan-line converter             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
#ifdef _STANDALONE_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
#define FT_CONFIG_STANDARD_LIBRARY_H  <stdlib.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
#include <string.h>           /* for memset */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
#include "ftmisc.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
#include "ftimage.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
#else /* !_STANDALONE_ */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
#include "ftraster.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
#include FT_INTERNAL_CALC_H   /* for FT_MulDiv only */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
#include "rastpic.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
#endif /* !_STANDALONE_ */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
  /* A simple technical note on how the raster works                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
  /* -----------------------------------------------                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
  /*   Converting an outline into a bitmap is achieved in several steps:   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
  /*   1 - Decomposing the outline into successive `profiles'.  Each       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
  /*       profile is simply an array of scanline intersections on a given */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
  /*       dimension.  A profile's main attributes are                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
  /*       o its scanline position boundaries, i.e. `Ymin' and `Ymax'      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
  /*       o an array of intersection coordinates for each scanline        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
  /*         between `Ymin' and `Ymax'                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
  /*       o a direction, indicating whether it was built going `up' or    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
  /*         `down', as this is very important for filling rules           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
  /*       o its drop-out mode                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
  /*   2 - Sweeping the target map's scanlines in order to compute segment */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
  /*       `spans' which are then filled.  Additionally, this pass         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
  /*       performs drop-out control.                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
  /*   The outline data is parsed during step 1 only.  The profiles are    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
  /*   built from the bottom of the render pool, used as a stack.  The     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
  /*   following graphics shows the profile list under construction:       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
  /*     __________________________________________________________ _ _    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
  /*    |         |                 |         |                 |          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
  /*    | profile | coordinates for | profile | coordinates for |-->       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
  /*    |    1    |  profile 1      |    2    |  profile 2      |-->       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
  /*    |_________|_________________|_________|_________________|__ _ _    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
  /*    ^                                                       ^          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
  /*    |                                                       |          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
  /* start of render pool                                      top         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
  /*   The top of the profile stack is kept in the `top' variable.         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
  /*   As you can see, a profile record is pushed on top of the render     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
  /*   pool, which is then followed by its coordinates/intersections.  If  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
  /*   a change of direction is detected in the outline, a new profile is  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
  /*   generated until the end of the outline.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
  /*   Note that when all profiles have been generated, the function       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
  /*   Finalize_Profile_Table() is used to record, for each profile, its   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
  /*   bottom-most scanline as well as the scanline above its upmost       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
  /*   boundary.  These positions are called `y-turns' because they (sort  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
  /*   of) correspond to local extrema.  They are stored in a sorted list  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
  /*   built from the top of the render pool as a downwards stack:         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
  /*      _ _ _______________________________________                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
  /*                            |                    |                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
  /*                         <--| sorted list of     |                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
  /*                         <--|  extrema scanlines |                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
  /*      _ _ __________________|____________________|                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
  /*                            ^                    ^                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
  /*                            |                    |                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
  /*                         maxBuff           sizeBuff = end of pool      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
  /*   This list is later used during the sweep phase in order to          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
  /*   optimize performance (see technical note on the sweep below).       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
  /*   Of course, the raster detects whether the two stacks collide and    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
  /*   handles the situation properly.                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
  /**                                                                     **/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
  /**  CONFIGURATION MACROS                                               **/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
  /**                                                                     **/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
  /* define DEBUG_RASTER if you want to compile a debugging version */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
/* #define DEBUG_RASTER */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
  /* define FT_RASTER_OPTION_ANTI_ALIASING if you want to support */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
  /* 5-levels anti-aliasing                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
/* #define FT_RASTER_OPTION_ANTI_ALIASING */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
  /* The size of the two-lines intermediate bitmap used */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
  /* for anti-aliasing, in bytes.                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
#define RASTER_GRAY_LINES  2048
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
  /**                                                                     **/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
  /**  OTHER MACROS (do not change)                                       **/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
  /**                                                                     **/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
  /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
  /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
  /* messages during execution.                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
#define FT_COMPONENT  trace_raster
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
#ifdef _STANDALONE_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
  /* This macro is used to indicate that a function parameter is unused. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
  /* Its purpose is simply to reduce compiler warnings.  Note also that  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
  /* simply defining it as `(void)x' doesn't avoid warnings with certain */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
  /* ANSI compilers (e.g. LCC).                                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
#define FT_UNUSED( x )  (x) = (x)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
  /* Disable the tracing mechanism for simplicity -- developers can      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
  /* activate it easily by redefining these two macros.                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
#ifndef FT_ERROR
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
#define FT_ERROR( x )  do { } while ( 0 )     /* nothing */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
#ifndef FT_TRACE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
#define FT_TRACE( x )   do { } while ( 0 )    /* nothing */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
#define FT_TRACE1( x )  do { } while ( 0 )    /* nothing */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
#define FT_TRACE6( x )  do { } while ( 0 )    /* nothing */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
#define Raster_Err_None          0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
#define Raster_Err_Not_Ini      -1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
#define Raster_Err_Overflow     -2
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
#define Raster_Err_Neg_Height   -3
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
#define Raster_Err_Invalid      -4
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
#define Raster_Err_Unsupported  -5
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
#define ft_memset  memset
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
#define FT_DEFINE_RASTER_FUNCS( class_, glyph_format_, raster_new_, \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
                                raster_reset_, raster_set_mode_,    \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
                                raster_render_, raster_done_ )      \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
          const FT_Raster_Funcs class_ =                            \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
          {                                                         \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
            glyph_format_,                                          \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
            raster_new_,                                            \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
            raster_reset_,                                          \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
            raster_set_mode_,                                       \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
            raster_render_,                                         \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
            raster_done_                                            \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
         };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
#else /* !_STANDALONE_ */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
#include FT_INTERNAL_OBJECTS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
#include FT_INTERNAL_DEBUG_H        /* for FT_TRACE() and FT_ERROR() */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
#include "rasterrs.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
#define Raster_Err_None         Raster_Err_Ok
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
#define Raster_Err_Not_Ini      Raster_Err_Raster_Uninitialized
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
#define Raster_Err_Overflow     Raster_Err_Raster_Overflow
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
#define Raster_Err_Neg_Height   Raster_Err_Raster_Negative_Height
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
#define Raster_Err_Invalid      Raster_Err_Invalid_Outline
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
#define Raster_Err_Unsupported  Raster_Err_Cannot_Render_Glyph
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
#endif /* !_STANDALONE_ */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
#ifndef FT_MEM_SET
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
#define FT_MEM_SET( d, s, c )  ft_memset( d, s, c )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
#ifndef FT_MEM_ZERO
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
#define FT_MEM_ZERO( dest, count )  FT_MEM_SET( dest, 0, count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
  /* FMulDiv means `Fast MulDiv'; it is used in case where `b' is       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
  /* typically a small value and the result of a*b is known to fit into */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
  /* 32 bits.                                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
#define FMulDiv( a, b, c )  ( (a) * (b) / (c) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
  /* On the other hand, SMulDiv means `Slow MulDiv', and is used typically */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
  /* for clipping computations.  It simply uses the FT_MulDiv() function   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
  /* defined in `ftcalc.h'.                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
#define SMulDiv  FT_MulDiv
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
  /* The rasterizer is a very general purpose component; please leave */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
  /* the following redefinitions there (you never know your target    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
  /* environment).                                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
#ifndef TRUE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
#define TRUE   1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
#ifndef FALSE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
#define FALSE  0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
#ifndef NULL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
#define NULL  (void*)0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
#ifndef SUCCESS
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
#define SUCCESS  0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
#ifndef FAILURE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
#define FAILURE  1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
#define MaxBezier  32   /* The maximum number of stacked Bezier curves. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
                        /* Setting this constant to more than 32 is a   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
                        /* pure waste of space.                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
#define Pixel_Bits  6   /* fractional bits of *input* coordinates */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
  /**                                                                     **/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
  /**  SIMPLE TYPE DECLARATIONS                                           **/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
  /**                                                                     **/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
  typedef int             Int;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
  typedef unsigned int    UInt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
  typedef short           Short;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
  typedef unsigned short  UShort, *PUShort;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
  typedef long            Long, *PLong;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
  typedef unsigned char   Byte, *PByte;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
  typedef char            Bool;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
  typedef union  Alignment_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
    long    l;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
    void*   p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
    void  (*f)(void);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
  } Alignment, *PAlignment;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
  typedef struct  TPoint_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
    Long  x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
    Long  y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
  } TPoint;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
  /* values for the `flags' bit field */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
#define Flow_Up           0x8
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
#define Overshoot_Top     0x10
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
#define Overshoot_Bottom  0x20
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
  /* States of each line, arc, and profile */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
  typedef enum  TStates_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
    Unknown_State,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
    Ascending_State,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
    Descending_State,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
    Flat_State
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
  } TStates;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
  typedef struct TProfile_  TProfile;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
  typedef TProfile*         PProfile;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
  struct  TProfile_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
    FT_F26Dot6  X;           /* current coordinate during sweep          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
    PProfile    link;        /* link to next profile (various purposes)  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
    PLong       offset;      /* start of profile's data in render pool   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
    unsigned    flags;       /* Bit 0-2: drop-out mode                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
                             /* Bit 3: profile orientation (up/down)     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
                             /* Bit 4: is top profile?                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
                             /* Bit 5: is bottom profile?                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
    long        height;      /* profile's height in scanlines            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
    long        start;       /* profile's starting scanline              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
    unsigned    countL;      /* number of lines to step before this      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
                             /* profile becomes drawable                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
    PProfile    next;        /* next profile in same contour, used       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
                             /* during drop-out control                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
  typedef PProfile   TProfileList;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
  typedef PProfile*  PProfileList;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
  /* Simple record used to implement a stack of bands, required */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
  /* by the sub-banding mechanism                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
  typedef struct  TBand_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
    Short  y_min;   /* band's minimum */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
    Short  y_max;   /* band's maximum */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
  } TBand;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
#define AlignProfileSize \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
  ( ( sizeof ( TProfile ) + sizeof ( Alignment ) - 1 ) / sizeof ( long ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
#ifdef FT_STATIC_RASTER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
#define RAS_ARGS       /* void */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
#define RAS_ARG        /* void */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
#define RAS_VARS       /* void */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
#define RAS_VAR        /* void */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
#define FT_UNUSED_RASTER  do { } while ( 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
#else /* !FT_STATIC_RASTER */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
#define RAS_ARGS       PWorker    worker,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
#define RAS_ARG        PWorker    worker
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
#define RAS_VARS       worker,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
#define RAS_VAR        worker
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
#define FT_UNUSED_RASTER  FT_UNUSED( worker )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
#endif /* !FT_STATIC_RASTER */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
  typedef struct TWorker_  TWorker, *PWorker;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
  /* prototypes used for sweep function dispatch */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
  typedef void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
  Function_Sweep_Init( RAS_ARGS Short*  min,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
                                Short*  max );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
  typedef void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
  Function_Sweep_Span( RAS_ARGS Short       y,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
                                FT_F26Dot6  x1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
                                FT_F26Dot6  x2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
                                PProfile    left,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
                                PProfile    right );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
  typedef void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   427
  Function_Sweep_Step( RAS_ARG );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
  /* NOTE: These operations are only valid on 2's complement processors */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   432
#define FLOOR( x )    ( (x) & -ras.precision )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
#define CEILING( x )  ( ( (x) + ras.precision - 1 ) & -ras.precision )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
#define TRUNC( x )    ( (signed long)(x) >> ras.precision_bits )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
#define FRAC( x )     ( (x) & ( ras.precision - 1 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
#define SCALED( x )   ( ( (x) << ras.scale_shift ) - ras.precision_half )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
#define IS_BOTTOM_OVERSHOOT( x )  ( CEILING( x ) - x >= ras.precision_half )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
#define IS_TOP_OVERSHOOT( x )     ( x - FLOOR( x ) >= ras.precision_half )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
  /* The most used variables are positioned at the top of the structure. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
  /* Thus, their offset can be coded with less opcodes, resulting in a   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
  /* smaller executable.                                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
  struct  TWorker_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
    Int         precision_bits;     /* precision related variables         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   448
    Int         precision;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   449
    Int         precision_half;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
    Int         precision_shift;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
    Int         precision_step;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
    Int         precision_jitter;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
    Int         scale_shift;        /* == precision_shift   for bitmaps    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
                                    /* == precision_shift+1 for pixmaps    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
    PLong       buff;               /* The profiles buffer                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
    PLong       sizeBuff;           /* Render pool size                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   459
    PLong       maxBuff;            /* Profiles buffer size                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
    PLong       top;                /* Current cursor in buffer            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   462
    FT_Error    error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   463
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
    Int         numTurns;           /* number of Y-turns in outline        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
    TPoint*     arc;                /* current Bezier arc pointer          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
    UShort      bWidth;             /* target bitmap width                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
    PByte       bTarget;            /* target bitmap buffer                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   470
    PByte       gTarget;            /* target pixmap buffer                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   471
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
    Long        lastX, lastY;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
    Long        minY, maxY;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
    UShort      num_Profs;          /* current number of profiles          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
    Bool        fresh;              /* signals a fresh new profile which   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
                                    /* `start' field must be completed     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
    Bool        joint;              /* signals that the last arc ended     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
                                    /* exactly on a scanline.  Allows      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   481
                                    /* removal of doublets                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   482
    PProfile    cProfile;           /* current profile                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
    PProfile    fProfile;           /* head of linked list of profiles     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
    PProfile    gProfile;           /* contour's first profile in case     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
                                    /* of impact                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
    TStates     state;              /* rendering state                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
    FT_Bitmap   target;             /* description of target bit/pixmap    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
    FT_Outline  outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   492
    Long        traceOfs;           /* current offset in target bitmap     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   493
    Long        traceG;             /* current offset in target pixmap     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   494
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   495
    Short       traceIncr;          /* sweep's increment in target bitmap  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   496
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   497
    Short       gray_min_x;         /* current min x during gray rendering */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
    Short       gray_max_x;         /* current max x during gray rendering */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   499
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   500
    /* dispatch variables */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   501
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   502
    Function_Sweep_Init*  Proc_Sweep_Init;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   503
    Function_Sweep_Span*  Proc_Sweep_Span;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
    Function_Sweep_Span*  Proc_Sweep_Drop;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
    Function_Sweep_Step*  Proc_Sweep_Step;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   506
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   507
    Byte        dropOutControl;     /* current drop_out control method     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
    Bool        second_pass;        /* indicates whether a horizontal pass */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   510
                                    /* should be performed to control      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   511
                                    /* drop-out accurately when calling    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   512
                                    /* Render_Glyph.  Note that there is   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   513
                                    /* no horizontal pass during gray      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
                                    /* rendering.                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   516
    TPoint      arcs[3 * MaxBezier + 1]; /* The Bezier stack               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   517
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
    TBand       band_stack[16];     /* band stack used for sub-banding     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
    Int         band_top;           /* band stack top                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   520
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   521
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   522
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   523
    Byte*       grays;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   524
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   525
    Byte        gray_lines[RASTER_GRAY_LINES];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
                                /* Intermediate table used to render the   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
                                /* graylevels pixmaps.                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
                                /* gray_lines is a buffer holding two      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
                                /* monochrome scanlines                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   530
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   531
    Short       gray_width;     /* width in bytes of one monochrome        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
                                /* intermediate scanline of gray_lines.    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   533
                                /* Each gray pixel takes 2 bits long there */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   534
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   535
                       /* The gray_lines must hold 2 lines, thus with size */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   536
                       /* in bytes of at least `gray_width*2'.             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   537
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
#endif /* FT_RASTER_ANTI_ALIASING */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   540
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   541
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   542
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   543
  typedef struct  TRaster_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   544
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   545
    char*    buffer;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   546
    long     buffer_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   547
    void*    memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   548
    PWorker  worker;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   549
    Byte     grays[5];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   550
    Short    gray_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   552
  } TRaster, *PRaster;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   553
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   554
#ifdef FT_STATIC_RASTER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   555
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   556
  static TWorker  cur_ras;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   557
#define ras  cur_ras
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   559
#else /* !FT_STATIC_RASTER */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   560
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
#define ras  (*worker)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   562
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   563
#endif /* !FT_STATIC_RASTER */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   564
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   566
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   567
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   568
  /* A lookup table used to quickly count set bits in four gray 2x2 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   569
  /* cells.  The values of the table have been produced with the    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   570
  /* following code:                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   571
  /*                                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   572
  /*   for ( i = 0; i < 256; i++ )                                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
  /*   {                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
  /*     l = 0;                                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
  /*     j = i;                                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
  /*                                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   577
  /*     for ( c = 0; c < 4; c++ )                                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   578
  /*     {                                                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   579
  /*       l <<= 4;                                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   580
  /*                                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
  /*       if ( j & 0x80 ) l++;                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   582
  /*       if ( j & 0x40 ) l++;                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   583
  /*                                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   584
  /*       j = ( j << 2 ) & 0xFF;                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   585
  /*     }                                                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   586
  /*     printf( "0x%04X", l );                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   587
  /*   }                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   588
  /*                                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   589
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   590
  static const short  count_table[256] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   591
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   592
    0x0000, 0x0001, 0x0001, 0x0002, 0x0010, 0x0011, 0x0011, 0x0012,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   593
    0x0010, 0x0011, 0x0011, 0x0012, 0x0020, 0x0021, 0x0021, 0x0022,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   594
    0x0100, 0x0101, 0x0101, 0x0102, 0x0110, 0x0111, 0x0111, 0x0112,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   595
    0x0110, 0x0111, 0x0111, 0x0112, 0x0120, 0x0121, 0x0121, 0x0122,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   596
    0x0100, 0x0101, 0x0101, 0x0102, 0x0110, 0x0111, 0x0111, 0x0112,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   597
    0x0110, 0x0111, 0x0111, 0x0112, 0x0120, 0x0121, 0x0121, 0x0122,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   598
    0x0200, 0x0201, 0x0201, 0x0202, 0x0210, 0x0211, 0x0211, 0x0212,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   599
    0x0210, 0x0211, 0x0211, 0x0212, 0x0220, 0x0221, 0x0221, 0x0222,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   600
    0x1000, 0x1001, 0x1001, 0x1002, 0x1010, 0x1011, 0x1011, 0x1012,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
    0x1010, 0x1011, 0x1011, 0x1012, 0x1020, 0x1021, 0x1021, 0x1022,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   602
    0x1100, 0x1101, 0x1101, 0x1102, 0x1110, 0x1111, 0x1111, 0x1112,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   603
    0x1110, 0x1111, 0x1111, 0x1112, 0x1120, 0x1121, 0x1121, 0x1122,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   604
    0x1100, 0x1101, 0x1101, 0x1102, 0x1110, 0x1111, 0x1111, 0x1112,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   605
    0x1110, 0x1111, 0x1111, 0x1112, 0x1120, 0x1121, 0x1121, 0x1122,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   606
    0x1200, 0x1201, 0x1201, 0x1202, 0x1210, 0x1211, 0x1211, 0x1212,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   607
    0x1210, 0x1211, 0x1211, 0x1212, 0x1220, 0x1221, 0x1221, 0x1222,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   608
    0x1000, 0x1001, 0x1001, 0x1002, 0x1010, 0x1011, 0x1011, 0x1012,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   609
    0x1010, 0x1011, 0x1011, 0x1012, 0x1020, 0x1021, 0x1021, 0x1022,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   610
    0x1100, 0x1101, 0x1101, 0x1102, 0x1110, 0x1111, 0x1111, 0x1112,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   611
    0x1110, 0x1111, 0x1111, 0x1112, 0x1120, 0x1121, 0x1121, 0x1122,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   612
    0x1100, 0x1101, 0x1101, 0x1102, 0x1110, 0x1111, 0x1111, 0x1112,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   613
    0x1110, 0x1111, 0x1111, 0x1112, 0x1120, 0x1121, 0x1121, 0x1122,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   614
    0x1200, 0x1201, 0x1201, 0x1202, 0x1210, 0x1211, 0x1211, 0x1212,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   615
    0x1210, 0x1211, 0x1211, 0x1212, 0x1220, 0x1221, 0x1221, 0x1222,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   616
    0x2000, 0x2001, 0x2001, 0x2002, 0x2010, 0x2011, 0x2011, 0x2012,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   617
    0x2010, 0x2011, 0x2011, 0x2012, 0x2020, 0x2021, 0x2021, 0x2022,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   618
    0x2100, 0x2101, 0x2101, 0x2102, 0x2110, 0x2111, 0x2111, 0x2112,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
    0x2110, 0x2111, 0x2111, 0x2112, 0x2120, 0x2121, 0x2121, 0x2122,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   620
    0x2100, 0x2101, 0x2101, 0x2102, 0x2110, 0x2111, 0x2111, 0x2112,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   621
    0x2110, 0x2111, 0x2111, 0x2112, 0x2120, 0x2121, 0x2121, 0x2122,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   622
    0x2200, 0x2201, 0x2201, 0x2202, 0x2210, 0x2211, 0x2211, 0x2212,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   623
    0x2210, 0x2211, 0x2211, 0x2212, 0x2220, 0x2221, 0x2221, 0x2222
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   624
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   626
#endif /* FT_RASTER_OPTION_ANTI_ALIASING */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   627
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   628
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   629
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   630
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   631
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   632
  /**                                                                     **/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   633
  /**  PROFILES COMPUTATION                                               **/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   634
  /**                                                                     **/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   635
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   636
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   637
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   638
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   639
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   640
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   641
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   642
  /*    Set_High_Precision                                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   643
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   644
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   645
  /*    Set precision variables according to param flag.                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   646
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   647
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   648
  /*    High :: Set to True for high precision (typically for ppem < 18),  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   649
  /*            false otherwise.                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   650
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   651
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   652
  Set_High_Precision( RAS_ARGS Int  High )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   653
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   654
    /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   655
     * `precision_step' is used in `Bezier_Up' to decide when to split a
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   656
     * given y-monotonous Bezier arc that crosses a scanline before
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   657
     * approximating it as a straight segment.  The default value of 32 (for
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   658
     * low accuracy) corresponds to
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   659
     *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   660
     *   32 / 64 == 0.5 pixels ,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   661
     *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   662
     * while for the high accuracy case we have
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   663
     *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   664
     *   256/ (1 << 12) = 0.0625 pixels .
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   665
     *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   666
     * `precision_jitter' is an epsilon threshold used in
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   667
     * `Vertical_Sweep_Span' to deal with small imperfections in the Bezier
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   668
     * decomposition (after all, we are working with approximations only);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   669
     * it avoids switching on additional pixels which would cause artifacts
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   670
     * otherwise.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   671
     *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   672
     * The value of `precision_jitter' has been determined heuristically.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   673
     *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   674
     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   675
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   676
    if ( High )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   677
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   678
      ras.precision_bits   = 12;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   679
      ras.precision_step   = 256;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   680
      ras.precision_jitter = 30;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   681
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   682
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   683
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   684
      ras.precision_bits   = 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   685
      ras.precision_step   = 32;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   686
      ras.precision_jitter = 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   687
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   688
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   689
    FT_TRACE6(( "Set_High_Precision(%s)\n", High ? "true" : "false" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   690
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   691
    ras.precision       = 1 << ras.precision_bits;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   692
    ras.precision_half  = ras.precision / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   693
    ras.precision_shift = ras.precision_bits - Pixel_Bits;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   694
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   695
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   696
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   697
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   698
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   699
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   700
  /*    New_Profile                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   701
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   702
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   703
  /*    Create a new profile in the render pool.                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   704
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   705
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   706
  /*    aState    :: The state/orientation of the new profile.             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   707
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   708
  /*    overshoot :: Whether the profile's unrounded start position        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   709
  /*                 differs by at least a half pixel.                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   710
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   711
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   712
  /*   SUCCESS on success.  FAILURE in case of overflow or of incoherent   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   713
  /*   profile.                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   714
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   715
  static Bool
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   716
  New_Profile( RAS_ARGS TStates  aState,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   717
                        Bool     overshoot )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   718
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   719
    if ( !ras.fProfile )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   720
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   721
      ras.cProfile  = (PProfile)ras.top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   722
      ras.fProfile  = ras.cProfile;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   723
      ras.top      += AlignProfileSize;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   724
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   725
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   726
    if ( ras.top >= ras.maxBuff )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   727
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   728
      ras.error = Raster_Err_Overflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   729
      return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   730
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   731
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   732
    ras.cProfile->flags  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   733
    ras.cProfile->start  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   734
    ras.cProfile->height = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   735
    ras.cProfile->offset = ras.top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   736
    ras.cProfile->link   = (PProfile)0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   737
    ras.cProfile->next   = (PProfile)0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   738
    ras.cProfile->flags  = ras.dropOutControl;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   739
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   740
    switch ( aState )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   741
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   742
    case Ascending_State:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   743
      ras.cProfile->flags |= Flow_Up;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   744
      if ( overshoot )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   745
        ras.cProfile->flags |= Overshoot_Bottom;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   746
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   747
      FT_TRACE6(( "New ascending profile = %p\n", ras.cProfile ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   748
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   749
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   750
    case Descending_State:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   751
      if ( overshoot )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   752
        ras.cProfile->flags |= Overshoot_Top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   753
      FT_TRACE6(( "New descending profile = %p\n", ras.cProfile ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   754
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   755
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   756
    default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   757
      FT_ERROR(( "New_Profile: invalid profile direction\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   758
      ras.error = Raster_Err_Invalid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   759
      return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   760
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   761
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   762
    if ( !ras.gProfile )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   763
      ras.gProfile = ras.cProfile;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   764
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   765
    ras.state = aState;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   766
    ras.fresh = TRUE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   767
    ras.joint = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   768
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   769
    return SUCCESS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   770
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   771
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   772
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   773
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   774
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   775
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   776
  /*    End_Profile                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   777
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   778
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   779
  /*    Finalize the current profile.                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   780
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   781
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   782
  /*    overshoot :: Whether the profile's unrounded end position differs  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   783
  /*                 by at least a half pixel.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   784
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   785
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   786
  /*    SUCCESS on success.  FAILURE in case of overflow or incoherency.   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   787
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   788
  static Bool
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   789
  End_Profile( RAS_ARGS Bool  overshoot )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   790
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   791
    Long      h;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   792
    PProfile  oldProfile;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   793
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   794
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   795
    h = (Long)( ras.top - ras.cProfile->offset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   796
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   797
    if ( h < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   798
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   799
      FT_ERROR(( "End_Profile: negative height encountered\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   800
      ras.error = Raster_Err_Neg_Height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   801
      return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   802
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   803
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   804
    if ( h > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   805
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   806
      FT_TRACE6(( "Ending profile %p, start = %ld, height = %ld\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   807
                  ras.cProfile, ras.cProfile->start, h ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   808
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   809
      ras.cProfile->height = h;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   810
      if ( overshoot )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   811
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   812
        if ( ras.cProfile->flags & Flow_Up )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   813
          ras.cProfile->flags |= Overshoot_Top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   814
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   815
          ras.cProfile->flags |= Overshoot_Bottom;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   816
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   817
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   818
      oldProfile   = ras.cProfile;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   819
      ras.cProfile = (PProfile)ras.top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   820
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   821
      ras.top += AlignProfileSize;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   822
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   823
      ras.cProfile->height = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   824
      ras.cProfile->offset = ras.top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   825
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   826
      oldProfile->next = ras.cProfile;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   827
      ras.num_Profs++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   828
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   829
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   830
    if ( ras.top >= ras.maxBuff )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   831
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   832
      FT_TRACE1(( "overflow in End_Profile\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   833
      ras.error = Raster_Err_Overflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   834
      return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   835
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   836
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   837
    ras.joint = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   838
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   839
    return SUCCESS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   840
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   841
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   842
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   843
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   844
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   845
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   846
  /*    Insert_Y_Turn                                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   847
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   848
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   849
  /*    Insert a salient into the sorted list placed on top of the render  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   850
  /*    pool.                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   851
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   852
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   853
  /*    New y scanline position.                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   854
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   855
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   856
  /*    SUCCESS on success.  FAILURE in case of overflow.                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   857
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   858
  static Bool
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   859
  Insert_Y_Turn( RAS_ARGS Int  y )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   860
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   861
    PLong  y_turns;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   862
    Int    y2, n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   863
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   864
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   865
    n       = ras.numTurns - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   866
    y_turns = ras.sizeBuff - ras.numTurns;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   867
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   868
    /* look for first y value that is <= */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   869
    while ( n >= 0 && y < y_turns[n] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   870
      n--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   871
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   872
    /* if it is <, simply insert it, ignore if == */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   873
    if ( n >= 0 && y > y_turns[n] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   874
      while ( n >= 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   875
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   876
        y2 = (Int)y_turns[n];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   877
        y_turns[n] = y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   878
        y = y2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   879
        n--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   880
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   881
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   882
    if ( n < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   883
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   884
      ras.maxBuff--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   885
      if ( ras.maxBuff <= ras.top )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   886
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   887
        ras.error = Raster_Err_Overflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   888
        return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   889
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   890
      ras.numTurns++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   891
      ras.sizeBuff[-ras.numTurns] = y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   892
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   893
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   894
    return SUCCESS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   895
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   896
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   897
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   898
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   899
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   900
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   901
  /*    Finalize_Profile_Table                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   902
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   903
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   904
  /*    Adjust all links in the profiles list.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   905
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   906
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   907
  /*    SUCCESS on success.  FAILURE in case of overflow.                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   908
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   909
  static Bool
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   910
  Finalize_Profile_Table( RAS_ARG )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   911
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   912
    Int       bottom, top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   913
    UShort    n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   914
    PProfile  p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   915
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   916
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   917
    n = ras.num_Profs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   918
    p = ras.fProfile;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   919
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   920
    if ( n > 1 && p )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   921
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   922
      while ( n > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   923
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   924
        if ( n > 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   925
          p->link = (PProfile)( p->offset + p->height );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   926
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   927
          p->link = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   928
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   929
        if ( p->flags & Flow_Up )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   930
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   931
          bottom = (Int)p->start;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   932
          top    = (Int)( p->start + p->height - 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   933
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   934
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   935
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   936
          bottom     = (Int)( p->start - p->height + 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   937
          top        = (Int)p->start;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   938
          p->start   = bottom;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   939
          p->offset += p->height - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   940
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   941
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   942
        if ( Insert_Y_Turn( RAS_VARS bottom )  ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   943
             Insert_Y_Turn( RAS_VARS top + 1 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   944
          return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   945
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   946
        p = p->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   947
        n--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   948
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   949
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   950
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   951
      ras.fProfile = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   952
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   953
    return SUCCESS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   954
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   955
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   956
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   957
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   958
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   959
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   960
  /*    Split_Conic                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   961
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   962
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   963
  /*    Subdivide one conic Bezier into two joint sub-arcs in the Bezier   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   964
  /*    stack.                                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   965
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   966
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   967
  /*    None (subdivided Bezier is taken from the top of the stack).       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   968
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   969
  /* <Note>                                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   970
  /*    This routine is the `beef' of this component.  It is  _the_ inner  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   971
  /*    loop that should be optimized to hell to get the best performance. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   972
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   973
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   974
  Split_Conic( TPoint*  base )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   975
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   976
    Long  a, b;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   977
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   978
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   979
    base[4].x = base[2].x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   980
    b = base[1].x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   981
    a = base[3].x = ( base[2].x + b ) / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   982
    b = base[1].x = ( base[0].x + b ) / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   983
    base[2].x = ( a + b ) / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   984
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   985
    base[4].y = base[2].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   986
    b = base[1].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   987
    a = base[3].y = ( base[2].y + b ) / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   988
    b = base[1].y = ( base[0].y + b ) / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   989
    base[2].y = ( a + b ) / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   990
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   991
    /* hand optimized.  gcc doesn't seem to be too good at common      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   992
    /* expression substitution and instruction scheduling ;-)          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   993
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   994
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   995
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   996
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   997
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   998
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   999
  /*    Split_Cubic                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1000
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1001
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1002
  /*    Subdivide a third-order Bezier arc into two joint sub-arcs in the  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1003
  /*    Bezier stack.                                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1004
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1005
  /* <Note>                                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1006
  /*    This routine is the `beef' of the component.  It is one of _the_   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1007
  /*    inner loops that should be optimized like hell to get the best     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1008
  /*    performance.                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1009
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1010
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1011
  Split_Cubic( TPoint*  base )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1012
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1013
    Long  a, b, c, d;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1014
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1015
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1016
    base[6].x = base[3].x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1017
    c = base[1].x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1018
    d = base[2].x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1019
    base[1].x = a = ( base[0].x + c + 1 ) >> 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1020
    base[5].x = b = ( base[3].x + d + 1 ) >> 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1021
    c = ( c + d + 1 ) >> 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1022
    base[2].x = a = ( a + c + 1 ) >> 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1023
    base[4].x = b = ( b + c + 1 ) >> 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1024
    base[3].x = ( a + b + 1 ) >> 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1025
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1026
    base[6].y = base[3].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1027
    c = base[1].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1028
    d = base[2].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1029
    base[1].y = a = ( base[0].y + c + 1 ) >> 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1030
    base[5].y = b = ( base[3].y + d + 1 ) >> 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1031
    c = ( c + d + 1 ) >> 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1032
    base[2].y = a = ( a + c + 1 ) >> 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1033
    base[4].y = b = ( b + c + 1 ) >> 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1034
    base[3].y = ( a + b + 1 ) >> 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1035
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1036
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1037
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1038
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1039
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1040
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1041
  /*    Line_Up                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1042
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1043
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1044
  /*    Compute the x-coordinates of an ascending line segment and store   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1045
  /*    them in the render pool.                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1046
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1047
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1048
  /*    x1   :: The x-coordinate of the segment's start point.             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1049
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1050
  /*    y1   :: The y-coordinate of the segment's start point.             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1051
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1052
  /*    x2   :: The x-coordinate of the segment's end point.               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1053
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1054
  /*    y2   :: The y-coordinate of the segment's end point.               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1055
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1056
  /*    miny :: A lower vertical clipping bound value.                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1057
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1058
  /*    maxy :: An upper vertical clipping bound value.                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1059
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1060
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1061
  /*    SUCCESS on success, FAILURE on render pool overflow.               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1062
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1063
  static Bool
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1064
  Line_Up( RAS_ARGS Long  x1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1065
                    Long  y1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1066
                    Long  x2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1067
                    Long  y2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1068
                    Long  miny,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1069
                    Long  maxy )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1070
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1071
    Long   Dx, Dy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1072
    Int    e1, e2, f1, f2, size;     /* XXX: is `Short' sufficient? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1073
    Long   Ix, Rx, Ax;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1074
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1075
    PLong  top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1076
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1077
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1078
    Dx = x2 - x1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1079
    Dy = y2 - y1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1080
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1081
    if ( Dy <= 0 || y2 < miny || y1 > maxy )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1082
      return SUCCESS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1083
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1084
    if ( y1 < miny )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1085
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1086
      /* Take care: miny-y1 can be a very large value; we use     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1087
      /*            a slow MulDiv function to avoid clipping bugs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1088
      x1 += SMulDiv( Dx, miny - y1, Dy );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1089
      e1  = (Int)TRUNC( miny );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1090
      f1  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1091
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1092
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1093
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1094
      e1 = (Int)TRUNC( y1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1095
      f1 = (Int)FRAC( y1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1096
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1097
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1098
    if ( y2 > maxy )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1099
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1100
      /* x2 += FMulDiv( Dx, maxy - y2, Dy );  UNNECESSARY */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1101
      e2  = (Int)TRUNC( maxy );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1102
      f2  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1103
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1104
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1105
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1106
      e2 = (Int)TRUNC( y2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1107
      f2 = (Int)FRAC( y2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1108
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1109
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1110
    if ( f1 > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1111
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1112
      if ( e1 == e2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1113
        return SUCCESS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1114
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1115
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1116
        x1 += SMulDiv( Dx, ras.precision - f1, Dy );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1117
        e1 += 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1118
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1119
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1120
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1121
      if ( ras.joint )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1122
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1123
        ras.top--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1124
        ras.joint = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1125
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1126
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1127
    ras.joint = (char)( f2 == 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1128
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1129
    if ( ras.fresh )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1130
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1131
      ras.cProfile->start = e1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1132
      ras.fresh           = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1133
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1134
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1135
    size = e2 - e1 + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1136
    if ( ras.top + size >= ras.maxBuff )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1137
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1138
      ras.error = Raster_Err_Overflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1139
      return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1140
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1141
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1142
    if ( Dx > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1143
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1144
      Ix = SMulDiv( ras.precision, Dx, Dy);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1145
      Rx = ( ras.precision * Dx ) % Dy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1146
      Dx = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1147
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1148
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1149
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1150
      Ix = SMulDiv( ras.precision, -Dx, Dy) * -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1151
      Rx =    ( ras.precision * -Dx ) % Dy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1152
      Dx = -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1153
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1154
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1155
    Ax  = -Dy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1156
    top = ras.top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1157
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1158
    while ( size > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1159
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1160
      *top++ = x1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1161
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1162
      x1 += Ix;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1163
      Ax += Rx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1164
      if ( Ax >= 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1165
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1166
        Ax -= Dy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1167
        x1 += Dx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1168
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1169
      size--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1170
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1171
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1172
    ras.top = top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1173
    return SUCCESS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1174
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1175
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1176
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1177
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1178
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1179
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1180
  /*    Line_Down                                                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1181
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1182
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1183
  /*    Compute the x-coordinates of an descending line segment and store  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1184
  /*    them in the render pool.                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1185
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1186
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1187
  /*    x1   :: The x-coordinate of the segment's start point.             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1188
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1189
  /*    y1   :: The y-coordinate of the segment's start point.             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1190
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1191
  /*    x2   :: The x-coordinate of the segment's end point.               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1192
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1193
  /*    y2   :: The y-coordinate of the segment's end point.               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1194
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1195
  /*    miny :: A lower vertical clipping bound value.                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1196
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1197
  /*    maxy :: An upper vertical clipping bound value.                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1198
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1199
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1200
  /*    SUCCESS on success, FAILURE on render pool overflow.               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1201
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1202
  static Bool
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1203
  Line_Down( RAS_ARGS Long  x1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1204
                      Long  y1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1205
                      Long  x2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1206
                      Long  y2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1207
                      Long  miny,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1208
                      Long  maxy )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1209
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1210
    Bool  result, fresh;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1211
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1212
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1213
    fresh  = ras.fresh;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1214
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1215
    result = Line_Up( RAS_VARS x1, -y1, x2, -y2, -maxy, -miny );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1216
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1217
    if ( fresh && !ras.fresh )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1218
      ras.cProfile->start = -ras.cProfile->start;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1219
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1220
    return result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1221
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1222
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1223
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1224
  /* A function type describing the functions used to split Bezier arcs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1225
  typedef void  (*TSplitter)( TPoint*  base );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1226
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1227
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1228
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1229
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1230
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1231
  /*    Bezier_Up                                                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1232
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1233
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1234
  /*    Compute the x-coordinates of an ascending Bezier arc and store     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1235
  /*    them in the render pool.                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1236
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1237
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1238
  /*    degree   :: The degree of the Bezier arc (either 2 or 3).          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1239
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1240
  /*    splitter :: The function to split Bezier arcs.                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1241
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1242
  /*    miny     :: A lower vertical clipping bound value.                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1243
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1244
  /*    maxy     :: An upper vertical clipping bound value.                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1245
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1246
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1247
  /*    SUCCESS on success, FAILURE on render pool overflow.               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1248
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1249
  static Bool
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1250
  Bezier_Up( RAS_ARGS Int        degree,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1251
                      TSplitter  splitter,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1252
                      Long       miny,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1253
                      Long       maxy )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1254
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1255
    Long   y1, y2, e, e2, e0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1256
    Short  f1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1257
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1258
    TPoint*  arc;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1259
    TPoint*  start_arc;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1260
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1261
    PLong top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1262
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1263
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1264
    arc = ras.arc;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1265
    y1  = arc[degree].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1266
    y2  = arc[0].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1267
    top = ras.top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1268
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1269
    if ( y2 < miny || y1 > maxy )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1270
      goto Fin;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1271
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1272
    e2 = FLOOR( y2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1273
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1274
    if ( e2 > maxy )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1275
      e2 = maxy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1276
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1277
    e0 = miny;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1278
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1279
    if ( y1 < miny )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1280
      e = miny;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1281
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1282
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1283
      e  = CEILING( y1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1284
      f1 = (Short)( FRAC( y1 ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1285
      e0 = e;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1286
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1287
      if ( f1 == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1288
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1289
        if ( ras.joint )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1290
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1291
          top--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1292
          ras.joint = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1293
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1294
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1295
        *top++ = arc[degree].x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1296
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1297
        e += ras.precision;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1298
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1299
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1300
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1301
    if ( ras.fresh )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1302
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1303
      ras.cProfile->start = TRUNC( e0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1304
      ras.fresh = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1305
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1306
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1307
    if ( e2 < e )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1308
      goto Fin;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1309
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1310
    if ( ( top + TRUNC( e2 - e ) + 1 ) >= ras.maxBuff )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1311
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1312
      ras.top   = top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1313
      ras.error = Raster_Err_Overflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1314
      return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1315
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1316
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1317
    start_arc = arc;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1318
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1319
    while ( arc >= start_arc && e <= e2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1320
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1321
      ras.joint = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1322
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1323
      y2 = arc[0].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1324
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1325
      if ( y2 > e )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1326
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1327
        y1 = arc[degree].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1328
        if ( y2 - y1 >= ras.precision_step )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1329
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1330
          splitter( arc );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1331
          arc += degree;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1332
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1333
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1334
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1335
          *top++ = arc[degree].x + FMulDiv( arc[0].x - arc[degree].x,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1336
                                            e - y1, y2 - y1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1337
          arc -= degree;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1338
          e   += ras.precision;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1339
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1340
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1341
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1342
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1343
        if ( y2 == e )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1344
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1345
          ras.joint  = TRUE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1346
          *top++     = arc[0].x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1347
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1348
          e += ras.precision;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1349
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1350
        arc -= degree;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1351
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1352
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1353
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1354
  Fin:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1355
    ras.top  = top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1356
    ras.arc -= degree;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1357
    return SUCCESS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1358
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1359
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1360
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1361
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1362
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1363
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1364
  /*    Bezier_Down                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1365
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1366
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1367
  /*    Compute the x-coordinates of an descending Bezier arc and store    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1368
  /*    them in the render pool.                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1369
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1370
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1371
  /*    degree   :: The degree of the Bezier arc (either 2 or 3).          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1372
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1373
  /*    splitter :: The function to split Bezier arcs.                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1374
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1375
  /*    miny     :: A lower vertical clipping bound value.                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1376
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1377
  /*    maxy     :: An upper vertical clipping bound value.                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1378
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1379
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1380
  /*    SUCCESS on success, FAILURE on render pool overflow.               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1381
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1382
  static Bool
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1383
  Bezier_Down( RAS_ARGS Int        degree,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1384
                        TSplitter  splitter,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1385
                        Long       miny,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1386
                        Long       maxy )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1387
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1388
    TPoint*  arc = ras.arc;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1389
    Bool     result, fresh;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1390
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1391
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1392
    arc[0].y = -arc[0].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1393
    arc[1].y = -arc[1].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1394
    arc[2].y = -arc[2].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1395
    if ( degree > 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1396
      arc[3].y = -arc[3].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1397
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1398
    fresh = ras.fresh;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1399
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1400
    result = Bezier_Up( RAS_VARS degree, splitter, -maxy, -miny );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1401
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1402
    if ( fresh && !ras.fresh )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1403
      ras.cProfile->start = -ras.cProfile->start;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1404
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1405
    arc[0].y = -arc[0].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1406
    return result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1407
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1408
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1409
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1410
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1411
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1412
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1413
  /*    Line_To                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1414
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1415
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1416
  /*    Inject a new line segment and adjust the Profiles list.            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1417
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1418
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1419
  /*   x :: The x-coordinate of the segment's end point (its start point   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1420
  /*        is stored in `lastX').                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1421
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1422
  /*   y :: The y-coordinate of the segment's end point (its start point   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1423
  /*        is stored in `lastY').                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1424
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1425
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1426
  /*   SUCCESS on success, FAILURE on render pool overflow or incorrect    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1427
  /*   profile.                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1428
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1429
  static Bool
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1430
  Line_To( RAS_ARGS Long  x,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1431
                    Long  y )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1432
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1433
    /* First, detect a change of direction */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1434
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1435
    switch ( ras.state )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1436
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1437
    case Unknown_State:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1438
      if ( y > ras.lastY )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1439
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1440
        if ( New_Profile( RAS_VARS Ascending_State,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1441
                                   IS_BOTTOM_OVERSHOOT( ras.lastY ) ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1442
          return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1443
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1444
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1445
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1446
        if ( y < ras.lastY )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1447
          if ( New_Profile( RAS_VARS Descending_State,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1448
                                     IS_TOP_OVERSHOOT( ras.lastY ) ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1449
            return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1450
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1451
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1452
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1453
    case Ascending_State:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1454
      if ( y < ras.lastY )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1455
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1456
        if ( End_Profile( RAS_VARS IS_TOP_OVERSHOOT( ras.lastY ) ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1457
             New_Profile( RAS_VARS Descending_State,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1458
                                   IS_TOP_OVERSHOOT( ras.lastY ) ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1459
          return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1460
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1461
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1462
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1463
    case Descending_State:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1464
      if ( y > ras.lastY )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1465
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1466
        if ( End_Profile( RAS_VARS IS_BOTTOM_OVERSHOOT( ras.lastY ) ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1467
             New_Profile( RAS_VARS Ascending_State,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1468
                                   IS_BOTTOM_OVERSHOOT( ras.lastY ) ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1469
          return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1470
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1471
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1472
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1473
    default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1474
      ;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1475
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1476
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1477
    /* Then compute the lines */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1478
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1479
    switch ( ras.state )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1480
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1481
    case Ascending_State:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1482
      if ( Line_Up( RAS_VARS ras.lastX, ras.lastY,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1483
                             x, y, ras.minY, ras.maxY ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1484
        return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1485
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1486
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1487
    case Descending_State:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1488
      if ( Line_Down( RAS_VARS ras.lastX, ras.lastY,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1489
                               x, y, ras.minY, ras.maxY ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1490
        return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1491
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1492
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1493
    default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1494
      ;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1495
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1496
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1497
    ras.lastX = x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1498
    ras.lastY = y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1499
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1500
    return SUCCESS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1501
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1502
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1503
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1504
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1505
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1506
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1507
  /*    Conic_To                                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1508
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1509
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1510
  /*    Inject a new conic arc and adjust the profile list.                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1511
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1512
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1513
  /*   cx :: The x-coordinate of the arc's new control point.              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1514
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1515
  /*   cy :: The y-coordinate of the arc's new control point.              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1516
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1517
  /*   x  :: The x-coordinate of the arc's end point (its start point is   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1518
  /*         stored in `lastX').                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1519
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1520
  /*   y  :: The y-coordinate of the arc's end point (its start point is   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1521
  /*         stored in `lastY').                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1522
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1523
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1524
  /*   SUCCESS on success, FAILURE on render pool overflow or incorrect    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1525
  /*   profile.                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1526
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1527
  static Bool
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1528
  Conic_To( RAS_ARGS Long  cx,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1529
                     Long  cy,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1530
                     Long  x,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1531
                     Long  y )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1532
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1533
    Long     y1, y2, y3, x3, ymin, ymax;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1534
    TStates  state_bez;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1535
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1536
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1537
    ras.arc      = ras.arcs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1538
    ras.arc[2].x = ras.lastX;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1539
    ras.arc[2].y = ras.lastY;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1540
    ras.arc[1].x = cx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1541
    ras.arc[1].y = cy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1542
    ras.arc[0].x = x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1543
    ras.arc[0].y = y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1544
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1545
    do
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1546
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1547
      y1 = ras.arc[2].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1548
      y2 = ras.arc[1].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1549
      y3 = ras.arc[0].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1550
      x3 = ras.arc[0].x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1551
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1552
      /* first, categorize the Bezier arc */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1553
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1554
      if ( y1 <= y3 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1555
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1556
        ymin = y1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1557
        ymax = y3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1558
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1559
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1560
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1561
        ymin = y3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1562
        ymax = y1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1563
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1564
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1565
      if ( y2 < ymin || y2 > ymax )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1566
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1567
        /* this arc has no given direction, split it! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1568
        Split_Conic( ras.arc );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1569
        ras.arc += 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1570
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1571
      else if ( y1 == y3 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1572
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1573
        /* this arc is flat, ignore it and pop it from the Bezier stack */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1574
        ras.arc -= 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1575
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1576
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1577
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1578
        /* the arc is y-monotonous, either ascending or descending */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1579
        /* detect a change of direction                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1580
        state_bez = y1 < y3 ? Ascending_State : Descending_State;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1581
        if ( ras.state != state_bez )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1582
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1583
          Bool  o = state_bez == Ascending_State ? IS_BOTTOM_OVERSHOOT( y1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1584
                                                 : IS_TOP_OVERSHOOT( y1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1585
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1586
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1587
          /* finalize current profile if any */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1588
          if ( ras.state != Unknown_State &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1589
               End_Profile( RAS_VARS o )  )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1590
            goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1591
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1592
          /* create a new profile */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1593
          if ( New_Profile( RAS_VARS state_bez, o ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1594
            goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1595
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1596
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1597
        /* now call the appropriate routine */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1598
        if ( state_bez == Ascending_State )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1599
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1600
          if ( Bezier_Up( RAS_VARS 2, Split_Conic, ras.minY, ras.maxY ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1601
            goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1602
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1603
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1604
          if ( Bezier_Down( RAS_VARS 2, Split_Conic, ras.minY, ras.maxY ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1605
            goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1606
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1607
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1608
    } while ( ras.arc >= ras.arcs );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1609
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1610
    ras.lastX = x3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1611
    ras.lastY = y3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1612
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1613
    return SUCCESS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1614
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1615
  Fail:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1616
    return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1617
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1618
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1619
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1620
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1621
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1622
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1623
  /*    Cubic_To                                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1624
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1625
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1626
  /*    Inject a new cubic arc and adjust the profile list.                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1627
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1628
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1629
  /*   cx1 :: The x-coordinate of the arc's first new control point.       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1630
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1631
  /*   cy1 :: The y-coordinate of the arc's first new control point.       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1632
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1633
  /*   cx2 :: The x-coordinate of the arc's second new control point.      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1634
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1635
  /*   cy2 :: The y-coordinate of the arc's second new control point.      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1636
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1637
  /*   x   :: The x-coordinate of the arc's end point (its start point is  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1638
  /*          stored in `lastX').                                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1639
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1640
  /*   y   :: The y-coordinate of the arc's end point (its start point is  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1641
  /*          stored in `lastY').                                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1642
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1643
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1644
  /*   SUCCESS on success, FAILURE on render pool overflow or incorrect    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1645
  /*   profile.                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1646
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1647
  static Bool
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1648
  Cubic_To( RAS_ARGS Long  cx1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1649
                     Long  cy1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1650
                     Long  cx2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1651
                     Long  cy2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1652
                     Long  x,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1653
                     Long  y )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1654
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1655
    Long     y1, y2, y3, y4, x4, ymin1, ymax1, ymin2, ymax2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1656
    TStates  state_bez;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1657
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1658
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1659
    ras.arc      = ras.arcs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1660
    ras.arc[3].x = ras.lastX;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1661
    ras.arc[3].y = ras.lastY;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1662
    ras.arc[2].x = cx1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1663
    ras.arc[2].y = cy1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1664
    ras.arc[1].x = cx2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1665
    ras.arc[1].y = cy2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1666
    ras.arc[0].x = x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1667
    ras.arc[0].y = y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1668
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1669
    do
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1670
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1671
      y1 = ras.arc[3].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1672
      y2 = ras.arc[2].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1673
      y3 = ras.arc[1].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1674
      y4 = ras.arc[0].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1675
      x4 = ras.arc[0].x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1676
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1677
      /* first, categorize the Bezier arc */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1678
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1679
      if ( y1 <= y4 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1680
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1681
        ymin1 = y1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1682
        ymax1 = y4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1683
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1684
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1685
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1686
        ymin1 = y4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1687
        ymax1 = y1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1688
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1689
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1690
      if ( y2 <= y3 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1691
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1692
        ymin2 = y2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1693
        ymax2 = y3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1694
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1695
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1696
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1697
        ymin2 = y3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1698
        ymax2 = y2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1699
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1700
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1701
      if ( ymin2 < ymin1 || ymax2 > ymax1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1702
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1703
        /* this arc has no given direction, split it! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1704
        Split_Cubic( ras.arc );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1705
        ras.arc += 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1706
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1707
      else if ( y1 == y4 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1708
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1709
        /* this arc is flat, ignore it and pop it from the Bezier stack */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1710
        ras.arc -= 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1711
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1712
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1713
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1714
        state_bez = ( y1 <= y4 ) ? Ascending_State : Descending_State;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1715
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1716
        /* detect a change of direction */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1717
        if ( ras.state != state_bez )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1718
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1719
          Bool  o = state_bez == Ascending_State ? IS_BOTTOM_OVERSHOOT( y1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1720
                                                 : IS_TOP_OVERSHOOT( y1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1721
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1722
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1723
          /* finalize current profile if any */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1724
          if ( ras.state != Unknown_State &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1725
               End_Profile( RAS_VARS o )  )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1726
            goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1727
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1728
          if ( New_Profile( RAS_VARS state_bez, o ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1729
            goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1730
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1731
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1732
        /* compute intersections */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1733
        if ( state_bez == Ascending_State )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1734
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1735
          if ( Bezier_Up( RAS_VARS 3, Split_Cubic, ras.minY, ras.maxY ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1736
            goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1737
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1738
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1739
          if ( Bezier_Down( RAS_VARS 3, Split_Cubic, ras.minY, ras.maxY ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1740
            goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1741
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1742
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1743
    } while ( ras.arc >= ras.arcs );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1744
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1745
    ras.lastX = x4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1746
    ras.lastY = y4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1747
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1748
    return SUCCESS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1749
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1750
  Fail:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1751
    return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1752
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1753
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1754
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1755
#undef  SWAP_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1756
#define SWAP_( x, y )  do                \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1757
                       {                 \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1758
                         Long  swap = x; \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1759
                                         \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1760
                                         \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1761
                         x = y;          \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1762
                         y = swap;       \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1763
                       } while ( 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1764
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1765
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1766
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1767
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1768
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1769
  /*    Decompose_Curve                                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1770
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1771
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1772
  /*    Scan the outline arrays in order to emit individual segments and   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1773
  /*    Beziers by calling Line_To() and Bezier_To().  It handles all      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1774
  /*    weird cases, like when the first point is off the curve, or when   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1775
  /*    there are simply no `on' points in the contour!                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1776
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1777
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1778
  /*    first   :: The index of the first point in the contour.            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1779
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1780
  /*    last    :: The index of the last point in the contour.             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1781
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1782
  /*    flipped :: If set, flip the direction of the curve.                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1783
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1784
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1785
  /*    SUCCESS on success, FAILURE on error.                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1786
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1787
  static Bool
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1788
  Decompose_Curve( RAS_ARGS UShort  first,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1789
                            UShort  last,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1790
                            int     flipped )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1791
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1792
    FT_Vector   v_last;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1793
    FT_Vector   v_control;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1794
    FT_Vector   v_start;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1795
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1796
    FT_Vector*  points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1797
    FT_Vector*  point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1798
    FT_Vector*  limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1799
    char*       tags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1800
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1801
    unsigned    tag;       /* current point's state           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1802
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1803
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1804
    points = ras.outline.points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1805
    limit  = points + last;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1806
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1807
    v_start.x = SCALED( points[first].x );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1808
    v_start.y = SCALED( points[first].y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1809
    v_last.x  = SCALED( points[last].x );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1810
    v_last.y  = SCALED( points[last].y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1811
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1812
    if ( flipped )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1813
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1814
      SWAP_( v_start.x, v_start.y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1815
      SWAP_( v_last.x, v_last.y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1816
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1817
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1818
    v_control = v_start;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1819
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1820
    point = points + first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1821
    tags  = ras.outline.tags + first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1822
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1823
    /* set scan mode if necessary */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1824
    if ( tags[0] & FT_CURVE_TAG_HAS_SCANMODE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1825
      ras.dropOutControl = (Byte)tags[0] >> 5;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1826
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1827
    tag = FT_CURVE_TAG( tags[0] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1828
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1829
    /* A contour cannot start with a cubic control point! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1830
    if ( tag == FT_CURVE_TAG_CUBIC )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1831
      goto Invalid_Outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1832
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1833
    /* check first point to determine origin */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1834
    if ( tag == FT_CURVE_TAG_CONIC )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1835
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1836
      /* first point is conic control.  Yes, this happens. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1837
      if ( FT_CURVE_TAG( ras.outline.tags[last] ) == FT_CURVE_TAG_ON )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1838
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1839
        /* start at last point if it is on the curve */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1840
        v_start = v_last;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1841
        limit--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1842
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1843
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1844
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1845
        /* if both first and last points are conic,         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1846
        /* start at their middle and record its position    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1847
        /* for closure                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1848
        v_start.x = ( v_start.x + v_last.x ) / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1849
        v_start.y = ( v_start.y + v_last.y ) / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1850
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1851
        v_last = v_start;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1852
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1853
      point--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1854
      tags--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1855
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1856
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1857
    ras.lastX = v_start.x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1858
    ras.lastY = v_start.y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1859
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1860
    while ( point < limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1861
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1862
      point++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1863
      tags++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1864
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1865
      tag = FT_CURVE_TAG( tags[0] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1866
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1867
      switch ( tag )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1868
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1869
      case FT_CURVE_TAG_ON:  /* emit a single line_to */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1870
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1871
          Long  x, y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1872
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1873
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1874
          x = SCALED( point->x );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1875
          y = SCALED( point->y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1876
          if ( flipped )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1877
            SWAP_( x, y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1878
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1879
          if ( Line_To( RAS_VARS x, y ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1880
            goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1881
          continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1882
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1883
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1884
      case FT_CURVE_TAG_CONIC:  /* consume conic arcs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1885
        v_control.x = SCALED( point[0].x );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1886
        v_control.y = SCALED( point[0].y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1887
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1888
        if ( flipped )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1889
          SWAP_( v_control.x, v_control.y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1890
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1891
      Do_Conic:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1892
        if ( point < limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1893
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1894
          FT_Vector  v_middle;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1895
          Long       x, y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1896
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1897
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1898
          point++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1899
          tags++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1900
          tag = FT_CURVE_TAG( tags[0] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1901
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1902
          x = SCALED( point[0].x );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1903
          y = SCALED( point[0].y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1904
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1905
          if ( flipped )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1906
            SWAP_( x, y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1907
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1908
          if ( tag == FT_CURVE_TAG_ON )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1909
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1910
            if ( Conic_To( RAS_VARS v_control.x, v_control.y, x, y ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1911
              goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1912
            continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1913
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1914
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1915
          if ( tag != FT_CURVE_TAG_CONIC )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1916
            goto Invalid_Outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1917
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1918
          v_middle.x = ( v_control.x + x ) / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1919
          v_middle.y = ( v_control.y + y ) / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1920
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1921
          if ( Conic_To( RAS_VARS v_control.x, v_control.y,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1922
                                  v_middle.x,  v_middle.y ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1923
            goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1924
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1925
          v_control.x = x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1926
          v_control.y = y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1927
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1928
          goto Do_Conic;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1929
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1930
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1931
        if ( Conic_To( RAS_VARS v_control.x, v_control.y,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1932
                                v_start.x,   v_start.y ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1933
          goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1934
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1935
        goto Close;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1936
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1937
      default:  /* FT_CURVE_TAG_CUBIC */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1938
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1939
          Long  x1, y1, x2, y2, x3, y3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1940
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1941
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1942
          if ( point + 1 > limit                             ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1943
               FT_CURVE_TAG( tags[1] ) != FT_CURVE_TAG_CUBIC )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1944
            goto Invalid_Outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1945
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1946
          point += 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1947
          tags  += 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1948
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1949
          x1 = SCALED( point[-2].x );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1950
          y1 = SCALED( point[-2].y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1951
          x2 = SCALED( point[-1].x );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1952
          y2 = SCALED( point[-1].y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1953
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1954
          if ( flipped )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1955
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1956
            SWAP_( x1, y1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1957
            SWAP_( x2, y2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1958
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1959
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1960
          if ( point <= limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1961
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1962
            x3 = SCALED( point[0].x );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1963
            y3 = SCALED( point[0].y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1964
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1965
            if ( flipped )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1966
              SWAP_( x3, y3 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1967
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1968
            if ( Cubic_To( RAS_VARS x1, y1, x2, y2, x3, y3 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1969
              goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1970
            continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1971
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1972
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1973
          if ( Cubic_To( RAS_VARS x1, y1, x2, y2, v_start.x, v_start.y ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1974
            goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1975
          goto Close;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1976
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1977
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1978
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1979
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1980
    /* close the contour with a line segment */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1981
    if ( Line_To( RAS_VARS v_start.x, v_start.y ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1982
      goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1983
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1984
  Close:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1985
    return SUCCESS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1986
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1987
  Invalid_Outline:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1988
    ras.error = Raster_Err_Invalid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1989
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1990
  Fail:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1991
    return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1992
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1993
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1994
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1995
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1996
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1997
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1998
  /*    Convert_Glyph                                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1999
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2000
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2001
  /*    Convert a glyph into a series of segments and arcs and make a      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2002
  /*    profiles list with them.                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2003
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2004
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2005
  /*    flipped :: If set, flip the direction of curve.                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2006
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2007
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2008
  /*    SUCCESS on success, FAILURE if any error was encountered during    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2009
  /*    rendering.                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2010
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2011
  static Bool
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2012
  Convert_Glyph( RAS_ARGS int  flipped )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2013
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2014
    int       i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2015
    unsigned  start;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2016
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2017
    PProfile  lastProfile;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2018
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2019
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2020
    ras.fProfile = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2021
    ras.joint    = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2022
    ras.fresh    = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2023
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2024
    ras.maxBuff  = ras.sizeBuff - AlignProfileSize;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2025
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2026
    ras.numTurns = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2027
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2028
    ras.cProfile         = (PProfile)ras.top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2029
    ras.cProfile->offset = ras.top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2030
    ras.num_Profs        = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2031
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2032
    start = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2033
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2034
    for ( i = 0; i < ras.outline.n_contours; i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2035
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2036
      Bool  o;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2037
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2038
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2039
      ras.state    = Unknown_State;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2040
      ras.gProfile = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2041
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2042
      if ( Decompose_Curve( RAS_VARS (unsigned short)start,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2043
                                     ras.outline.contours[i],
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2044
                                     flipped ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2045
        return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2046
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2047
      start = ras.outline.contours[i] + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2048
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2049
      /* we must now check whether the extreme arcs join or not */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2050
      if ( FRAC( ras.lastY ) == 0 &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2051
           ras.lastY >= ras.minY  &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2052
           ras.lastY <= ras.maxY  )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2053
        if ( ras.gProfile                        &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2054
             ( ras.gProfile->flags & Flow_Up ) ==
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2055
               ( ras.cProfile->flags & Flow_Up ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2056
          ras.top--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2057
        /* Note that ras.gProfile can be nil if the contour was too small */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2058
        /* to be drawn.                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2059
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2060
      lastProfile = ras.cProfile;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2061
      if ( ras.cProfile->flags & Flow_Up )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2062
        o = IS_TOP_OVERSHOOT( ras.lastY );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2063
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2064
        o = IS_BOTTOM_OVERSHOOT( ras.lastY );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2065
      if ( End_Profile( RAS_VARS o ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2066
        return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2067
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2068
      /* close the `next profile in contour' linked list */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2069
      if ( ras.gProfile )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2070
        lastProfile->next = ras.gProfile;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2071
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2072
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2073
    if ( Finalize_Profile_Table( RAS_VAR ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2074
      return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2075
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2076
    return (Bool)( ras.top < ras.maxBuff ? SUCCESS : FAILURE );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2077
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2078
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2079
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2080
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2081
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2082
  /**                                                                     **/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2083
  /**  SCAN-LINE SWEEPS AND DRAWING                                       **/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2084
  /**                                                                     **/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2085
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2086
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2087
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2088
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2089
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2090
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2091
  /*  Init_Linked                                                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2092
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2093
  /*    Initializes an empty linked list.                                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2094
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2095
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2096
  Init_Linked( TProfileList*  l )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2097
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2098
    *l = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2099
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2100
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2101
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2102
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2103
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2104
  /*  InsNew                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2105
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2106
  /*    Inserts a new profile in a linked list.                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2107
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2108
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2109
  InsNew( PProfileList  list,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2110
          PProfile      profile )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2111
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2112
    PProfile  *old, current;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2113
    Long       x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2114
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2115
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2116
    old     = list;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2117
    current = *old;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2118
    x       = profile->X;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2119
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2120
    while ( current )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2121
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2122
      if ( x < current->X )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2123
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2124
      old     = &current->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2125
      current = *old;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2126
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2127
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2128
    profile->link = current;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2129
    *old          = profile;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2130
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2131
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2132
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2133
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2134
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2135
  /*  DelOld                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2136
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2137
  /*    Removes an old profile from a linked list.                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2138
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2139
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2140
  DelOld( PProfileList  list,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2141
          PProfile      profile )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2142
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2143
    PProfile  *old, current;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2144
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2145
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2146
    old     = list;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2147
    current = *old;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2148
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2149
    while ( current )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2150
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2151
      if ( current == profile )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2152
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2153
        *old = current->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2154
        return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2155
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2156
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2157
      old     = &current->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2158
      current = *old;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2159
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2160
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2161
    /* we should never get there, unless the profile was not part of */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2162
    /* the list.                                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2163
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2164
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2165
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2166
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2167
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2168
  /*  Sort                                                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2169
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2170
  /*    Sorts a trace list.  In 95%, the list is already sorted.  We need  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2171
  /*    an algorithm which is fast in this case.  Bubble sort is enough    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2172
  /*    and simple.                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2173
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2174
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2175
  Sort( PProfileList  list )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2176
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2177
    PProfile  *old, current, next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2178
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2179
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2180
    /* First, set the new X coordinate of each profile */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2181
    current = *list;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2182
    while ( current )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2183
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2184
      current->X       = *current->offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2185
      current->offset += current->flags & Flow_Up ? 1 : -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2186
      current->height--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2187
      current = current->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2188
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2189
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2190
    /* Then sort them */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2191
    old     = list;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2192
    current = *old;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2193
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2194
    if ( !current )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2195
      return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2196
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2197
    next = current->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2198
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2199
    while ( next )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2200
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2201
      if ( current->X <= next->X )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2202
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2203
        old     = &current->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2204
        current = *old;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2205
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2206
        if ( !current )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2207
          return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2208
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2209
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2210
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2211
        *old          = next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2212
        current->link = next->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2213
        next->link    = current;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2214
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2215
        old     = list;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2216
        current = *old;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2217
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2218
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2219
      next = current->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2220
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2221
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2222
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2223
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2224
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2225
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2226
  /*  Vertical Sweep Procedure Set                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2227
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2228
  /*  These four routines are used during the vertical black/white sweep   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2229
  /*  phase by the generic Draw_Sweep() function.                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2230
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2231
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2232
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2233
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2234
  Vertical_Sweep_Init( RAS_ARGS Short*  min,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2235
                                Short*  max )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2236
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2237
    Long  pitch = ras.target.pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2238
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2239
    FT_UNUSED( max );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2240
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2241
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2242
    ras.traceIncr = (Short)-pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2243
    ras.traceOfs  = -*min * pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2244
    if ( pitch > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2245
      ras.traceOfs += ( ras.target.rows - 1 ) * pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2246
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2247
    ras.gray_min_x = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2248
    ras.gray_max_x = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2249
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2250
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2251
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2252
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2253
  Vertical_Sweep_Span( RAS_ARGS Short       y,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2254
                                FT_F26Dot6  x1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2255
                                FT_F26Dot6  x2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2256
                                PProfile    left,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2257
                                PProfile    right )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2258
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2259
    Long   e1, e2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2260
    int    c1, c2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2261
    Byte   f1, f2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2262
    Byte*  target;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2263
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2264
    FT_UNUSED( y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2265
    FT_UNUSED( left );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2266
    FT_UNUSED( right );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2267
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2268
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2269
    /* Drop-out control */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2270
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2271
    e1 = TRUNC( CEILING( x1 ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2272
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2273
    if ( x2 - x1 - ras.precision <= ras.precision_jitter )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2274
      e2 = e1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2275
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2276
      e2 = TRUNC( FLOOR( x2 ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2277
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2278
    if ( e2 >= 0 && e1 < ras.bWidth )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2279
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2280
      if ( e1 < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2281
        e1 = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2282
      if ( e2 >= ras.bWidth )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2283
        e2 = ras.bWidth - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2284
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2285
      c1 = (Short)( e1 >> 3 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2286
      c2 = (Short)( e2 >> 3 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2287
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2288
      f1 = (Byte)  ( 0xFF >> ( e1 & 7 ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2289
      f2 = (Byte) ~( 0x7F >> ( e2 & 7 ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2290
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2291
      if ( ras.gray_min_x > c1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2292
        ras.gray_min_x = (short)c1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2293
      if ( ras.gray_max_x < c2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2294
        ras.gray_max_x = (short)c2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2295
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2296
      target = ras.bTarget + ras.traceOfs + c1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2297
      c2 -= c1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2298
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2299
      if ( c2 > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2300
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2301
        target[0] |= f1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2302
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2303
        /* memset() is slower than the following code on many platforms. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2304
        /* This is due to the fact that, in the vast majority of cases,  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2305
        /* the span length in bytes is relatively small.                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2306
        c2--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2307
        while ( c2 > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2308
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2309
          *(++target) = 0xFF;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2310
          c2--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2311
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2312
        target[1] |= f2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2313
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2314
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2315
        *target |= ( f1 & f2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2316
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2317
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2318
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2319
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2320
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2321
  Vertical_Sweep_Drop( RAS_ARGS Short       y,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2322
                                FT_F26Dot6  x1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2323
                                FT_F26Dot6  x2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2324
                                PProfile    left,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2325
                                PProfile    right )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2326
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2327
    Long   e1, e2, pxl;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2328
    Short  c1, f1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2329
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2330
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2331
    /* Drop-out control */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2332
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2333
    /*   e2            x2                    x1           e1   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2334
    /*                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2335
    /*                 ^                     |                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2336
    /*                 |                     |                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2337
    /*   +-------------+---------------------+------------+    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2338
    /*                 |                     |                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2339
    /*                 |                     v                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2340
    /*                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2341
    /* pixel         contour              contour       pixel  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2342
    /* center                                           center */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2343
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2344
    /* drop-out mode    scan conversion rules (as defined in OpenType) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2345
    /* --------------------------------------------------------------- */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2346
    /*  0                1, 2, 3                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2347
    /*  1                1, 2, 4                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2348
    /*  2                1, 2                                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2349
    /*  3                same as mode 2                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2350
    /*  4                1, 2, 5                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2351
    /*  5                1, 2, 6                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2352
    /*  6, 7             same as mode 2                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2353
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2354
    e1  = CEILING( x1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2355
    e2  = FLOOR  ( x2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2356
    pxl = e1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2357
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2358
    if ( e1 > e2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2359
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2360
      Int  dropOutControl = left->flags & 7;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2361
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2362
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2363
      if ( e1 == e2 + ras.precision )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2364
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2365
        switch ( dropOutControl )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2366
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2367
        case 0: /* simple drop-outs including stubs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2368
          pxl = e2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2369
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2370
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2371
        case 4: /* smart drop-outs including stubs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2372
          pxl = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2373
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2374
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2375
        case 1: /* simple drop-outs excluding stubs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2376
        case 5: /* smart drop-outs excluding stubs  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2377
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2378
          /* Drop-out Control Rules #4 and #6 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2379
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2380
          /* The specification neither provides an exact definition */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2381
          /* of a `stub' nor gives exact rules to exclude them.     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2382
          /*                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2383
          /* Here the constraints we use to recognize a stub.       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2384
          /*                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2385
          /*  upper stub:                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2386
          /*                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2387
          /*   - P_Left and P_Right are in the same contour         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2388
          /*   - P_Right is the successor of P_Left in that contour */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2389
          /*   - y is the top of P_Left and P_Right                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2390
          /*                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2391
          /*  lower stub:                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2392
          /*                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2393
          /*   - P_Left and P_Right are in the same contour         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2394
          /*   - P_Left is the successor of P_Right in that contour */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2395
          /*   - y is the bottom of P_Left                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2396
          /*                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2397
          /* We draw a stub if the following constraints are met.   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2398
          /*                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2399
          /*   - for an upper or lower stub, there is top or bottom */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2400
          /*     overshoot, respectively                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2401
          /*   - the covered interval is greater or equal to a half */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2402
          /*     pixel                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2403
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2404
          /* upper stub test */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2405
          if ( left->next == right                &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2406
               left->height <= 0                  &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2407
               !( left->flags & Overshoot_Top   &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2408
                  x2 - x1 >= ras.precision_half ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2409
            return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2410
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2411
          /* lower stub test */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2412
          if ( right->next == left                 &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2413
               left->start == y                    &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2414
               !( left->flags & Overshoot_Bottom &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2415
                  x2 - x1 >= ras.precision_half  ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2416
            return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2417
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2418
          if ( dropOutControl == 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2419
            pxl = e2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2420
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2421
            pxl = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2422
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2423
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2424
        default: /* modes 2, 3, 6, 7 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2425
          return;  /* no drop-out control */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2426
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2427
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2428
        /* undocumented but confirmed: If the drop-out would result in a  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2429
        /* pixel outside of the bounding box, use the pixel inside of the */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2430
        /* bounding box instead                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2431
        if ( pxl < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2432
          pxl = e1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2433
        else if ( TRUNC( pxl ) >= ras.bWidth )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2434
          pxl = e2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2435
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2436
        /* check that the other pixel isn't set */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2437
        e1 = pxl == e1 ? e2 : e1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2438
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2439
        e1 = TRUNC( e1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2440
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2441
        c1 = (Short)( e1 >> 3 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2442
        f1 = (Short)( e1 &  7 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2443
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2444
        if ( e1 >= 0 && e1 < ras.bWidth                      &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2445
             ras.bTarget[ras.traceOfs + c1] & ( 0x80 >> f1 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2446
          return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2447
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2448
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2449
        return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2450
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2451
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2452
    e1 = TRUNC( pxl );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2453
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2454
    if ( e1 >= 0 && e1 < ras.bWidth )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2455
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2456
      c1 = (Short)( e1 >> 3 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2457
      f1 = (Short)( e1 & 7 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2458
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2459
      if ( ras.gray_min_x > c1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2460
        ras.gray_min_x = c1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2461
      if ( ras.gray_max_x < c1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2462
        ras.gray_max_x = c1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2463
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2464
      ras.bTarget[ras.traceOfs + c1] |= (char)( 0x80 >> f1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2465
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2466
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2467
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2468
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2469
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2470
  Vertical_Sweep_Step( RAS_ARG )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2471
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2472
    ras.traceOfs += ras.traceIncr;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2473
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2474
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2475
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2476
  /***********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2477
  /*                                                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2478
  /*  Horizontal Sweep Procedure Set                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2479
  /*                                                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2480
  /*  These four routines are used during the horizontal black/white     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2481
  /*  sweep phase by the generic Draw_Sweep() function.                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2482
  /*                                                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2483
  /***********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2484
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2485
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2486
  Horizontal_Sweep_Init( RAS_ARGS Short*  min,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2487
                                  Short*  max )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2488
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2489
    /* nothing, really */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2490
    FT_UNUSED_RASTER;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2491
    FT_UNUSED( min );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2492
    FT_UNUSED( max );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2493
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2494
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2495
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2496
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2497
  Horizontal_Sweep_Span( RAS_ARGS Short       y,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2498
                                  FT_F26Dot6  x1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2499
                                  FT_F26Dot6  x2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2500
                                  PProfile    left,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2501
                                  PProfile    right )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2502
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2503
    Long   e1, e2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2504
    PByte  bits;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2505
    Byte   f1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2506
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2507
    FT_UNUSED( left );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2508
    FT_UNUSED( right );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2509
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2510
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2511
    if ( x2 - x1 < ras.precision )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2512
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2513
      e1 = CEILING( x1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2514
      e2 = FLOOR  ( x2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2515
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2516
      if ( e1 == e2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2517
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2518
        bits = ras.bTarget + ( y >> 3 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2519
        f1   = (Byte)( 0x80 >> ( y & 7 ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2520
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2521
        e1 = TRUNC( e1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2522
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2523
        if ( e1 >= 0 && e1 < ras.target.rows )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2524
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2525
          PByte  p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2526
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2527
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2528
          p = bits - e1 * ras.target.pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2529
          if ( ras.target.pitch > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2530
            p += ( ras.target.rows - 1 ) * ras.target.pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2531
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2532
          p[0] |= f1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2533
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2534
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2535
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2536
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2537
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2538
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2539
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2540
  Horizontal_Sweep_Drop( RAS_ARGS Short       y,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2541
                                  FT_F26Dot6  x1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2542
                                  FT_F26Dot6  x2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2543
                                  PProfile    left,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2544
                                  PProfile    right )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2545
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2546
    Long   e1, e2, pxl;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2547
    PByte  bits;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2548
    Byte   f1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2549
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2550
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2551
    /* During the horizontal sweep, we only take care of drop-outs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2552
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2553
    /* e1     +       <-- pixel center */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2554
    /*        |                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2555
    /* x1  ---+-->    <-- contour      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2556
    /*        |                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2557
    /*        |                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2558
    /* x2  <--+---    <-- contour      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2559
    /*        |                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2560
    /*        |                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2561
    /* e2     +       <-- pixel center */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2562
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2563
    e1  = CEILING( x1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2564
    e2  = FLOOR  ( x2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2565
    pxl = e1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2566
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2567
    if ( e1 > e2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2568
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2569
      Int  dropOutControl = left->flags & 7;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2570
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2571
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2572
      if ( e1 == e2 + ras.precision )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2573
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2574
        switch ( dropOutControl )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2575
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2576
        case 0: /* simple drop-outs including stubs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2577
          pxl = e2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2578
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2579
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2580
        case 4: /* smart drop-outs including stubs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2581
          pxl = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2582
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2583
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2584
        case 1: /* simple drop-outs excluding stubs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2585
        case 5: /* smart drop-outs excluding stubs  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2586
          /* see Vertical_Sweep_Drop for details */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2587
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2588
          /* rightmost stub test */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2589
          if ( left->next == right                &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2590
               left->height <= 0                  &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2591
               !( left->flags & Overshoot_Top   &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2592
                  x2 - x1 >= ras.precision_half ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2593
            return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2594
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2595
          /* leftmost stub test */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2596
          if ( right->next == left                 &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2597
               left->start == y                    &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2598
               !( left->flags & Overshoot_Bottom &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2599
                  x2 - x1 >= ras.precision_half  ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2600
            return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2601
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2602
          if ( dropOutControl == 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2603
            pxl = e2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2604
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2605
            pxl = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2606
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2607
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2608
        default: /* modes 2, 3, 6, 7 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2609
          return;  /* no drop-out control */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2610
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2611
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2612
        /* undocumented but confirmed: If the drop-out would result in a  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2613
        /* pixel outside of the bounding box, use the pixel inside of the */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2614
        /* bounding box instead                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2615
        if ( pxl < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2616
          pxl = e1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2617
        else if ( TRUNC( pxl ) >= ras.target.rows )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2618
          pxl = e2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2619
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2620
        /* check that the other pixel isn't set */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2621
        e1 = pxl == e1 ? e2 : e1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2622
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2623
        e1 = TRUNC( e1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2624
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2625
        bits = ras.bTarget + ( y >> 3 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2626
        f1   = (Byte)( 0x80 >> ( y & 7 ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2627
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2628
        bits -= e1 * ras.target.pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2629
        if ( ras.target.pitch > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2630
          bits += ( ras.target.rows - 1 ) * ras.target.pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2631
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2632
        if ( e1 >= 0              &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2633
             e1 < ras.target.rows &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2634
             *bits & f1           )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2635
          return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2636
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2637
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2638
        return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2639
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2640
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2641
    bits = ras.bTarget + ( y >> 3 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2642
    f1   = (Byte)( 0x80 >> ( y & 7 ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2643
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2644
    e1 = TRUNC( pxl );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2645
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2646
    if ( e1 >= 0 && e1 < ras.target.rows )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2647
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2648
      bits -= e1 * ras.target.pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2649
      if ( ras.target.pitch > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2650
        bits += ( ras.target.rows - 1 ) * ras.target.pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2651
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2652
      bits[0] |= f1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2653
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2654
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2655
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2656
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2657
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2658
  Horizontal_Sweep_Step( RAS_ARG )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2659
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2660
    /* Nothing, really */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2661
    FT_UNUSED_RASTER;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2662
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2663
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2664
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2665
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2666
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2667
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2668
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2669
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2670
  /*  Vertical Gray Sweep Procedure Set                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2671
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2672
  /*  These two routines are used during the vertical gray-levels sweep    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2673
  /*  phase by the generic Draw_Sweep() function.                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2674
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2675
  /*  NOTES                                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2676
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2677
  /*  - The target pixmap's width *must* be a multiple of 4.               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2678
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2679
  /*  - You have to use the function Vertical_Sweep_Span() for the gray    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2680
  /*    span call.                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2681
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2682
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2683
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2684
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2685
  Vertical_Gray_Sweep_Init( RAS_ARGS Short*  min,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2686
                                     Short*  max )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2687
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2688
    Long  pitch, byte_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2689
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2690
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2691
    *min = *min & -2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2692
    *max = ( *max + 3 ) & -2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2693
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2694
    ras.traceOfs  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2695
    pitch         = ras.target.pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2696
    byte_len      = -pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2697
    ras.traceIncr = (Short)byte_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2698
    ras.traceG    = ( *min / 2 ) * byte_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2699
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2700
    if ( pitch > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2701
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2702
      ras.traceG += ( ras.target.rows - 1 ) * pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2703
      byte_len    = -byte_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2704
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2705
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2706
    ras.gray_min_x =  (Short)byte_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2707
    ras.gray_max_x = -(Short)byte_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2708
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2709
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2710
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2711
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2712
  Vertical_Gray_Sweep_Step( RAS_ARG )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2713
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2714
    Int     c1, c2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2715
    PByte   pix, bit, bit2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2716
    short*  count = (short*)count_table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2717
    Byte*   grays;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2718
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2719
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2720
    ras.traceOfs += ras.gray_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2721
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2722
    if ( ras.traceOfs > ras.gray_width )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2723
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2724
      pix   = ras.gTarget + ras.traceG + ras.gray_min_x * 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2725
      grays = ras.grays;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2726
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2727
      if ( ras.gray_max_x >= 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2728
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2729
        Long  last_pixel = ras.target.width - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2730
        Int   last_cell  = last_pixel >> 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2731
        Int   last_bit   = last_pixel & 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2732
        Bool  over       = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2733
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2734
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2735
        if ( ras.gray_max_x >= last_cell && last_bit != 3 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2736
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2737
          ras.gray_max_x = last_cell - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2738
          over = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2739
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2740
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2741
        if ( ras.gray_min_x < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2742
          ras.gray_min_x = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2743
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2744
        bit  = ras.bTarget + ras.gray_min_x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2745
        bit2 = bit + ras.gray_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2746
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2747
        c1 = ras.gray_max_x - ras.gray_min_x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2748
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2749
        while ( c1 >= 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2750
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2751
          c2 = count[*bit] + count[*bit2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2752
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2753
          if ( c2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2754
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2755
            pix[0] = grays[(c2 >> 12) & 0x000F];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2756
            pix[1] = grays[(c2 >> 8 ) & 0x000F];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2757
            pix[2] = grays[(c2 >> 4 ) & 0x000F];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2758
            pix[3] = grays[ c2        & 0x000F];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2759
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2760
            *bit  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2761
            *bit2 = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2762
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2763
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2764
          bit++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2765
          bit2++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2766
          pix += 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2767
          c1--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2768
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2769
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2770
        if ( over )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2771
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2772
          c2 = count[*bit] + count[*bit2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2773
          if ( c2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2774
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2775
            switch ( last_bit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2776
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2777
            case 2:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2778
              pix[2] = grays[(c2 >> 4 ) & 0x000F];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2779
            case 1:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2780
              pix[1] = grays[(c2 >> 8 ) & 0x000F];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2781
            default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2782
              pix[0] = grays[(c2 >> 12) & 0x000F];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2783
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2784
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2785
            *bit  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2786
            *bit2 = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2787
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2788
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2789
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2790
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2791
      ras.traceOfs = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2792
      ras.traceG  += ras.traceIncr;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2793
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2794
      ras.gray_min_x =  32000;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2795
      ras.gray_max_x = -32000;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2796
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2797
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2798
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2799
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2800
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2801
  Horizontal_Gray_Sweep_Span( RAS_ARGS Short       y,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2802
                                       FT_F26Dot6  x1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2803
                                       FT_F26Dot6  x2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2804
                                       PProfile    left,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2805
                                       PProfile    right )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2806
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2807
    /* nothing, really */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2808
    FT_UNUSED_RASTER;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2809
    FT_UNUSED( y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2810
    FT_UNUSED( x1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2811
    FT_UNUSED( x2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2812
    FT_UNUSED( left );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2813
    FT_UNUSED( right );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2814
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2815
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2816
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2817
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2818
  Horizontal_Gray_Sweep_Drop( RAS_ARGS Short       y,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2819
                                       FT_F26Dot6  x1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2820
                                       FT_F26Dot6  x2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2821
                                       PProfile    left,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2822
                                       PProfile    right )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2823
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2824
    Long   e1, e2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2825
    PByte  pixel;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2826
    Byte   color;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2827
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2828
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2829
    /* During the horizontal sweep, we only take care of drop-outs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2830
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2831
    e1 = CEILING( x1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2832
    e2 = FLOOR  ( x2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2833
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2834
    if ( e1 > e2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2835
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2836
      Int  dropOutControl = left->flags & 7;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2837
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2838
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2839
      if ( e1 == e2 + ras.precision )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2840
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2841
        switch ( dropOutControl )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2842
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2843
        case 0: /* simple drop-outs including stubs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2844
          e1 = e2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2845
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2846
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2847
        case 4: /* smart drop-outs including stubs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2848
          e1 = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2849
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2850
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2851
        case 1: /* simple drop-outs excluding stubs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2852
        case 5: /* smart drop-outs excluding stubs  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2853
          /* see Vertical_Sweep_Drop for details */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2854
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2855
          /* rightmost stub test */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2856
          if ( left->next == right && left->height <= 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2857
            return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2858
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2859
          /* leftmost stub test */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2860
          if ( right->next == left && left->start == y )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2861
            return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2862
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2863
          if ( dropOutControl == 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2864
            e1 = e2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2865
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2866
            e1 = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2867
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2868
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2869
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2870
        default: /* modes 2, 3, 6, 7 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2871
          return;  /* no drop-out control */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2872
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2873
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2874
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2875
        return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2876
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2877
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2878
    if ( e1 >= 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2879
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2880
      if ( x2 - x1 >= ras.precision_half )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2881
        color = ras.grays[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2882
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2883
        color = ras.grays[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2884
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2885
      e1 = TRUNC( e1 ) / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2886
      if ( e1 < ras.target.rows )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2887
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2888
        pixel = ras.gTarget - e1 * ras.target.pitch + y / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2889
        if ( ras.target.pitch > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2890
          pixel += ( ras.target.rows - 1 ) * ras.target.pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2891
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2892
        if ( pixel[0] == ras.grays[0] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2893
          pixel[0] = color;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2894
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2895
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2896
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2897
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2898
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2899
#endif /* FT_RASTER_OPTION_ANTI_ALIASING */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2900
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2901
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2902
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2903
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2904
  /*  Generic Sweep Drawing routine                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2905
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2906
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2907
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2908
  static Bool
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2909
  Draw_Sweep( RAS_ARG )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2910
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2911
    Short         y, y_change, y_height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2912
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2913
    PProfile      P, Q, P_Left, P_Right;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2914
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2915
    Short         min_Y, max_Y, top, bottom, dropouts;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2916
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2917
    Long          x1, x2, xs, e1, e2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2918
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2919
    TProfileList  waiting;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2920
    TProfileList  draw_left, draw_right;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2921
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2922
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2923
    /* initialize empty linked lists */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2924
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2925
    Init_Linked( &waiting );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2926
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2927
    Init_Linked( &draw_left  );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2928
    Init_Linked( &draw_right );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2929
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2930
    /* first, compute min and max Y */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2931
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2932
    P     = ras.fProfile;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2933
    max_Y = (Short)TRUNC( ras.minY );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2934
    min_Y = (Short)TRUNC( ras.maxY );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2935
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2936
    while ( P )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2937
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2938
      Q = P->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2939
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2940
      bottom = (Short)P->start;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2941
      top    = (Short)( P->start + P->height - 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2942
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2943
      if ( min_Y > bottom )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2944
        min_Y = bottom;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2945
      if ( max_Y < top )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2946
        max_Y = top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2947
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2948
      P->X = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2949
      InsNew( &waiting, P );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2950
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2951
      P = Q;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2952
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2953
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2954
    /* check the Y-turns */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2955
    if ( ras.numTurns == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2956
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2957
      ras.error = Raster_Err_Invalid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2958
      return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2959
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2960
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2961
    /* now initialize the sweep */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2962
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2963
    ras.Proc_Sweep_Init( RAS_VARS &min_Y, &max_Y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2964
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2965
    /* then compute the distance of each profile from min_Y */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2966
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2967
    P = waiting;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2968
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2969
    while ( P )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2970
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2971
      P->countL = (UShort)( P->start - min_Y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2972
      P = P->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2973
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2974
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2975
    /* let's go */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2976
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2977
    y        = min_Y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2978
    y_height = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2979
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2980
    if ( ras.numTurns > 0                     &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2981
         ras.sizeBuff[-ras.numTurns] == min_Y )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2982
      ras.numTurns--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2983
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2984
    while ( ras.numTurns > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2985
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2986
      /* check waiting list for new activations */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2987
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2988
      P = waiting;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2989
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2990
      while ( P )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2991
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2992
        Q = P->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2993
        P->countL -= y_height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2994
        if ( P->countL == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2995
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2996
          DelOld( &waiting, P );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2997
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2998
          if ( P->flags & Flow_Up )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2999
            InsNew( &draw_left,  P );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3000
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3001
            InsNew( &draw_right, P );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3002
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3003
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3004
        P = Q;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3005
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3006
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3007
      /* sort the drawing lists */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3008
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3009
      Sort( &draw_left );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3010
      Sort( &draw_right );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3011
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3012
      y_change = (Short)ras.sizeBuff[-ras.numTurns--];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3013
      y_height = (Short)( y_change - y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3014
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3015
      while ( y < y_change )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3016
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3017
        /* let's trace */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3018
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3019
        dropouts = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3020
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3021
        P_Left  = draw_left;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3022
        P_Right = draw_right;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3023
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3024
        while ( P_Left )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3025
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3026
          x1 = P_Left ->X;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3027
          x2 = P_Right->X;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3028
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3029
          if ( x1 > x2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3030
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3031
            xs = x1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3032
            x1 = x2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3033
            x2 = xs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3034
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3035
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3036
          e1 = FLOOR( x1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3037
          e2 = CEILING( x2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3038
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3039
          if ( x2 - x1 <= ras.precision &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3040
               e1 != x1 && e2 != x2     )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3041
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3042
            if ( e1 > e2 || e2 == e1 + ras.precision )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3043
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3044
              Int  dropOutControl = P_Left->flags & 7;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3045
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3046
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3047
              if ( dropOutControl != 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3048
              {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3049
                /* a drop-out was detected */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3050
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3051
                P_Left ->X = x1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3052
                P_Right->X = x2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3053
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3054
                /* mark profile for drop-out processing */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3055
                P_Left->countL = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3056
                dropouts++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3057
              }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3058
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3059
              goto Skip_To_Next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3060
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3061
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3062
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3063
          ras.Proc_Sweep_Span( RAS_VARS y, x1, x2, P_Left, P_Right );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3064
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3065
        Skip_To_Next:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3066
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3067
          P_Left  = P_Left->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3068
          P_Right = P_Right->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3069
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3070
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3071
        /* handle drop-outs _after_ the span drawing --       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3072
        /* drop-out processing has been moved out of the loop */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3073
        /* for performance tuning                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3074
        if ( dropouts > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3075
          goto Scan_DropOuts;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3076
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3077
      Next_Line:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3078
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3079
        ras.Proc_Sweep_Step( RAS_VAR );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3080
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3081
        y++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3082
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3083
        if ( y < y_change )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3084
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3085
          Sort( &draw_left  );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3086
          Sort( &draw_right );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3087
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3088
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3089
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3090
      /* now finalize the profiles that need it */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3091
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3092
      P = draw_left;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3093
      while ( P )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3094
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3095
        Q = P->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3096
        if ( P->height == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3097
          DelOld( &draw_left, P );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3098
        P = Q;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3099
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3100
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3101
      P = draw_right;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3102
      while ( P )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3103
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3104
        Q = P->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3105
        if ( P->height == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3106
          DelOld( &draw_right, P );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3107
        P = Q;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3108
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3109
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3110
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3111
    /* for gray-scaling, flush the bitmap scanline cache */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3112
    while ( y <= max_Y )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3113
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3114
      ras.Proc_Sweep_Step( RAS_VAR );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3115
      y++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3116
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3117
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3118
    return SUCCESS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3119
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3120
  Scan_DropOuts:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3121
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3122
    P_Left  = draw_left;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3123
    P_Right = draw_right;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3124
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3125
    while ( P_Left )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3126
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3127
      if ( P_Left->countL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3128
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3129
        P_Left->countL = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3130
#if 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3131
        dropouts--;  /* -- this is useful when debugging only */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3132
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3133
        ras.Proc_Sweep_Drop( RAS_VARS y,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3134
                                      P_Left->X,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3135
                                      P_Right->X,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3136
                                      P_Left,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3137
                                      P_Right );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3138
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3139
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3140
      P_Left  = P_Left->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3141
      P_Right = P_Right->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3142
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3143
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3144
    goto Next_Line;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3145
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3146
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3147
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3148
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3149
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3150
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3151
  /*    Render_Single_Pass                                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3152
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3153
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3154
  /*    Perform one sweep with sub-banding.                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3155
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3156
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3157
  /*    flipped :: If set, flip the direction of the outline.              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3158
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3159
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3160
  /*    Renderer error code.                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3161
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3162
  static int
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3163
  Render_Single_Pass( RAS_ARGS Bool  flipped )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3164
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3165
    Short  i, j, k;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3166
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3167
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3168
    while ( ras.band_top >= 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3169
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3170
      ras.maxY = (Long)ras.band_stack[ras.band_top].y_max * ras.precision;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3171
      ras.minY = (Long)ras.band_stack[ras.band_top].y_min * ras.precision;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3173
      ras.top = ras.buff;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3174
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3175
      ras.error = Raster_Err_None;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3176
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3177
      if ( Convert_Glyph( RAS_VARS flipped ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3178
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3179
        if ( ras.error != Raster_Err_Overflow )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3180
          return FAILURE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3181
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3182
        ras.error = Raster_Err_None;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3183
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3184
        /* sub-banding */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3185
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3186
#ifdef DEBUG_RASTER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3187
        ClearBand( RAS_VARS TRUNC( ras.minY ), TRUNC( ras.maxY ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3188
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3189
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3190
        i = ras.band_stack[ras.band_top].y_min;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3191
        j = ras.band_stack[ras.band_top].y_max;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3192
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3193
        k = (Short)( ( i + j ) / 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3194
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3195
        if ( ras.band_top >= 7 || k < i )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3196
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3197
          ras.band_top = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3198
          ras.error    = Raster_Err_Invalid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3199
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3200
          return ras.error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3201
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3202
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3203
        ras.band_stack[ras.band_top + 1].y_min = k;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3204
        ras.band_stack[ras.band_top + 1].y_max = j;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3205
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3206
        ras.band_stack[ras.band_top].y_max = (Short)( k - 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3207
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3208
        ras.band_top++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3209
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3210
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3211
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3212
        if ( ras.fProfile )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3213
          if ( Draw_Sweep( RAS_VAR ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3214
             return ras.error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3215
        ras.band_top--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3216
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3217
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3218
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3219
    return SUCCESS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3220
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3221
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3222
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3223
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3224
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3225
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3226
  /*    Render_Glyph                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3227
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3228
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3229
  /*    Render a glyph in a bitmap.  Sub-banding if needed.                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3230
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3231
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3232
  /*    FreeType error code.  0 means success.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3233
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3234
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3235
  Render_Glyph( RAS_ARG )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3236
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3237
    FT_Error  error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3238
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3239
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3240
    Set_High_Precision( RAS_VARS ras.outline.flags &
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3241
                                 FT_OUTLINE_HIGH_PRECISION );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3242
    ras.scale_shift = ras.precision_shift;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3243
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3244
    if ( ras.outline.flags & FT_OUTLINE_IGNORE_DROPOUTS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3245
      ras.dropOutControl = 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3246
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3247
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3248
      if ( ras.outline.flags & FT_OUTLINE_SMART_DROPOUTS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3249
        ras.dropOutControl = 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3250
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3251
        ras.dropOutControl = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3252
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3253
      if ( !( ras.outline.flags & FT_OUTLINE_INCLUDE_STUBS ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3254
        ras.dropOutControl += 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3255
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3256
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3257
    ras.second_pass = (FT_Byte)( !( ras.outline.flags &
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3258
                                    FT_OUTLINE_SINGLE_PASS ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3259
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3260
    /* Vertical Sweep */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3261
    ras.Proc_Sweep_Init = Vertical_Sweep_Init;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3262
    ras.Proc_Sweep_Span = Vertical_Sweep_Span;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3263
    ras.Proc_Sweep_Drop = Vertical_Sweep_Drop;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3264
    ras.Proc_Sweep_Step = Vertical_Sweep_Step;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3265
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3266
    ras.band_top            = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3267
    ras.band_stack[0].y_min = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3268
    ras.band_stack[0].y_max = (short)( ras.target.rows - 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3269
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3270
    ras.bWidth  = (unsigned short)ras.target.width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3271
    ras.bTarget = (Byte*)ras.target.buffer;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3272
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3273
    if ( ( error = Render_Single_Pass( RAS_VARS 0 ) ) != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3274
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3275
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3276
    /* Horizontal Sweep */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3277
    if ( ras.second_pass && ras.dropOutControl != 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3278
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3279
      ras.Proc_Sweep_Init = Horizontal_Sweep_Init;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3280
      ras.Proc_Sweep_Span = Horizontal_Sweep_Span;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3281
      ras.Proc_Sweep_Drop = Horizontal_Sweep_Drop;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3282
      ras.Proc_Sweep_Step = Horizontal_Sweep_Step;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3283
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3284
      ras.band_top            = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3285
      ras.band_stack[0].y_min = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3286
      ras.band_stack[0].y_max = (short)( ras.target.width - 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3287
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3288
      if ( ( error = Render_Single_Pass( RAS_VARS 1 ) ) != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3289
        return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3290
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3291
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3292
    return Raster_Err_None;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3293
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3294
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3295
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3296
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3297
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3298
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3299
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3300
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3301
  /*    Render_Gray_Glyph                                                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3302
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3303
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3304
  /*    Render a glyph with grayscaling.  Sub-banding if needed.           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3305
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3306
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3307
  /*    FreeType error code.  0 means success.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3308
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3309
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3310
  Render_Gray_Glyph( RAS_ARG )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3311
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3312
    Long      pixel_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3313
    FT_Error  error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3314
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3315
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3316
    Set_High_Precision( RAS_VARS ras.outline.flags &
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3317
                                 FT_OUTLINE_HIGH_PRECISION );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3318
    ras.scale_shift = ras.precision_shift + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3319
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3320
    if ( ras.outline.flags & FT_OUTLINE_IGNORE_DROPOUTS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3321
      ras.dropOutControl = 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3322
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3323
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3324
      if ( ras.outline.flags & FT_OUTLINE_SMART_DROPOUTS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3325
        ras.dropOutControl = 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3326
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3327
        ras.dropOutControl = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3328
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3329
      if ( !( ras.outline.flags & FT_OUTLINE_INCLUDE_STUBS ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3330
        ras.dropOutControl += 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3331
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3332
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3333
    ras.second_pass = !( ras.outline.flags & FT_OUTLINE_SINGLE_PASS );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3334
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3335
    /* Vertical Sweep */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3336
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3337
    ras.band_top            = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3338
    ras.band_stack[0].y_min = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3339
    ras.band_stack[0].y_max = 2 * ras.target.rows - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3340
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3341
    ras.bWidth  = ras.gray_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3342
    pixel_width = 2 * ( ( ras.target.width + 3 ) >> 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3343
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3344
    if ( ras.bWidth > pixel_width )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3345
      ras.bWidth = pixel_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3346
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3347
    ras.bWidth  = ras.bWidth * 8;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3348
    ras.bTarget = (Byte*)ras.gray_lines;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3349
    ras.gTarget = (Byte*)ras.target.buffer;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3350
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3351
    ras.Proc_Sweep_Init = Vertical_Gray_Sweep_Init;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3352
    ras.Proc_Sweep_Span = Vertical_Sweep_Span;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3353
    ras.Proc_Sweep_Drop = Vertical_Sweep_Drop;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3354
    ras.Proc_Sweep_Step = Vertical_Gray_Sweep_Step;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3355
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3356
    error = Render_Single_Pass( RAS_VARS 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3357
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3358
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3359
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3360
    /* Horizontal Sweep */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3361
    if ( ras.second_pass && ras.dropOutControl != 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3362
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3363
      ras.Proc_Sweep_Init = Horizontal_Sweep_Init;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3364
      ras.Proc_Sweep_Span = Horizontal_Gray_Sweep_Span;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3365
      ras.Proc_Sweep_Drop = Horizontal_Gray_Sweep_Drop;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3366
      ras.Proc_Sweep_Step = Horizontal_Sweep_Step;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3367
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3368
      ras.band_top            = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3369
      ras.band_stack[0].y_min = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3370
      ras.band_stack[0].y_max = ras.target.width * 2 - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3371
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3372
      error = Render_Single_Pass( RAS_VARS 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3373
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3374
        return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3375
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3376
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3377
    return Raster_Err_None;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3378
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3379
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3380
#else /* !FT_RASTER_OPTION_ANTI_ALIASING */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3381
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3382
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3383
  Render_Gray_Glyph( RAS_ARG )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3384
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3385
    FT_UNUSED_RASTER;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3386
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3387
    return Raster_Err_Unsupported;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3388
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3389
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3390
#endif /* !FT_RASTER_OPTION_ANTI_ALIASING */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3391
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3392
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3393
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3394
  ft_black_init( PRaster  raster )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3395
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3396
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3397
    FT_UInt  n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3398
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3399
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3400
    /* set default 5-levels gray palette */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3401
    for ( n = 0; n < 5; n++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3402
      raster->grays[n] = n * 255 / 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3403
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3404
    raster->gray_width = RASTER_GRAY_LINES / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3405
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3406
    FT_UNUSED( raster );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3407
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3408
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3409
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3410
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3411
  /**** RASTER OBJECT CREATION: In standalone mode, we simply use *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3412
  /****                         a static object.                  *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3413
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3414
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3415
#ifdef _STANDALONE_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3416
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3417
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3418
  static int
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3419
  ft_black_new( void*       memory,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3420
                FT_Raster  *araster )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3421
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3422
     static TRaster  the_raster;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3423
     FT_UNUSED( memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3424
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3425
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3426
     *araster = (FT_Raster)&the_raster;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3427
     FT_MEM_ZERO( &the_raster, sizeof ( the_raster ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3428
     ft_black_init( &the_raster );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3429
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3430
     return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3431
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3432
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3433
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3434
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3435
  ft_black_done( FT_Raster  raster )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3436
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3437
    /* nothing */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3438
    FT_UNUSED( raster );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3439
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3440
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3441
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3442
#else /* !_STANDALONE_ */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3443
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3444
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3445
  static int
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3446
  ft_black_new( FT_Memory   memory,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3447
                PRaster    *araster )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3448
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3449
    FT_Error  error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3450
    PRaster   raster = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3451
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3452
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3453
    *araster = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3454
    if ( !FT_NEW( raster ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3455
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3456
      raster->memory = memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3457
      ft_black_init( raster );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3458
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3459
      *araster = raster;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3460
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3461
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3462
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3463
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3464
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3465
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3466
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3467
  ft_black_done( PRaster  raster )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3468
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3469
    FT_Memory  memory = (FT_Memory)raster->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3470
    FT_FREE( raster );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3471
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3472
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3473
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3474
#endif /* !_STANDALONE_ */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3475
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3476
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3477
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3478
  ft_black_reset( PRaster  raster,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3479
                  char*    pool_base,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3480
                  long     pool_size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3481
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3482
    if ( raster )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3483
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3484
      if ( pool_base && pool_size >= (long)sizeof(TWorker) + 2048 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3485
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3486
        PWorker  worker = (PWorker)pool_base;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3487
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3488
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3489
        raster->buffer      = pool_base + ( ( sizeof ( *worker ) + 7 ) & ~7 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3490
        raster->buffer_size = pool_base + pool_size - (char*)raster->buffer;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3491
        raster->worker      = worker;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3492
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3493
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3494
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3495
        raster->buffer      = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3496
        raster->buffer_size = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3497
        raster->worker      = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3498
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3499
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3500
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3501
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3502
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3503
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3504
  ft_black_set_mode( PRaster        raster,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3505
                     unsigned long  mode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3506
                     const char*    palette )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3507
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3508
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3509
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3510
    if ( mode == FT_MAKE_TAG( 'p', 'a', 'l', '5' ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3511
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3512
      /* set 5-levels gray palette */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3513
      raster->grays[0] = palette[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3514
      raster->grays[1] = palette[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3515
      raster->grays[2] = palette[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3516
      raster->grays[3] = palette[3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3517
      raster->grays[4] = palette[4];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3518
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3519
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3520
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3521
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3522
    FT_UNUSED( raster );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3523
    FT_UNUSED( mode );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3524
    FT_UNUSED( palette );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3525
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3526
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3527
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3528
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3529
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3530
  static int
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3531
  ft_black_render( PRaster                  raster,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3532
                   const FT_Raster_Params*  params )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3533
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3534
    const FT_Outline*  outline    = (const FT_Outline*)params->source;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3535
    const FT_Bitmap*   target_map = params->target;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3536
    PWorker            worker;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3537
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3538
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3539
    if ( !raster || !raster->buffer || !raster->buffer_size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3540
      return Raster_Err_Not_Ini;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3541
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3542
    if ( !outline )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3543
      return Raster_Err_Invalid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3544
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3545
    /* return immediately if the outline is empty */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3546
    if ( outline->n_points == 0 || outline->n_contours <= 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3547
      return Raster_Err_None;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3548
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3549
    if ( !outline->contours || !outline->points )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3550
      return Raster_Err_Invalid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3551
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3552
    if ( outline->n_points !=
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3553
           outline->contours[outline->n_contours - 1] + 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3554
      return Raster_Err_Invalid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3555
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3556
    worker = raster->worker;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3557
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3558
    /* this version of the raster does not support direct rendering, sorry */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3559
    if ( params->flags & FT_RASTER_FLAG_DIRECT )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3560
      return Raster_Err_Unsupported;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3561
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3562
    if ( !target_map )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3563
      return Raster_Err_Invalid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3564
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3565
    /* nothing to do */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3566
    if ( !target_map->width || !target_map->rows )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3567
      return Raster_Err_None;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3568
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3569
    if ( !target_map->buffer )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3570
      return Raster_Err_Invalid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3571
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3572
    ras.outline = *outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3573
    ras.target  = *target_map;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3574
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3575
    worker->buff       = (PLong) raster->buffer;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3576
    worker->sizeBuff   = worker->buff +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3577
                           raster->buffer_size / sizeof ( Long );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3578
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3579
    worker->grays      = raster->grays;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3580
    worker->gray_width = raster->gray_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3581
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3582
    FT_MEM_ZERO( worker->gray_lines, worker->gray_width * 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3583
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3584
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3585
    return ( params->flags & FT_RASTER_FLAG_AA )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3586
           ? Render_Gray_Glyph( RAS_VAR )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3587
           : Render_Glyph( RAS_VAR );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3588
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3589
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3590
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3591
  FT_DEFINE_RASTER_FUNCS( ft_standard_raster,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3592
    FT_GLYPH_FORMAT_OUTLINE,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3593
    (FT_Raster_New_Func)     ft_black_new,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3594
    (FT_Raster_Reset_Func)   ft_black_reset,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3595
    (FT_Raster_Set_Mode_Func)ft_black_set_mode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3596
    (FT_Raster_Render_Func)  ft_black_render,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3597
    (FT_Raster_Done_Func)    ft_black_done
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3598
  )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3599
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3600
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  3601
/* END */