ftraster.c revision c242fe41ec634af32845cd17bcd1a0ee2653feb9
1a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner/***************************************************************************/
2a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner/*                                                                         */
3a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner/*  ftraster.c                                                             */
4a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner/*                                                                         */
5a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner/*    The FreeType glyph rasterizer (body).                                */
6a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner/*                                                                         */
77be2a94a50109773459414687151d70a99a1b6bdSean McBride/*  Copyright 1996-2003, 2005, 2007-2014 by                                */
8a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
9a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner/*                                                                         */
10a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner/*  This file is part of the FreeType project, and may only be used,       */
11a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner/*  modified, and distributed under the terms of the FreeType project      */
12a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
13a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner/*  this file you indicate that you have read the license and              */
14a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner/*  understand and accept it fully.                                        */
15a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner/*                                                                         */
16a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner/***************************************************************************/
17a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
18a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
19a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
20f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /* This file can be compiled without the rest of the FreeType engine, by */
21f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /* defining the _STANDALONE_ macro when compiling it.  You also need to  */
22f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /* put the files `ftimage.h' and `ftmisc.h' into the $(incdir)           */
23f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /* directory.  Typically, you should do something like                   */
24f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /*                                                                       */
25f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /* - copy `src/raster/ftraster.c' (this file) to your current directory  */
26f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /*                                                                       */
27fae382076409db198dfbff36ac4cbb97b05b30a1Werner Lemberg  /* - copy `include/ftimage.h' and `src/raster/ftmisc.h' to your current  */
28fae382076409db198dfbff36ac4cbb97b05b30a1Werner Lemberg  /*   directory                                                           */
29f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /*                                                                       */
30f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /* - compile `ftraster' with the _STANDALONE_ macro defined, as in       */
31f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /*                                                                       */
32f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /*     cc -c -D_STANDALONE_ ftraster.c                                   */
33f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /*                                                                       */
34f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /* The renderer can be initialized with a call to                        */
35f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /* `ft_standard_raster.raster_new'; a bitmap can be generated            */
36f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /* with a call to `ft_standard_raster.raster_render'.                    */
37f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /*                                                                       */
38f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /* See the comments and documentation in the file `ftimage.h' for more   */
39f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /* details on how the raster works.                                      */
40f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /*                                                                       */
41f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /*************************************************************************/
42f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg
43f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg
44f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /*************************************************************************/
45f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg  /*                                                                       */
46a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* This is a rewrite of the FreeType 1.x scan-line converter             */
47a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
48a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
49a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
50f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg#ifdef _STANDALONE_
51f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg
520d02317fb2a6f46e568cefc1132273cdd1bc80b7Werner Lemberg#define FT_CONFIG_STANDARD_LIBRARY_H  <stdlib.h>
530d02317fb2a6f46e568cefc1132273cdd1bc80b7Werner Lemberg
54766b822f4c1cc84cc11545b63be87108d0954b48Werner Lemberg#include <string.h>           /* for memset */
550d02317fb2a6f46e568cefc1132273cdd1bc80b7Werner Lemberg
56f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg#include "ftmisc.h"
57f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg#include "ftimage.h"
58f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg
59f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg#else /* !_STANDALONE_ */
60a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
6119ed8afe60bbc5becf0fbbe3987a91b35a36aad4David Turner#include <ft2build.h>
628d3a401fa808a8c70bd6a9ce17d5a840fb0ae2dbDavid Turner#include "ftraster.h"
63495bd3cc4f54f5f4604709391a716fcd0c033277Werner Lemberg#include FT_INTERNAL_CALC_H   /* for FT_MulDiv and FT_MulDiv_No_Round */
64a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
650d02317fb2a6f46e568cefc1132273cdd1bc80b7Werner Lemberg#include "rastpic.h"
660d02317fb2a6f46e568cefc1132273cdd1bc80b7Werner Lemberg
67f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg#endif /* !_STANDALONE_ */
68f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg
69a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
70a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
71a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
72a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* A simple technical note on how the raster works                       */
73a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* -----------------------------------------------                       */
74a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
75a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   Converting an outline into a bitmap is achieved in several steps:   */
76a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
77a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   1 - Decomposing the outline into successive `profiles'.  Each       */
78a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*       profile is simply an array of scanline intersections on a given */
79a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*       dimension.  A profile's main attributes are                     */
80a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
818262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg  /*       o its scanline position boundaries, i.e. `Ymin' and `Ymax'      */
82a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
83a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*       o an array of intersection coordinates for each scanline        */
848262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg  /*         between `Ymin' and `Ymax'                                     */
85a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
86a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*       o a direction, indicating whether it was built going `up' or    */
878262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg  /*         `down', as this is very important for filling rules           */
888262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg  /*                                                                       */
898262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg  /*       o its drop-out mode                                             */
90a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
91a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   2 - Sweeping the target map's scanlines in order to compute segment */
92a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*       `spans' which are then filled.  Additionally, this pass         */
93a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*       performs drop-out control.                                      */
94a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
95a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   The outline data is parsed during step 1 only.  The profiles are    */
96a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   built from the bottom of the render pool, used as a stack.  The     */
97a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   following graphics shows the profile list under construction:       */
98a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
998262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg  /*     __________________________________________________________ _ _    */
1008262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg  /*    |         |                 |         |                 |          */
1018262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg  /*    | profile | coordinates for | profile | coordinates for |-->       */
1028262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg  /*    |    1    |  profile 1      |    2    |  profile 2      |-->       */
1038262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg  /*    |_________|_________________|_________|_________________|__ _ _    */
104a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1058262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg  /*    ^                                                       ^          */
1068262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg  /*    |                                                       |          */
1078262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg  /* start of render pool                                      top         */
108a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
109a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   The top of the profile stack is kept in the `top' variable.         */
110a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
111a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   As you can see, a profile record is pushed on top of the render     */
112a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   pool, which is then followed by its coordinates/intersections.  If  */
113a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   a change of direction is detected in the outline, a new profile is  */
114a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   generated until the end of the outline.                             */
115a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
116a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   Note that when all profiles have been generated, the function       */
117a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   Finalize_Profile_Table() is used to record, for each profile, its   */
118a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   bottom-most scanline as well as the scanline above its upmost       */
119a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   boundary.  These positions are called `y-turns' because they (sort  */
120a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   of) correspond to local extrema.  They are stored in a sorted list  */
121a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   built from the top of the render pool as a downwards stack:         */
122a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
123a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*      _ _ _______________________________________                      */
124a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                            |                    |                     */
125a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                         <--| sorted list of     |                     */
126a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                         <--|  extrema scanlines |                     */
127a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*      _ _ __________________|____________________|                     */
128a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
129a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                            ^                    ^                     */
130a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                            |                    |                     */
131a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                         maxBuff           sizeBuff = end of pool      */
132a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
133a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   This list is later used during the sweep phase in order to          */
134a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   optimize performance (see technical note on the sweep below).       */
135a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
136a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   Of course, the raster detects whether the two stacks collide and    */
1376e87ed9f04f7914e15f9284b0b762b730222c399Werner Lemberg  /*   handles the situation properly.                                     */
138a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
139a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
140a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
141a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
142a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
143a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
144a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /**                                                                     **/
145a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /**  CONFIGURATION MACROS                                               **/
146a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /**                                                                     **/
147a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
148a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
149a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
150a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* define DEBUG_RASTER if you want to compile a debugging version */
151766b822f4c1cc84cc11545b63be87108d0954b48Werner Lemberg/* #define DEBUG_RASTER */
152a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
153a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
154a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
155a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
156a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /**                                                                     **/
157a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /**  OTHER MACROS (do not change)                                       **/
158a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /**                                                                     **/
159a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
160a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
161a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
162a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
163a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
164a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
165a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
166a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* messages during execution.                                            */
167a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
168a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#undef  FT_COMPONENT
169a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define FT_COMPONENT  trace_raster
170a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
171a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
172a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#ifdef _STANDALONE_
173a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
174059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg  /* Auxiliary macros for token concatenation. */
175059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg#define FT_ERR_XCAT( x, y )  x ## y
176059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg#define FT_ERR_CAT( x, y )   FT_ERR_XCAT( x, y )
177a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
178a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* This macro is used to indicate that a function parameter is unused. */
179a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* Its purpose is simply to reduce compiler warnings.  Note also that  */
180a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* simply defining it as `(void)x' doesn't avoid warnings with certain */
181a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* ANSI compilers (e.g. LCC).                                          */
182a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define FT_UNUSED( x )  (x) = (x)
183a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
184a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* Disable the tracing mechanism for simplicity -- developers can      */
185059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg  /* activate it easily by redefining these macros.                      */
186a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#ifndef FT_ERROR
187f47acf2b5fcd9d6c9dc58809ef8ecf1b1e0b46adWerner Lemberg#define FT_ERROR( x )  do { } while ( 0 )     /* nothing */
188a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#endif
189a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
190a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#ifndef FT_TRACE
191f47acf2b5fcd9d6c9dc58809ef8ecf1b1e0b46adWerner Lemberg#define FT_TRACE( x )   do { } while ( 0 )    /* nothing */
192f47acf2b5fcd9d6c9dc58809ef8ecf1b1e0b46adWerner Lemberg#define FT_TRACE1( x )  do { } while ( 0 )    /* nothing */
193f47acf2b5fcd9d6c9dc58809ef8ecf1b1e0b46adWerner Lemberg#define FT_TRACE6( x )  do { } while ( 0 )    /* nothing */
194a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#endif
195a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
196059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg#ifndef FT_THROW
197059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg#define FT_THROW( e )  FT_ERR_CAT( Raster_Err_, e )
198059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg#endif
199059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg
200a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define Raster_Err_None          0
201a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define Raster_Err_Not_Ini      -1
202a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define Raster_Err_Overflow     -2
203a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define Raster_Err_Neg_Height   -3
204a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define Raster_Err_Invalid      -4
205a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define Raster_Err_Unsupported  -5
206a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2070d02317fb2a6f46e568cefc1132273cdd1bc80b7Werner Lemberg#define ft_memset  memset
2080d02317fb2a6f46e568cefc1132273cdd1bc80b7Werner Lemberg
2090d02317fb2a6f46e568cefc1132273cdd1bc80b7Werner Lemberg#define FT_DEFINE_RASTER_FUNCS( class_, glyph_format_, raster_new_, \
2100d02317fb2a6f46e568cefc1132273cdd1bc80b7Werner Lemberg                                raster_reset_, raster_set_mode_,    \
2110d02317fb2a6f46e568cefc1132273cdd1bc80b7Werner Lemberg                                raster_render_, raster_done_ )      \
2120d02317fb2a6f46e568cefc1132273cdd1bc80b7Werner Lemberg          const FT_Raster_Funcs class_ =                            \
2130d02317fb2a6f46e568cefc1132273cdd1bc80b7Werner Lemberg          {                                                         \
2140d02317fb2a6f46e568cefc1132273cdd1bc80b7Werner Lemberg            glyph_format_,                                          \
2150d02317fb2a6f46e568cefc1132273cdd1bc80b7Werner Lemberg            raster_new_,                                            \
2160d02317fb2a6f46e568cefc1132273cdd1bc80b7Werner Lemberg            raster_reset_,                                          \
2170d02317fb2a6f46e568cefc1132273cdd1bc80b7Werner Lemberg            raster_set_mode_,                                       \
2180d02317fb2a6f46e568cefc1132273cdd1bc80b7Werner Lemberg            raster_render_,                                         \
2190d02317fb2a6f46e568cefc1132273cdd1bc80b7Werner Lemberg            raster_done_                                            \
2200d02317fb2a6f46e568cefc1132273cdd1bc80b7Werner Lemberg         };
2218262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg
2228262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg#else /* !_STANDALONE_ */
223a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
224a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2251f7f0e87e58168b2e739e2622db0ee06e0c9acccWerner Lemberg#include FT_INTERNAL_OBJECTS_H
226059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg#include FT_INTERNAL_DEBUG_H       /* for FT_TRACE, FT_ERROR, and FT_THROW */
227a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2281f7f0e87e58168b2e739e2622db0ee06e0c9acccWerner Lemberg#include "rasterrs.h"
2291f7f0e87e58168b2e739e2622db0ee06e0c9acccWerner Lemberg
230e3c9301581a450fae5db73a3b94b10ed6a0aeb5eWerner Lemberg#define Raster_Err_None         FT_Err_Ok
2311f7f0e87e58168b2e739e2622db0ee06e0c9acccWerner Lemberg#define Raster_Err_Not_Ini      Raster_Err_Raster_Uninitialized
2321f7f0e87e58168b2e739e2622db0ee06e0c9acccWerner Lemberg#define Raster_Err_Overflow     Raster_Err_Raster_Overflow
2331f7f0e87e58168b2e739e2622db0ee06e0c9acccWerner Lemberg#define Raster_Err_Neg_Height   Raster_Err_Raster_Negative_Height
2341f7f0e87e58168b2e739e2622db0ee06e0c9acccWerner Lemberg#define Raster_Err_Invalid      Raster_Err_Invalid_Outline
2351f7f0e87e58168b2e739e2622db0ee06e0c9acccWerner Lemberg#define Raster_Err_Unsupported  Raster_Err_Cannot_Render_Glyph
236a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
237a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2388262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg#endif /* !_STANDALONE_ */
239a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
240a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
241e459d742e6236df43f542b8c29dfdcf05d69716cDavid Turner#ifndef FT_MEM_SET
242d15bc0d13a163995e1ca11925349bd64d1c33617David Turner#define FT_MEM_SET( d, s, c )  ft_memset( d, s, c )
243c3b21608699a72698d382ad44c5f9fd6946ce43cWerner Lemberg#endif
244c3b21608699a72698d382ad44c5f9fd6946ce43cWerner Lemberg
245f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg#ifndef FT_MEM_ZERO
246f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg#define FT_MEM_ZERO( dest, count )  FT_MEM_SET( dest, 0, count )
247f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg#endif
248c3b21608699a72698d382ad44c5f9fd6946ce43cWerner Lemberg
249a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* FMulDiv means `Fast MulDiv'; it is used in case where `b' is       */
250a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* typically a small value and the result of a*b is known to fit into */
251a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* 32 bits.                                                           */
252a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define FMulDiv( a, b, c )  ( (a) * (b) / (c) )
253a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
254a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* On the other hand, SMulDiv means `Slow MulDiv', and is used typically */
255a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* for clipping computations.  It simply uses the FT_MulDiv() function   */
256a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* defined in `ftcalc.h'.                                                */
257495bd3cc4f54f5f4604709391a716fcd0c033277Werner Lemberg#define SMulDiv           FT_MulDiv
258495bd3cc4f54f5f4604709391a716fcd0c033277Werner Lemberg#define SMulDiv_No_Round  FT_MulDiv_No_Round
259a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
260a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* The rasterizer is a very general purpose component; please leave */
261a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* the following redefinitions there (you never know your target    */
262a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* environment).                                                    */
263a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
264a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#ifndef TRUE
265a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define TRUE   1
266a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#endif
267a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
268a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#ifndef FALSE
269a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define FALSE  0
270a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#endif
271a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
272a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#ifndef NULL
273a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define NULL  (void*)0
274a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#endif
275a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
276a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#ifndef SUCCESS
277a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define SUCCESS  0
278a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#endif
279a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
280a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#ifndef FAILURE
281a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define FAILURE  1
282a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#endif
283a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
284a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
285a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define MaxBezier  32   /* The maximum number of stacked Bezier curves. */
286a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                        /* Setting this constant to more than 32 is a   */
287a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                        /* pure waste of space.                         */
288a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
289a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define Pixel_Bits  6   /* fractional bits of *input* coordinates */
290a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
291a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
292a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
293a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
294a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /**                                                                     **/
295a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /**  SIMPLE TYPE DECLARATIONS                                           **/
296a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /**                                                                     **/
297a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
298a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
299a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
300a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  typedef int             Int;
301a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  typedef unsigned int    UInt;
302a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  typedef short           Short;
303a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  typedef unsigned short  UShort, *PUShort;
304a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  typedef long            Long, *PLong;
305073a0e2901e931d457f205d870ee77eb0ed763cbWerner Lemberg  typedef unsigned long   ULong;
306a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
307a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  typedef unsigned char   Byte, *PByte;
308a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  typedef char            Bool;
309a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
310fefd8742928491a9da356cc1c37f434c76d73514Werner Lemberg
311fefd8742928491a9da356cc1c37f434c76d73514Werner Lemberg  typedef union  Alignment_
3128530a228889128adfd446514928f36663ed20f04David Turner  {
3138530a228889128adfd446514928f36663ed20f04David Turner    long    l;
3148530a228889128adfd446514928f36663ed20f04David Turner    void*   p;
3158530a228889128adfd446514928f36663ed20f04David Turner    void  (*f)(void);
3168530a228889128adfd446514928f36663ed20f04David Turner
3178530a228889128adfd446514928f36663ed20f04David Turner  } Alignment, *PAlignment;
3188530a228889128adfd446514928f36663ed20f04David Turner
319fefd8742928491a9da356cc1c37f434c76d73514Werner Lemberg
320a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  typedef struct  TPoint_
321a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
322a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Long  x;
323a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Long  y;
324a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
325a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  } TPoint;
326a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
327a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
32842206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg  /* values for the `flags' bit field */
32972271140434028186a49a5dc5925f0727559e46fWerner Lemberg#define Flow_Up           0x8
33072271140434028186a49a5dc5925f0727559e46fWerner Lemberg#define Overshoot_Top     0x10
33172271140434028186a49a5dc5925f0727559e46fWerner Lemberg#define Overshoot_Bottom  0x20
332a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
333a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
334a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* States of each line, arc, and profile */
335a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  typedef enum  TStates_
336a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
3379ca7a157273201e4e40168e7b239e12bb813f9a7Werner Lemberg    Unknown_State,
3389ca7a157273201e4e40168e7b239e12bb813f9a7Werner Lemberg    Ascending_State,
3399ca7a157273201e4e40168e7b239e12bb813f9a7Werner Lemberg    Descending_State,
3409ca7a157273201e4e40168e7b239e12bb813f9a7Werner Lemberg    Flat_State
341a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
342a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  } TStates;
343a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
344a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
345a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  typedef struct TProfile_  TProfile;
346a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  typedef TProfile*         PProfile;
347a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
348a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  struct  TProfile_
349a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
35042206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg    FT_F26Dot6  X;           /* current coordinate during sweep          */
35142206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg    PProfile    link;        /* link to next profile (various purposes)  */
35242206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg    PLong       offset;      /* start of profile's data in render pool   */
35372271140434028186a49a5dc5925f0727559e46fWerner Lemberg    unsigned    flags;       /* Bit 0-2: drop-out mode                   */
35472271140434028186a49a5dc5925f0727559e46fWerner Lemberg                             /* Bit 3: profile orientation (up/down)     */
35572271140434028186a49a5dc5925f0727559e46fWerner Lemberg                             /* Bit 4: is top profile?                   */
35672271140434028186a49a5dc5925f0727559e46fWerner Lemberg                             /* Bit 5: is bottom profile?                */
35742206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg    long        height;      /* profile's height in scanlines            */
35842206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg    long        start;       /* profile's starting scanline              */
35942206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg
36042206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg    unsigned    countL;      /* number of lines to step before this      */
36142206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg                             /* profile becomes drawable                 */
36242206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg
36342206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg    PProfile    next;        /* next profile in same contour, used       */
36442206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg                             /* during drop-out control                  */
365a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  };
366a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
367a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  typedef PProfile   TProfileList;
368a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  typedef PProfile*  PProfileList;
369a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
370a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
371a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* Simple record used to implement a stack of bands, required */
372a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* by the sub-banding mechanism                               */
373126405adde4caf69ea6eacf478ce805f6635f42aVinnie Falco  typedef struct  black_TBand_
374a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
375a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Short  y_min;   /* band's minimum */
376a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Short  y_max;   /* band's maximum */
377a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
378126405adde4caf69ea6eacf478ce805f6635f42aVinnie Falco  } black_TBand;
379a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
380a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
381a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define AlignProfileSize \
382fefd8742928491a9da356cc1c37f434c76d73514Werner Lemberg  ( ( sizeof ( TProfile ) + sizeof ( Alignment ) - 1 ) / sizeof ( long ) )
383a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
384a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
38595111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco#undef RAS_ARG
38695111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco#undef RAS_ARGS
38795111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco#undef RAS_VAR
38895111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco#undef RAS_VARS
38995111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco
390f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg#ifdef FT_STATIC_RASTER
391a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
392a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
393a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define RAS_ARGS       /* void */
394a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define RAS_ARG        /* void */
395a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
396a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define RAS_VARS       /* void */
397a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define RAS_VAR        /* void */
398a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
399f47acf2b5fcd9d6c9dc58809ef8ecf1b1e0b46adWerner Lemberg#define FT_UNUSED_RASTER  do { } while ( 0 )
400a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
401a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
4028262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg#else /* !FT_STATIC_RASTER */
403a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
404a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
405d55f16df11121ef4d5af8dfa0d7670d0bb0e238fVinnie Falco#define RAS_ARGS       black_PWorker  worker,
406d55f16df11121ef4d5af8dfa0d7670d0bb0e238fVinnie Falco#define RAS_ARG        black_PWorker  worker
407a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
4088a2c7f8fb804f3b74ea062f1c367b78d12c5b3f2David Turner#define RAS_VARS       worker,
4098a2c7f8fb804f3b74ea062f1c367b78d12c5b3f2David Turner#define RAS_VAR        worker
410a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
4118a2c7f8fb804f3b74ea062f1c367b78d12c5b3f2David Turner#define FT_UNUSED_RASTER  FT_UNUSED( worker )
412a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
413a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
4148262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg#endif /* !FT_STATIC_RASTER */
415a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
416a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
417d55f16df11121ef4d5af8dfa0d7670d0bb0e238fVinnie Falco  typedef struct black_TWorker_  black_TWorker, *black_PWorker;
418a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
419a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
420a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* prototypes used for sweep function dispatch */
42152005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  typedef void
42252005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Function_Sweep_Init( RAS_ARGS Short*  min,
42352005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                Short*  max );
424a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
42552005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  typedef void
42652005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Function_Sweep_Span( RAS_ARGS Short       y,
42752005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                FT_F26Dot6  x1,
42852005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                FT_F26Dot6  x2,
42952005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                PProfile    left,
43052005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                PProfile    right );
431a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
43252005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  typedef void
43352005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Function_Sweep_Step( RAS_ARG );
434a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
435a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
436a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* NOTE: These operations are only valid on 2's complement processors */
4375ccebc4e1eb71e5ee82a88edb9cd553e08fc69b9Vinnie Falco#undef FLOOR
4385ccebc4e1eb71e5ee82a88edb9cd553e08fc69b9Vinnie Falco#undef CEILING
4395ccebc4e1eb71e5ee82a88edb9cd553e08fc69b9Vinnie Falco#undef TRUNC
4405ccebc4e1eb71e5ee82a88edb9cd553e08fc69b9Vinnie Falco#undef SCALED
441a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
442a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define FLOOR( x )    ( (x) & -ras.precision )
443a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define CEILING( x )  ( ( (x) + ras.precision - 1 ) & -ras.precision )
444073a0e2901e931d457f205d870ee77eb0ed763cbWerner Lemberg#define TRUNC( x )    ( (Long)(x) >> ras.precision_bits )
445a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define FRAC( x )     ( (x) & ( ras.precision - 1 ) )
446073a0e2901e931d457f205d870ee77eb0ed763cbWerner Lemberg#define SCALED( x )   ( ( (ULong)(x) << ras.scale_shift ) - ras.precision_half )
447a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
448c06889eb2c42b40d9ef557b03c9b57d6057e0f12Werner Lemberg#define IS_BOTTOM_OVERSHOOT( x ) \
449c06889eb2c42b40d9ef557b03c9b57d6057e0f12Werner Lemberg          (Bool)( CEILING( x ) - x >= ras.precision_half )
450c06889eb2c42b40d9ef557b03c9b57d6057e0f12Werner Lemberg#define IS_TOP_OVERSHOOT( x )    \
451c06889eb2c42b40d9ef557b03c9b57d6057e0f12Werner Lemberg          (Bool)( x - FLOOR( x ) >= ras.precision_half )
45242206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg
4538262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg  /* The most used variables are positioned at the top of the structure. */
4548262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg  /* Thus, their offset can be coded with less opcodes, resulting in a   */
4558262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg  /* smaller executable.                                                 */
456a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
457d55f16df11121ef4d5af8dfa0d7670d0bb0e238fVinnie Falco  struct  black_TWorker_
458a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
4598262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    Int         precision_bits;     /* precision related variables         */
4608262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    Int         precision;
4618262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    Int         precision_half;
4628262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    Int         precision_shift;
4638262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    Int         precision_step;
4648262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    Int         precision_jitter;
4658262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg
4668262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    Int         scale_shift;        /* == precision_shift   for bitmaps    */
467a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                                    /* == precision_shift+1 for pixmaps    */
468a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
4698262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    PLong       buff;               /* The profiles buffer                 */
4708262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    PLong       sizeBuff;           /* Render pool size                    */
4718262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    PLong       maxBuff;            /* Profiles buffer size                */
4728262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    PLong       top;                /* Current cursor in buffer            */
473a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
4748262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    FT_Error    error;
475a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
4768262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    Int         numTurns;           /* number of Y-turns in outline        */
477a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
4788262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    TPoint*     arc;                /* current Bezier arc pointer          */
479a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
4808262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    UShort      bWidth;             /* target bitmap width                 */
4818262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    PByte       bTarget;            /* target bitmap buffer                */
4828262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    PByte       gTarget;            /* target pixmap buffer                */
483a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
4848262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    Long        lastX, lastY;
4858262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    Long        minY, maxY;
486a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
4878262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    UShort      num_Profs;          /* current number of profiles          */
488a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
4898262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    Bool        fresh;              /* signals a fresh new profile which   */
49090c699af0cb6e40ba96f43e80433818c83d2560fWerner Lemberg                                    /* `start' field must be completed     */
4918262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    Bool        joint;              /* signals that the last arc ended     */
492a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                                    /* exactly on a scanline.  Allows      */
493a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                                    /* removal of doublets                 */
4948262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    PProfile    cProfile;           /* current profile                     */
4958262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    PProfile    fProfile;           /* head of linked list of profiles     */
4968262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    PProfile    gProfile;           /* contour's first profile in case     */
497a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                                    /* of impact                           */
498a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
4998262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    TStates     state;              /* rendering state                     */
500a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
501a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_Bitmap   target;             /* description of target bit/pixmap    */
502a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_Outline  outline;
503a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
5048262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    Long        traceOfs;           /* current offset in target bitmap     */
5058262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    Long        traceG;             /* current offset in target pixmap     */
506a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
5078262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    Short       traceIncr;          /* sweep's increment in target bitmap  */
508a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
509a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* dispatch variables */
510a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
511a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Function_Sweep_Init*  Proc_Sweep_Init;
512a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Function_Sweep_Span*  Proc_Sweep_Span;
513a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Function_Sweep_Span*  Proc_Sweep_Drop;
514a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Function_Sweep_Step*  Proc_Sweep_Step;
515a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
5168262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    Byte        dropOutControl;     /* current drop_out control method     */
517a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
5188262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    Bool        second_pass;        /* indicates whether a horizontal pass */
519a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                                    /* should be performed to control      */
520a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                                    /* drop-out accurately when calling    */
5218dc863587440d0a1d2eec2a7973a8eda99d2767dBehdad Esfahbod                                    /* Render_Glyph.                       */
522a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
5238262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg    TPoint      arcs[3 * MaxBezier + 1]; /* The Bezier stack               */
524a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
525126405adde4caf69ea6eacf478ce805f6635f42aVinnie Falco    black_TBand  band_stack[16];    /* band stack used for sub-banding     */
526126405adde4caf69ea6eacf478ce805f6635f42aVinnie Falco    Int          band_top;          /* band stack top                      */
527a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
5288a2c7f8fb804f3b74ea062f1c367b78d12c5b3f2David Turner  };
529a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
530a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
53195111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco  typedef struct  black_TRaster_
5328a2c7f8fb804f3b74ea062f1c367b78d12c5b3f2David Turner  {
533d55f16df11121ef4d5af8dfa0d7670d0bb0e238fVinnie Falco    void*          memory;
534a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
53595111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco  } black_TRaster, *black_PRaster;
536a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
537f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg#ifdef FT_STATIC_RASTER
538a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
539d55f16df11121ef4d5af8dfa0d7670d0bb0e238fVinnie Falco  static black_TWorker  cur_ras;
540a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define ras  cur_ras
541a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
5428262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg#else /* !FT_STATIC_RASTER */
543a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
5448a2c7f8fb804f3b74ea062f1c367b78d12c5b3f2David Turner#define ras  (*worker)
545a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
5468262213192704679677edfd6f1b89c94b8de8f3bWerner Lemberg#endif /* !FT_STATIC_RASTER */
547a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
548a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
549a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
550a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
551a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /**                                                                     **/
552a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /**  PROFILES COMPUTATION                                               **/
553a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /**                                                                     **/
554a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
555a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
556a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
557a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
558a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
559a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
560a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Function>                                                            */
561a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Set_High_Precision                                                 */
562a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
563a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Description>                                                         */
564174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg  /*    Set precision variables according to param flag.                   */
565a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
566a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Input>                                                               */
567762bf19ab7416a40c8c3cf553bd4f02eec45c3b2Werner Lemberg  /*    High :: Set to True for high precision (typically for ppem < 24),  */
568a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*            false otherwise.                                           */
569a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
57052005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static void
57152005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Set_High_Precision( RAS_ARGS Int  High )
572a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
573c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg    /*
574c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg     * `precision_step' is used in `Bezier_Up' to decide when to split a
575c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg     * given y-monotonous Bezier arc that crosses a scanline before
576c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg     * approximating it as a straight segment.  The default value of 32 (for
577c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg     * low accuracy) corresponds to
578c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg     *
579c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg     *   32 / 64 == 0.5 pixels ,
580c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg     *
581c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg     * while for the high accuracy case we have
582c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg     *
583c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg     *   256/ (1 << 12) = 0.0625 pixels .
584c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg     *
585c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg     * `precision_jitter' is an epsilon threshold used in
586c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg     * `Vertical_Sweep_Span' to deal with small imperfections in the Bezier
587c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg     * decomposition (after all, we are working with approximations only);
588c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg     * it avoids switching on additional pixels which would cause artifacts
589c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg     * otherwise.
590c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg     *
591c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg     * The value of `precision_jitter' has been determined heuristically.
592c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg     *
593c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg     */
594c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg
595a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( High )
596a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
5970409ef32686188c1947298e0fca9fbeadd23c1c3Werner Lemberg      ras.precision_bits   = 12;
5980409ef32686188c1947298e0fca9fbeadd23c1c3Werner Lemberg      ras.precision_step   = 256;
599c02485cb725f94ea0487351596adc1e3ef8d1ae6Werner Lemberg      ras.precision_jitter = 30;
600a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
601a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    else
602a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
603a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.precision_bits   = 6;
604a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.precision_step   = 32;
605a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.precision_jitter = 2;
606a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
607a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
608a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_TRACE6(( "Set_High_Precision(%s)\n", High ? "true" : "false" ));
609a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
61068e9f927105b22ec6952a5bc929cfabfc6b7e810Werner Lemberg    ras.precision       = 1 << ras.precision_bits;
611a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.precision_half  = ras.precision / 2;
612a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.precision_shift = ras.precision_bits - Pixel_Bits;
613a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
614a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
615a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
616a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
617a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
618a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Function>                                                            */
619a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    New_Profile                                                        */
620a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
621a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Description>                                                         */
622174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg  /*    Create a new profile in the render pool.                           */
623a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
624a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Input>                                                               */
62542206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg  /*    aState    :: The state/orientation of the new profile.             */
62642206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg  /*                                                                       */
62742206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg  /*    overshoot :: Whether the profile's unrounded start position        */
62842206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg  /*                 differs by at least a half pixel.                     */
629a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
630a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Return>                                                              */
631a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   SUCCESS on success.  FAILURE in case of overflow or of incoherent   */
632a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   profile.                                                            */
633a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
63452005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static Bool
63542206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg  New_Profile( RAS_ARGS TStates  aState,
63642206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg                        Bool     overshoot )
637a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
638a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( !ras.fProfile )
639a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
640a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.cProfile  = (PProfile)ras.top;
641a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.fProfile  = ras.cProfile;
642a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.top      += AlignProfileSize;
643a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
644a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
645a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( ras.top >= ras.maxBuff )
646a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
647059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg      ras.error = FT_THROW( Overflow );
648a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      return FAILURE;
649a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
650a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
65142206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg    ras.cProfile->flags  = 0;
65242206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg    ras.cProfile->start  = 0;
65342206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg    ras.cProfile->height = 0;
65442206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg    ras.cProfile->offset = ras.top;
65542206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg    ras.cProfile->link   = (PProfile)0;
65642206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg    ras.cProfile->next   = (PProfile)0;
65772271140434028186a49a5dc5925f0727559e46fWerner Lemberg    ras.cProfile->flags  = ras.dropOutControl;
65842206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg
659a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    switch ( aState )
660a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
6619ca7a157273201e4e40168e7b239e12bb813f9a7Werner Lemberg    case Ascending_State:
66290c699af0cb6e40ba96f43e80433818c83d2560fWerner Lemberg      ras.cProfile->flags |= Flow_Up;
66342206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg      if ( overshoot )
66442206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg        ras.cProfile->flags |= Overshoot_Bottom;
66542206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg
66646c371c2c7398d25fa614065c28a27ebb4b5d489Suzuki, Toshiya (鈴木俊哉)      FT_TRACE6(( "New ascending profile = %p\n", ras.cProfile ));
667a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      break;
668a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
6699ca7a157273201e4e40168e7b239e12bb813f9a7Werner Lemberg    case Descending_State:
67042206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg      if ( overshoot )
67142206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg        ras.cProfile->flags |= Overshoot_Top;
67246c371c2c7398d25fa614065c28a27ebb4b5d489Suzuki, Toshiya (鈴木俊哉)      FT_TRACE6(( "New descending profile = %p\n", ras.cProfile ));
673a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      break;
674a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
675a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    default:
676858abbedc0c156965aba830bfc2072a3c21144cfWerner Lemberg      FT_ERROR(( "New_Profile: invalid profile direction\n" ));
677059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg      ras.error = FT_THROW( Invalid );
678a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      return FAILURE;
679a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
680a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
681a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( !ras.gProfile )
682a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.gProfile = ras.cProfile;
683a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
684a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.state = aState;
685a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.fresh = TRUE;
686a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.joint = FALSE;
687a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
688a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    return SUCCESS;
689a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
690a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
691a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
692a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
693a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
694a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Function>                                                            */
695a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    End_Profile                                                        */
696a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
697a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Description>                                                         */
698174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg  /*    Finalize the current profile.                                      */
699a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
70042206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg  /* <Input>                                                               */
70142206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg  /*    overshoot :: Whether the profile's unrounded end position differs  */
70242206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg  /*                 by at least a half pixel.                             */
70342206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg  /*                                                                       */
704a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Return>                                                              */
705a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    SUCCESS on success.  FAILURE in case of overflow or incoherency.   */
706a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
70752005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static Bool
70842206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg  End_Profile( RAS_ARGS Bool  overshoot )
709a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
710dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg    Long  h;
711a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
712a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
713914b289f1623b1030b66537d3b3ce4b652e4606cWerner Lemberg    h = (Long)( ras.top - ras.cProfile->offset );
714a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
715a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( h < 0 )
716a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
717858abbedc0c156965aba830bfc2072a3c21144cfWerner Lemberg      FT_ERROR(( "End_Profile: negative height encountered\n" ));
718059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg      ras.error = FT_THROW( Neg_Height );
719a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      return FAILURE;
720a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
721a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
722a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( h > 0 )
723a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
724dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg      PProfile  oldProfile;
725dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg
726dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg
72746c371c2c7398d25fa614065c28a27ebb4b5d489Suzuki, Toshiya (鈴木俊哉)      FT_TRACE6(( "Ending profile %p, start = %ld, height = %ld\n",
72846c371c2c7398d25fa614065c28a27ebb4b5d489Suzuki, Toshiya (鈴木俊哉)                  ras.cProfile, ras.cProfile->start, h ));
729a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
730a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.cProfile->height = h;
73142206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg      if ( overshoot )
73242206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg      {
73342206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg        if ( ras.cProfile->flags & Flow_Up )
73442206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          ras.cProfile->flags |= Overshoot_Top;
73542206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg        else
73642206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          ras.cProfile->flags |= Overshoot_Bottom;
73742206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg      }
738a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
73942206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg      oldProfile   = ras.cProfile;
74042206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg      ras.cProfile = (PProfile)ras.top;
74142206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg
74242206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg      ras.top += AlignProfileSize;
743a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
744a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.cProfile->height = 0;
745a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.cProfile->offset = ras.top;
74642206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg
74742206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg      oldProfile->next = ras.cProfile;
748a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.num_Profs++;
749a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
750a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
751a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( ras.top >= ras.maxBuff )
752a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
753a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      FT_TRACE1(( "overflow in End_Profile\n" ));
754059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg      ras.error = FT_THROW( Overflow );
755a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      return FAILURE;
756a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
757a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
758a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.joint = FALSE;
759a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
760a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    return SUCCESS;
761a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
762a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
763a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
764a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
765a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
766a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Function>                                                            */
767a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Insert_Y_Turn                                                      */
768a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
769a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Description>                                                         */
770174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg  /*    Insert a salient into the sorted list placed on top of the render  */
771a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    pool.                                                              */
772a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
773a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Input>                                                               */
774a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    New y scanline position.                                           */
775a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
776a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Return>                                                              */
777a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    SUCCESS on success.  FAILURE in case of overflow.                  */
778a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
77952005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static Bool
78052005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Insert_Y_Turn( RAS_ARGS Int  y )
781a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
78251daa4feb18fce52a3c5d40bd6c9969203ec6b28Werner Lemberg    PLong  y_turns;
783dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg    Int    n;
784a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
785a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
786a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    n       = ras.numTurns - 1;
787a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    y_turns = ras.sizeBuff - ras.numTurns;
788a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
789a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* look for first y value that is <= */
790a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    while ( n >= 0 && y < y_turns[n] )
791a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      n--;
792a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
793a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* if it is <, simply insert it, ignore if == */
794a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( n >= 0 && y > y_turns[n] )
795a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      while ( n >= 0 )
796a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
797dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg        Int  y2 = (Int)y_turns[n];
798dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg
799dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg
800a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        y_turns[n] = y;
801a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        y = y2;
802a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        n--;
803a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
804a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
805a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( n < 0 )
806a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
80751daa4feb18fce52a3c5d40bd6c9969203ec6b28Werner Lemberg      ras.maxBuff--;
808a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( ras.maxBuff <= ras.top )
809a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
810059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg        ras.error = FT_THROW( Overflow );
811a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        return FAILURE;
812a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
813a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.numTurns++;
814a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.sizeBuff[-ras.numTurns] = y;
815a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
816a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
817a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    return SUCCESS;
818a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
819a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
820a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
821a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
822a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
823a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Function>                                                            */
824a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Finalize_Profile_Table                                             */
825a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
826a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Description>                                                         */
827174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg  /*    Adjust all links in the profiles list.                             */
828a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
829a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Return>                                                              */
830a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    SUCCESS on success.  FAILURE in case of overflow.                  */
831a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
83252005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static Bool
83352005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Finalize_Profile_Table( RAS_ARG )
834a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
835a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    UShort    n;
836a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    PProfile  p;
837a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
838a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
839a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    n = ras.num_Profs;
840b66efefdcde552e4880896aa961a0b9a583762d2Werner Lemberg    p = ras.fProfile;
841a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
842b66efefdcde552e4880896aa961a0b9a583762d2Werner Lemberg    if ( n > 1 && p )
843a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
844a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      while ( n > 0 )
845a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
846dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg        Int  bottom, top;
847dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg
848dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg
849a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        if ( n > 1 )
850a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          p->link = (PProfile)( p->offset + p->height );
851a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        else
852a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          p->link = NULL;
853a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
85490c699af0cb6e40ba96f43e80433818c83d2560fWerner Lemberg        if ( p->flags & Flow_Up )
85590c699af0cb6e40ba96f43e80433818c83d2560fWerner Lemberg        {
85690c699af0cb6e40ba96f43e80433818c83d2560fWerner Lemberg          bottom = (Int)p->start;
85790c699af0cb6e40ba96f43e80433818c83d2560fWerner Lemberg          top    = (Int)( p->start + p->height - 1 );
85890c699af0cb6e40ba96f43e80433818c83d2560fWerner Lemberg        }
85990c699af0cb6e40ba96f43e80433818c83d2560fWerner Lemberg        else
860a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        {
86168e9f927105b22ec6952a5bc929cfabfc6b7e810Werner Lemberg          bottom     = (Int)( p->start - p->height + 1 );
86268e9f927105b22ec6952a5bc929cfabfc6b7e810Werner Lemberg          top        = (Int)p->start;
863a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          p->start   = bottom;
864a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          p->offset += p->height - 1;
865a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        }
866a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
86790c699af0cb6e40ba96f43e80433818c83d2560fWerner Lemberg        if ( Insert_Y_Turn( RAS_VARS bottom )  ||
86890c699af0cb6e40ba96f43e80433818c83d2560fWerner Lemberg             Insert_Y_Turn( RAS_VARS top + 1 ) )
869a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          return FAILURE;
870a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
871a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        p = p->link;
872a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        n--;
873a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
874a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
875a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    else
876a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.fProfile = NULL;
877a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
878a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    return SUCCESS;
879a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
880a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
881a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
882a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
883a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
884a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Function>                                                            */
885a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Split_Conic                                                        */
886a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
887a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Description>                                                         */
888174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg  /*    Subdivide one conic Bezier into two joint sub-arcs in the Bezier   */
889a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    stack.                                                             */
890a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
891a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Input>                                                               */
892a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    None (subdivided Bezier is taken from the top of the stack).       */
893a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
894a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Note>                                                                */
895a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    This routine is the `beef' of this component.  It is  _the_ inner  */
896a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    loop that should be optimized to hell to get the best performance. */
897a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
89852005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static void
89952005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Split_Conic( TPoint*  base )
900a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
901a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Long  a, b;
902a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
903a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
904a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    base[4].x = base[2].x;
905a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    b = base[1].x;
906a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    a = base[3].x = ( base[2].x + b ) / 2;
907a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    b = base[1].x = ( base[0].x + b ) / 2;
908a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    base[2].x = ( a + b ) / 2;
909a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
910a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    base[4].y = base[2].y;
911a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    b = base[1].y;
912a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    a = base[3].y = ( base[2].y + b ) / 2;
913a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    b = base[1].y = ( base[0].y + b ) / 2;
914a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    base[2].y = ( a + b ) / 2;
915a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
916a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* hand optimized.  gcc doesn't seem to be too good at common      */
917a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* expression substitution and instruction scheduling ;-)          */
918a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
919a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
920a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
921a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
922a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
923a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Function>                                                            */
924a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Split_Cubic                                                        */
925a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
926a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Description>                                                         */
927174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg  /*    Subdivide a third-order Bezier arc into two joint sub-arcs in the  */
928a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Bezier stack.                                                      */
929a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
930a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Note>                                                                */
931a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    This routine is the `beef' of the component.  It is one of _the_   */
932a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    inner loops that should be optimized like hell to get the best     */
933a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    performance.                                                       */
934a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
93552005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static void
93652005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Split_Cubic( TPoint*  base )
937a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
938a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Long  a, b, c, d;
939a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
940a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
941a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    base[6].x = base[3].x;
942a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    c = base[1].x;
943a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    d = base[2].x;
944a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    base[1].x = a = ( base[0].x + c + 1 ) >> 1;
945a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    base[5].x = b = ( base[3].x + d + 1 ) >> 1;
946a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    c = ( c + d + 1 ) >> 1;
947a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    base[2].x = a = ( a + c + 1 ) >> 1;
948a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    base[4].x = b = ( b + c + 1 ) >> 1;
949a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    base[3].x = ( a + b + 1 ) >> 1;
950a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
951a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    base[6].y = base[3].y;
952a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    c = base[1].y;
953a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    d = base[2].y;
954a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    base[1].y = a = ( base[0].y + c + 1 ) >> 1;
955a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    base[5].y = b = ( base[3].y + d + 1 ) >> 1;
956a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    c = ( c + d + 1 ) >> 1;
957a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    base[2].y = a = ( a + c + 1 ) >> 1;
958a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    base[4].y = b = ( b + c + 1 ) >> 1;
959a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    base[3].y = ( a + b + 1 ) >> 1;
960a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
961a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
962a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
963a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
964a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
965a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Function>                                                            */
966a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Line_Up                                                            */
967a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
968a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Description>                                                         */
969174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg  /*    Compute the x-coordinates of an ascending line segment and store   */
970a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    them in the render pool.                                           */
971a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
972a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Input>                                                               */
973a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    x1   :: The x-coordinate of the segment's start point.             */
974a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
975a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    y1   :: The y-coordinate of the segment's start point.             */
976a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
977a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    x2   :: The x-coordinate of the segment's end point.               */
978a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
979a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    y2   :: The y-coordinate of the segment's end point.               */
980a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
981a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    miny :: A lower vertical clipping bound value.                     */
982a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
983a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    maxy :: An upper vertical clipping bound value.                    */
984a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
985a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Return>                                                              */
986a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    SUCCESS on success, FAILURE on render pool overflow.               */
987a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
98852005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static Bool
98952005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Line_Up( RAS_ARGS Long  x1,
99052005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                    Long  y1,
99152005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                    Long  x2,
99252005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                    Long  y2,
99352005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                    Long  miny,
99452005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                    Long  maxy )
995a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
996a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Long   Dx, Dy;
997a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Int    e1, e2, f1, f2, size;     /* XXX: is `Short' sufficient? */
998a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Long   Ix, Rx, Ax;
999a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1000a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    PLong  top;
1001a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1002a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1003a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Dx = x2 - x1;
1004a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Dy = y2 - y1;
1005a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1006a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( Dy <= 0 || y2 < miny || y1 > maxy )
1007a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      return SUCCESS;
1008a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1009a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( y1 < miny )
1010a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
1011a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      /* Take care: miny-y1 can be a very large value; we use     */
1012a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      /*            a slow MulDiv function to avoid clipping bugs */
1013a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      x1 += SMulDiv( Dx, miny - y1, Dy );
101473861976779a754cc9b808760cc8e6cf98d52549Werner Lemberg      e1  = (Int)TRUNC( miny );
1015a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      f1  = 0;
1016a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
1017a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    else
1018a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
101968e9f927105b22ec6952a5bc929cfabfc6b7e810Werner Lemberg      e1 = (Int)TRUNC( y1 );
102068e9f927105b22ec6952a5bc929cfabfc6b7e810Werner Lemberg      f1 = (Int)FRAC( y1 );
1021a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
1022a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1023a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( y2 > maxy )
1024a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
1025a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      /* x2 += FMulDiv( Dx, maxy - y2, Dy );  UNNECESSARY */
102668e9f927105b22ec6952a5bc929cfabfc6b7e810Werner Lemberg      e2  = (Int)TRUNC( maxy );
1027a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      f2  = 0;
1028a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
1029a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    else
1030a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
103168e9f927105b22ec6952a5bc929cfabfc6b7e810Werner Lemberg      e2 = (Int)TRUNC( y2 );
103268e9f927105b22ec6952a5bc929cfabfc6b7e810Werner Lemberg      f2 = (Int)FRAC( y2 );
1033a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
1034a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1035a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( f1 > 0 )
1036a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
1037a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( e1 == e2 )
1038a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        return SUCCESS;
1039a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      else
1040a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1041f0987abdc24b136100656f49ecfe3997869cd93dWerner Lemberg        x1 += SMulDiv( Dx, ras.precision - f1, Dy );
1042a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        e1 += 1;
1043a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1044a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
1045a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    else
1046a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( ras.joint )
1047a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1048a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ras.top--;
1049a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ras.joint = FALSE;
1050a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1051a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
10528edbcabce1b3756fb1921f85901dcce944bdf1e7David Turner    ras.joint = (char)( f2 == 0 );
1053a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1054a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( ras.fresh )
1055a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
1056a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.cProfile->start = e1;
1057a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.fresh           = FALSE;
1058a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
1059a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1060a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    size = e2 - e1 + 1;
1061a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( ras.top + size >= ras.maxBuff )
1062a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
1063059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg      ras.error = FT_THROW( Overflow );
1064a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      return FAILURE;
1065a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
1066a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1067a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( Dx > 0 )
1068a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
1069495bd3cc4f54f5f4604709391a716fcd0c033277Werner Lemberg      Ix = SMulDiv_No_Round( ras.precision, Dx, Dy );
1070a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      Rx = ( ras.precision * Dx ) % Dy;
1071a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      Dx = 1;
1072a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
1073a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    else
1074a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
1075495bd3cc4f54f5f4604709391a716fcd0c033277Werner Lemberg      Ix = -SMulDiv_No_Round( ras.precision, -Dx, Dy );
1076495bd3cc4f54f5f4604709391a716fcd0c033277Werner Lemberg      Rx = ( ras.precision * -Dx ) % Dy;
1077a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      Dx = -1;
1078a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
1079a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1080a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Ax  = -Dy;
1081a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    top = ras.top;
1082a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1083a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    while ( size > 0 )
1084a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
1085a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      *top++ = x1;
1086a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1087a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      x1 += Ix;
1088a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      Ax += Rx;
1089a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( Ax >= 0 )
1090a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1091a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        Ax -= Dy;
1092a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        x1 += Dx;
1093a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1094a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      size--;
1095a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
1096a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1097a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.top = top;
1098a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    return SUCCESS;
1099a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
1100a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1101a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1102a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
1103a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1104a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Function>                                                            */
1105a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Line_Down                                                          */
1106a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1107a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Description>                                                         */
1108174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg  /*    Compute the x-coordinates of an descending line segment and store  */
1109174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg  /*    them in the render pool.                                           */
1110a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1111a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Input>                                                               */
1112a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    x1   :: The x-coordinate of the segment's start point.             */
1113a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1114a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    y1   :: The y-coordinate of the segment's start point.             */
1115a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1116a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    x2   :: The x-coordinate of the segment's end point.               */
1117a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1118a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    y2   :: The y-coordinate of the segment's end point.               */
1119a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1120a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    miny :: A lower vertical clipping bound value.                     */
1121a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1122a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    maxy :: An upper vertical clipping bound value.                    */
1123a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1124a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Return>                                                              */
1125a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    SUCCESS on success, FAILURE on render pool overflow.               */
1126a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
112752005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static Bool
112852005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Line_Down( RAS_ARGS Long  x1,
112952005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                      Long  y1,
113052005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                      Long  x2,
113152005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                      Long  y2,
113252005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                      Long  miny,
113352005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                      Long  maxy )
1134a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
1135a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Bool  result, fresh;
1136a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1137a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1138a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    fresh  = ras.fresh;
1139a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1140a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    result = Line_Up( RAS_VARS x1, -y1, x2, -y2, -maxy, -miny );
1141a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1142a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( fresh && !ras.fresh )
1143a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.cProfile->start = -ras.cProfile->start;
1144a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1145a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    return result;
1146a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
1147a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1148a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1149a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* A function type describing the functions used to split Bezier arcs */
1150a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  typedef void  (*TSplitter)( TPoint*  base );
1151a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1152a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1153a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
1154a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1155a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Function>                                                            */
1156a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Bezier_Up                                                          */
1157a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1158a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Description>                                                         */
1159174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg  /*    Compute the x-coordinates of an ascending Bezier arc and store     */
1160a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    them in the render pool.                                           */
1161a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1162a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Input>                                                               */
1163a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    degree   :: The degree of the Bezier arc (either 2 or 3).          */
1164a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1165a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    splitter :: The function to split Bezier arcs.                     */
1166a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1167a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    miny     :: A lower vertical clipping bound value.                 */
1168a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1169a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    maxy     :: An upper vertical clipping bound value.                */
1170a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1171a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Return>                                                              */
1172a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    SUCCESS on success, FAILURE on render pool overflow.               */
1173a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
117452005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static Bool
117552005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Bezier_Up( RAS_ARGS Int        degree,
117652005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                      TSplitter  splitter,
117752005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                      Long       miny,
117852005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                      Long       maxy )
1179a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
1180a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Long   y1, y2, e, e2, e0;
1181a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Short  f1;
1182a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1183a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    TPoint*  arc;
1184a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    TPoint*  start_arc;
1185a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1186a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    PLong top;
1187a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1188a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1189a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    arc = ras.arc;
1190a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    y1  = arc[degree].y;
1191a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    y2  = arc[0].y;
1192a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    top = ras.top;
1193a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1194a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( y2 < miny || y1 > maxy )
1195a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      goto Fin;
1196a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1197a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    e2 = FLOOR( y2 );
1198a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1199a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( e2 > maxy )
1200a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      e2 = maxy;
1201a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1202a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    e0 = miny;
1203a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1204a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( y1 < miny )
1205a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      e = miny;
1206a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    else
1207a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
1208a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      e  = CEILING( y1 );
1209914b289f1623b1030b66537d3b3ce4b652e4606cWerner Lemberg      f1 = (Short)( FRAC( y1 ) );
1210a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      e0 = e;
1211a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1212a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( f1 == 0 )
1213a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1214a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        if ( ras.joint )
1215a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        {
1216a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          top--;
1217a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          ras.joint = FALSE;
1218a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        }
1219a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1220a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        *top++ = arc[degree].x;
1221a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1222a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        e += ras.precision;
1223a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1224a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
1225a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1226a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( ras.fresh )
1227a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
1228a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.cProfile->start = TRUNC( e0 );
1229a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.fresh = FALSE;
1230a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
1231a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1232a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( e2 < e )
1233a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      goto Fin;
1234a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1235a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( ( top + TRUNC( e2 - e ) + 1 ) >= ras.maxBuff )
1236a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
1237a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.top   = top;
1238059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg      ras.error = FT_THROW( Overflow );
1239a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      return FAILURE;
1240a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
1241a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1242a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    start_arc = arc;
1243a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1244a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    while ( arc >= start_arc && e <= e2 )
1245a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
1246a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.joint = FALSE;
1247a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1248a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      y2 = arc[0].y;
1249a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1250a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( y2 > e )
1251a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1252a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        y1 = arc[degree].y;
1253a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        if ( y2 - y1 >= ras.precision_step )
1254a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        {
1255a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          splitter( arc );
1256a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          arc += degree;
1257a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        }
1258a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        else
1259a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        {
1260cbdba615115b0f07984130d9420ee7299ab0a3ccWerner Lemberg          *top++ = arc[degree].x + FMulDiv( arc[0].x - arc[degree].x,
1261a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                                            e - y1, y2 - y1 );
1262a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          arc -= degree;
1263a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          e   += ras.precision;
1264a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        }
1265a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1266a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      else
1267a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1268a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        if ( y2 == e )
1269a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        {
1270a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          ras.joint  = TRUE;
1271a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          *top++     = arc[0].x;
1272a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1273a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          e += ras.precision;
1274a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        }
1275a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        arc -= degree;
1276a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1277a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
1278a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1279a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  Fin:
1280a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.top  = top;
1281a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.arc -= degree;
1282a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    return SUCCESS;
1283a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
1284a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1285a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1286a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
1287a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1288a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Function>                                                            */
1289a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Bezier_Down                                                        */
1290a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1291a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Description>                                                         */
1292174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg  /*    Compute the x-coordinates of an descending Bezier arc and store    */
1293a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    them in the render pool.                                           */
1294a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1295a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Input>                                                               */
1296a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    degree   :: The degree of the Bezier arc (either 2 or 3).          */
1297a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1298a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    splitter :: The function to split Bezier arcs.                     */
1299a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1300a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    miny     :: A lower vertical clipping bound value.                 */
1301a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1302a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    maxy     :: An upper vertical clipping bound value.                */
1303a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1304a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Return>                                                              */
1305a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    SUCCESS on success, FAILURE on render pool overflow.               */
1306a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
130752005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static Bool
130852005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Bezier_Down( RAS_ARGS Int        degree,
130952005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                        TSplitter  splitter,
131052005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                        Long       miny,
131152005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                        Long       maxy )
1312a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
1313a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    TPoint*  arc = ras.arc;
1314a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Bool     result, fresh;
1315a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1316a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1317a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    arc[0].y = -arc[0].y;
1318a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    arc[1].y = -arc[1].y;
1319a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    arc[2].y = -arc[2].y;
1320a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( degree > 2 )
1321a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      arc[3].y = -arc[3].y;
1322a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1323a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    fresh = ras.fresh;
1324a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1325a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    result = Bezier_Up( RAS_VARS degree, splitter, -maxy, -miny );
1326a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1327a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( fresh && !ras.fresh )
1328a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.cProfile->start = -ras.cProfile->start;
1329a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1330a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    arc[0].y = -arc[0].y;
1331a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    return result;
1332a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
1333a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1334a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1335a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
1336a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1337a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Function>                                                            */
1338a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Line_To                                                            */
1339a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1340a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Description>                                                         */
1341174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg  /*    Inject a new line segment and adjust the Profiles list.            */
1342a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1343a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Input>                                                               */
1344a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   x :: The x-coordinate of the segment's end point (its start point   */
1345ce235eaf099765b1a868ce27fef4e83171767e11Werner Lemberg  /*        is stored in `lastX').                                         */
1346a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1347a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   y :: The y-coordinate of the segment's end point (its start point   */
1348ce235eaf099765b1a868ce27fef4e83171767e11Werner Lemberg  /*        is stored in `lastY').                                         */
1349a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1350a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Return>                                                              */
1351a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   SUCCESS on success, FAILURE on render pool overflow or incorrect    */
1352a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   profile.                                                            */
1353a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
135452005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static Bool
135552005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Line_To( RAS_ARGS Long  x,
135652005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                    Long  y )
1357a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
1358a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* First, detect a change of direction */
1359a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1360a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    switch ( ras.state )
1361a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
13629ca7a157273201e4e40168e7b239e12bb813f9a7Werner Lemberg    case Unknown_State:
1363a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( y > ras.lastY )
1364a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
136542206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg        if ( New_Profile( RAS_VARS Ascending_State,
136642206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg                                   IS_BOTTOM_OVERSHOOT( ras.lastY ) ) )
1367a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          return FAILURE;
1368a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1369a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      else
1370a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1371a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        if ( y < ras.lastY )
137242206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          if ( New_Profile( RAS_VARS Descending_State,
137342206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg                                     IS_TOP_OVERSHOOT( ras.lastY ) ) )
1374a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            return FAILURE;
1375a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1376a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      break;
1377a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
13789ca7a157273201e4e40168e7b239e12bb813f9a7Werner Lemberg    case Ascending_State:
1379a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( y < ras.lastY )
1380a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
138142206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg        if ( End_Profile( RAS_VARS IS_TOP_OVERSHOOT( ras.lastY ) ) ||
138242206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg             New_Profile( RAS_VARS Descending_State,
138342206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg                                   IS_TOP_OVERSHOOT( ras.lastY ) ) )
1384a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          return FAILURE;
1385a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1386a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      break;
1387a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
13889ca7a157273201e4e40168e7b239e12bb813f9a7Werner Lemberg    case Descending_State:
1389a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( y > ras.lastY )
1390a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
139142206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg        if ( End_Profile( RAS_VARS IS_BOTTOM_OVERSHOOT( ras.lastY ) ) ||
139242206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg             New_Profile( RAS_VARS Ascending_State,
139342206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg                                   IS_BOTTOM_OVERSHOOT( ras.lastY ) ) )
1394a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          return FAILURE;
1395a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1396a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      break;
1397a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1398a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    default:
1399a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ;
1400a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
1401a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1402a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* Then compute the lines */
1403a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1404a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    switch ( ras.state )
1405a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
14069ca7a157273201e4e40168e7b239e12bb813f9a7Werner Lemberg    case Ascending_State:
1407a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( Line_Up( RAS_VARS ras.lastX, ras.lastY,
140842206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg                             x, y, ras.minY, ras.maxY ) )
1409a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        return FAILURE;
1410a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      break;
1411a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
14129ca7a157273201e4e40168e7b239e12bb813f9a7Werner Lemberg    case Descending_State:
1413a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( Line_Down( RAS_VARS ras.lastX, ras.lastY,
141442206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg                               x, y, ras.minY, ras.maxY ) )
1415a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        return FAILURE;
1416a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      break;
1417a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1418a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    default:
1419a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ;
1420a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
1421a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1422a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.lastX = x;
1423a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.lastY = y;
1424a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1425a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    return SUCCESS;
1426a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
1427a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1428a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1429a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
1430a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1431a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Function>                                                            */
1432a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Conic_To                                                           */
1433a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1434a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Description>                                                         */
1435174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg  /*    Inject a new conic arc and adjust the profile list.                */
1436a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1437a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Input>                                                               */
1438a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   cx :: The x-coordinate of the arc's new control point.              */
1439a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1440a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   cy :: The y-coordinate of the arc's new control point.              */
1441a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1442a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   x  :: The x-coordinate of the arc's end point (its start point is   */
1443ce235eaf099765b1a868ce27fef4e83171767e11Werner Lemberg  /*         stored in `lastX').                                           */
1444a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1445a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   y  :: The y-coordinate of the arc's end point (its start point is   */
1446ce235eaf099765b1a868ce27fef4e83171767e11Werner Lemberg  /*         stored in `lastY').                                           */
1447a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1448a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Return>                                                              */
1449a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   SUCCESS on success, FAILURE on render pool overflow or incorrect    */
1450a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   profile.                                                            */
1451a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
145252005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static Bool
145352005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Conic_To( RAS_ARGS Long  cx,
145452005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                     Long  cy,
145552005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                     Long  x,
145652005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                     Long  y )
1457a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
1458a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Long     y1, y2, y3, x3, ymin, ymax;
1459a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    TStates  state_bez;
1460a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1461a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1462a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.arc      = ras.arcs;
1463a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.arc[2].x = ras.lastX;
1464a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.arc[2].y = ras.lastY;
1465cbdba615115b0f07984130d9420ee7299ab0a3ccWerner Lemberg    ras.arc[1].x = cx;
1466cbdba615115b0f07984130d9420ee7299ab0a3ccWerner Lemberg    ras.arc[1].y = cy;
1467cbdba615115b0f07984130d9420ee7299ab0a3ccWerner Lemberg    ras.arc[0].x = x;
1468cbdba615115b0f07984130d9420ee7299ab0a3ccWerner Lemberg    ras.arc[0].y = y;
1469a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1470a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    do
1471a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
1472a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      y1 = ras.arc[2].y;
1473a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      y2 = ras.arc[1].y;
1474a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      y3 = ras.arc[0].y;
1475a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      x3 = ras.arc[0].x;
1476a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1477a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      /* first, categorize the Bezier arc */
1478a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1479a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( y1 <= y3 )
1480a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1481a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ymin = y1;
1482a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ymax = y3;
1483a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1484a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      else
1485a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1486a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ymin = y3;
1487a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ymax = y1;
1488a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1489a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1490a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( y2 < ymin || y2 > ymax )
1491a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1492a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        /* this arc has no given direction, split it! */
1493a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        Split_Conic( ras.arc );
1494a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ras.arc += 2;
1495a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1496a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      else if ( y1 == y3 )
1497a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1498a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        /* this arc is flat, ignore it and pop it from the Bezier stack */
1499a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ras.arc -= 2;
1500a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1501a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      else
1502a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1503a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        /* the arc is y-monotonous, either ascending or descending */
1504a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        /* detect a change of direction                            */
15059ca7a157273201e4e40168e7b239e12bb813f9a7Werner Lemberg        state_bez = y1 < y3 ? Ascending_State : Descending_State;
1506a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        if ( ras.state != state_bez )
1507a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        {
150842206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          Bool  o = state_bez == Ascending_State ? IS_BOTTOM_OVERSHOOT( y1 )
150942206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg                                                 : IS_TOP_OVERSHOOT( y1 );
151042206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg
151142206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg
1512a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          /* finalize current profile if any */
1513cbdba615115b0f07984130d9420ee7299ab0a3ccWerner Lemberg          if ( ras.state != Unknown_State &&
151442206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg               End_Profile( RAS_VARS o )  )
1515a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            goto Fail;
1516a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1517a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          /* create a new profile */
151842206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          if ( New_Profile( RAS_VARS state_bez, o ) )
1519a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            goto Fail;
1520a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        }
1521a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1522a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        /* now call the appropriate routine */
15239ca7a157273201e4e40168e7b239e12bb813f9a7Werner Lemberg        if ( state_bez == Ascending_State )
1524a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        {
1525a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          if ( Bezier_Up( RAS_VARS 2, Split_Conic, ras.minY, ras.maxY ) )
1526a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            goto Fail;
1527a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        }
1528a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        else
1529a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          if ( Bezier_Down( RAS_VARS 2, Split_Conic, ras.minY, ras.maxY ) )
1530a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            goto Fail;
1531a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1532a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1533a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    } while ( ras.arc >= ras.arcs );
1534a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1535a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.lastX = x3;
1536a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.lastY = y3;
1537a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1538a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    return SUCCESS;
1539a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1540a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  Fail:
1541a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    return FAILURE;
1542a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
1543a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1544a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1545a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
1546a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1547a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Function>                                                            */
1548a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Cubic_To                                                           */
1549a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1550a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Description>                                                         */
1551174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg  /*    Inject a new cubic arc and adjust the profile list.                */
1552a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1553a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Input>                                                               */
1554a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   cx1 :: The x-coordinate of the arc's first new control point.       */
1555a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1556a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   cy1 :: The y-coordinate of the arc's first new control point.       */
1557a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1558a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   cx2 :: The x-coordinate of the arc's second new control point.      */
1559a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1560a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   cy2 :: The y-coordinate of the arc's second new control point.      */
1561a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1562a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   x   :: The x-coordinate of the arc's end point (its start point is  */
1563ce235eaf099765b1a868ce27fef4e83171767e11Werner Lemberg  /*          stored in `lastX').                                          */
1564a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1565a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   y   :: The y-coordinate of the arc's end point (its start point is  */
1566ce235eaf099765b1a868ce27fef4e83171767e11Werner Lemberg  /*          stored in `lastY').                                          */
1567a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1568a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Return>                                                              */
1569a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   SUCCESS on success, FAILURE on render pool overflow or incorrect    */
1570a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*   profile.                                                            */
1571a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
157252005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static Bool
157352005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Cubic_To( RAS_ARGS Long  cx1,
157452005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                     Long  cy1,
157552005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                     Long  cx2,
157652005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                     Long  cy2,
157752005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                     Long  x,
157852005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                     Long  y )
1579a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
1580a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Long     y1, y2, y3, y4, x4, ymin1, ymax1, ymin2, ymax2;
1581a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    TStates  state_bez;
1582a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1583a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1584a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.arc      = ras.arcs;
1585a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.arc[3].x = ras.lastX;
1586a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.arc[3].y = ras.lastY;
1587cbdba615115b0f07984130d9420ee7299ab0a3ccWerner Lemberg    ras.arc[2].x = cx1;
1588cbdba615115b0f07984130d9420ee7299ab0a3ccWerner Lemberg    ras.arc[2].y = cy1;
1589cbdba615115b0f07984130d9420ee7299ab0a3ccWerner Lemberg    ras.arc[1].x = cx2;
1590cbdba615115b0f07984130d9420ee7299ab0a3ccWerner Lemberg    ras.arc[1].y = cy2;
1591cbdba615115b0f07984130d9420ee7299ab0a3ccWerner Lemberg    ras.arc[0].x = x;
1592cbdba615115b0f07984130d9420ee7299ab0a3ccWerner Lemberg    ras.arc[0].y = y;
1593a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1594a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    do
1595a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
1596a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      y1 = ras.arc[3].y;
1597a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      y2 = ras.arc[2].y;
1598a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      y3 = ras.arc[1].y;
1599a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      y4 = ras.arc[0].y;
1600a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      x4 = ras.arc[0].x;
1601a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1602a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      /* first, categorize the Bezier arc */
1603a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1604a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( y1 <= y4 )
1605a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1606a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ymin1 = y1;
1607a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ymax1 = y4;
1608a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1609a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      else
1610a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1611a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ymin1 = y4;
1612a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ymax1 = y1;
1613a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1614a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1615a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( y2 <= y3 )
1616a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1617a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ymin2 = y2;
1618a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ymax2 = y3;
1619a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1620a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      else
1621a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1622a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ymin2 = y3;
1623a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ymax2 = y2;
1624a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1625a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1626a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( ymin2 < ymin1 || ymax2 > ymax1 )
1627a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1628a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        /* this arc has no given direction, split it! */
1629a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        Split_Cubic( ras.arc );
1630a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ras.arc += 3;
1631a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1632a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      else if ( y1 == y4 )
1633a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1634a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        /* this arc is flat, ignore it and pop it from the Bezier stack */
1635a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ras.arc -= 3;
1636a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1637a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      else
1638a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
16399ca7a157273201e4e40168e7b239e12bb813f9a7Werner Lemberg        state_bez = ( y1 <= y4 ) ? Ascending_State : Descending_State;
1640a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1641a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        /* detect a change of direction */
1642a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        if ( ras.state != state_bez )
1643a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        {
164442206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          Bool  o = state_bez == Ascending_State ? IS_BOTTOM_OVERSHOOT( y1 )
164542206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg                                                 : IS_TOP_OVERSHOOT( y1 );
164642206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg
164742206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg
164842206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          /* finalize current profile if any */
1649cbdba615115b0f07984130d9420ee7299ab0a3ccWerner Lemberg          if ( ras.state != Unknown_State &&
165042206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg               End_Profile( RAS_VARS o )  )
1651a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            goto Fail;
1652a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
165342206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          if ( New_Profile( RAS_VARS state_bez, o ) )
1654a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            goto Fail;
1655a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        }
1656a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1657a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        /* compute intersections */
16589ca7a157273201e4e40168e7b239e12bb813f9a7Werner Lemberg        if ( state_bez == Ascending_State )
1659a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        {
1660a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          if ( Bezier_Up( RAS_VARS 3, Split_Cubic, ras.minY, ras.maxY ) )
1661a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            goto Fail;
1662a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        }
1663a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        else
1664a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          if ( Bezier_Down( RAS_VARS 3, Split_Cubic, ras.minY, ras.maxY ) )
1665a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            goto Fail;
1666a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1667a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1668a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    } while ( ras.arc >= ras.arcs );
1669a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1670a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.lastX = x4;
1671a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.lastY = y4;
1672a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1673a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    return SUCCESS;
1674a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1675a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  Fail:
1676a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    return FAILURE;
1677a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
1678a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1679a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1680a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#undef  SWAP_
1681a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#define SWAP_( x, y )  do                \
1682a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                       {                 \
1683a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                         Long  swap = x; \
1684a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                                         \
1685a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                                         \
1686a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                         x = y;          \
1687a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                         y = swap;       \
1688a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                       } while ( 0 )
1689a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1690a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1691a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
1692a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1693a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Function>                                                            */
1694a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Decompose_Curve                                                    */
1695a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1696a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Description>                                                         */
1697174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg  /*    Scan the outline arrays in order to emit individual segments and   */
1698a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Beziers by calling Line_To() and Bezier_To().  It handles all      */
1699a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    weird cases, like when the first point is off the curve, or when   */
1700a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    there are simply no `on' points in the contour!                    */
1701a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1702a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Input>                                                               */
1703a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    first   :: The index of the first point in the contour.            */
1704a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1705a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    last    :: The index of the last point in the contour.             */
1706a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1707a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    flipped :: If set, flip the direction of the curve.                */
1708a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1709a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Return>                                                              */
1710a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    SUCCESS on success, FAILURE on error.                              */
1711a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
171252005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static Bool
171352005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Decompose_Curve( RAS_ARGS UShort  first,
171452005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                            UShort  last,
171552005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                            int     flipped )
1716a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
1717a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_Vector   v_last;
1718a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_Vector   v_control;
1719a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_Vector   v_start;
1720a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1721a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_Vector*  points;
1722a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_Vector*  point;
1723a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_Vector*  limit;
1724a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    char*       tags;
1725a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
17268edbcabce1b3756fb1921f85901dcce944bdf1e7David Turner    unsigned    tag;       /* current point's state           */
1727a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1728a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1729a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    points = ras.outline.points;
1730a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    limit  = points + last;
1731a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1732a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    v_start.x = SCALED( points[first].x );
1733a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    v_start.y = SCALED( points[first].y );
1734a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    v_last.x  = SCALED( points[last].x );
1735a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    v_last.y  = SCALED( points[last].y );
1736a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1737a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( flipped )
1738a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
1739a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      SWAP_( v_start.x, v_start.y );
1740a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      SWAP_( v_last.x, v_last.y );
1741a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
1742a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1743a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    v_control = v_start;
1744a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1745a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    point = points + first;
1746cbdba615115b0f07984130d9420ee7299ab0a3ccWerner Lemberg    tags  = ras.outline.tags + first;
174772271140434028186a49a5dc5925f0727559e46fWerner Lemberg
174872271140434028186a49a5dc5925f0727559e46fWerner Lemberg    /* set scan mode if necessary */
174972271140434028186a49a5dc5925f0727559e46fWerner Lemberg    if ( tags[0] & FT_CURVE_TAG_HAS_SCANMODE )
175072271140434028186a49a5dc5925f0727559e46fWerner Lemberg      ras.dropOutControl = (Byte)tags[0] >> 5;
175172271140434028186a49a5dc5925f0727559e46fWerner Lemberg
175272271140434028186a49a5dc5925f0727559e46fWerner Lemberg    tag = FT_CURVE_TAG( tags[0] );
1753a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1754a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* A contour cannot start with a cubic control point! */
1755b08fe2dc7af972a61f4e6bcadd7bb522861faec5David Turner    if ( tag == FT_CURVE_TAG_CUBIC )
1756a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      goto Invalid_Outline;
1757a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1758a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* check first point to determine origin */
1759b08fe2dc7af972a61f4e6bcadd7bb522861faec5David Turner    if ( tag == FT_CURVE_TAG_CONIC )
1760a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
1761a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      /* first point is conic control.  Yes, this happens. */
1762b08fe2dc7af972a61f4e6bcadd7bb522861faec5David Turner      if ( FT_CURVE_TAG( ras.outline.tags[last] ) == FT_CURVE_TAG_ON )
1763a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1764a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        /* start at last point if it is on the curve */
1765a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        v_start = v_last;
1766a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        limit--;
1767a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1768a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      else
1769a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1770a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        /* if both first and last points are conic,         */
1771a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        /* start at their middle and record its position    */
1772a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        /* for closure                                      */
1773a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        v_start.x = ( v_start.x + v_last.x ) / 2;
1774a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        v_start.y = ( v_start.y + v_last.y ) / 2;
1775a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
17767be2a94a50109773459414687151d70a99a1b6bdSean McBride     /* v_last = v_start; */
1777a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1778a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      point--;
1779a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      tags--;
1780a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
1781a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1782a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.lastX = v_start.x;
1783a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.lastY = v_start.y;
1784a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1785a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    while ( point < limit )
1786a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
1787a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      point++;
1788a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      tags++;
1789a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1790a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      tag = FT_CURVE_TAG( tags[0] );
1791a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1792a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      switch ( tag )
1793a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
1794b08fe2dc7af972a61f4e6bcadd7bb522861faec5David Turner      case FT_CURVE_TAG_ON:  /* emit a single line_to */
1795a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        {
1796a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          Long  x, y;
1797a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1798a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1799a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          x = SCALED( point->x );
1800a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          y = SCALED( point->y );
1801a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          if ( flipped )
1802a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            SWAP_( x, y );
1803a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1804a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          if ( Line_To( RAS_VARS x, y ) )
1805a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            goto Fail;
1806a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          continue;
1807a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        }
1808a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1809b08fe2dc7af972a61f4e6bcadd7bb522861faec5David Turner      case FT_CURVE_TAG_CONIC:  /* consume conic arcs */
1810a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        v_control.x = SCALED( point[0].x );
1811a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        v_control.y = SCALED( point[0].y );
1812a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1813a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        if ( flipped )
1814a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          SWAP_( v_control.x, v_control.y );
1815a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1816a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      Do_Conic:
1817a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        if ( point < limit )
1818a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        {
1819a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          FT_Vector  v_middle;
1820a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          Long       x, y;
1821a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1822a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1823a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          point++;
1824a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          tags++;
1825a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          tag = FT_CURVE_TAG( tags[0] );
1826a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1827a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          x = SCALED( point[0].x );
1828a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          y = SCALED( point[0].y );
1829a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1830a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          if ( flipped )
1831a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            SWAP_( x, y );
1832a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1833b08fe2dc7af972a61f4e6bcadd7bb522861faec5David Turner          if ( tag == FT_CURVE_TAG_ON )
1834a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          {
1835a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            if ( Conic_To( RAS_VARS v_control.x, v_control.y, x, y ) )
1836a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner              goto Fail;
1837a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            continue;
1838a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          }
1839a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1840b08fe2dc7af972a61f4e6bcadd7bb522861faec5David Turner          if ( tag != FT_CURVE_TAG_CONIC )
1841a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            goto Invalid_Outline;
1842a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1843a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          v_middle.x = ( v_control.x + x ) / 2;
1844a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          v_middle.y = ( v_control.y + y ) / 2;
1845a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1846a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          if ( Conic_To( RAS_VARS v_control.x, v_control.y,
1847a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                                  v_middle.x,  v_middle.y ) )
1848a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            goto Fail;
1849a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1850a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          v_control.x = x;
1851a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          v_control.y = y;
1852a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1853a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          goto Do_Conic;
1854a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        }
1855a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1856a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        if ( Conic_To( RAS_VARS v_control.x, v_control.y,
1857a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                                v_start.x,   v_start.y ) )
1858a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          goto Fail;
1859a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1860a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        goto Close;
1861a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1862b08fe2dc7af972a61f4e6bcadd7bb522861faec5David Turner      default:  /* FT_CURVE_TAG_CUBIC */
1863a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        {
1864a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          Long  x1, y1, x2, y2, x3, y3;
1865a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1866a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1867a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          if ( point + 1 > limit                             ||
1868b08fe2dc7af972a61f4e6bcadd7bb522861faec5David Turner               FT_CURVE_TAG( tags[1] ) != FT_CURVE_TAG_CUBIC )
1869a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            goto Invalid_Outline;
1870a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1871a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          point += 2;
1872a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          tags  += 2;
1873a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1874a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          x1 = SCALED( point[-2].x );
1875a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          y1 = SCALED( point[-2].y );
1876a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          x2 = SCALED( point[-1].x );
1877a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          y2 = SCALED( point[-1].y );
1878a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1879a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          if ( flipped )
1880a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          {
1881a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            SWAP_( x1, y1 );
1882a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            SWAP_( x2, y2 );
1883a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          }
1884a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1885a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          if ( point <= limit )
1886a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          {
1887c9de9cbd56caea5ceeab8d984e71441803c41aefYuriy Kaminskiy            x3 = SCALED( point[0].x );
1888c9de9cbd56caea5ceeab8d984e71441803c41aefYuriy Kaminskiy            y3 = SCALED( point[0].y );
1889c9de9cbd56caea5ceeab8d984e71441803c41aefYuriy Kaminskiy
1890c9de9cbd56caea5ceeab8d984e71441803c41aefYuriy Kaminskiy            if ( flipped )
1891c9de9cbd56caea5ceeab8d984e71441803c41aefYuriy Kaminskiy              SWAP_( x3, y3 );
1892c9de9cbd56caea5ceeab8d984e71441803c41aefYuriy Kaminskiy
1893a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            if ( Cubic_To( RAS_VARS x1, y1, x2, y2, x3, y3 ) )
1894a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner              goto Fail;
1895a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            continue;
1896a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          }
1897a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1898a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          if ( Cubic_To( RAS_VARS x1, y1, x2, y2, v_start.x, v_start.y ) )
1899a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            goto Fail;
1900a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          goto Close;
1901a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        }
1902a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
1903a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
1904a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1905a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* close the contour with a line segment */
1906a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( Line_To( RAS_VARS v_start.x, v_start.y ) )
1907a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      goto Fail;
1908a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1909a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  Close:
1910a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    return SUCCESS;
1911a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1912a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  Invalid_Outline:
1913059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg    ras.error = FT_THROW( Invalid );
1914a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1915a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  Fail:
1916a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    return FAILURE;
1917a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
1918a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1919a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1920a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
1921a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1922a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Function>                                                            */
1923a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Convert_Glyph                                                      */
1924a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1925a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Description>                                                         */
1926174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg  /*    Convert a glyph into a series of segments and arcs and make a      */
1927a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    profiles list with them.                                           */
1928a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1929a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Input>                                                               */
1930a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    flipped :: If set, flip the direction of curve.                    */
1931a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
1932a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Return>                                                              */
1933a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    SUCCESS on success, FAILURE if any error was encountered during    */
1934a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    rendering.                                                         */
1935a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
193652005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static Bool
193752005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Convert_Glyph( RAS_ARGS int  flipped )
1938a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
19398edbcabce1b3756fb1921f85901dcce944bdf1e7David Turner    int       i;
19408edbcabce1b3756fb1921f85901dcce944bdf1e7David Turner    unsigned  start;
1941a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1942a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1943a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.fProfile = NULL;
1944a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.joint    = FALSE;
1945a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.fresh    = FALSE;
1946a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1947a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.maxBuff  = ras.sizeBuff - AlignProfileSize;
1948a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1949a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.numTurns = 0;
1950a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1951a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.cProfile         = (PProfile)ras.top;
1952a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.cProfile->offset = ras.top;
1953a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.num_Profs        = 0;
1954a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1955a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    start = 0;
1956a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1957a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    for ( i = 0; i < ras.outline.n_contours; i++ )
1958a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
1959dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg      PProfile  lastProfile;
1960dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg      Bool      o;
196142206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg
196242206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg
19639ca7a157273201e4e40168e7b239e12bb813f9a7Werner Lemberg      ras.state    = Unknown_State;
1964a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.gProfile = NULL;
1965a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
19668eb0353fec1494ab7d9fe9bb91a5954449ab30c1Werner Lemberg      if ( Decompose_Curve( RAS_VARS (unsigned short)start,
196742206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg                                     ras.outline.contours[i],
196842206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg                                     flipped ) )
1969a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        return FAILURE;
1970a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1971a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      start = ras.outline.contours[i] + 1;
1972a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1973cbdba615115b0f07984130d9420ee7299ab0a3ccWerner Lemberg      /* we must now check whether the extreme arcs join or not */
1974a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( FRAC( ras.lastY ) == 0 &&
1975a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner           ras.lastY >= ras.minY  &&
1976a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner           ras.lastY <= ras.maxY  )
197742206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg        if ( ras.gProfile                        &&
197842206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg             ( ras.gProfile->flags & Flow_Up ) ==
197942206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg               ( ras.cProfile->flags & Flow_Up ) )
1980a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          ras.top--;
1981a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        /* Note that ras.gProfile can be nil if the contour was too small */
1982a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        /* to be drawn.                                                   */
1983a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1984a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      lastProfile = ras.cProfile;
1985c242fe41ec634af32845cd17bcd1a0ee2653feb9Behdad Esfahbod      if ( ras.top != ras.cProfile->offset &&
1986c242fe41ec634af32845cd17bcd1a0ee2653feb9Behdad Esfahbod           ( ras.cProfile->flags & Flow_Up ) )
198742206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg        o = IS_TOP_OVERSHOOT( ras.lastY );
198842206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg      else
198942206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg        o = IS_BOTTOM_OVERSHOOT( ras.lastY );
199042206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg      if ( End_Profile( RAS_VARS o ) )
1991a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        return FAILURE;
1992a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1993a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      /* close the `next profile in contour' linked list */
1994a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( ras.gProfile )
1995a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        lastProfile->next = ras.gProfile;
1996a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
1997a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
1998a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( Finalize_Profile_Table( RAS_VAR ) )
1999a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      return FAILURE;
2000a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
20018edbcabce1b3756fb1921f85901dcce944bdf1e7David Turner    return (Bool)( ras.top < ras.maxBuff ? SUCCESS : FAILURE );
2002a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
2003a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2004a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2005a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
2006a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
2007a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /**                                                                     **/
2008a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /**  SCAN-LINE SWEEPS AND DRAWING                                       **/
2009a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /**                                                                     **/
2010a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
2011a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
2012a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2013a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2014a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
2015a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2016a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*  Init_Linked                                                          */
2017a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2018a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Initializes an empty linked list.                                  */
2019a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
202052005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static void
202152005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Init_Linked( TProfileList*  l )
2022a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
2023a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    *l = NULL;
2024a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
2025a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2026a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2027a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
2028a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2029a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*  InsNew                                                               */
2030a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2031a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Inserts a new profile in a linked list.                            */
2032a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
203352005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static void
203452005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  InsNew( PProfileList  list,
203552005c304229e2bfc54c0d406944d125d4849920Werner Lemberg          PProfile      profile )
2036a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
2037a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    PProfile  *old, current;
2038a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Long       x;
2039a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2040a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2041a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    old     = list;
2042a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    current = *old;
2043a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    x       = profile->X;
2044a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2045a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    while ( current )
2046a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
2047a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( x < current->X )
2048a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        break;
2049a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      old     = &current->link;
2050a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      current = *old;
2051a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
2052a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2053a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    profile->link = current;
2054a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    *old          = profile;
2055a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
2056a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2057a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2058a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
2059a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2060a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*  DelOld                                                               */
2061a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2062a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Removes an old profile from a linked list.                         */
2063a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
206452005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static void
206552005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  DelOld( PProfileList  list,
206652005c304229e2bfc54c0d406944d125d4849920Werner Lemberg          PProfile      profile )
2067a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
2068a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    PProfile  *old, current;
2069a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2070a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2071a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    old     = list;
2072a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    current = *old;
2073a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2074a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    while ( current )
2075a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
2076a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( current == profile )
2077a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
2078a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        *old = current->link;
2079a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        return;
2080a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
2081a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2082a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      old     = &current->link;
2083a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      current = *old;
2084a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
2085a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2086a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* we should never get there, unless the profile was not part of */
2087a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* the list.                                                     */
2088a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
2089a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2090a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2091a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
2092a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2093a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*  Sort                                                                 */
2094a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2095a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Sorts a trace list.  In 95%, the list is already sorted.  We need  */
2096a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    an algorithm which is fast in this case.  Bubble sort is enough    */
2097a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    and simple.                                                        */
2098a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
209952005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static void
210052005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Sort( PProfileList  list )
2101a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
2102a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    PProfile  *old, current, next;
2103a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2104a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2105a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* First, set the new X coordinate of each profile */
2106ea5a981c7d000b11cf29dd7f1a9cf96defdff059David Turner    current = *list;
2107ea5a981c7d000b11cf29dd7f1a9cf96defdff059David Turner    while ( current )
2108ea5a981c7d000b11cf29dd7f1a9cf96defdff059David Turner    {
2109ea5a981c7d000b11cf29dd7f1a9cf96defdff059David Turner      current->X       = *current->offset;
211090c699af0cb6e40ba96f43e80433818c83d2560fWerner Lemberg      current->offset += current->flags & Flow_Up ? 1 : -1;
2111ea5a981c7d000b11cf29dd7f1a9cf96defdff059David Turner      current->height--;
2112ea5a981c7d000b11cf29dd7f1a9cf96defdff059David Turner      current = current->link;
2113ea5a981c7d000b11cf29dd7f1a9cf96defdff059David Turner    }
2114a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2115a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* Then sort them */
2116a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    old     = list;
2117a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    current = *old;
2118a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2119a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( !current )
2120a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      return;
2121a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2122a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    next = current->link;
2123a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2124a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    while ( next )
2125a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
2126a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( current->X <= next->X )
2127a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
2128a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        old     = &current->link;
2129a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        current = *old;
2130a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2131a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        if ( !current )
2132a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          return;
2133a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
2134a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      else
2135a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
2136a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        *old          = next;
2137a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        current->link = next->link;
2138a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        next->link    = current;
2139a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2140a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        old     = list;
2141a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        current = *old;
2142a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
2143a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2144a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      next = current->link;
2145a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
2146a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
2147a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2148a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2149a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
2150a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2151a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*  Vertical Sweep Procedure Set                                         */
2152a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2153a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*  These four routines are used during the vertical black/white sweep   */
2154a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*  phase by the generic Draw_Sweep() function.                          */
2155a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2156a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
2157a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
215852005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static void
215952005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Vertical_Sweep_Init( RAS_ARGS Short*  min,
216052005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                Short*  max )
2161a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
2162a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Long  pitch = ras.target.pitch;
2163a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2164a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_UNUSED( max );
2165a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2166a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2167a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.traceIncr = (Short)-pitch;
2168a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.traceOfs  = -*min * pitch;
2169a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( pitch > 0 )
2170a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.traceOfs += ( ras.target.rows - 1 ) * pitch;
2171a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
2172a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2173a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
217452005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static void
217552005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Vertical_Sweep_Span( RAS_ARGS Short       y,
217652005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                FT_F26Dot6  x1,
217752005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                FT_F26Dot6  x2,
217852005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                PProfile    left,
217952005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                PProfile    right )
2180a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
2181a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Long   e1, e2;
2182a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Byte*  target;
2183a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2184f193637f63738eb451a6a23be70d763e78bc0c11Werner Lemberg    Int  dropOutControl = left->flags & 7;
2185f193637f63738eb451a6a23be70d763e78bc0c11Werner Lemberg
2186a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_UNUSED( y );
2187a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_UNUSED( left );
2188a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_UNUSED( right );
2189a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2190a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2191a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* Drop-out control */
2192a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2193a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    e1 = TRUNC( CEILING( x1 ) );
2194a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2195426f0e0453f172dc411783356834fb6f01ef6cd7Werner Lemberg    if ( dropOutControl != 2                             &&
2196426f0e0453f172dc411783356834fb6f01ef6cd7Werner Lemberg         x2 - x1 - ras.precision <= ras.precision_jitter )
2197a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      e2 = e1;
2198a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    else
2199a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      e2 = TRUNC( FLOOR( x2 ) );
2200a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2201a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( e2 >= 0 && e1 < ras.bWidth )
2202a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
2203dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg      int   c1, c2;
2204dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg      Byte  f1, f2;
2205dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg
2206dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg
2207a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( e1 < 0 )
2208a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        e1 = 0;
2209a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( e2 >= ras.bWidth )
2210a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        e2 = ras.bWidth - 1;
2211a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2212a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      c1 = (Short)( e1 >> 3 );
2213a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      c2 = (Short)( e2 >> 3 );
2214a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
22158edbcabce1b3756fb1921f85901dcce944bdf1e7David Turner      f1 = (Byte)  ( 0xFF >> ( e1 & 7 ) );
22168edbcabce1b3756fb1921f85901dcce944bdf1e7David Turner      f2 = (Byte) ~( 0x7F >> ( e2 & 7 ) );
2217a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2218a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      target = ras.bTarget + ras.traceOfs + c1;
2219a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      c2 -= c1;
2220a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2221a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( c2 > 0 )
2222a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
2223a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        target[0] |= f1;
2224a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
222594ffae5239631a18b8b5a39674c0afa8a992410eWerner Lemberg        /* memset() is slower than the following code on many platforms. */
2226a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        /* This is due to the fact that, in the vast majority of cases,  */
2227a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        /* the span length in bytes is relatively small.                 */
2228a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        c2--;
2229a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        while ( c2 > 0 )
2230a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        {
2231a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          *(++target) = 0xFF;
2232a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          c2--;
2233a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        }
2234a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        target[1] |= f2;
2235a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
2236a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      else
2237a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        *target |= ( f1 & f2 );
2238a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
2239a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
2240a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2241a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
224252005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static void
224352005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Vertical_Sweep_Drop( RAS_ARGS Short       y,
224452005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                FT_F26Dot6  x1,
224552005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                FT_F26Dot6  x2,
224652005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                PProfile    left,
224752005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                PProfile    right )
2248a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
22495df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    Long   e1, e2, pxl;
2250a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Short  c1, f1;
2251a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2252a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2253a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* Drop-out control */
2254a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
22555df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /*   e2            x2                    x1           e1   */
22565df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /*                                                         */
22575df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /*                 ^                     |                 */
22585df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /*                 |                     |                 */
22595df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /*   +-------------+---------------------+------------+    */
22605df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /*                 |                     |                 */
22615df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /*                 |                     v                 */
22625df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /*                                                         */
22635df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /* pixel         contour              contour       pixel  */
22645df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /* center                                           center */
22655df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg
22665df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /* drop-out mode    scan conversion rules (as defined in OpenType) */
22675df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /* --------------------------------------------------------------- */
22685df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /*  0                1, 2, 3                                       */
22695df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /*  1                1, 2, 4                                       */
22705df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /*  2                1, 2                                          */
22715df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /*  3                same as mode 2                                */
22725df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /*  4                1, 2, 5                                       */
22735df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /*  5                1, 2, 6                                       */
22745df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /*  6, 7             same as mode 2                                */
22755df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg
22765df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    e1  = CEILING( x1 );
22775df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    e2  = FLOOR  ( x2 );
22785df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    pxl = e1;
2279a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2280a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( e1 > e2 )
2281a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
228272271140434028186a49a5dc5925f0727559e46fWerner Lemberg      Int  dropOutControl = left->flags & 7;
228372271140434028186a49a5dc5925f0727559e46fWerner Lemberg
228472271140434028186a49a5dc5925f0727559e46fWerner Lemberg
2285a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( e1 == e2 + ras.precision )
2286a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
228772271140434028186a49a5dc5925f0727559e46fWerner Lemberg        switch ( dropOutControl )
2288a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        {
22895df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        case 0: /* simple drop-outs including stubs */
22905df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg          pxl = e2;
2291a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          break;
2292a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
22935df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        case 4: /* smart drop-outs including stubs */
22942f2b780e00235356ffcf1e8f98e19f3bb1910ed2Werner Lemberg          pxl = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half );
2295a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          break;
2296a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
22975df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        case 1: /* simple drop-outs excluding stubs */
22985df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        case 5: /* smart drop-outs excluding stubs  */
2299a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
23005df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg          /* Drop-out Control Rules #4 and #6 */
23015df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg
230242206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          /* The specification neither provides an exact definition */
230342206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          /* of a `stub' nor gives exact rules to exclude them.     */
2304a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          /*                                                        */
230542206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          /* Here the constraints we use to recognize a stub.       */
2306a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          /*                                                        */
2307a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          /*  upper stub:                                           */
2308a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          /*                                                        */
2309a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          /*   - P_Left and P_Right are in the same contour         */
2310a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          /*   - P_Right is the successor of P_Left in that contour */
2311a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          /*   - y is the top of P_Left and P_Right                 */
2312a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          /*                                                        */
2313a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          /*  lower stub:                                           */
2314a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          /*                                                        */
2315a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          /*   - P_Left and P_Right are in the same contour         */
2316a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          /*   - P_Left is the successor of P_Right in that contour */
2317a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          /*   - y is the bottom of P_Left                          */
2318a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          /*                                                        */
231942206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          /* We draw a stub if the following constraints are met.   */
232042206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          /*                                                        */
232142206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          /*   - for an upper or lower stub, there is top or bottom */
232242206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          /*     overshoot, respectively                            */
232342206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          /*   - the covered interval is greater or equal to a half */
232442206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          /*     pixel                                              */
232542206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg
232642206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          /* upper stub test */
232742206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          if ( left->next == right                &&
232842206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg               left->height <= 0                  &&
232942206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg               !( left->flags & Overshoot_Top   &&
233042206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg                  x2 - x1 >= ras.precision_half ) )
233142206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg            return;
2332a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
233342206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          /* lower stub test */
233442206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          if ( right->next == left                 &&
233542206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg               left->start == y                    &&
233642206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg               !( left->flags & Overshoot_Bottom &&
233742206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg                  x2 - x1 >= ras.precision_half  ) )
233842206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg            return;
2339a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
234072271140434028186a49a5dc5925f0727559e46fWerner Lemberg          if ( dropOutControl == 1 )
23415df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg            pxl = e2;
23425df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg          else
23432f2b780e00235356ffcf1e8f98e19f3bb1910ed2Werner Lemberg            pxl = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half );
23445df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg          break;
2345a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
23465df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        default: /* modes 2, 3, 6, 7 */
23475df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg          return;  /* no drop-out control */
23485df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        }
2349a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
235029bc310563d4c8c728adfa78e18af9e4d3c89116Werner Lemberg        /* undocumented but confirmed: If the drop-out would result in a  */
23510039d0120e08bdcbe88dac66f65003d3ed5251b4Werner Lemberg        /* pixel outside of the bounding box, use the pixel inside of the */
23520039d0120e08bdcbe88dac66f65003d3ed5251b4Werner Lemberg        /* bounding box instead                                           */
235329bc310563d4c8c728adfa78e18af9e4d3c89116Werner Lemberg        if ( pxl < 0 )
235429bc310563d4c8c728adfa78e18af9e4d3c89116Werner Lemberg          pxl = e1;
23550039d0120e08bdcbe88dac66f65003d3ed5251b4Werner Lemberg        else if ( TRUNC( pxl ) >= ras.bWidth )
23560039d0120e08bdcbe88dac66f65003d3ed5251b4Werner Lemberg          pxl = e2;
235729bc310563d4c8c728adfa78e18af9e4d3c89116Werner Lemberg
23585df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        /* check that the other pixel isn't set */
23595df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        e1 = pxl == e1 ? e2 : e1;
2360a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
23615df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        e1 = TRUNC( e1 );
2362a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
23635df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        c1 = (Short)( e1 >> 3 );
23645df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        f1 = (Short)( e1 &  7 );
2365a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
23665df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        if ( e1 >= 0 && e1 < ras.bWidth                      &&
23675df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg             ras.bTarget[ras.traceOfs + c1] & ( 0x80 >> f1 ) )
23685df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg          return;
2369a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
2370a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      else
2371a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        return;
2372a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
2373a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
23745df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    e1 = TRUNC( pxl );
2375a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2376a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( e1 >= 0 && e1 < ras.bWidth )
2377a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
2378a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      c1 = (Short)( e1 >> 3 );
2379914b289f1623b1030b66537d3b3ce4b652e4606cWerner Lemberg      f1 = (Short)( e1 & 7 );
2380a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2381a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.bTarget[ras.traceOfs + c1] |= (char)( 0x80 >> f1 );
2382a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
2383a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
2384a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2385a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
238652005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static void
238752005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Vertical_Sweep_Step( RAS_ARG )
2388a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
2389a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.traceOfs += ras.traceIncr;
2390a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
2391a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2392a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2393a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /***********************************************************************/
2394a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                     */
2395a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*  Horizontal Sweep Procedure Set                                     */
2396a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                     */
2397a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*  These four routines are used during the horizontal black/white     */
2398a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*  sweep phase by the generic Draw_Sweep() function.                  */
2399a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                     */
2400a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /***********************************************************************/
2401a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
240252005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static void
240352005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Horizontal_Sweep_Init( RAS_ARGS Short*  min,
240452005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                  Short*  max )
2405a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
2406a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* nothing, really */
2407f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg    FT_UNUSED_RASTER;
2408a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_UNUSED( min );
2409a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_UNUSED( max );
2410a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
2411a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2412a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
241352005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static void
241452005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Horizontal_Sweep_Span( RAS_ARGS Short       y,
241552005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                  FT_F26Dot6  x1,
241652005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                  FT_F26Dot6  x2,
241752005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                  PProfile    left,
241852005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                  PProfile    right )
2419a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
2420a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_UNUSED( left );
2421a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_UNUSED( right );
2422a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2423a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2424a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( x2 - x1 < ras.precision )
2425a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
2426dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg      Long  e1, e2;
2427dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg
2428dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg
2429a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      e1 = CEILING( x1 );
2430a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      e2 = FLOOR  ( x2 );
2431a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2432a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( e1 == e2 )
2433a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
24348d8508e4d25eee31eef9c39bf790320bfd429d08Werner Lemberg        Byte   f1;
2435dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg        PByte  bits;
2436dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg
2437dc624ca4dcac1cbfb6870414e6aaedba43aeb9eeWerner Lemberg
2438a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        bits = ras.bTarget + ( y >> 3 );
2439a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        f1   = (Byte)( 0x80 >> ( y & 7 ) );
2440a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2441a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        e1 = TRUNC( e1 );
2442a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2443b3500af717010137046ec4076d1e1c0641e33727Werner Lemberg        if ( e1 >= 0 && (ULong)e1 < ras.target.rows )
2444a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        {
2445a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          PByte  p;
2446a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2447a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2448c9de9cbd56caea5ceeab8d984e71441803c41aefYuriy Kaminskiy          p = bits - e1 * ras.target.pitch;
2449a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          if ( ras.target.pitch > 0 )
2450a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            p += ( ras.target.rows - 1 ) * ras.target.pitch;
2451a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2452a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          p[0] |= f1;
2453a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        }
2454a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
2455a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
2456a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
2457a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2458a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
245952005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static void
246052005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Horizontal_Sweep_Drop( RAS_ARGS Short       y,
246152005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                  FT_F26Dot6  x1,
246252005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                  FT_F26Dot6  x2,
246352005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                  PProfile    left,
246452005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                                  PProfile    right )
2465a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
24665df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    Long   e1, e2, pxl;
2467a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    PByte  bits;
2468a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Byte   f1;
2469a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2470a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2471a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* During the horizontal sweep, we only take care of drop-outs */
2472a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
24735df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /* e1     +       <-- pixel center */
24745df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /*        |                        */
24755df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /* x1  ---+-->    <-- contour      */
24765df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /*        |                        */
24775df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /*        |                        */
24785df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /* x2  <--+---    <-- contour      */
24795df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /*        |                        */
24805df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /*        |                        */
24815df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    /* e2     +       <-- pixel center */
24825df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg
24835df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    e1  = CEILING( x1 );
24845df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    e2  = FLOOR  ( x2 );
24855df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    pxl = e1;
2486a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2487a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( e1 > e2 )
2488a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
248972271140434028186a49a5dc5925f0727559e46fWerner Lemberg      Int  dropOutControl = left->flags & 7;
249072271140434028186a49a5dc5925f0727559e46fWerner Lemberg
249172271140434028186a49a5dc5925f0727559e46fWerner Lemberg
2492a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( e1 == e2 + ras.precision )
2493a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
249472271140434028186a49a5dc5925f0727559e46fWerner Lemberg        switch ( dropOutControl )
2495a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        {
24965df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        case 0: /* simple drop-outs including stubs */
24975df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg          pxl = e2;
2498a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          break;
2499a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
25005df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        case 4: /* smart drop-outs including stubs */
25012f2b780e00235356ffcf1e8f98e19f3bb1910ed2Werner Lemberg          pxl = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half );
2502a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          break;
2503a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
25045df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        case 1: /* simple drop-outs excluding stubs */
25055df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        case 5: /* smart drop-outs excluding stubs  */
25065df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg          /* see Vertical_Sweep_Drop for details */
2507a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2508a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          /* rightmost stub test */
250942206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          if ( left->next == right                &&
251042206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg               left->height <= 0                  &&
251142206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg               !( left->flags & Overshoot_Top   &&
251242206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg                  x2 - x1 >= ras.precision_half ) )
2513a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            return;
2514a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2515a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          /* leftmost stub test */
251642206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg          if ( right->next == left                 &&
251742206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg               left->start == y                    &&
251842206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg               !( left->flags & Overshoot_Bottom &&
251942206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg                  x2 - x1 >= ras.precision_half  ) )
2520a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            return;
2521a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
252272271140434028186a49a5dc5925f0727559e46fWerner Lemberg          if ( dropOutControl == 1 )
25235df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg            pxl = e2;
25245df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg          else
25252f2b780e00235356ffcf1e8f98e19f3bb1910ed2Werner Lemberg            pxl = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half );
25265df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg          break;
2527a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
25285df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        default: /* modes 2, 3, 6, 7 */
25295df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg          return;  /* no drop-out control */
25305df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        }
2531a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
25320039d0120e08bdcbe88dac66f65003d3ed5251b4Werner Lemberg        /* undocumented but confirmed: If the drop-out would result in a  */
25330039d0120e08bdcbe88dac66f65003d3ed5251b4Werner Lemberg        /* pixel outside of the bounding box, use the pixel inside of the */
25340039d0120e08bdcbe88dac66f65003d3ed5251b4Werner Lemberg        /* bounding box instead                                           */
253529bc310563d4c8c728adfa78e18af9e4d3c89116Werner Lemberg        if ( pxl < 0 )
253629bc310563d4c8c728adfa78e18af9e4d3c89116Werner Lemberg          pxl = e1;
2537b3500af717010137046ec4076d1e1c0641e33727Werner Lemberg        else if ( (ULong)( TRUNC( pxl ) ) >= ras.target.rows )
25380039d0120e08bdcbe88dac66f65003d3ed5251b4Werner Lemberg          pxl = e2;
253929bc310563d4c8c728adfa78e18af9e4d3c89116Werner Lemberg
25405df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        /* check that the other pixel isn't set */
25415df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        e1 = pxl == e1 ? e2 : e1;
2542a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
25435df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        e1 = TRUNC( e1 );
2544a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
25455df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        bits = ras.bTarget + ( y >> 3 );
25465df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        f1   = (Byte)( 0x80 >> ( y & 7 ) );
2547a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
25485df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        bits -= e1 * ras.target.pitch;
25495df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        if ( ras.target.pitch > 0 )
25505df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg          bits += ( ras.target.rows - 1 ) * ras.target.pitch;
2551a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2552b3500af717010137046ec4076d1e1c0641e33727Werner Lemberg        if ( e1 >= 0                     &&
2553b3500af717010137046ec4076d1e1c0641e33727Werner Lemberg             (ULong)e1 < ras.target.rows &&
2554b3500af717010137046ec4076d1e1c0641e33727Werner Lemberg             *bits & f1                  )
25555df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg          return;
2556a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
2557a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      else
2558a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        return;
2559a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
2560a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2561a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    bits = ras.bTarget + ( y >> 3 );
2562a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    f1   = (Byte)( 0x80 >> ( y & 7 ) );
2563a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
25645df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    e1 = TRUNC( pxl );
2565a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2566b3500af717010137046ec4076d1e1c0641e33727Werner Lemberg    if ( e1 >= 0 && (ULong)e1 < ras.target.rows )
2567a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
2568a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      bits -= e1 * ras.target.pitch;
2569a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( ras.target.pitch > 0 )
2570a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        bits += ( ras.target.rows - 1 ) * ras.target.pitch;
2571a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2572a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      bits[0] |= f1;
2573a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
2574a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
2575a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2576a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
257752005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static void
257852005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Horizontal_Sweep_Step( RAS_ARG )
2579a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
2580a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* Nothing, really */
2581f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg    FT_UNUSED_RASTER;
2582a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
2583a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2584a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2585a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
2586a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2587a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*  Generic Sweep Drawing routine                                        */
2588a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2589a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
2590a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
259152005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static Bool
259252005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Draw_Sweep( RAS_ARG )
2593a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
2594a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Short         y, y_change, y_height;
2595a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2596a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    PProfile      P, Q, P_Left, P_Right;
2597a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2598a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Short         min_Y, max_Y, top, bottom, dropouts;
2599a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2600a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Long          x1, x2, xs, e1, e2;
2601a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
26023c403e4c17fa68a8a7992fa347fda312e1bae2a0Werner Lemberg    TProfileList  waiting;
2603a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    TProfileList  draw_left, draw_right;
2604a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2605a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2606174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg    /* initialize empty linked lists */
2607a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
26083c403e4c17fa68a8a7992fa347fda312e1bae2a0Werner Lemberg    Init_Linked( &waiting );
2609a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2610a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Init_Linked( &draw_left  );
2611a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Init_Linked( &draw_right );
2612a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2613a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* first, compute min and max Y */
2614a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2615a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    P     = ras.fProfile;
2616a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    max_Y = (Short)TRUNC( ras.minY );
2617a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    min_Y = (Short)TRUNC( ras.maxY );
2618a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2619a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    while ( P )
2620a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
2621a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      Q = P->link;
2622a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2623a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      bottom = (Short)P->start;
2624914b289f1623b1030b66537d3b3ce4b652e4606cWerner Lemberg      top    = (Short)( P->start + P->height - 1 );
2625a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
26265df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg      if ( min_Y > bottom )
26275df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        min_Y = bottom;
26285df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg      if ( max_Y < top )
26295df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        max_Y = top;
2630a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2631a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      P->X = 0;
26323c403e4c17fa68a8a7992fa347fda312e1bae2a0Werner Lemberg      InsNew( &waiting, P );
2633a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2634a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      P = Q;
2635a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
2636a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2637174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg    /* check the Y-turns */
2638a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( ras.numTurns == 0 )
2639a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
2640059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg      ras.error = FT_THROW( Invalid );
2641a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      return FAILURE;
2642a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
2643a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2644174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg    /* now initialize the sweep */
2645a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2646a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.Proc_Sweep_Init( RAS_VARS &min_Y, &max_Y );
2647a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2648174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg    /* then compute the distance of each profile from min_Y */
2649a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
26503c403e4c17fa68a8a7992fa347fda312e1bae2a0Werner Lemberg    P = waiting;
2651a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2652a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    while ( P )
2653a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
2654914b289f1623b1030b66537d3b3ce4b652e4606cWerner Lemberg      P->countL = (UShort)( P->start - min_Y );
2655a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      P = P->link;
2656a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
2657a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2658174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg    /* let's go */
2659a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2660a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    y        = min_Y;
2661a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    y_height = 0;
2662a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2663cbdba615115b0f07984130d9420ee7299ab0a3ccWerner Lemberg    if ( ras.numTurns > 0                     &&
2664a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner         ras.sizeBuff[-ras.numTurns] == min_Y )
2665a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.numTurns--;
2666a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2667a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    while ( ras.numTurns > 0 )
2668a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
2669174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg      /* check waiting list for new activations */
2670a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
26713c403e4c17fa68a8a7992fa347fda312e1bae2a0Werner Lemberg      P = waiting;
2672a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2673a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      while ( P )
2674a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
2675a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        Q = P->link;
2676a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        P->countL -= y_height;
2677a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        if ( P->countL == 0 )
2678a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        {
26793c403e4c17fa68a8a7992fa347fda312e1bae2a0Werner Lemberg          DelOld( &waiting, P );
2680a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
268190c699af0cb6e40ba96f43e80433818c83d2560fWerner Lemberg          if ( P->flags & Flow_Up )
2682a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            InsNew( &draw_left,  P );
268390c699af0cb6e40ba96f43e80433818c83d2560fWerner Lemberg          else
2684a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            InsNew( &draw_right, P );
2685a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        }
2686a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2687a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        P = Q;
2688a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
2689a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2690174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg      /* sort the drawing lists */
2691a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2692a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      Sort( &draw_left );
2693a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      Sort( &draw_right );
2694a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2695a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      y_change = (Short)ras.sizeBuff[-ras.numTurns--];
26968eb0353fec1494ab7d9fe9bb91a5954449ab30c1Werner Lemberg      y_height = (Short)( y_change - y );
2697a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2698a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      while ( y < y_change )
2699a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
2700174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg        /* let's trace */
2701a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2702a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        dropouts = 0;
2703a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2704a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        P_Left  = draw_left;
2705a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        P_Right = draw_right;
2706a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2707a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        while ( P_Left )
2708a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        {
2709a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          x1 = P_Left ->X;
2710a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          x2 = P_Right->X;
2711a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2712a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          if ( x1 > x2 )
2713a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          {
2714a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            xs = x1;
2715a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            x1 = x2;
2716a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            x2 = xs;
2717a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          }
2718a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
271971b8f3f2ed06ce2a437b31e34c75e6aeab781640Werner Lemberg          e1 = FLOOR( x1 );
272071b8f3f2ed06ce2a437b31e34c75e6aeab781640Werner Lemberg          e2 = CEILING( x2 );
2721a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
272271b8f3f2ed06ce2a437b31e34c75e6aeab781640Werner Lemberg          if ( x2 - x1 <= ras.precision &&
272371b8f3f2ed06ce2a437b31e34c75e6aeab781640Werner Lemberg               e1 != x1 && e2 != x2     )
272471b8f3f2ed06ce2a437b31e34c75e6aeab781640Werner Lemberg          {
2725ce8853af8158368eae51b14c89dc3b79f48ce8ceWerner Lemberg            if ( e1 > e2 || e2 == e1 + ras.precision )
2726a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            {
272772271140434028186a49a5dc5925f0727559e46fWerner Lemberg              Int  dropOutControl = P_Left->flags & 7;
272872271140434028186a49a5dc5925f0727559e46fWerner Lemberg
272972271140434028186a49a5dc5925f0727559e46fWerner Lemberg
273072271140434028186a49a5dc5925f0727559e46fWerner Lemberg              if ( dropOutControl != 2 )
2731ce8853af8158368eae51b14c89dc3b79f48ce8ceWerner Lemberg              {
2732174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg                /* a drop-out was detected */
2733a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2734ce8853af8158368eae51b14c89dc3b79f48ce8ceWerner Lemberg                P_Left ->X = x1;
2735ce8853af8158368eae51b14c89dc3b79f48ce8ceWerner Lemberg                P_Right->X = x2;
2736a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2737ce8853af8158368eae51b14c89dc3b79f48ce8ceWerner Lemberg                /* mark profile for drop-out processing */
2738ce8853af8158368eae51b14c89dc3b79f48ce8ceWerner Lemberg                P_Left->countL = 1;
2739ce8853af8158368eae51b14c89dc3b79f48ce8ceWerner Lemberg                dropouts++;
2740ce8853af8158368eae51b14c89dc3b79f48ce8ceWerner Lemberg              }
2741a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2742a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner              goto Skip_To_Next;
2743a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner            }
2744a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          }
2745a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2746a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          ras.Proc_Sweep_Span( RAS_VARS y, x1, x2, P_Left, P_Right );
2747a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2748a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        Skip_To_Next:
2749a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2750a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          P_Left  = P_Left->link;
2751a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          P_Right = P_Right->link;
2752a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        }
2753a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2754174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg        /* handle drop-outs _after_ the span drawing --       */
2755174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg        /* drop-out processing has been moved out of the loop */
2756174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg        /* for performance tuning                             */
2757a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        if ( dropouts > 0 )
2758a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          goto Scan_DropOuts;
2759a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2760a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      Next_Line:
2761a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2762a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ras.Proc_Sweep_Step( RAS_VAR );
2763a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2764a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        y++;
2765a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2766a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        if ( y < y_change )
2767a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        {
2768a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          Sort( &draw_left  );
2769a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          Sort( &draw_right );
2770a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        }
2771a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
2772a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2773174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg      /* now finalize the profiles that need it */
2774a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2775a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      P = draw_left;
2776a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      while ( P )
2777a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
2778a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        Q = P->link;
2779a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        if ( P->height == 0 )
2780a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          DelOld( &draw_left, P );
2781a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        P = Q;
2782a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
2783a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2784a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      P = draw_right;
2785a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      while ( P )
2786a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
2787a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        Q = P->link;
2788a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        if ( P->height == 0 )
2789a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          DelOld( &draw_right, P );
2790a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        P = Q;
2791a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
2792a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
2793a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2794174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg    /* for gray-scaling, flush the bitmap scanline cache */
2795a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    while ( y <= max_Y )
2796a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
2797a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.Proc_Sweep_Step( RAS_VAR );
2798a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      y++;
2799a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
2800a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2801a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    return SUCCESS;
2802a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2803a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  Scan_DropOuts:
2804a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2805a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    P_Left  = draw_left;
2806a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    P_Right = draw_right;
2807a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2808a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    while ( P_Left )
2809a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
2810a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( P_Left->countL )
2811a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
2812a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        P_Left->countL = 0;
2813a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#if 0
2814a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        dropouts--;  /* -- this is useful when debugging only */
2815a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#endif
2816a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ras.Proc_Sweep_Drop( RAS_VARS y,
2817a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                                      P_Left->X,
2818a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                                      P_Right->X,
2819a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                                      P_Left,
2820a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner                                      P_Right );
2821a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
2822a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2823a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      P_Left  = P_Left->link;
2824a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      P_Right = P_Right->link;
2825a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
2826a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2827a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    goto Next_Line;
2828a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
2829a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2830a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2831a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
2832a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2833a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Function>                                                            */
2834a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Render_Single_Pass                                                 */
2835a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2836a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Description>                                                         */
2837174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg  /*    Perform one sweep with sub-banding.                                */
2838a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2839a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Input>                                                               */
2840a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    flipped :: If set, flip the direction of the outline.              */
2841a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2842a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Return>                                                              */
2843a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Renderer error code.                                               */
2844a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
284552005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static int
284652005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Render_Single_Pass( RAS_ARGS Bool  flipped )
2847a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
2848a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Short  i, j, k;
2849a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2850a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2851a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    while ( ras.band_top >= 0 )
2852a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
2853a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.maxY = (Long)ras.band_stack[ras.band_top].y_max * ras.precision;
2854a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.minY = (Long)ras.band_stack[ras.band_top].y_min * ras.precision;
2855a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2856a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.top = ras.buff;
2857a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2858a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.error = Raster_Err_None;
2859a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2860a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( Convert_Glyph( RAS_VARS flipped ) )
2861a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
2862a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        if ( ras.error != Raster_Err_Overflow )
2863a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          return FAILURE;
2864a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2865a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ras.error = Raster_Err_None;
2866a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2867a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        /* sub-banding */
2868a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2869a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#ifdef DEBUG_RASTER
2870a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ClearBand( RAS_VARS TRUNC( ras.minY ), TRUNC( ras.maxY ) );
2871a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#endif
2872a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2873a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        i = ras.band_stack[ras.band_top].y_min;
2874a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        j = ras.band_stack[ras.band_top].y_max;
2875a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
28768eb0353fec1494ab7d9fe9bb91a5954449ab30c1Werner Lemberg        k = (Short)( ( i + j ) / 2 );
2877a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2878a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        if ( ras.band_top >= 7 || k < i )
2879a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        {
2880a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          ras.band_top = 0;
2881059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg          ras.error    = FT_THROW( Invalid );
2882a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2883a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          return ras.error;
2884a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        }
2885a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2886a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ras.band_stack[ras.band_top + 1].y_min = k;
2887a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ras.band_stack[ras.band_top + 1].y_max = j;
2888a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
28898eb0353fec1494ab7d9fe9bb91a5954449ab30c1Werner Lemberg        ras.band_stack[ras.band_top].y_max = (Short)( k - 1 );
2890a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2891a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ras.band_top++;
2892a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
2893a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      else
2894a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      {
2895a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        if ( ras.fProfile )
2896a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner          if ( Draw_Sweep( RAS_VAR ) )
2897a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner             return ras.error;
2898a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        ras.band_top--;
2899a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      }
2900a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
2901a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2902a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    return SUCCESS;
2903a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
2904a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2905a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2906a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*************************************************************************/
2907a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2908a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Function>                                                            */
2909a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    Render_Glyph                                                       */
2910a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2911a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Description>                                                         */
2912174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg  /*    Render a glyph in a bitmap.  Sub-banding if needed.                */
2913a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2914a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /* <Return>                                                              */
2915a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*    FreeType error code.  0 means success.                             */
2916a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /*                                                                       */
2917bc82f1bbefa90c649a9ad2c28938d55b4acbf380David Turner  FT_LOCAL_DEF( FT_Error )
291852005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  Render_Glyph( RAS_ARG )
2919a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
2920a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_Error  error;
2921a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2922a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2923a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    Set_High_Precision( RAS_VARS ras.outline.flags &
292442206ad86aac3c3c344fcd9730d80165514584c9Werner Lemberg                                 FT_OUTLINE_HIGH_PRECISION );
29255df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    ras.scale_shift = ras.precision_shift;
29265df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg
29275df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    if ( ras.outline.flags & FT_OUTLINE_IGNORE_DROPOUTS )
29285df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg      ras.dropOutControl = 2;
29295df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    else
29305df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    {
29315df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg      if ( ras.outline.flags & FT_OUTLINE_SMART_DROPOUTS )
29325df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        ras.dropOutControl = 4;
29335df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg      else
29345df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        ras.dropOutControl = 0;
29355df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg
29365df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg      if ( !( ras.outline.flags & FT_OUTLINE_INCLUDE_STUBS ) )
29375df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg        ras.dropOutControl += 1;
29385df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    }
29395df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg
29405df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    ras.second_pass = (FT_Byte)( !( ras.outline.flags &
29415df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg                                    FT_OUTLINE_SINGLE_PASS ) );
2942a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2943a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* Vertical Sweep */
2944a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.Proc_Sweep_Init = Vertical_Sweep_Init;
2945a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.Proc_Sweep_Span = Vertical_Sweep_Span;
2946a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.Proc_Sweep_Drop = Vertical_Sweep_Drop;
2947a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.Proc_Sweep_Step = Vertical_Sweep_Step;
2948a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2949a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.band_top            = 0;
2950a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.band_stack[0].y_min = 0;
29518eb0353fec1494ab7d9fe9bb91a5954449ab30c1Werner Lemberg    ras.band_stack[0].y_max = (short)( ras.target.rows - 1 );
2952a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
29538edbcabce1b3756fb1921f85901dcce944bdf1e7David Turner    ras.bWidth  = (unsigned short)ras.target.width;
2954a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    ras.bTarget = (Byte*)ras.target.buffer;
2955a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2956a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( ( error = Render_Single_Pass( RAS_VARS 0 ) ) != 0 )
2957a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      return error;
2958a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2959a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* Horizontal Sweep */
2960ce8853af8158368eae51b14c89dc3b79f48ce8ceWerner Lemberg    if ( ras.second_pass && ras.dropOutControl != 2 )
2961a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
2962a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.Proc_Sweep_Init = Horizontal_Sweep_Init;
2963a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.Proc_Sweep_Span = Horizontal_Sweep_Span;
2964a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.Proc_Sweep_Drop = Horizontal_Sweep_Drop;
2965a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.Proc_Sweep_Step = Horizontal_Sweep_Step;
2966a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2967a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.band_top            = 0;
2968a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ras.band_stack[0].y_min = 0;
29698eb0353fec1494ab7d9fe9bb91a5954449ab30c1Werner Lemberg      ras.band_stack[0].y_max = (short)( ras.target.width - 1 );
2970a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2971a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      if ( ( error = Render_Single_Pass( RAS_VARS 1 ) ) != 0 )
2972a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner        return error;
2973a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
2974a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2975f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg    return Raster_Err_None;
2976a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
2977a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2978a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
297952005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static void
298095111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco  ft_black_init( black_PRaster  raster )
2981a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
2982eca1f2790578ce8e9907ef3373ab69b7816b3093Werner Lemberg    FT_UNUSED( raster );
2983a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
2984a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2985a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2986a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /**** RASTER OBJECT CREATION: In standalone mode, we simply use *****/
2987a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  /****                         a static object.                  *****/
2988a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2989a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2990a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner#ifdef _STANDALONE_
2991a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
2992a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
299352005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static int
2994174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg  ft_black_new( void*       memory,
299552005c304229e2bfc54c0d406944d125d4849920Werner Lemberg                FT_Raster  *araster )
2996a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
299795111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco     static black_TRaster  the_raster;
299812cf031644ddd2531fa315e948aad24499adb251Werner Lemberg     FT_UNUSED( memory );
2999a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3000a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3001f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg     *araster = (FT_Raster)&the_raster;
3002b3d5e9cf03dce78e606b79c81cb1f29ce06555d5Werner Lemberg     FT_MEM_ZERO( &the_raster, sizeof ( the_raster ) );
3003a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner     ft_black_init( &the_raster );
3004a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3005a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner     return 0;
3006a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
3007a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3008a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
300952005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static void
301052005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  ft_black_done( FT_Raster  raster )
3011a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
3012a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* nothing */
3013f9fccbee8b265a7576b358191e940299ebe60827Werner Lemberg    FT_UNUSED( raster );
3014a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
3015a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3016a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3017c8f5b98be26df911f41d804d69ccb6d4bf818a53Werner Lemberg#else /* !_STANDALONE_ */
3018a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3019a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
302052005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static int
302195111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco  ft_black_new( FT_Memory       memory,
302295111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco                black_PRaster  *araster )
3023a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
302495111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco    FT_Error       error;
302595111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco    black_PRaster  raster = NULL;
3026a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3027a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3028a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    *araster = 0;
3029e459d742e6236df43f542b8c29dfdcf05d69716cDavid Turner    if ( !FT_NEW( raster ) )
3030a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    {
3031a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      raster->memory = memory;
3032a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      ft_black_init( raster );
3033a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3034a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      *araster = raster;
3035a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    }
3036a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3037a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    return error;
3038a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
3039a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3040a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
304152005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static void
304295111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco  ft_black_done( black_PRaster  raster )
3043a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
3044a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_Memory  memory = (FT_Memory)raster->memory;
304595111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco
304695111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco
3047e459d742e6236df43f542b8c29dfdcf05d69716cDavid Turner    FT_FREE( raster );
3048a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
3049a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3050a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3051c8f5b98be26df911f41d804d69ccb6d4bf818a53Werner Lemberg#endif /* !_STANDALONE_ */
3052a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3053a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
305452005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static void
305595111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco  ft_black_reset( black_PRaster  raster,
305695111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco                  char*          pool_base,
305795111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco                  long           pool_size )
3058a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
3059a773c3041e024975241d110989f617f032c4b7e3Behdad Esfahbod    FT_UNUSED( raster );
3060a773c3041e024975241d110989f617f032c4b7e3Behdad Esfahbod    FT_UNUSED( pool_base );
3061a773c3041e024975241d110989f617f032c4b7e3Behdad Esfahbod    FT_UNUSED( pool_size );
3062a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
3063a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3064a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
30653e86711ebf6efdea405f8f35bc34baf737b744dfWerner Lemberg  static int
306695111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco  ft_black_set_mode( black_PRaster  raster,
3067174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg                     unsigned long  mode,
3068174b8de3283c921d8bddf48325fe42ba7330a930Werner Lemberg                     const char*    palette )
3069a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
3070a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_UNUSED( raster );
3071a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_UNUSED( mode );
3072a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    FT_UNUSED( palette );
3073a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
30743e86711ebf6efdea405f8f35bc34baf737b744dfWerner Lemberg    return 0;
3075a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
3076a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3077a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
307852005c304229e2bfc54c0d406944d125d4849920Werner Lemberg  static int
307995111433853850345e4c3103b3bdf28a525ebb92Vinnie Falco  ft_black_render( black_PRaster            raster,
3080fa420250c59414e432243feffb70be68654b8c27Werner Lemberg                   const FT_Raster_Params*  params )
3081a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  {
30828ae1dceb94effa59a307c0b778b37483f808f3d4Werner Lemberg    const FT_Outline*  outline    = (const FT_Outline*)params->source;
30838ae1dceb94effa59a307c0b778b37483f808f3d4Werner Lemberg    const FT_Bitmap*   target_map = params->target;
3084a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3085a773c3041e024975241d110989f617f032c4b7e3Behdad Esfahbod    black_TWorker  worker[1];
3086a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3087a773c3041e024975241d110989f617f032c4b7e3Behdad Esfahbod    Long  buffer[FT_MAX( FT_RENDER_POOL_SIZE, 2048 ) / sizeof ( Long )];
3088a773c3041e024975241d110989f617f032c4b7e3Behdad Esfahbod
3089a773c3041e024975241d110989f617f032c4b7e3Behdad Esfahbod
3090a773c3041e024975241d110989f617f032c4b7e3Behdad Esfahbod    if ( !raster )
3091059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg      return FT_THROW( Not_Ini );
3092a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
30931ddd1b768dc3821e275e97c9391e54a14a8dc136Werner Lemberg    if ( !outline )
3094059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg      return FT_THROW( Invalid );
30951ddd1b768dc3821e275e97c9391e54a14a8dc136Werner Lemberg
3096a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* return immediately if the outline is empty */
3097a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    if ( outline->n_points == 0 || outline->n_contours <= 0 )
3098a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner      return Raster_Err_None;
3099a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
31001ddd1b768dc3821e275e97c9391e54a14a8dc136Werner Lemberg    if ( !outline->contours || !outline->points )
3101059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg      return FT_THROW( Invalid );
3102a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3103c938131856e288d7dd5d9e7c0437d0097b2ccc0cWerner Lemberg    if ( outline->n_points !=
3104c938131856e288d7dd5d9e7c0437d0097b2ccc0cWerner Lemberg           outline->contours[outline->n_contours - 1] + 1 )
3105059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg      return FT_THROW( Invalid );
3106a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3107a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    /* this version of the raster does not support direct rendering, sorry */
3108b08fe2dc7af972a61f4e6bcadd7bb522861faec5David Turner    if ( params->flags & FT_RASTER_FLAG_DIRECT )
3109059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg      return FT_THROW( Unsupported );
3110a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3111c938131856e288d7dd5d9e7c0437d0097b2ccc0cWerner Lemberg    if ( !target_map )
3112059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg      return FT_THROW( Invalid );
3113c938131856e288d7dd5d9e7c0437d0097b2ccc0cWerner Lemberg
3114c938131856e288d7dd5d9e7c0437d0097b2ccc0cWerner Lemberg    /* nothing to do */
3115c938131856e288d7dd5d9e7c0437d0097b2ccc0cWerner Lemberg    if ( !target_map->width || !target_map->rows )
3116c938131856e288d7dd5d9e7c0437d0097b2ccc0cWerner Lemberg      return Raster_Err_None;
3117c938131856e288d7dd5d9e7c0437d0097b2ccc0cWerner Lemberg
3118c938131856e288d7dd5d9e7c0437d0097b2ccc0cWerner Lemberg    if ( !target_map->buffer )
3119059bc335ce42220b222763379e89d0cbf2b949ebWerner Lemberg      return FT_THROW( Invalid );
31201eb9a43aa14e02b56d981bae334e6e24c63298f7David Turner
31215df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    ras.outline = *outline;
31225df5dbb722cf008b3f617448d8d28fde4d725556Werner Lemberg    ras.target  = *target_map;
3123a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3124a773c3041e024975241d110989f617f032c4b7e3Behdad Esfahbod    worker->buff     = buffer;
3125a773c3041e024975241d110989f617f032c4b7e3Behdad Esfahbod    worker->sizeBuff = (&buffer)[1]; /* Points to right after buffer. */
31268a2c7f8fb804f3b74ea062f1c367b78d12c5b3f2David Turner
31278dc863587440d0a1d2eec2a7973a8eda99d2767dBehdad Esfahbod    return Render_Glyph( RAS_VAR );
3128a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner  }
3129a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3130a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
31310d02317fb2a6f46e568cefc1132273cdd1bc80b7Werner Lemberg  FT_DEFINE_RASTER_FUNCS( ft_standard_raster,
3132b08fe2dc7af972a61f4e6bcadd7bb522861faec5David Turner    FT_GLYPH_FORMAT_OUTLINE,
3133a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    (FT_Raster_New_Func)     ft_black_new,
3134a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    (FT_Raster_Reset_Func)   ft_black_reset,
3135a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    (FT_Raster_Set_Mode_Func)ft_black_set_mode,
3136a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    (FT_Raster_Render_Func)  ft_black_render,
3137a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner    (FT_Raster_Done_Func)    ft_black_done
3138056095096fdce9084e23116f7825784a2ad5e677Oran Agra  )
3139a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3140a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner
3141a4e2894e03de65c5e0cd14b11b6fa30b14ed6769David Turner/* END */
3142