| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qgrayraster.c |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||
| 5 | ** | - | ||||||||||||||||||
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||||||||
| 7 | ** | - | ||||||||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||||||||
| 16 | ** | - | ||||||||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||
| 25 | ** | - | ||||||||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||
| 29 | ** | - | ||||||||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
| 31 | ** | - | ||||||||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||||||||
| 33 | - | |||||||||||||||||||
| 34 | /***************************************************************************/ | - | ||||||||||||||||||
| 35 | /* */ | - | ||||||||||||||||||
| 36 | /* qgrayraster.c, derived from ftgrays.c */ | - | ||||||||||||||||||
| 37 | /* */ | - | ||||||||||||||||||
| 38 | /* A new `perfect' anti-aliasing renderer (body). */ | - | ||||||||||||||||||
| 39 | /* */ | - | ||||||||||||||||||
| 40 | /* Copyright 2000-2001, 2002, 2003 by */ | - | ||||||||||||||||||
| 41 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | - | ||||||||||||||||||
| 42 | /* */ | - | ||||||||||||||||||
| 43 | /* This file is part of the FreeType project, and may only be used, */ | - | ||||||||||||||||||
| 44 | /* modified, and distributed under the terms of the FreeType project */ | - | ||||||||||||||||||
| 45 | /* license, ../../3rdparty/freetype/docs/FTL.TXT. By continuing to use, */ | - | ||||||||||||||||||
| 46 | /* modify, or distribute this file you indicate that you have read */ | - | ||||||||||||||||||
| 47 | /* the license and understand and accept it fully. */ | - | ||||||||||||||||||
| 48 | /* */ | - | ||||||||||||||||||
| 49 | /***************************************************************************/ | - | ||||||||||||||||||
| 50 | - | |||||||||||||||||||
| 51 | /*************************************************************************/ | - | ||||||||||||||||||
| 52 | /* */ | - | ||||||||||||||||||
| 53 | /* This file can be compiled without the rest of the FreeType engine, by */ | - | ||||||||||||||||||
| 54 | /* defining the _STANDALONE_ macro when compiling it. You also need to */ | - | ||||||||||||||||||
| 55 | /* put the files `ftgrays.h' and `ftimage.h' into the current */ | - | ||||||||||||||||||
| 56 | /* compilation directory. Typically, you could do something like */ | - | ||||||||||||||||||
| 57 | /* */ | - | ||||||||||||||||||
| 58 | /* - copy `src/smooth/ftgrays.c' (this file) to your current directory */ | - | ||||||||||||||||||
| 59 | /* */ | - | ||||||||||||||||||
| 60 | /* - copy `include/freetype/ftimage.h' and `src/smooth/ftgrays.h' to the */ | - | ||||||||||||||||||
| 61 | /* same directory */ | - | ||||||||||||||||||
| 62 | /* */ | - | ||||||||||||||||||
| 63 | /* - compile `ftgrays' with the _STANDALONE_ macro defined, as in */ | - | ||||||||||||||||||
| 64 | /* */ | - | ||||||||||||||||||
| 65 | /* cc -c -D_STANDALONE_ ftgrays.c */ | - | ||||||||||||||||||
| 66 | /* */ | - | ||||||||||||||||||
| 67 | /* The renderer can be initialized with a call to */ | - | ||||||||||||||||||
| 68 | /* `qt_ft_gray_raster.raster_new'; an anti-aliased bitmap can be generated */ | - | ||||||||||||||||||
| 69 | /* with a call to `qt_ft_gray_raster.raster_render'. */ | - | ||||||||||||||||||
| 70 | /* */ | - | ||||||||||||||||||
| 71 | /* See the comments and documentation in the file `ftimage.h' for more */ | - | ||||||||||||||||||
| 72 | /* details on how the raster works. */ | - | ||||||||||||||||||
| 73 | /* */ | - | ||||||||||||||||||
| 74 | /*************************************************************************/ | - | ||||||||||||||||||
| 75 | - | |||||||||||||||||||
| 76 | /*************************************************************************/ | - | ||||||||||||||||||
| 77 | /* */ | - | ||||||||||||||||||
| 78 | /* This is a new anti-aliasing scan-converter for FreeType 2. The */ | - | ||||||||||||||||||
| 79 | /* algorithm used here is _very_ different from the one in the standard */ | - | ||||||||||||||||||
| 80 | /* `ftraster' module. Actually, `ftgrays' computes the _exact_ */ | - | ||||||||||||||||||
| 81 | /* coverage of the outline on each pixel cell. */ | - | ||||||||||||||||||
| 82 | /* */ | - | ||||||||||||||||||
| 83 | /* It is based on ideas that I initially found in Raph Levien's */ | - | ||||||||||||||||||
| 84 | /* excellent LibArt graphics library (see http://www.levien.com/libart */ | - | ||||||||||||||||||
| 85 | /* for more information, though the web pages do not tell anything */ | - | ||||||||||||||||||
| 86 | /* about the renderer; you'll have to dive into the source code to */ | - | ||||||||||||||||||
| 87 | /* understand how it works). */ | - | ||||||||||||||||||
| 88 | /* */ | - | ||||||||||||||||||
| 89 | /* Note, however, that this is a _very_ different implementation */ | - | ||||||||||||||||||
| 90 | /* compared to Raph's. Coverage information is stored in a very */ | - | ||||||||||||||||||
| 91 | /* different way, and I don't use sorted vector paths. Also, it doesn't */ | - | ||||||||||||||||||
| 92 | /* use floating point values. */ | - | ||||||||||||||||||
| 93 | /* */ | - | ||||||||||||||||||
| 94 | /* This renderer has the following advantages: */ | - | ||||||||||||||||||
| 95 | /* */ | - | ||||||||||||||||||
| 96 | /* - It doesn't need an intermediate bitmap. Instead, one can supply a */ | - | ||||||||||||||||||
| 97 | /* callback function that will be called by the renderer to draw gray */ | - | ||||||||||||||||||
| 98 | /* spans on any target surface. You can thus do direct composition on */ | - | ||||||||||||||||||
| 99 | /* any kind of bitmap, provided that you give the renderer the right */ | - | ||||||||||||||||||
| 100 | /* callback. */ | - | ||||||||||||||||||
| 101 | /* */ | - | ||||||||||||||||||
| 102 | /* - A perfect anti-aliaser, i.e., it computes the _exact_ coverage on */ | - | ||||||||||||||||||
| 103 | /* each pixel cell. */ | - | ||||||||||||||||||
| 104 | /* */ | - | ||||||||||||||||||
| 105 | /* - It performs a single pass on the outline (the `standard' FT2 */ | - | ||||||||||||||||||
| 106 | /* renderer makes two passes). */ | - | ||||||||||||||||||
| 107 | /* */ | - | ||||||||||||||||||
| 108 | /* - It can easily be modified to render to _any_ number of gray levels */ | - | ||||||||||||||||||
| 109 | /* cheaply. */ | - | ||||||||||||||||||
| 110 | /* */ | - | ||||||||||||||||||
| 111 | /* - For small (< 20) pixel sizes, it is faster than the standard */ | - | ||||||||||||||||||
| 112 | /* renderer. */ | - | ||||||||||||||||||
| 113 | /* */ | - | ||||||||||||||||||
| 114 | /*************************************************************************/ | - | ||||||||||||||||||
| 115 | - | |||||||||||||||||||
| 116 | /* experimental support for gamma correction within the rasterizer */ | - | ||||||||||||||||||
| 117 | #define xxxGRAYS_USE_GAMMA | - | ||||||||||||||||||
| 118 | - | |||||||||||||||||||
| 119 | - | |||||||||||||||||||
| 120 | /*************************************************************************/ | - | ||||||||||||||||||
| 121 | /* */ | - | ||||||||||||||||||
| 122 | /* The macro QT_FT_COMPONENT is used in trace mode. It is an implicit */ | - | ||||||||||||||||||
| 123 | /* parameter of the QT_FT_TRACE() and QT_FT_ERROR() macros, used to print/log */ | - | ||||||||||||||||||
| 124 | /* messages during execution. */ | - | ||||||||||||||||||
| 125 | /* */ | - | ||||||||||||||||||
| 126 | #undef QT_FT_COMPONENT | - | ||||||||||||||||||
| 127 | #define QT_FT_COMPONENT trace_smooth | - | ||||||||||||||||||
| 128 | - | |||||||||||||||||||
| 129 | - | |||||||||||||||||||
| 130 | #define ErrRaster_MemoryOverflow -4 | - | ||||||||||||||||||
| 131 | - | |||||||||||||||||||
| 132 | #if defined(VXWORKS) | - | ||||||||||||||||||
| 133 | # include <vxWorksCommon.h> /* needed for setjmp.h */ | - | ||||||||||||||||||
| 134 | #endif | - | ||||||||||||||||||
| 135 | #include <string.h> /* for qt_ft_memcpy() */ | - | ||||||||||||||||||
| 136 | #include <setjmp.h> | - | ||||||||||||||||||
| 137 | #include <limits.h> | - | ||||||||||||||||||
| 138 | - | |||||||||||||||||||
| 139 | #define QT_FT_UINT_MAX UINT_MAX | - | ||||||||||||||||||
| 140 | - | |||||||||||||||||||
| 141 | #define qt_ft_memset memset | - | ||||||||||||||||||
| 142 | - | |||||||||||||||||||
| 143 | #define qt_ft_setjmp setjmp | - | ||||||||||||||||||
| 144 | #define qt_ft_longjmp longjmp | - | ||||||||||||||||||
| 145 | #define qt_ft_jmp_buf jmp_buf | - | ||||||||||||||||||
| 146 | - | |||||||||||||||||||
| 147 | #define ErrRaster_Invalid_Mode -2 | - | ||||||||||||||||||
| 148 | #define ErrRaster_Invalid_Outline -1 | - | ||||||||||||||||||
| 149 | #define ErrRaster_Invalid_Argument -3 | - | ||||||||||||||||||
| 150 | #define ErrRaster_Memory_Overflow -4 | - | ||||||||||||||||||
| 151 | #define ErrRaster_OutOfMemory -6 | - | ||||||||||||||||||
| 152 | - | |||||||||||||||||||
| 153 | #define QT_FT_BEGIN_HEADER | - | ||||||||||||||||||
| 154 | #define QT_FT_END_HEADER | - | ||||||||||||||||||
| 155 | - | |||||||||||||||||||
| 156 | #include <private/qrasterdefs_p.h> | - | ||||||||||||||||||
| 157 | #include <private/qgrayraster_p.h> | - | ||||||||||||||||||
| 158 | - | |||||||||||||||||||
| 159 | #include <stdlib.h> | - | ||||||||||||||||||
| 160 | #include <stdio.h> | - | ||||||||||||||||||
| 161 | - | |||||||||||||||||||
| 162 | /* This macro is used to indicate that a function parameter is unused. */ | - | ||||||||||||||||||
| 163 | /* Its purpose is simply to reduce compiler warnings. Note also that */ | - | ||||||||||||||||||
| 164 | /* simply defining it as `(void)x' doesn't avoid warnings with certain */ | - | ||||||||||||||||||
| 165 | /* ANSI compilers (e.g. LCC). */ | - | ||||||||||||||||||
| 166 | #define QT_FT_UNUSED( x ) (x) = (x) | - | ||||||||||||||||||
| 167 | - | |||||||||||||||||||
| 168 | /* Disable the tracing mechanism for simplicity -- developers can */ | - | ||||||||||||||||||
| 169 | /* activate it easily by redefining these two macros. */ | - | ||||||||||||||||||
| 170 | #ifndef QT_FT_ERROR | - | ||||||||||||||||||
| 171 | #define QT_FT_ERROR( x ) do ; while ( 0 ) /* nothing */ | - | ||||||||||||||||||
| 172 | #endif | - | ||||||||||||||||||
| 173 | - | |||||||||||||||||||
| 174 | #ifndef QT_FT_TRACE | - | ||||||||||||||||||
| 175 | #define QT_FT_TRACE( x ) do ; while ( 0 ) /* nothing */ | - | ||||||||||||||||||
| 176 | #endif | - | ||||||||||||||||||
| 177 | - | |||||||||||||||||||
| 178 | #ifndef QT_FT_MEM_SET | - | ||||||||||||||||||
| 179 | #define QT_FT_MEM_SET( d, s, c ) qt_ft_memset( d, s, c ) | - | ||||||||||||||||||
| 180 | #endif | - | ||||||||||||||||||
| 181 | - | |||||||||||||||||||
| 182 | #ifndef QT_FT_MEM_ZERO | - | ||||||||||||||||||
| 183 | #define QT_FT_MEM_ZERO( dest, count ) QT_FT_MEM_SET( dest, 0, count ) | - | ||||||||||||||||||
| 184 | #endif | - | ||||||||||||||||||
| 185 | - | |||||||||||||||||||
| 186 | /* define this to dump debugging information */ | - | ||||||||||||||||||
| 187 | #define xxxDEBUG_GRAYS | - | ||||||||||||||||||
| 188 | - | |||||||||||||||||||
| 189 | - | |||||||||||||||||||
| 190 | #define RAS_ARG PWorker worker | - | ||||||||||||||||||
| 191 | #define RAS_ARG_ PWorker worker, | - | ||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | #define RAS_VAR worker | - | ||||||||||||||||||
| 194 | #define RAS_VAR_ worker, | - | ||||||||||||||||||
| 195 | - | |||||||||||||||||||
| 196 | #define ras (*worker) | - | ||||||||||||||||||
| 197 | - | |||||||||||||||||||
| 198 | - | |||||||||||||||||||
| 199 | /* must be at least 6 bits! */ | - | ||||||||||||||||||
| 200 | #define PIXEL_BITS 8 | - | ||||||||||||||||||
| 201 | - | |||||||||||||||||||
| 202 | #define ONE_PIXEL ( 1L << PIXEL_BITS ) | - | ||||||||||||||||||
| 203 | #define PIXEL_MASK ( -1L << PIXEL_BITS ) | - | ||||||||||||||||||
| 204 | #define TRUNC( x ) ( (TCoord)( (x) >> PIXEL_BITS ) ) | - | ||||||||||||||||||
| 205 | #define SUBPIXELS( x ) ( (TPos)(x) * ( 1 << PIXEL_BITS ) ) | - | ||||||||||||||||||
| 206 | #define FLOOR( x ) ( (x) & -ONE_PIXEL ) | - | ||||||||||||||||||
| 207 | #define CEILING( x ) ( ( (x) + ONE_PIXEL - 1 ) & -ONE_PIXEL ) | - | ||||||||||||||||||
| 208 | #define ROUND( x ) ( ( (x) + ONE_PIXEL / 2 ) & -ONE_PIXEL ) | - | ||||||||||||||||||
| 209 | - | |||||||||||||||||||
| 210 | #if PIXEL_BITS >= 6 | - | ||||||||||||||||||
| 211 | #define UPSCALE( x ) ( (x) * ( 1 << ( PIXEL_BITS - 6 ) ) ) | - | ||||||||||||||||||
| 212 | #define DOWNSCALE( x ) ( (x) >> ( PIXEL_BITS - 6 ) ) | - | ||||||||||||||||||
| 213 | #else | - | ||||||||||||||||||
| 214 | #define UPSCALE( x ) ( (x) >> ( 6 - PIXEL_BITS ) ) | - | ||||||||||||||||||
| 215 | #define DOWNSCALE( x ) ( (x) << ( 6 - PIXEL_BITS ) ) | - | ||||||||||||||||||
| 216 | #endif | - | ||||||||||||||||||
| 217 | - | |||||||||||||||||||
| 218 | /*************************************************************************/ | - | ||||||||||||||||||
| 219 | /* */ | - | ||||||||||||||||||
| 220 | /* TYPE DEFINITIONS */ | - | ||||||||||||||||||
| 221 | /* */ | - | ||||||||||||||||||
| 222 | - | |||||||||||||||||||
| 223 | /* don't change the following types to QT_FT_Int or QT_FT_Pos, since we might */ | - | ||||||||||||||||||
| 224 | /* need to define them to "float" or "double" when experimenting with */ | - | ||||||||||||||||||
| 225 | /* new algorithms */ | - | ||||||||||||||||||
| 226 | - | |||||||||||||||||||
| 227 | typedef int TCoord; /* integer scanline/pixel coordinate */ | - | ||||||||||||||||||
| 228 | typedef int TPos; /* sub-pixel coordinate */ | - | ||||||||||||||||||
| 229 | - | |||||||||||||||||||
| 230 | /* determine the type used to store cell areas. This normally takes at */ | - | ||||||||||||||||||
| 231 | /* least PIXEL_BITS*2 + 1 bits. On 16-bit systems, we need to use */ | - | ||||||||||||||||||
| 232 | /* `long' instead of `int', otherwise bad things happen */ | - | ||||||||||||||||||
| 233 | - | |||||||||||||||||||
| 234 | #if PIXEL_BITS <= 7 | - | ||||||||||||||||||
| 235 | - | |||||||||||||||||||
| 236 | typedef int TArea; | - | ||||||||||||||||||
| 237 | - | |||||||||||||||||||
| 238 | #else /* PIXEL_BITS >= 8 */ | - | ||||||||||||||||||
| 239 | - | |||||||||||||||||||
| 240 | /* approximately determine the size of integers using an ANSI-C header */ | - | ||||||||||||||||||
| 241 | #if QT_FT_UINT_MAX == 0xFFFFU | - | ||||||||||||||||||
| 242 | typedef long TArea; | - | ||||||||||||||||||
| 243 | #else | - | ||||||||||||||||||
| 244 | typedef int TArea; | - | ||||||||||||||||||
| 245 | #endif | - | ||||||||||||||||||
| 246 | - | |||||||||||||||||||
| 247 | #endif /* PIXEL_BITS >= 8 */ | - | ||||||||||||||||||
| 248 | - | |||||||||||||||||||
| 249 | - | |||||||||||||||||||
| 250 | /* maximal number of gray spans in a call to the span callback */ | - | ||||||||||||||||||
| 251 | #define QT_FT_MAX_GRAY_SPANS 256 | - | ||||||||||||||||||
| 252 | - | |||||||||||||||||||
| 253 | - | |||||||||||||||||||
| 254 | typedef struct TCell_* PCell; | - | ||||||||||||||||||
| 255 | - | |||||||||||||||||||
| 256 | typedef struct TCell_ | - | ||||||||||||||||||
| 257 | { | - | ||||||||||||||||||
| 258 | int x; | - | ||||||||||||||||||
| 259 | int cover; | - | ||||||||||||||||||
| 260 | TArea area; | - | ||||||||||||||||||
| 261 | PCell next; | - | ||||||||||||||||||
| 262 | - | |||||||||||||||||||
| 263 | } TCell; | - | ||||||||||||||||||
| 264 | - | |||||||||||||||||||
| 265 | - | |||||||||||||||||||
| 266 | typedef struct TWorker_ | - | ||||||||||||||||||
| 267 | { | - | ||||||||||||||||||
| 268 | TCoord ex, ey; | - | ||||||||||||||||||
| 269 | TPos min_ex, max_ex; | - | ||||||||||||||||||
| 270 | TPos min_ey, max_ey; | - | ||||||||||||||||||
| 271 | TPos count_ex, count_ey; | - | ||||||||||||||||||
| 272 | - | |||||||||||||||||||
| 273 | TArea area; | - | ||||||||||||||||||
| 274 | int cover; | - | ||||||||||||||||||
| 275 | int invalid; | - | ||||||||||||||||||
| 276 | - | |||||||||||||||||||
| 277 | PCell cells; | - | ||||||||||||||||||
| 278 | int max_cells; | - | ||||||||||||||||||
| 279 | int num_cells; | - | ||||||||||||||||||
| 280 | - | |||||||||||||||||||
| 281 | TCoord cx, cy; | - | ||||||||||||||||||
| 282 | TPos x, y; | - | ||||||||||||||||||
| 283 | - | |||||||||||||||||||
| 284 | TPos last_ey; | - | ||||||||||||||||||
| 285 | - | |||||||||||||||||||
| 286 | QT_FT_Vector bez_stack[32 * 3 + 1]; | - | ||||||||||||||||||
| 287 | int lev_stack[32]; | - | ||||||||||||||||||
| 288 | - | |||||||||||||||||||
| 289 | QT_FT_Outline outline; | - | ||||||||||||||||||
| 290 | QT_FT_Bitmap target; | - | ||||||||||||||||||
| 291 | QT_FT_BBox clip_box; | - | ||||||||||||||||||
| 292 | - | |||||||||||||||||||
| 293 | QT_FT_Span gray_spans[QT_FT_MAX_GRAY_SPANS]; | - | ||||||||||||||||||
| 294 | int num_gray_spans; | - | ||||||||||||||||||
| 295 | - | |||||||||||||||||||
| 296 | QT_FT_Raster_Span_Func render_span; | - | ||||||||||||||||||
| 297 | void* render_span_data; | - | ||||||||||||||||||
| 298 | - | |||||||||||||||||||
| 299 | int band_size; | - | ||||||||||||||||||
| 300 | int band_shoot; | - | ||||||||||||||||||
| 301 | int conic_level; | - | ||||||||||||||||||
| 302 | int cubic_level; | - | ||||||||||||||||||
| 303 | - | |||||||||||||||||||
| 304 | qt_ft_jmp_buf jump_buffer; | - | ||||||||||||||||||
| 305 | - | |||||||||||||||||||
| 306 | void* buffer; | - | ||||||||||||||||||
| 307 | long buffer_size; | - | ||||||||||||||||||
| 308 | - | |||||||||||||||||||
| 309 | PCell* ycells; | - | ||||||||||||||||||
| 310 | int ycount; | - | ||||||||||||||||||
| 311 | - | |||||||||||||||||||
| 312 | int skip_spans; | - | ||||||||||||||||||
| 313 | } TWorker, *PWorker; | - | ||||||||||||||||||
| 314 | - | |||||||||||||||||||
| 315 | - | |||||||||||||||||||
| 316 | typedef struct TRaster_ | - | ||||||||||||||||||
| 317 | { | - | ||||||||||||||||||
| 318 | void* buffer; | - | ||||||||||||||||||
| 319 | long buffer_size; | - | ||||||||||||||||||
| 320 | long buffer_allocated_size; | - | ||||||||||||||||||
| 321 | int band_size; | - | ||||||||||||||||||
| 322 | void* memory; | - | ||||||||||||||||||
| 323 | PWorker worker; | - | ||||||||||||||||||
| 324 | - | |||||||||||||||||||
| 325 | } TRaster, *PRaster; | - | ||||||||||||||||||
| 326 | - | |||||||||||||||||||
| 327 | int q_gray_rendered_spans(TRaster *raster) | - | ||||||||||||||||||
| 328 | { | - | ||||||||||||||||||
| 329 | if ( raster && raster->worker )
| 0 | ||||||||||||||||||
| 330 | return raster->worker->skip_spans > 0 ? 0 : -raster->worker->skip_spans; never executed: return raster->worker->skip_spans > 0 ? 0 : -raster->worker->skip_spans;
| 0 | ||||||||||||||||||
| 331 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 332 | } | - | ||||||||||||||||||
| 333 | - | |||||||||||||||||||
| 334 | /*************************************************************************/ | - | ||||||||||||||||||
| 335 | /* */ | - | ||||||||||||||||||
| 336 | /* Initialize the cells table. */ | - | ||||||||||||||||||
| 337 | /* */ | - | ||||||||||||||||||
| 338 | static void | - | ||||||||||||||||||
| 339 | gray_init_cells( RAS_ARG_ void* buffer, | - | ||||||||||||||||||
| 340 | long byte_size ) | - | ||||||||||||||||||
| 341 | { | - | ||||||||||||||||||
| 342 | ras.buffer = buffer; | - | ||||||||||||||||||
| 343 | ras.buffer_size = byte_size; | - | ||||||||||||||||||
| 344 | - | |||||||||||||||||||
| 345 | ras.ycells = (PCell*) buffer; | - | ||||||||||||||||||
| 346 | ras.cells = NULL; | - | ||||||||||||||||||
| 347 | ras.max_cells = 0; | - | ||||||||||||||||||
| 348 | ras.num_cells = 0; | - | ||||||||||||||||||
| 349 | ras.area = 0; | - | ||||||||||||||||||
| 350 | ras.cover = 0; | - | ||||||||||||||||||
| 351 | ras.invalid = 1; | - | ||||||||||||||||||
| 352 | } never executed: end of block | 0 | ||||||||||||||||||
| 353 | - | |||||||||||||||||||
| 354 | - | |||||||||||||||||||
| 355 | /*************************************************************************/ | - | ||||||||||||||||||
| 356 | /* */ | - | ||||||||||||||||||
| 357 | /* Compute the outline bounding box. */ | - | ||||||||||||||||||
| 358 | /* */ | - | ||||||||||||||||||
| 359 | static void | - | ||||||||||||||||||
| 360 | gray_compute_cbox( RAS_ARG ) | - | ||||||||||||||||||
| 361 | { | - | ||||||||||||||||||
| 362 | QT_FT_Outline* outline = &ras.outline; | - | ||||||||||||||||||
| 363 | QT_FT_Vector* vec = outline->points; | - | ||||||||||||||||||
| 364 | QT_FT_Vector* limit = vec + outline->n_points; | - | ||||||||||||||||||
| 365 | - | |||||||||||||||||||
| 366 | - | |||||||||||||||||||
| 367 | if ( outline->n_points <= 0 )
| 0 | ||||||||||||||||||
| 368 | { | - | ||||||||||||||||||
| 369 | ras.min_ex = ras.max_ex = 0; | - | ||||||||||||||||||
| 370 | ras.min_ey = ras.max_ey = 0; | - | ||||||||||||||||||
| 371 | return; never executed: return; | 0 | ||||||||||||||||||
| 372 | } | - | ||||||||||||||||||
| 373 | - | |||||||||||||||||||
| 374 | ras.min_ex = ras.max_ex = vec->x; | - | ||||||||||||||||||
| 375 | ras.min_ey = ras.max_ey = vec->y; | - | ||||||||||||||||||
| 376 | - | |||||||||||||||||||
| 377 | vec++; | - | ||||||||||||||||||
| 378 | - | |||||||||||||||||||
| 379 | for ( ; vec < limit; vec++ )
| 0 | ||||||||||||||||||
| 380 | { | - | ||||||||||||||||||
| 381 | TPos x = vec->x; | - | ||||||||||||||||||
| 382 | TPos y = vec->y; | - | ||||||||||||||||||
| 383 | - | |||||||||||||||||||
| 384 | - | |||||||||||||||||||
| 385 | if ( x < ras.min_ex ) ras.min_ex = x; never executed: (*worker).min_ex = x;
| 0 | ||||||||||||||||||
| 386 | if ( x > ras.max_ex ) ras.max_ex = x; never executed: (*worker).max_ex = x;
| 0 | ||||||||||||||||||
| 387 | if ( y < ras.min_ey ) ras.min_ey = y; never executed: (*worker).min_ey = y;
| 0 | ||||||||||||||||||
| 388 | if ( y > ras.max_ey ) ras.max_ey = y; never executed: (*worker).max_ey = y;
| 0 | ||||||||||||||||||
| 389 | } never executed: end of block | 0 | ||||||||||||||||||
| 390 | - | |||||||||||||||||||
| 391 | /* truncate the bounding box to integer pixels */ | - | ||||||||||||||||||
| 392 | ras.min_ex = ras.min_ex >> 6; | - | ||||||||||||||||||
| 393 | ras.min_ey = ras.min_ey >> 6; | - | ||||||||||||||||||
| 394 | ras.max_ex = ( ras.max_ex + 63 ) >> 6; | - | ||||||||||||||||||
| 395 | ras.max_ey = ( ras.max_ey + 63 ) >> 6; | - | ||||||||||||||||||
| 396 | } never executed: end of block | 0 | ||||||||||||||||||
| 397 | - | |||||||||||||||||||
| 398 | - | |||||||||||||||||||
| 399 | /*************************************************************************/ | - | ||||||||||||||||||
| 400 | /* */ | - | ||||||||||||||||||
| 401 | /* Record the current cell in the table. */ | - | ||||||||||||||||||
| 402 | /* */ | - | ||||||||||||||||||
| 403 | static void | - | ||||||||||||||||||
| 404 | gray_record_cell( RAS_ARG ) | - | ||||||||||||||||||
| 405 | { | - | ||||||||||||||||||
| 406 | PCell *pcell, cell; | - | ||||||||||||||||||
| 407 | int x = ras.ex; | - | ||||||||||||||||||
| 408 | - | |||||||||||||||||||
| 409 | if ( ras.invalid || !( ras.area | ras.cover ) )
| 0 | ||||||||||||||||||
| 410 | return; never executed: return; | 0 | ||||||||||||||||||
| 411 | - | |||||||||||||||||||
| 412 | if ( x > ras.max_ex )
| 0 | ||||||||||||||||||
| 413 | x = ras.max_ex; never executed: x = (*worker).max_ex; | 0 | ||||||||||||||||||
| 414 | - | |||||||||||||||||||
| 415 | pcell = &ras.ycells[ras.ey]; | - | ||||||||||||||||||
| 416 | - | |||||||||||||||||||
| 417 | for (;;) | - | ||||||||||||||||||
| 418 | { | - | ||||||||||||||||||
| 419 | cell = *pcell; | - | ||||||||||||||||||
| 420 | if ( cell == NULL || cell->x > x )
| 0 | ||||||||||||||||||
| 421 | break; never executed: break; | 0 | ||||||||||||||||||
| 422 | - | |||||||||||||||||||
| 423 | if ( cell->x == x ) {
| 0 | ||||||||||||||||||
| 424 | cell->area += ras.area; | - | ||||||||||||||||||
| 425 | cell->cover += ras.cover; | - | ||||||||||||||||||
| 426 | return; never executed: return; | 0 | ||||||||||||||||||
| 427 | } | - | ||||||||||||||||||
| 428 | - | |||||||||||||||||||
| 429 | pcell = &cell->next; | - | ||||||||||||||||||
| 430 | } never executed: end of block | 0 | ||||||||||||||||||
| 431 | - | |||||||||||||||||||
| 432 | if ( ras.num_cells >= ras.max_cells )
| 0 | ||||||||||||||||||
| 433 | qt_ft_longjmp( ras.jump_buffer, 1 ); never executed: longjmp( (*worker).jump_buffer, 1 ); | 0 | ||||||||||||||||||
| 434 | - | |||||||||||||||||||
| 435 | cell = ras.cells + ras.num_cells++; | - | ||||||||||||||||||
| 436 | cell->x = x; | - | ||||||||||||||||||
| 437 | cell->area = ras.area; | - | ||||||||||||||||||
| 438 | cell->cover = ras.cover; | - | ||||||||||||||||||
| 439 | - | |||||||||||||||||||
| 440 | cell->next = *pcell; | - | ||||||||||||||||||
| 441 | *pcell = cell; | - | ||||||||||||||||||
| 442 | } never executed: end of block | 0 | ||||||||||||||||||
| 443 | - | |||||||||||||||||||
| 444 | - | |||||||||||||||||||
| 445 | /*************************************************************************/ | - | ||||||||||||||||||
| 446 | /* */ | - | ||||||||||||||||||
| 447 | /* Set the current cell to a new position. */ | - | ||||||||||||||||||
| 448 | /* */ | - | ||||||||||||||||||
| 449 | static void | - | ||||||||||||||||||
| 450 | gray_set_cell( RAS_ARG_ TCoord ex, | - | ||||||||||||||||||
| 451 | TCoord ey ) | - | ||||||||||||||||||
| 452 | { | - | ||||||||||||||||||
| 453 | /* Move the cell pointer to a new position. We set the `invalid' */ | - | ||||||||||||||||||
| 454 | /* flag to indicate that the cell isn't part of those we're interested */ | - | ||||||||||||||||||
| 455 | /* in during the render phase. This means that: */ | - | ||||||||||||||||||
| 456 | /* */ | - | ||||||||||||||||||
| 457 | /* . the new vertical position must be within min_ey..max_ey-1. */ | - | ||||||||||||||||||
| 458 | /* . the new horizontal position must be strictly less than max_ex */ | - | ||||||||||||||||||
| 459 | /* */ | - | ||||||||||||||||||
| 460 | /* Note that if a cell is to the left of the clipping region, it is */ | - | ||||||||||||||||||
| 461 | /* actually set to the (min_ex-1) horizontal position. */ | - | ||||||||||||||||||
| 462 | - | |||||||||||||||||||
| 463 | /* All cells that are on the left of the clipping region go to the */ | - | ||||||||||||||||||
| 464 | /* min_ex - 1 horizontal position. */ | - | ||||||||||||||||||
| 465 | ey -= ras.min_ey; | - | ||||||||||||||||||
| 466 | - | |||||||||||||||||||
| 467 | if ( ex > ras.max_ex )
| 0 | ||||||||||||||||||
| 468 | ex = ras.max_ex; never executed: ex = (*worker).max_ex; | 0 | ||||||||||||||||||
| 469 | - | |||||||||||||||||||
| 470 | ex -= ras.min_ex; | - | ||||||||||||||||||
| 471 | if ( ex < 0 )
| 0 | ||||||||||||||||||
| 472 | ex = -1; never executed: ex = -1; | 0 | ||||||||||||||||||
| 473 | - | |||||||||||||||||||
| 474 | /* are we moving to a different cell ? */ | - | ||||||||||||||||||
| 475 | if ( ex != ras.ex || ey != ras.ey )
| 0 | ||||||||||||||||||
| 476 | { | - | ||||||||||||||||||
| 477 | /* record the current one if it is valid */ | - | ||||||||||||||||||
| 478 | if ( !ras.invalid )
| 0 | ||||||||||||||||||
| 479 | gray_record_cell( RAS_VAR ); never executed: gray_record_cell( worker ); | 0 | ||||||||||||||||||
| 480 | - | |||||||||||||||||||
| 481 | ras.area = 0; | - | ||||||||||||||||||
| 482 | ras.cover = 0; | - | ||||||||||||||||||
| 483 | ras.ex = ex; | - | ||||||||||||||||||
| 484 | ras.ey = ey; | - | ||||||||||||||||||
| 485 | } never executed: end of block | 0 | ||||||||||||||||||
| 486 | - | |||||||||||||||||||
| 487 | ras.invalid = ( (unsigned)ey >= (unsigned)ras.count_ey ||
| 0 | ||||||||||||||||||
| 488 | ex >= ras.count_ex );
| 0 | ||||||||||||||||||
| 489 | } never executed: end of block | 0 | ||||||||||||||||||
| 490 | - | |||||||||||||||||||
| 491 | - | |||||||||||||||||||
| 492 | /*************************************************************************/ | - | ||||||||||||||||||
| 493 | /* */ | - | ||||||||||||||||||
| 494 | /* Start a new contour at a given cell. */ | - | ||||||||||||||||||
| 495 | /* */ | - | ||||||||||||||||||
| 496 | static void | - | ||||||||||||||||||
| 497 | gray_start_cell( RAS_ARG_ TCoord ex, | - | ||||||||||||||||||
| 498 | TCoord ey ) | - | ||||||||||||||||||
| 499 | { | - | ||||||||||||||||||
| 500 | if ( ex > ras.max_ex )
| 0 | ||||||||||||||||||
| 501 | ex = (TCoord)( ras.max_ex ); never executed: ex = (TCoord)( (*worker).max_ex ); | 0 | ||||||||||||||||||
| 502 | - | |||||||||||||||||||
| 503 | if ( ex < ras.min_ex )
| 0 | ||||||||||||||||||
| 504 | ex = (TCoord)( ras.min_ex - 1 ); never executed: ex = (TCoord)( (*worker).min_ex - 1 ); | 0 | ||||||||||||||||||
| 505 | - | |||||||||||||||||||
| 506 | ras.area = 0; | - | ||||||||||||||||||
| 507 | ras.cover = 0; | - | ||||||||||||||||||
| 508 | ras.ex = ex - ras.min_ex; | - | ||||||||||||||||||
| 509 | ras.ey = ey - ras.min_ey; | - | ||||||||||||||||||
| 510 | ras.last_ey = SUBPIXELS( ey ); | - | ||||||||||||||||||
| 511 | ras.invalid = 0; | - | ||||||||||||||||||
| 512 | - | |||||||||||||||||||
| 513 | gray_set_cell( RAS_VAR_ ex, ey ); | - | ||||||||||||||||||
| 514 | } never executed: end of block | 0 | ||||||||||||||||||
| 515 | - | |||||||||||||||||||
| 516 | - | |||||||||||||||||||
| 517 | /*************************************************************************/ | - | ||||||||||||||||||
| 518 | /* */ | - | ||||||||||||||||||
| 519 | /* Render a scanline as one or more cells. */ | - | ||||||||||||||||||
| 520 | /* */ | - | ||||||||||||||||||
| 521 | static void | - | ||||||||||||||||||
| 522 | gray_render_scanline( RAS_ARG_ TCoord ey, | - | ||||||||||||||||||
| 523 | TPos x1, | - | ||||||||||||||||||
| 524 | TCoord y1, | - | ||||||||||||||||||
| 525 | TPos x2, | - | ||||||||||||||||||
| 526 | TCoord y2 ) | - | ||||||||||||||||||
| 527 | { | - | ||||||||||||||||||
| 528 | TCoord ex1, ex2, fx1, fx2, delta; | - | ||||||||||||||||||
| 529 | int p, first, dx; | - | ||||||||||||||||||
| 530 | int incr, lift, mod, rem; | - | ||||||||||||||||||
| 531 | - | |||||||||||||||||||
| 532 | - | |||||||||||||||||||
| 533 | dx = x2 - x1; | - | ||||||||||||||||||
| 534 | - | |||||||||||||||||||
| 535 | ex1 = TRUNC( x1 ); | - | ||||||||||||||||||
| 536 | ex2 = TRUNC( x2 ); | - | ||||||||||||||||||
| 537 | fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) ); | - | ||||||||||||||||||
| 538 | fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) ); | - | ||||||||||||||||||
| 539 | - | |||||||||||||||||||
| 540 | /* trivial case. Happens often */ | - | ||||||||||||||||||
| 541 | if ( y1 == y2 )
| 0 | ||||||||||||||||||
| 542 | { | - | ||||||||||||||||||
| 543 | gray_set_cell( RAS_VAR_ ex2, ey ); | - | ||||||||||||||||||
| 544 | return; never executed: return; | 0 | ||||||||||||||||||
| 545 | } | - | ||||||||||||||||||
| 546 | - | |||||||||||||||||||
| 547 | /* everything is located in a single cell. That is easy! */ | - | ||||||||||||||||||
| 548 | /* */ | - | ||||||||||||||||||
| 549 | if ( ex1 == ex2 )
| 0 | ||||||||||||||||||
| 550 | { | - | ||||||||||||||||||
| 551 | delta = y2 - y1; | - | ||||||||||||||||||
| 552 | ras.area += (TArea)( fx1 + fx2 ) * delta; | - | ||||||||||||||||||
| 553 | ras.cover += delta; | - | ||||||||||||||||||
| 554 | return; never executed: return; | 0 | ||||||||||||||||||
| 555 | } | - | ||||||||||||||||||
| 556 | - | |||||||||||||||||||
| 557 | /* ok, we'll have to render a run of adjacent cells on the same */ | - | ||||||||||||||||||
| 558 | /* scanline... */ | - | ||||||||||||||||||
| 559 | /* */ | - | ||||||||||||||||||
| 560 | p = ( ONE_PIXEL - fx1 ) * ( y2 - y1 ); | - | ||||||||||||||||||
| 561 | first = ONE_PIXEL; | - | ||||||||||||||||||
| 562 | incr = 1; | - | ||||||||||||||||||
| 563 | - | |||||||||||||||||||
| 564 | if ( dx < 0 )
| 0 | ||||||||||||||||||
| 565 | { | - | ||||||||||||||||||
| 566 | p = fx1 * ( y2 - y1 ); | - | ||||||||||||||||||
| 567 | first = 0; | - | ||||||||||||||||||
| 568 | incr = -1; | - | ||||||||||||||||||
| 569 | dx = -dx; | - | ||||||||||||||||||
| 570 | } never executed: end of block | 0 | ||||||||||||||||||
| 571 | - | |||||||||||||||||||
| 572 | delta = (TCoord)( p / dx ); | - | ||||||||||||||||||
| 573 | mod = (TCoord)( p % dx ); | - | ||||||||||||||||||
| 574 | if ( mod < 0 )
| 0 | ||||||||||||||||||
| 575 | { | - | ||||||||||||||||||
| 576 | delta--; | - | ||||||||||||||||||
| 577 | mod += (TCoord)dx; | - | ||||||||||||||||||
| 578 | } never executed: end of block | 0 | ||||||||||||||||||
| 579 | - | |||||||||||||||||||
| 580 | ras.area += (TArea)( fx1 + first ) * delta; | - | ||||||||||||||||||
| 581 | ras.cover += delta; | - | ||||||||||||||||||
| 582 | - | |||||||||||||||||||
| 583 | ex1 += incr; | - | ||||||||||||||||||
| 584 | gray_set_cell( RAS_VAR_ ex1, ey ); | - | ||||||||||||||||||
| 585 | y1 += delta; | - | ||||||||||||||||||
| 586 | - | |||||||||||||||||||
| 587 | if ( ex1 != ex2 )
| 0 | ||||||||||||||||||
| 588 | { | - | ||||||||||||||||||
| 589 | p = ONE_PIXEL * ( y2 - y1 + delta ); | - | ||||||||||||||||||
| 590 | lift = (TCoord)( p / dx ); | - | ||||||||||||||||||
| 591 | rem = (TCoord)( p % dx ); | - | ||||||||||||||||||
| 592 | if ( rem < 0 )
| 0 | ||||||||||||||||||
| 593 | { | - | ||||||||||||||||||
| 594 | lift--; | - | ||||||||||||||||||
| 595 | rem += (TCoord)dx; | - | ||||||||||||||||||
| 596 | } never executed: end of block | 0 | ||||||||||||||||||
| 597 | - | |||||||||||||||||||
| 598 | mod -= (int)dx; | - | ||||||||||||||||||
| 599 | - | |||||||||||||||||||
| 600 | while ( ex1 != ex2 )
| 0 | ||||||||||||||||||
| 601 | { | - | ||||||||||||||||||
| 602 | delta = lift; | - | ||||||||||||||||||
| 603 | mod += rem; | - | ||||||||||||||||||
| 604 | if ( mod >= 0 )
| 0 | ||||||||||||||||||
| 605 | { | - | ||||||||||||||||||
| 606 | mod -= (TCoord)dx; | - | ||||||||||||||||||
| 607 | delta++; | - | ||||||||||||||||||
| 608 | } never executed: end of block | 0 | ||||||||||||||||||
| 609 | - | |||||||||||||||||||
| 610 | ras.area += (TArea)ONE_PIXEL * delta; | - | ||||||||||||||||||
| 611 | ras.cover += delta; | - | ||||||||||||||||||
| 612 | y1 += delta; | - | ||||||||||||||||||
| 613 | ex1 += incr; | - | ||||||||||||||||||
| 614 | gray_set_cell( RAS_VAR_ ex1, ey ); | - | ||||||||||||||||||
| 615 | } never executed: end of block | 0 | ||||||||||||||||||
| 616 | } never executed: end of block | 0 | ||||||||||||||||||
| 617 | - | |||||||||||||||||||
| 618 | delta = y2 - y1; | - | ||||||||||||||||||
| 619 | ras.area += (TArea)( fx2 + ONE_PIXEL - first ) * delta; | - | ||||||||||||||||||
| 620 | ras.cover += delta; | - | ||||||||||||||||||
| 621 | } never executed: end of block | 0 | ||||||||||||||||||
| 622 | - | |||||||||||||||||||
| 623 | - | |||||||||||||||||||
| 624 | /*************************************************************************/ | - | ||||||||||||||||||
| 625 | /* */ | - | ||||||||||||||||||
| 626 | /* Render a given line as a series of scanlines. */ | - | ||||||||||||||||||
| 627 | /* */ | - | ||||||||||||||||||
| 628 | static void | - | ||||||||||||||||||
| 629 | gray_render_line( RAS_ARG_ TPos to_x, | - | ||||||||||||||||||
| 630 | TPos to_y ) | - | ||||||||||||||||||
| 631 | { | - | ||||||||||||||||||
| 632 | TCoord ey1, ey2, fy1, fy2; | - | ||||||||||||||||||
| 633 | TPos dx, dy, x, x2; | - | ||||||||||||||||||
| 634 | int p, first; | - | ||||||||||||||||||
| 635 | int delta, rem, mod, lift, incr; | - | ||||||||||||||||||
| 636 | - | |||||||||||||||||||
| 637 | - | |||||||||||||||||||
| 638 | ey1 = TRUNC( ras.last_ey ); | - | ||||||||||||||||||
| 639 | ey2 = TRUNC( to_y ); /* if (ey2 >= ras.max_ey) ey2 = ras.max_ey-1; */ | - | ||||||||||||||||||
| 640 | fy1 = (TCoord)( ras.y - ras.last_ey ); | - | ||||||||||||||||||
| 641 | fy2 = (TCoord)( to_y - SUBPIXELS( ey2 ) ); | - | ||||||||||||||||||
| 642 | - | |||||||||||||||||||
| 643 | dx = to_x - ras.x; | - | ||||||||||||||||||
| 644 | dy = to_y - ras.y; | - | ||||||||||||||||||
| 645 | - | |||||||||||||||||||
| 646 | /* XXX: we should do something about the trivial case where dx == 0, */ | - | ||||||||||||||||||
| 647 | /* as it happens very often! */ | - | ||||||||||||||||||
| 648 | - | |||||||||||||||||||
| 649 | /* perform vertical clipping */ | - | ||||||||||||||||||
| 650 | { | - | ||||||||||||||||||
| 651 | TCoord min, max; | - | ||||||||||||||||||
| 652 | - | |||||||||||||||||||
| 653 | - | |||||||||||||||||||
| 654 | min = ey1; | - | ||||||||||||||||||
| 655 | max = ey2; | - | ||||||||||||||||||
| 656 | if ( ey1 > ey2 )
| 0 | ||||||||||||||||||
| 657 | { | - | ||||||||||||||||||
| 658 | min = ey2; | - | ||||||||||||||||||
| 659 | max = ey1; | - | ||||||||||||||||||
| 660 | } never executed: end of block | 0 | ||||||||||||||||||
| 661 | if ( min >= ras.max_ey || max < ras.min_ey )
| 0 | ||||||||||||||||||
| 662 | goto End; never executed: goto End; | 0 | ||||||||||||||||||
| 663 | } | - | ||||||||||||||||||
| 664 | - | |||||||||||||||||||
| 665 | /* everything is on a single scanline */ | - | ||||||||||||||||||
| 666 | if ( ey1 == ey2 )
| 0 | ||||||||||||||||||
| 667 | { | - | ||||||||||||||||||
| 668 | gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, to_x, fy2 ); | - | ||||||||||||||||||
| 669 | goto End; never executed: goto End; | 0 | ||||||||||||||||||
| 670 | } | - | ||||||||||||||||||
| 671 | - | |||||||||||||||||||
| 672 | /* vertical line - avoid calling gray_render_scanline */ | - | ||||||||||||||||||
| 673 | if ( dx == 0 )
| 0 | ||||||||||||||||||
| 674 | { | - | ||||||||||||||||||
| 675 | TCoord ex = TRUNC( ras.x ); | - | ||||||||||||||||||
| 676 | TCoord two_fx = (TCoord)( ( ras.x - SUBPIXELS( ex ) ) << 1 ); | - | ||||||||||||||||||
| 677 | TPos area, max_ey1; | - | ||||||||||||||||||
| 678 | - | |||||||||||||||||||
| 679 | - | |||||||||||||||||||
| 680 | first = ONE_PIXEL; | - | ||||||||||||||||||
| 681 | if ( dy < 0 )
| 0 | ||||||||||||||||||
| 682 | first = 0; never executed: first = 0; | 0 | ||||||||||||||||||
| 683 | - | |||||||||||||||||||
| 684 | delta = (int)( first - fy1 ); | - | ||||||||||||||||||
| 685 | ras.area += (TArea)two_fx * delta; | - | ||||||||||||||||||
| 686 | ras.cover += delta; | - | ||||||||||||||||||
| 687 | - | |||||||||||||||||||
| 688 | delta = (int)( first + first - ONE_PIXEL ); | - | ||||||||||||||||||
| 689 | area = (TArea)two_fx * delta; | - | ||||||||||||||||||
| 690 | max_ey1 = ras.count_ey + ras.min_ey; | - | ||||||||||||||||||
| 691 | if (dy < 0) {
| 0 | ||||||||||||||||||
| 692 | if (ey1 > max_ey1) {
| 0 | ||||||||||||||||||
| 693 | ey1 = (max_ey1 > ey2) ? max_ey1 : ey2;
| 0 | ||||||||||||||||||
| 694 | gray_set_cell( &ras, ex, ey1 ); | - | ||||||||||||||||||
| 695 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 696 | ey1--; | - | ||||||||||||||||||
| 697 | gray_set_cell( &ras, ex, ey1 ); | - | ||||||||||||||||||
| 698 | } never executed: end of block | 0 | ||||||||||||||||||
| 699 | while ( ey1 > ey2 && ey1 >= ras.min_ey)
| 0 | ||||||||||||||||||
| 700 | { | - | ||||||||||||||||||
| 701 | ras.area += area; | - | ||||||||||||||||||
| 702 | ras.cover += delta; | - | ||||||||||||||||||
| 703 | ey1--; | - | ||||||||||||||||||
| 704 | - | |||||||||||||||||||
| 705 | gray_set_cell( &ras, ex, ey1 ); | - | ||||||||||||||||||
| 706 | } never executed: end of block | 0 | ||||||||||||||||||
| 707 | if (ey1 != ey2) {
| 0 | ||||||||||||||||||
| 708 | ey1 = ey2; | - | ||||||||||||||||||
| 709 | gray_set_cell( &ras, ex, ey1 ); | - | ||||||||||||||||||
| 710 | } never executed: end of block | 0 | ||||||||||||||||||
| 711 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 712 | if (ey1 < ras.min_ey) {
| 0 | ||||||||||||||||||
| 713 | ey1 = (ras.min_ey < ey2) ? ras.min_ey : ey2;
| 0 | ||||||||||||||||||
| 714 | gray_set_cell( &ras, ex, ey1 ); | - | ||||||||||||||||||
| 715 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 716 | ey1++; | - | ||||||||||||||||||
| 717 | gray_set_cell( &ras, ex, ey1 ); | - | ||||||||||||||||||
| 718 | } never executed: end of block | 0 | ||||||||||||||||||
| 719 | while ( ey1 < ey2 && ey1 < max_ey1)
| 0 | ||||||||||||||||||
| 720 | { | - | ||||||||||||||||||
| 721 | ras.area += area; | - | ||||||||||||||||||
| 722 | ras.cover += delta; | - | ||||||||||||||||||
| 723 | ey1++; | - | ||||||||||||||||||
| 724 | - | |||||||||||||||||||
| 725 | gray_set_cell( &ras, ex, ey1 ); | - | ||||||||||||||||||
| 726 | } never executed: end of block | 0 | ||||||||||||||||||
| 727 | if (ey1 != ey2) {
| 0 | ||||||||||||||||||
| 728 | ey1 = ey2; | - | ||||||||||||||||||
| 729 | gray_set_cell( &ras, ex, ey1 ); | - | ||||||||||||||||||
| 730 | } never executed: end of block | 0 | ||||||||||||||||||
| 731 | } never executed: end of block | 0 | ||||||||||||||||||
| 732 | - | |||||||||||||||||||
| 733 | delta = (int)( fy2 - ONE_PIXEL + first ); | - | ||||||||||||||||||
| 734 | ras.area += (TArea)two_fx * delta; | - | ||||||||||||||||||
| 735 | ras.cover += delta; | - | ||||||||||||||||||
| 736 | - | |||||||||||||||||||
| 737 | goto End; never executed: goto End; | 0 | ||||||||||||||||||
| 738 | } | - | ||||||||||||||||||
| 739 | - | |||||||||||||||||||
| 740 | /* ok, we have to render several scanlines */ | - | ||||||||||||||||||
| 741 | p = ( ONE_PIXEL - fy1 ) * dx; | - | ||||||||||||||||||
| 742 | first = ONE_PIXEL; | - | ||||||||||||||||||
| 743 | incr = 1; | - | ||||||||||||||||||
| 744 | - | |||||||||||||||||||
| 745 | if ( dy < 0 )
| 0 | ||||||||||||||||||
| 746 | { | - | ||||||||||||||||||
| 747 | p = fy1 * dx; | - | ||||||||||||||||||
| 748 | first = 0; | - | ||||||||||||||||||
| 749 | incr = -1; | - | ||||||||||||||||||
| 750 | dy = -dy; | - | ||||||||||||||||||
| 751 | } never executed: end of block | 0 | ||||||||||||||||||
| 752 | - | |||||||||||||||||||
| 753 | delta = (int)( p / dy ); | - | ||||||||||||||||||
| 754 | mod = (int)( p % dy ); | - | ||||||||||||||||||
| 755 | if ( mod < 0 )
| 0 | ||||||||||||||||||
| 756 | { | - | ||||||||||||||||||
| 757 | delta--; | - | ||||||||||||||||||
| 758 | mod += (TCoord)dy; | - | ||||||||||||||||||
| 759 | } never executed: end of block | 0 | ||||||||||||||||||
| 760 | - | |||||||||||||||||||
| 761 | x = ras.x + delta; | - | ||||||||||||||||||
| 762 | gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, x, (TCoord)first ); | - | ||||||||||||||||||
| 763 | - | |||||||||||||||||||
| 764 | ey1 += incr; | - | ||||||||||||||||||
| 765 | gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 ); | - | ||||||||||||||||||
| 766 | - | |||||||||||||||||||
| 767 | if ( ey1 != ey2 )
| 0 | ||||||||||||||||||
| 768 | { | - | ||||||||||||||||||
| 769 | p = ONE_PIXEL * dx; | - | ||||||||||||||||||
| 770 | lift = (int)( p / dy ); | - | ||||||||||||||||||
| 771 | rem = (int)( p % dy ); | - | ||||||||||||||||||
| 772 | if ( rem < 0 )
| 0 | ||||||||||||||||||
| 773 | { | - | ||||||||||||||||||
| 774 | lift--; | - | ||||||||||||||||||
| 775 | rem += (int)dy; | - | ||||||||||||||||||
| 776 | } never executed: end of block | 0 | ||||||||||||||||||
| 777 | mod -= (int)dy; | - | ||||||||||||||||||
| 778 | - | |||||||||||||||||||
| 779 | while ( ey1 != ey2 )
| 0 | ||||||||||||||||||
| 780 | { | - | ||||||||||||||||||
| 781 | delta = lift; | - | ||||||||||||||||||
| 782 | mod += rem; | - | ||||||||||||||||||
| 783 | if ( mod >= 0 )
| 0 | ||||||||||||||||||
| 784 | { | - | ||||||||||||||||||
| 785 | mod -= (int)dy; | - | ||||||||||||||||||
| 786 | delta++; | - | ||||||||||||||||||
| 787 | } never executed: end of block | 0 | ||||||||||||||||||
| 788 | - | |||||||||||||||||||
| 789 | x2 = x + delta; | - | ||||||||||||||||||
| 790 | gray_render_scanline( RAS_VAR_ ey1, x, | - | ||||||||||||||||||
| 791 | (TCoord)( ONE_PIXEL - first ), x2, | - | ||||||||||||||||||
| 792 | (TCoord)first ); | - | ||||||||||||||||||
| 793 | x = x2; | - | ||||||||||||||||||
| 794 | - | |||||||||||||||||||
| 795 | ey1 += incr; | - | ||||||||||||||||||
| 796 | gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 ); | - | ||||||||||||||||||
| 797 | } never executed: end of block | 0 | ||||||||||||||||||
| 798 | } never executed: end of block | 0 | ||||||||||||||||||
| 799 | - | |||||||||||||||||||
| 800 | gray_render_scanline( RAS_VAR_ ey1, x, | - | ||||||||||||||||||
| 801 | (TCoord)( ONE_PIXEL - first ), to_x, | - | ||||||||||||||||||
| 802 | fy2 ); | - | ||||||||||||||||||
| 803 | - | |||||||||||||||||||
| 804 | End: code before this statement never executed: End: | 0 | ||||||||||||||||||
| 805 | ras.x = to_x; | - | ||||||||||||||||||
| 806 | ras.y = to_y; | - | ||||||||||||||||||
| 807 | ras.last_ey = SUBPIXELS( ey2 ); | - | ||||||||||||||||||
| 808 | } never executed: end of block | 0 | ||||||||||||||||||
| 809 | - | |||||||||||||||||||
| 810 | - | |||||||||||||||||||
| 811 | static void | - | ||||||||||||||||||
| 812 | gray_split_conic( QT_FT_Vector* base ) | - | ||||||||||||||||||
| 813 | { | - | ||||||||||||||||||
| 814 | TPos a, b; | - | ||||||||||||||||||
| 815 | - | |||||||||||||||||||
| 816 | - | |||||||||||||||||||
| 817 | base[4].x = base[2].x; | - | ||||||||||||||||||
| 818 | b = base[1].x; | - | ||||||||||||||||||
| 819 | a = base[3].x = ( base[2].x + b ) / 2; | - | ||||||||||||||||||
| 820 | b = base[1].x = ( base[0].x + b ) / 2; | - | ||||||||||||||||||
| 821 | base[2].x = ( a + b ) / 2; | - | ||||||||||||||||||
| 822 | - | |||||||||||||||||||
| 823 | base[4].y = base[2].y; | - | ||||||||||||||||||
| 824 | b = base[1].y; | - | ||||||||||||||||||
| 825 | a = base[3].y = ( base[2].y + b ) / 2; | - | ||||||||||||||||||
| 826 | b = base[1].y = ( base[0].y + b ) / 2; | - | ||||||||||||||||||
| 827 | base[2].y = ( a + b ) / 2; | - | ||||||||||||||||||
| 828 | } never executed: end of block | 0 | ||||||||||||||||||
| 829 | - | |||||||||||||||||||
| 830 | - | |||||||||||||||||||
| 831 | static void | - | ||||||||||||||||||
| 832 | gray_render_conic( RAS_ARG_ const QT_FT_Vector* control, | - | ||||||||||||||||||
| 833 | const QT_FT_Vector* to ) | - | ||||||||||||||||||
| 834 | { | - | ||||||||||||||||||
| 835 | TPos dx, dy; | - | ||||||||||||||||||
| 836 | int top, level; | - | ||||||||||||||||||
| 837 | int* levels; | - | ||||||||||||||||||
| 838 | QT_FT_Vector* arc; | - | ||||||||||||||||||
| 839 | - | |||||||||||||||||||
| 840 | - | |||||||||||||||||||
| 841 | dx = DOWNSCALE( ras.x ) + to->x - ( control->x << 1 ); | - | ||||||||||||||||||
| 842 | if ( dx < 0 )
| 0 | ||||||||||||||||||
| 843 | dx = -dx; never executed: dx = -dx; | 0 | ||||||||||||||||||
| 844 | dy = DOWNSCALE( ras.y ) + to->y - ( control->y << 1 ); | - | ||||||||||||||||||
| 845 | if ( dy < 0 )
| 0 | ||||||||||||||||||
| 846 | dy = -dy; never executed: dy = -dy; | 0 | ||||||||||||||||||
| 847 | if ( dx < dy )
| 0 | ||||||||||||||||||
| 848 | dx = dy; never executed: dx = dy; | 0 | ||||||||||||||||||
| 849 | - | |||||||||||||||||||
| 850 | level = 1; | - | ||||||||||||||||||
| 851 | dx = dx / ras.conic_level; | - | ||||||||||||||||||
| 852 | while ( dx > 0 )
| 0 | ||||||||||||||||||
| 853 | { | - | ||||||||||||||||||
| 854 | dx >>= 2; | - | ||||||||||||||||||
| 855 | level++; | - | ||||||||||||||||||
| 856 | } never executed: end of block | 0 | ||||||||||||||||||
| 857 | - | |||||||||||||||||||
| 858 | /* a shortcut to speed things up */ | - | ||||||||||||||||||
| 859 | if ( level <= 1 )
| 0 | ||||||||||||||||||
| 860 | { | - | ||||||||||||||||||
| 861 | /* we compute the mid-point directly in order to avoid */ | - | ||||||||||||||||||
| 862 | /* calling gray_split_conic() */ | - | ||||||||||||||||||
| 863 | TPos to_x, to_y, mid_x, mid_y; | - | ||||||||||||||||||
| 864 | - | |||||||||||||||||||
| 865 | - | |||||||||||||||||||
| 866 | to_x = UPSCALE( to->x ); | - | ||||||||||||||||||
| 867 | to_y = UPSCALE( to->y ); | - | ||||||||||||||||||
| 868 | mid_x = ( ras.x + to_x + 2 * UPSCALE( control->x ) ) / 4; | - | ||||||||||||||||||
| 869 | mid_y = ( ras.y + to_y + 2 * UPSCALE( control->y ) ) / 4; | - | ||||||||||||||||||
| 870 | - | |||||||||||||||||||
| 871 | gray_render_line( RAS_VAR_ mid_x, mid_y ); | - | ||||||||||||||||||
| 872 | gray_render_line( RAS_VAR_ to_x, to_y ); | - | ||||||||||||||||||
| 873 | - | |||||||||||||||||||
| 874 | return; never executed: return; | 0 | ||||||||||||||||||
| 875 | } | - | ||||||||||||||||||
| 876 | - | |||||||||||||||||||
| 877 | arc = ras.bez_stack; | - | ||||||||||||||||||
| 878 | levels = ras.lev_stack; | - | ||||||||||||||||||
| 879 | top = 0; | - | ||||||||||||||||||
| 880 | levels[0] = level; | - | ||||||||||||||||||
| 881 | - | |||||||||||||||||||
| 882 | arc[0].x = UPSCALE( to->x ); | - | ||||||||||||||||||
| 883 | arc[0].y = UPSCALE( to->y ); | - | ||||||||||||||||||
| 884 | arc[1].x = UPSCALE( control->x ); | - | ||||||||||||||||||
| 885 | arc[1].y = UPSCALE( control->y ); | - | ||||||||||||||||||
| 886 | arc[2].x = ras.x; | - | ||||||||||||||||||
| 887 | arc[2].y = ras.y; | - | ||||||||||||||||||
| 888 | - | |||||||||||||||||||
| 889 | while ( top >= 0 )
| 0 | ||||||||||||||||||
| 890 | { | - | ||||||||||||||||||
| 891 | level = levels[top]; | - | ||||||||||||||||||
| 892 | if ( level > 1 )
| 0 | ||||||||||||||||||
| 893 | { | - | ||||||||||||||||||
| 894 | /* check that the arc crosses the current band */ | - | ||||||||||||||||||
| 895 | TPos min, max, y; | - | ||||||||||||||||||
| 896 | - | |||||||||||||||||||
| 897 | - | |||||||||||||||||||
| 898 | min = max = arc[0].y; | - | ||||||||||||||||||
| 899 | - | |||||||||||||||||||
| 900 | y = arc[1].y; | - | ||||||||||||||||||
| 901 | if ( y < min ) min = y; never executed: min = y;
| 0 | ||||||||||||||||||
| 902 | if ( y > max ) max = y; never executed: max = y;
| 0 | ||||||||||||||||||
| 903 | - | |||||||||||||||||||
| 904 | y = arc[2].y; | - | ||||||||||||||||||
| 905 | if ( y < min ) min = y; never executed: min = y;
| 0 | ||||||||||||||||||
| 906 | if ( y > max ) max = y; never executed: max = y;
| 0 | ||||||||||||||||||
| 907 | - | |||||||||||||||||||
| 908 | if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey )
| 0 | ||||||||||||||||||
| 909 | goto Draw; never executed: goto Draw; | 0 | ||||||||||||||||||
| 910 | - | |||||||||||||||||||
| 911 | gray_split_conic( arc ); | - | ||||||||||||||||||
| 912 | arc += 2; | - | ||||||||||||||||||
| 913 | top++; | - | ||||||||||||||||||
| 914 | levels[top] = levels[top - 1] = level - 1; | - | ||||||||||||||||||
| 915 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 916 | } | - | ||||||||||||||||||
| 917 | - | |||||||||||||||||||
| 918 | Draw: code before this statement never executed: Draw: | 0 | ||||||||||||||||||
| 919 | { | - | ||||||||||||||||||
| 920 | TPos to_x, to_y, mid_x, mid_y; | - | ||||||||||||||||||
| 921 | - | |||||||||||||||||||
| 922 | - | |||||||||||||||||||
| 923 | to_x = arc[0].x; | - | ||||||||||||||||||
| 924 | to_y = arc[0].y; | - | ||||||||||||||||||
| 925 | mid_x = ( ras.x + to_x + 2 * arc[1].x ) / 4; | - | ||||||||||||||||||
| 926 | mid_y = ( ras.y + to_y + 2 * arc[1].y ) / 4; | - | ||||||||||||||||||
| 927 | - | |||||||||||||||||||
| 928 | gray_render_line( RAS_VAR_ mid_x, mid_y ); | - | ||||||||||||||||||
| 929 | gray_render_line( RAS_VAR_ to_x, to_y ); | - | ||||||||||||||||||
| 930 | - | |||||||||||||||||||
| 931 | top--; | - | ||||||||||||||||||
| 932 | arc -= 2; | - | ||||||||||||||||||
| 933 | } | - | ||||||||||||||||||
| 934 | } never executed: end of block | 0 | ||||||||||||||||||
| 935 | - | |||||||||||||||||||
| 936 | return; never executed: return; | 0 | ||||||||||||||||||
| 937 | } | - | ||||||||||||||||||
| 938 | - | |||||||||||||||||||
| 939 | - | |||||||||||||||||||
| 940 | static void | - | ||||||||||||||||||
| 941 | gray_split_cubic( QT_FT_Vector* base ) | - | ||||||||||||||||||
| 942 | { | - | ||||||||||||||||||
| 943 | TPos a, b, c, d; | - | ||||||||||||||||||
| 944 | - | |||||||||||||||||||
| 945 | - | |||||||||||||||||||
| 946 | base[6].x = base[3].x; | - | ||||||||||||||||||
| 947 | c = base[1].x; | - | ||||||||||||||||||
| 948 | d = base[2].x; | - | ||||||||||||||||||
| 949 | base[1].x = a = ( base[0].x + c ) / 2; | - | ||||||||||||||||||
| 950 | base[5].x = b = ( base[3].x + d ) / 2; | - | ||||||||||||||||||
| 951 | c = ( c + d ) / 2; | - | ||||||||||||||||||
| 952 | base[2].x = a = ( a + c ) / 2; | - | ||||||||||||||||||
| 953 | base[4].x = b = ( b + c ) / 2; | - | ||||||||||||||||||
| 954 | base[3].x = ( a + b ) / 2; | - | ||||||||||||||||||
| 955 | - | |||||||||||||||||||
| 956 | base[6].y = base[3].y; | - | ||||||||||||||||||
| 957 | c = base[1].y; | - | ||||||||||||||||||
| 958 | d = base[2].y; | - | ||||||||||||||||||
| 959 | base[1].y = a = ( base[0].y + c ) / 2; | - | ||||||||||||||||||
| 960 | base[5].y = b = ( base[3].y + d ) / 2; | - | ||||||||||||||||||
| 961 | c = ( c + d ) / 2; | - | ||||||||||||||||||
| 962 | base[2].y = a = ( a + c ) / 2; | - | ||||||||||||||||||
| 963 | base[4].y = b = ( b + c ) / 2; | - | ||||||||||||||||||
| 964 | base[3].y = ( a + b ) / 2; | - | ||||||||||||||||||
| 965 | } never executed: end of block | 0 | ||||||||||||||||||
| 966 | - | |||||||||||||||||||
| 967 | - | |||||||||||||||||||
| 968 | static void | - | ||||||||||||||||||
| 969 | gray_render_cubic( RAS_ARG_ const QT_FT_Vector* control1, | - | ||||||||||||||||||
| 970 | const QT_FT_Vector* control2, | - | ||||||||||||||||||
| 971 | const QT_FT_Vector* to ) | - | ||||||||||||||||||
| 972 | { | - | ||||||||||||||||||
| 973 | TPos dx, dy, da, db; | - | ||||||||||||||||||
| 974 | int top, level; | - | ||||||||||||||||||
| 975 | int* levels; | - | ||||||||||||||||||
| 976 | QT_FT_Vector* arc; | - | ||||||||||||||||||
| 977 | - | |||||||||||||||||||
| 978 | - | |||||||||||||||||||
| 979 | dx = DOWNSCALE( ras.x ) + to->x - ( control1->x << 1 ); | - | ||||||||||||||||||
| 980 | if ( dx < 0 )
| 0 | ||||||||||||||||||
| 981 | dx = -dx; never executed: dx = -dx; | 0 | ||||||||||||||||||
| 982 | dy = DOWNSCALE( ras.y ) + to->y - ( control1->y << 1 ); | - | ||||||||||||||||||
| 983 | if ( dy < 0 )
| 0 | ||||||||||||||||||
| 984 | dy = -dy; never executed: dy = -dy; | 0 | ||||||||||||||||||
| 985 | if ( dx < dy )
| 0 | ||||||||||||||||||
| 986 | dx = dy; never executed: dx = dy; | 0 | ||||||||||||||||||
| 987 | da = dx; | - | ||||||||||||||||||
| 988 | - | |||||||||||||||||||
| 989 | dx = DOWNSCALE( ras.x ) + to->x - 3 * ( control1->x + control2->x ); | - | ||||||||||||||||||
| 990 | if ( dx < 0 )
| 0 | ||||||||||||||||||
| 991 | dx = -dx; never executed: dx = -dx; | 0 | ||||||||||||||||||
| 992 | dy = DOWNSCALE( ras.y ) + to->y - 3 * ( control1->y + control2->y ); | - | ||||||||||||||||||
| 993 | if ( dy < 0 )
| 0 | ||||||||||||||||||
| 994 | dy = -dy; never executed: dy = -dy; | 0 | ||||||||||||||||||
| 995 | if ( dx < dy )
| 0 | ||||||||||||||||||
| 996 | dx = dy; never executed: dx = dy; | 0 | ||||||||||||||||||
| 997 | db = dx; | - | ||||||||||||||||||
| 998 | - | |||||||||||||||||||
| 999 | level = 1; | - | ||||||||||||||||||
| 1000 | da = da / ras.cubic_level; | - | ||||||||||||||||||
| 1001 | db = db / ras.conic_level; | - | ||||||||||||||||||
| 1002 | while ( da > 0 || db > 0 )
| 0 | ||||||||||||||||||
| 1003 | { | - | ||||||||||||||||||
| 1004 | da >>= 2; | - | ||||||||||||||||||
| 1005 | db >>= 3; | - | ||||||||||||||||||
| 1006 | level++; | - | ||||||||||||||||||
| 1007 | } never executed: end of block | 0 | ||||||||||||||||||
| 1008 | - | |||||||||||||||||||
| 1009 | if ( level <= 1 )
| 0 | ||||||||||||||||||
| 1010 | { | - | ||||||||||||||||||
| 1011 | TPos to_x, to_y, mid_x, mid_y; | - | ||||||||||||||||||
| 1012 | - | |||||||||||||||||||
| 1013 | - | |||||||||||||||||||
| 1014 | to_x = UPSCALE( to->x ); | - | ||||||||||||||||||
| 1015 | to_y = UPSCALE( to->y ); | - | ||||||||||||||||||
| 1016 | mid_x = ( ras.x + to_x + | - | ||||||||||||||||||
| 1017 | 3 * UPSCALE( control1->x + control2->x ) ) / 8; | - | ||||||||||||||||||
| 1018 | mid_y = ( ras.y + to_y + | - | ||||||||||||||||||
| 1019 | 3 * UPSCALE( control1->y + control2->y ) ) / 8; | - | ||||||||||||||||||
| 1020 | - | |||||||||||||||||||
| 1021 | gray_render_line( RAS_VAR_ mid_x, mid_y ); | - | ||||||||||||||||||
| 1022 | gray_render_line( RAS_VAR_ to_x, to_y ); | - | ||||||||||||||||||
| 1023 | return; never executed: return; | 0 | ||||||||||||||||||
| 1024 | } | - | ||||||||||||||||||
| 1025 | - | |||||||||||||||||||
| 1026 | arc = ras.bez_stack; | - | ||||||||||||||||||
| 1027 | arc[0].x = UPSCALE( to->x ); | - | ||||||||||||||||||
| 1028 | arc[0].y = UPSCALE( to->y ); | - | ||||||||||||||||||
| 1029 | arc[1].x = UPSCALE( control2->x ); | - | ||||||||||||||||||
| 1030 | arc[1].y = UPSCALE( control2->y ); | - | ||||||||||||||||||
| 1031 | arc[2].x = UPSCALE( control1->x ); | - | ||||||||||||||||||
| 1032 | arc[2].y = UPSCALE( control1->y ); | - | ||||||||||||||||||
| 1033 | arc[3].x = ras.x; | - | ||||||||||||||||||
| 1034 | arc[3].y = ras.y; | - | ||||||||||||||||||
| 1035 | - | |||||||||||||||||||
| 1036 | levels = ras.lev_stack; | - | ||||||||||||||||||
| 1037 | top = 0; | - | ||||||||||||||||||
| 1038 | levels[0] = level; | - | ||||||||||||||||||
| 1039 | - | |||||||||||||||||||
| 1040 | while ( top >= 0 )
| 0 | ||||||||||||||||||
| 1041 | { | - | ||||||||||||||||||
| 1042 | level = levels[top]; | - | ||||||||||||||||||
| 1043 | if ( level > 1 )
| 0 | ||||||||||||||||||
| 1044 | { | - | ||||||||||||||||||
| 1045 | /* check that the arc crosses the current band */ | - | ||||||||||||||||||
| 1046 | TPos min, max, y; | - | ||||||||||||||||||
| 1047 | - | |||||||||||||||||||
| 1048 | - | |||||||||||||||||||
| 1049 | min = max = arc[0].y; | - | ||||||||||||||||||
| 1050 | y = arc[1].y; | - | ||||||||||||||||||
| 1051 | if ( y < min ) min = y; never executed: min = y;
| 0 | ||||||||||||||||||
| 1052 | if ( y > max ) max = y; never executed: max = y;
| 0 | ||||||||||||||||||
| 1053 | y = arc[2].y; | - | ||||||||||||||||||
| 1054 | if ( y < min ) min = y; never executed: min = y;
| 0 | ||||||||||||||||||
| 1055 | if ( y > max ) max = y; never executed: max = y;
| 0 | ||||||||||||||||||
| 1056 | y = arc[3].y; | - | ||||||||||||||||||
| 1057 | if ( y < min ) min = y; never executed: min = y;
| 0 | ||||||||||||||||||
| 1058 | if ( y > max ) max = y; never executed: max = y;
| 0 | ||||||||||||||||||
| 1059 | if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < 0 )
| 0 | ||||||||||||||||||
| 1060 | goto Draw; never executed: goto Draw; | 0 | ||||||||||||||||||
| 1061 | gray_split_cubic( arc ); | - | ||||||||||||||||||
| 1062 | arc += 3; | - | ||||||||||||||||||
| 1063 | top ++; | - | ||||||||||||||||||
| 1064 | levels[top] = levels[top - 1] = level - 1; | - | ||||||||||||||||||
| 1065 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 1066 | } | - | ||||||||||||||||||
| 1067 | - | |||||||||||||||||||
| 1068 | Draw: code before this statement never executed: Draw: | 0 | ||||||||||||||||||
| 1069 | { | - | ||||||||||||||||||
| 1070 | TPos to_x, to_y, mid_x, mid_y; | - | ||||||||||||||||||
| 1071 | - | |||||||||||||||||||
| 1072 | - | |||||||||||||||||||
| 1073 | to_x = arc[0].x; | - | ||||||||||||||||||
| 1074 | to_y = arc[0].y; | - | ||||||||||||||||||
| 1075 | mid_x = ( ras.x + to_x + 3 * ( arc[1].x + arc[2].x ) ) / 8; | - | ||||||||||||||||||
| 1076 | mid_y = ( ras.y + to_y + 3 * ( arc[1].y + arc[2].y ) ) / 8; | - | ||||||||||||||||||
| 1077 | - | |||||||||||||||||||
| 1078 | gray_render_line( RAS_VAR_ mid_x, mid_y ); | - | ||||||||||||||||||
| 1079 | gray_render_line( RAS_VAR_ to_x, to_y ); | - | ||||||||||||||||||
| 1080 | top --; | - | ||||||||||||||||||
| 1081 | arc -= 3; | - | ||||||||||||||||||
| 1082 | } | - | ||||||||||||||||||
| 1083 | } never executed: end of block | 0 | ||||||||||||||||||
| 1084 | - | |||||||||||||||||||
| 1085 | return; never executed: return; | 0 | ||||||||||||||||||
| 1086 | } | - | ||||||||||||||||||
| 1087 | - | |||||||||||||||||||
| 1088 | - | |||||||||||||||||||
| 1089 | - | |||||||||||||||||||
| 1090 | static int | - | ||||||||||||||||||
| 1091 | gray_move_to( const QT_FT_Vector* to, | - | ||||||||||||||||||
| 1092 | PWorker worker ) | - | ||||||||||||||||||
| 1093 | { | - | ||||||||||||||||||
| 1094 | TPos x, y; | - | ||||||||||||||||||
| 1095 | - | |||||||||||||||||||
| 1096 | - | |||||||||||||||||||
| 1097 | /* record current cell, if any */ | - | ||||||||||||||||||
| 1098 | gray_record_cell( worker ); | - | ||||||||||||||||||
| 1099 | - | |||||||||||||||||||
| 1100 | /* start to a new position */ | - | ||||||||||||||||||
| 1101 | x = UPSCALE( to->x ); | - | ||||||||||||||||||
| 1102 | y = UPSCALE( to->y ); | - | ||||||||||||||||||
| 1103 | - | |||||||||||||||||||
| 1104 | gray_start_cell( worker, TRUNC( x ), TRUNC( y ) ); | - | ||||||||||||||||||
| 1105 | - | |||||||||||||||||||
| 1106 | worker->x = x; | - | ||||||||||||||||||
| 1107 | worker->y = y; | - | ||||||||||||||||||
| 1108 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 1109 | } | - | ||||||||||||||||||
| 1110 | - | |||||||||||||||||||
| 1111 | static void | - | ||||||||||||||||||
| 1112 | gray_render_span( int count, | - | ||||||||||||||||||
| 1113 | const QT_FT_Span* spans, | - | ||||||||||||||||||
| 1114 | PWorker worker ) | - | ||||||||||||||||||
| 1115 | { | - | ||||||||||||||||||
| 1116 | unsigned char* p; | - | ||||||||||||||||||
| 1117 | QT_FT_Bitmap* map = &worker->target; | - | ||||||||||||||||||
| 1118 | - | |||||||||||||||||||
| 1119 | for ( ; count > 0; count--, spans++ )
| 0 | ||||||||||||||||||
| 1120 | { | - | ||||||||||||||||||
| 1121 | unsigned char coverage = spans->coverage; | - | ||||||||||||||||||
| 1122 | - | |||||||||||||||||||
| 1123 | /* first of all, compute the scanline offset */ | - | ||||||||||||||||||
| 1124 | p = (unsigned char*)map->buffer - spans->y * map->pitch; | - | ||||||||||||||||||
| 1125 | if ( map->pitch >= 0 )
| 0 | ||||||||||||||||||
| 1126 | p += ( map->rows - 1 ) * map->pitch; never executed: p += ( map->rows - 1 ) * map->pitch; | 0 | ||||||||||||||||||
| 1127 | - | |||||||||||||||||||
| 1128 | - | |||||||||||||||||||
| 1129 | if ( coverage )
| 0 | ||||||||||||||||||
| 1130 | { | - | ||||||||||||||||||
| 1131 | /* For small-spans it is faster to do it by ourselves than | - | ||||||||||||||||||
| 1132 | * calling `memset'. This is mainly due to the cost of the | - | ||||||||||||||||||
| 1133 | * function call. | - | ||||||||||||||||||
| 1134 | */ | - | ||||||||||||||||||
| 1135 | if ( spans->len >= 8 )
| 0 | ||||||||||||||||||
| 1136 | QT_FT_MEM_SET( p + spans->x, (unsigned char)coverage, spans->len ); never executed: memset( p + spans->x, (unsigned char)coverage, spans->len ); | 0 | ||||||||||||||||||
| 1137 | else | - | ||||||||||||||||||
| 1138 | { | - | ||||||||||||||||||
| 1139 | unsigned char* q = p + spans->x; | - | ||||||||||||||||||
| 1140 | - | |||||||||||||||||||
| 1141 | - | |||||||||||||||||||
| 1142 | switch ( spans->len ) | - | ||||||||||||||||||
| 1143 | { | - | ||||||||||||||||||
| 1144 | case 7: *q++ = (unsigned char)coverage; never executed: case 7: | 0 | ||||||||||||||||||
| 1145 | case 6: *q++ = (unsigned char)coverage; code before this statement never executed: case 6:never executed: case 6: | 0 | ||||||||||||||||||
| 1146 | case 5: *q++ = (unsigned char)coverage; code before this statement never executed: case 5:never executed: case 5: | 0 | ||||||||||||||||||
| 1147 | case 4: *q++ = (unsigned char)coverage; code before this statement never executed: case 4:never executed: case 4: | 0 | ||||||||||||||||||
| 1148 | case 3: *q++ = (unsigned char)coverage; code before this statement never executed: case 3:never executed: case 3: | 0 | ||||||||||||||||||
| 1149 | case 2: *q++ = (unsigned char)coverage; code before this statement never executed: case 2:never executed: case 2: | 0 | ||||||||||||||||||
| 1150 | case 1: *q = (unsigned char)coverage; code before this statement never executed: case 1:never executed: case 1: | 0 | ||||||||||||||||||
| 1151 | default: code before this statement never executed: default:never executed: default: | 0 | ||||||||||||||||||
| 1152 | ; | - | ||||||||||||||||||
| 1153 | } never executed: end of block | 0 | ||||||||||||||||||
| 1154 | } | - | ||||||||||||||||||
| 1155 | } | - | ||||||||||||||||||
| 1156 | } never executed: end of block | 0 | ||||||||||||||||||
| 1157 | } never executed: end of block | 0 | ||||||||||||||||||
| 1158 | - | |||||||||||||||||||
| 1159 | - | |||||||||||||||||||
| 1160 | static void | - | ||||||||||||||||||
| 1161 | gray_hline( RAS_ARG_ TCoord x, | - | ||||||||||||||||||
| 1162 | TCoord y, | - | ||||||||||||||||||
| 1163 | TPos area, | - | ||||||||||||||||||
| 1164 | int acount ) | - | ||||||||||||||||||
| 1165 | { | - | ||||||||||||||||||
| 1166 | QT_FT_Span* span; | - | ||||||||||||||||||
| 1167 | int coverage; | - | ||||||||||||||||||
| 1168 | int skip; | - | ||||||||||||||||||
| 1169 | - | |||||||||||||||||||
| 1170 | - | |||||||||||||||||||
| 1171 | /* compute the coverage line's coverage, depending on the */ | - | ||||||||||||||||||
| 1172 | /* outline fill rule */ | - | ||||||||||||||||||
| 1173 | /* */ | - | ||||||||||||||||||
| 1174 | /* the coverage percentage is area/(PIXEL_BITS*PIXEL_BITS*2) */ | - | ||||||||||||||||||
| 1175 | /* */ | - | ||||||||||||||||||
| 1176 | coverage = (int)( area >> ( PIXEL_BITS * 2 + 1 - 8 ) ); | - | ||||||||||||||||||
| 1177 | /* use range 0..256 */ | - | ||||||||||||||||||
| 1178 | if ( coverage < 0 )
| 0 | ||||||||||||||||||
| 1179 | coverage = -coverage; never executed: coverage = -coverage; | 0 | ||||||||||||||||||
| 1180 | - | |||||||||||||||||||
| 1181 | if ( ras.outline.flags & QT_FT_OUTLINE_EVEN_ODD_FILL )
| 0 | ||||||||||||||||||
| 1182 | { | - | ||||||||||||||||||
| 1183 | coverage &= 511; | - | ||||||||||||||||||
| 1184 | - | |||||||||||||||||||
| 1185 | if ( coverage > 256 )
| 0 | ||||||||||||||||||
| 1186 | coverage = 512 - coverage; never executed: coverage = 512 - coverage; | 0 | ||||||||||||||||||
| 1187 | else if ( coverage == 256 )
| 0 | ||||||||||||||||||
| 1188 | coverage = 255; never executed: coverage = 255; | 0 | ||||||||||||||||||
| 1189 | } never executed: end of block | 0 | ||||||||||||||||||
| 1190 | else | - | ||||||||||||||||||
| 1191 | { | - | ||||||||||||||||||
| 1192 | /* normal non-zero winding rule */ | - | ||||||||||||||||||
| 1193 | if ( coverage >= 256 )
| 0 | ||||||||||||||||||
| 1194 | coverage = 255; never executed: coverage = 255; | 0 | ||||||||||||||||||
| 1195 | } never executed: end of block | 0 | ||||||||||||||||||
| 1196 | - | |||||||||||||||||||
| 1197 | y += (TCoord)ras.min_ey; | - | ||||||||||||||||||
| 1198 | x += (TCoord)ras.min_ex; | - | ||||||||||||||||||
| 1199 | - | |||||||||||||||||||
| 1200 | /* QT_FT_Span.x is a 16-bit short, so limit our coordinates appropriately */ | - | ||||||||||||||||||
| 1201 | if ( x >= 32768 )
| 0 | ||||||||||||||||||
| 1202 | x = 32767; never executed: x = 32767; | 0 | ||||||||||||||||||
| 1203 | - | |||||||||||||||||||
| 1204 | if ( coverage )
| 0 | ||||||||||||||||||
| 1205 | { | - | ||||||||||||||||||
| 1206 | /* see whether we can add this span to the current list */ | - | ||||||||||||||||||
| 1207 | span = ras.gray_spans + ras.num_gray_spans - 1; | - | ||||||||||||||||||
| 1208 | if ( ras.num_gray_spans > 0 &&
| 0 | ||||||||||||||||||
| 1209 | span->y == y &&
| 0 | ||||||||||||||||||
| 1210 | (int)span->x + span->len == (int)x &&
| 0 | ||||||||||||||||||
| 1211 | span->coverage == coverage )
| 0 | ||||||||||||||||||
| 1212 | { | - | ||||||||||||||||||
| 1213 | span->len = (unsigned short)( span->len + acount ); | - | ||||||||||||||||||
| 1214 | return; never executed: return; | 0 | ||||||||||||||||||
| 1215 | } | - | ||||||||||||||||||
| 1216 | - | |||||||||||||||||||
| 1217 | if ( ras.num_gray_spans >= QT_FT_MAX_GRAY_SPANS )
| 0 | ||||||||||||||||||
| 1218 | { | - | ||||||||||||||||||
| 1219 | if ( ras.render_span && ras.num_gray_spans > ras.skip_spans )
| 0 | ||||||||||||||||||
| 1220 | { | - | ||||||||||||||||||
| 1221 | skip = ras.skip_spans > 0 ? ras.skip_spans : 0;
| 0 | ||||||||||||||||||
| 1222 | ras.render_span( ras.num_gray_spans - skip, | - | ||||||||||||||||||
| 1223 | ras.gray_spans + skip, | - | ||||||||||||||||||
| 1224 | ras.render_span_data ); | - | ||||||||||||||||||
| 1225 | } never executed: end of block | 0 | ||||||||||||||||||
| 1226 | - | |||||||||||||||||||
| 1227 | ras.skip_spans -= ras.num_gray_spans; | - | ||||||||||||||||||
| 1228 | - | |||||||||||||||||||
| 1229 | /* ras.render_span( span->y, ras.gray_spans, count ); */ | - | ||||||||||||||||||
| 1230 | - | |||||||||||||||||||
| 1231 | #ifdef DEBUG_GRAYS | - | ||||||||||||||||||
| 1232 | - | |||||||||||||||||||
| 1233 | if ( 1 ) | - | ||||||||||||||||||
| 1234 | { | - | ||||||||||||||||||
| 1235 | int n; | - | ||||||||||||||||||
| 1236 | - | |||||||||||||||||||
| 1237 | - | |||||||||||||||||||
| 1238 | fprintf( stderr, "y=%3d ", y ); | - | ||||||||||||||||||
| 1239 | span = ras.gray_spans; | - | ||||||||||||||||||
| 1240 | for ( n = 0; n < count; n++, span++ ) | - | ||||||||||||||||||
| 1241 | fprintf( stderr, "[%d..%d]:%02x ", | - | ||||||||||||||||||
| 1242 | span->x, span->x + span->len - 1, span->coverage ); | - | ||||||||||||||||||
| 1243 | fprintf( stderr, "\n" ); | - | ||||||||||||||||||
| 1244 | } | - | ||||||||||||||||||
| 1245 | - | |||||||||||||||||||
| 1246 | #endif /* DEBUG_GRAYS */ | - | ||||||||||||||||||
| 1247 | - | |||||||||||||||||||
| 1248 | ras.num_gray_spans = 0; | - | ||||||||||||||||||
| 1249 | - | |||||||||||||||||||
| 1250 | span = ras.gray_spans; | - | ||||||||||||||||||
| 1251 | } never executed: end of block | 0 | ||||||||||||||||||
| 1252 | else | - | ||||||||||||||||||
| 1253 | span++; never executed: span++; | 0 | ||||||||||||||||||
| 1254 | - | |||||||||||||||||||
| 1255 | /* add a gray span to the current list */ | - | ||||||||||||||||||
| 1256 | span->x = (short)x; | - | ||||||||||||||||||
| 1257 | span->len = (unsigned short)acount; | - | ||||||||||||||||||
| 1258 | span->y = (short)y; | - | ||||||||||||||||||
| 1259 | span->coverage = (unsigned char)coverage; | - | ||||||||||||||||||
| 1260 | - | |||||||||||||||||||
| 1261 | ras.num_gray_spans++; | - | ||||||||||||||||||
| 1262 | } never executed: end of block | 0 | ||||||||||||||||||
| 1263 | } never executed: end of block | 0 | ||||||||||||||||||
| 1264 | - | |||||||||||||||||||
| 1265 | - | |||||||||||||||||||
| 1266 | #ifdef DEBUG_GRAYS | - | ||||||||||||||||||
| 1267 | - | |||||||||||||||||||
| 1268 | /* to be called while in the debugger */ | - | ||||||||||||||||||
| 1269 | gray_dump_cells( RAS_ARG ) | - | ||||||||||||||||||
| 1270 | { | - | ||||||||||||||||||
| 1271 | int yindex; | - | ||||||||||||||||||
| 1272 | - | |||||||||||||||||||
| 1273 | - | |||||||||||||||||||
| 1274 | for ( yindex = 0; yindex < ras.ycount; yindex++ ) | - | ||||||||||||||||||
| 1275 | { | - | ||||||||||||||||||
| 1276 | PCell cell; | - | ||||||||||||||||||
| 1277 | - | |||||||||||||||||||
| 1278 | - | |||||||||||||||||||
| 1279 | printf( "%3d:", yindex ); | - | ||||||||||||||||||
| 1280 | - | |||||||||||||||||||
| 1281 | for ( cell = ras.ycells[yindex]; cell != NULL; cell = cell->next ) | - | ||||||||||||||||||
| 1282 | printf( " (%3d, c:%4d, a:%6d)", cell->x, cell->cover, cell->area ); | - | ||||||||||||||||||
| 1283 | printf( "\n" ); | - | ||||||||||||||||||
| 1284 | } | - | ||||||||||||||||||
| 1285 | } | - | ||||||||||||||||||
| 1286 | - | |||||||||||||||||||
| 1287 | #endif /* DEBUG_GRAYS */ | - | ||||||||||||||||||
| 1288 | - | |||||||||||||||||||
| 1289 | - | |||||||||||||||||||
| 1290 | static void | - | ||||||||||||||||||
| 1291 | gray_sweep( RAS_ARG_ const QT_FT_Bitmap* target ) | - | ||||||||||||||||||
| 1292 | { | - | ||||||||||||||||||
| 1293 | int yindex; | - | ||||||||||||||||||
| 1294 | - | |||||||||||||||||||
| 1295 | QT_FT_UNUSED( target ); | - | ||||||||||||||||||
| 1296 | - | |||||||||||||||||||
| 1297 | - | |||||||||||||||||||
| 1298 | if ( ras.num_cells == 0 )
| 0 | ||||||||||||||||||
| 1299 | return; never executed: return; | 0 | ||||||||||||||||||
| 1300 | - | |||||||||||||||||||
| 1301 | for ( yindex = 0; yindex < ras.ycount; yindex++ )
| 0 | ||||||||||||||||||
| 1302 | { | - | ||||||||||||||||||
| 1303 | PCell cell = ras.ycells[yindex]; | - | ||||||||||||||||||
| 1304 | TCoord cover = 0; | - | ||||||||||||||||||
| 1305 | TCoord x = 0; | - | ||||||||||||||||||
| 1306 | - | |||||||||||||||||||
| 1307 | - | |||||||||||||||||||
| 1308 | for ( ; cell != NULL; cell = cell->next )
| 0 | ||||||||||||||||||
| 1309 | { | - | ||||||||||||||||||
| 1310 | TArea area; | - | ||||||||||||||||||
| 1311 | - | |||||||||||||||||||
| 1312 | - | |||||||||||||||||||
| 1313 | if ( cell->x > x && cover != 0 )
| 0 | ||||||||||||||||||
| 1314 | gray_hline( RAS_VAR_ x, yindex, cover * ( ONE_PIXEL * 2 ), never executed: gray_hline( worker, x, yindex, cover * ( ( 1L << 8 ) * 2 ), cell->x - x ); | 0 | ||||||||||||||||||
| 1315 | cell->x - x ); never executed: gray_hline( worker, x, yindex, cover * ( ( 1L << 8 ) * 2 ), cell->x - x ); | 0 | ||||||||||||||||||
| 1316 | - | |||||||||||||||||||
| 1317 | cover += cell->cover; | - | ||||||||||||||||||
| 1318 | area = cover * ( ONE_PIXEL * 2 ) - cell->area; | - | ||||||||||||||||||
| 1319 | - | |||||||||||||||||||
| 1320 | if ( area != 0 && cell->x >= 0 )
| 0 | ||||||||||||||||||
| 1321 | gray_hline( RAS_VAR_ cell->x, yindex, area, 1 ); never executed: gray_hline( worker, cell->x, yindex, area, 1 ); | 0 | ||||||||||||||||||
| 1322 | - | |||||||||||||||||||
| 1323 | x = cell->x + 1; | - | ||||||||||||||||||
| 1324 | } never executed: end of block | 0 | ||||||||||||||||||
| 1325 | - | |||||||||||||||||||
| 1326 | if ( ras.count_ex > x && cover != 0 )
| 0 | ||||||||||||||||||
| 1327 | gray_hline( RAS_VAR_ x, yindex, cover * ( ONE_PIXEL * 2 ), never executed: gray_hline( worker, x, yindex, cover * ( ( 1L << 8 ) * 2 ), (*worker).count_ex - x ); | 0 | ||||||||||||||||||
| 1328 | ras.count_ex - x ); never executed: gray_hline( worker, x, yindex, cover * ( ( 1L << 8 ) * 2 ), (*worker).count_ex - x ); | 0 | ||||||||||||||||||
| 1329 | } never executed: end of block | 0 | ||||||||||||||||||
| 1330 | } never executed: end of block | 0 | ||||||||||||||||||
| 1331 | - | |||||||||||||||||||
| 1332 | /*************************************************************************/ | - | ||||||||||||||||||
| 1333 | /* */ | - | ||||||||||||||||||
| 1334 | /* The following function should only compile in stand_alone mode, */ | - | ||||||||||||||||||
| 1335 | /* i.e., when building this component without the rest of FreeType. */ | - | ||||||||||||||||||
| 1336 | /* */ | - | ||||||||||||||||||
| 1337 | /*************************************************************************/ | - | ||||||||||||||||||
| 1338 | - | |||||||||||||||||||
| 1339 | /*************************************************************************/ | - | ||||||||||||||||||
| 1340 | /* */ | - | ||||||||||||||||||
| 1341 | /* <Function> */ | - | ||||||||||||||||||
| 1342 | /* QT_FT_Outline_Decompose */ | - | ||||||||||||||||||
| 1343 | /* */ | - | ||||||||||||||||||
| 1344 | /* <Description> */ | - | ||||||||||||||||||
| 1345 | /* Walks over an outline's structure to decompose it into individual */ | - | ||||||||||||||||||
| 1346 | /* segments and Bezier arcs. This function is also able to emit */ | - | ||||||||||||||||||
| 1347 | /* `move to' and `close to' operations to indicate the start and end */ | - | ||||||||||||||||||
| 1348 | /* of new contours in the outline. */ | - | ||||||||||||||||||
| 1349 | /* */ | - | ||||||||||||||||||
| 1350 | /* <Input> */ | - | ||||||||||||||||||
| 1351 | /* outline :: A pointer to the source target. */ | - | ||||||||||||||||||
| 1352 | /* */ | - | ||||||||||||||||||
| 1353 | /* user :: A typeless pointer which is passed to each */ | - | ||||||||||||||||||
| 1354 | /* emitter during the decomposition. It can be */ | - | ||||||||||||||||||
| 1355 | /* used to store the state during the */ | - | ||||||||||||||||||
| 1356 | /* decomposition. */ | - | ||||||||||||||||||
| 1357 | /* */ | - | ||||||||||||||||||
| 1358 | /* <Return> */ | - | ||||||||||||||||||
| 1359 | /* Error code. 0 means success. */ | - | ||||||||||||||||||
| 1360 | /* */ | - | ||||||||||||||||||
| 1361 | static | - | ||||||||||||||||||
| 1362 | int QT_FT_Outline_Decompose( const QT_FT_Outline* outline, | - | ||||||||||||||||||
| 1363 | void* user ) | - | ||||||||||||||||||
| 1364 | { | - | ||||||||||||||||||
| 1365 | #undef SCALED | - | ||||||||||||||||||
| 1366 | #define SCALED( x ) (x) | - | ||||||||||||||||||
| 1367 | - | |||||||||||||||||||
| 1368 | QT_FT_Vector v_last; | - | ||||||||||||||||||
| 1369 | QT_FT_Vector v_control; | - | ||||||||||||||||||
| 1370 | QT_FT_Vector v_start; | - | ||||||||||||||||||
| 1371 | - | |||||||||||||||||||
| 1372 | QT_FT_Vector* point; | - | ||||||||||||||||||
| 1373 | QT_FT_Vector* limit; | - | ||||||||||||||||||
| 1374 | char* tags; | - | ||||||||||||||||||
| 1375 | - | |||||||||||||||||||
| 1376 | int n; /* index of contour in outline */ | - | ||||||||||||||||||
| 1377 | int first; /* index of first point in contour */ | - | ||||||||||||||||||
| 1378 | int error; | - | ||||||||||||||||||
| 1379 | char tag; /* current point's state */ | - | ||||||||||||||||||
| 1380 | - | |||||||||||||||||||
| 1381 | first = 0; | - | ||||||||||||||||||
| 1382 | - | |||||||||||||||||||
| 1383 | for ( n = 0; n < outline->n_contours; n++ )
| 0 | ||||||||||||||||||
| 1384 | { | - | ||||||||||||||||||
| 1385 | int last; /* index of last point in contour */ | - | ||||||||||||||||||
| 1386 | - | |||||||||||||||||||
| 1387 | - | |||||||||||||||||||
| 1388 | last = outline->contours[n]; | - | ||||||||||||||||||
| 1389 | limit = outline->points + last; | - | ||||||||||||||||||
| 1390 | - | |||||||||||||||||||
| 1391 | v_start = outline->points[first]; | - | ||||||||||||||||||
| 1392 | v_last = outline->points[last]; | - | ||||||||||||||||||
| 1393 | - | |||||||||||||||||||
| 1394 | v_start.x = SCALED( v_start.x ); | - | ||||||||||||||||||
| 1395 | v_start.y = SCALED( v_start.y ); | - | ||||||||||||||||||
| 1396 | - | |||||||||||||||||||
| 1397 | v_last.x = SCALED( v_last.x ); | - | ||||||||||||||||||
| 1398 | v_last.y = SCALED( v_last.y ); | - | ||||||||||||||||||
| 1399 | - | |||||||||||||||||||
| 1400 | v_control = v_start; | - | ||||||||||||||||||
| 1401 | - | |||||||||||||||||||
| 1402 | point = outline->points + first; | - | ||||||||||||||||||
| 1403 | tags = outline->tags + first; | - | ||||||||||||||||||
| 1404 | tag = QT_FT_CURVE_TAG( tags[0] ); | - | ||||||||||||||||||
| 1405 | - | |||||||||||||||||||
| 1406 | /* A contour cannot start with a cubic control point! */ | - | ||||||||||||||||||
| 1407 | if ( tag == QT_FT_CURVE_TAG_CUBIC )
| 0 | ||||||||||||||||||
| 1408 | goto Invalid_Outline; never executed: goto Invalid_Outline; | 0 | ||||||||||||||||||
| 1409 | - | |||||||||||||||||||
| 1410 | /* check first point to determine origin */ | - | ||||||||||||||||||
| 1411 | if ( tag == QT_FT_CURVE_TAG_CONIC )
| 0 | ||||||||||||||||||
| 1412 | { | - | ||||||||||||||||||
| 1413 | /* first point is conic control. Yes, this happens. */ | - | ||||||||||||||||||
| 1414 | if ( QT_FT_CURVE_TAG( outline->tags[last] ) == QT_FT_CURVE_TAG_ON )
| 0 | ||||||||||||||||||
| 1415 | { | - | ||||||||||||||||||
| 1416 | /* start at last point if it is on the curve */ | - | ||||||||||||||||||
| 1417 | v_start = v_last; | - | ||||||||||||||||||
| 1418 | limit--; | - | ||||||||||||||||||
| 1419 | } never executed: end of block | 0 | ||||||||||||||||||
| 1420 | else | - | ||||||||||||||||||
| 1421 | { | - | ||||||||||||||||||
| 1422 | /* if both first and last points are conic, */ | - | ||||||||||||||||||
| 1423 | /* start at their middle and record its position */ | - | ||||||||||||||||||
| 1424 | /* for closure */ | - | ||||||||||||||||||
| 1425 | v_start.x = ( v_start.x + v_last.x ) / 2; | - | ||||||||||||||||||
| 1426 | v_start.y = ( v_start.y + v_last.y ) / 2; | - | ||||||||||||||||||
| 1427 | - | |||||||||||||||||||
| 1428 | v_last = v_start; | - | ||||||||||||||||||
| 1429 | } never executed: end of block | 0 | ||||||||||||||||||
| 1430 | point--; | - | ||||||||||||||||||
| 1431 | tags--; | - | ||||||||||||||||||
| 1432 | } never executed: end of block | 0 | ||||||||||||||||||
| 1433 | - | |||||||||||||||||||
| 1434 | error = gray_move_to( &v_start, user ); | - | ||||||||||||||||||
| 1435 | if ( error )
| 0 | ||||||||||||||||||
| 1436 | goto Exit; never executed: goto Exit; | 0 | ||||||||||||||||||
| 1437 | - | |||||||||||||||||||
| 1438 | while ( point < limit )
| 0 | ||||||||||||||||||
| 1439 | { | - | ||||||||||||||||||
| 1440 | point++; | - | ||||||||||||||||||
| 1441 | tags++; | - | ||||||||||||||||||
| 1442 | - | |||||||||||||||||||
| 1443 | tag = QT_FT_CURVE_TAG( tags[0] ); | - | ||||||||||||||||||
| 1444 | switch ( tag ) | - | ||||||||||||||||||
| 1445 | { | - | ||||||||||||||||||
| 1446 | case QT_FT_CURVE_TAG_ON: /* emit a single line_to */ never executed: case 1: | 0 | ||||||||||||||||||
| 1447 | { | - | ||||||||||||||||||
| 1448 | QT_FT_Vector vec; | - | ||||||||||||||||||
| 1449 | - | |||||||||||||||||||
| 1450 | - | |||||||||||||||||||
| 1451 | vec.x = SCALED( point->x ); | - | ||||||||||||||||||
| 1452 | vec.y = SCALED( point->y ); | - | ||||||||||||||||||
| 1453 | - | |||||||||||||||||||
| 1454 | gray_render_line(user, UPSCALE(vec.x), UPSCALE(vec.y)); | - | ||||||||||||||||||
| 1455 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 1456 | } | - | ||||||||||||||||||
| 1457 | - | |||||||||||||||||||
| 1458 | case QT_FT_CURVE_TAG_CONIC: /* consume conic arcs */ never executed: case 0: | 0 | ||||||||||||||||||
| 1459 | { | - | ||||||||||||||||||
| 1460 | v_control.x = SCALED( point->x ); | - | ||||||||||||||||||
| 1461 | v_control.y = SCALED( point->y ); | - | ||||||||||||||||||
| 1462 | - | |||||||||||||||||||
| 1463 | Do_Conic: code before this statement never executed: Do_Conic: | 0 | ||||||||||||||||||
| 1464 | if ( point < limit )
| 0 | ||||||||||||||||||
| 1465 | { | - | ||||||||||||||||||
| 1466 | QT_FT_Vector vec; | - | ||||||||||||||||||
| 1467 | QT_FT_Vector v_middle; | - | ||||||||||||||||||
| 1468 | - | |||||||||||||||||||
| 1469 | - | |||||||||||||||||||
| 1470 | point++; | - | ||||||||||||||||||
| 1471 | tags++; | - | ||||||||||||||||||
| 1472 | tag = QT_FT_CURVE_TAG( tags[0] ); | - | ||||||||||||||||||
| 1473 | - | |||||||||||||||||||
| 1474 | vec.x = SCALED( point->x ); | - | ||||||||||||||||||
| 1475 | vec.y = SCALED( point->y ); | - | ||||||||||||||||||
| 1476 | - | |||||||||||||||||||
| 1477 | if ( tag == QT_FT_CURVE_TAG_ON )
| 0 | ||||||||||||||||||
| 1478 | { | - | ||||||||||||||||||
| 1479 | gray_render_conic(user, &v_control, &vec); | - | ||||||||||||||||||
| 1480 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 1481 | } | - | ||||||||||||||||||
| 1482 | - | |||||||||||||||||||
| 1483 | if ( tag != QT_FT_CURVE_TAG_CONIC )
| 0 | ||||||||||||||||||
| 1484 | goto Invalid_Outline; never executed: goto Invalid_Outline; | 0 | ||||||||||||||||||
| 1485 | - | |||||||||||||||||||
| 1486 | v_middle.x = ( v_control.x + vec.x ) / 2; | - | ||||||||||||||||||
| 1487 | v_middle.y = ( v_control.y + vec.y ) / 2; | - | ||||||||||||||||||
| 1488 | - | |||||||||||||||||||
| 1489 | gray_render_conic(user, &v_control, &v_middle); | - | ||||||||||||||||||
| 1490 | v_control = vec; | - | ||||||||||||||||||
| 1491 | goto Do_Conic; never executed: goto Do_Conic; | 0 | ||||||||||||||||||
| 1492 | } | - | ||||||||||||||||||
| 1493 | - | |||||||||||||||||||
| 1494 | gray_render_conic(user, &v_control, &v_start); | - | ||||||||||||||||||
| 1495 | goto Close; never executed: goto Close; | 0 | ||||||||||||||||||
| 1496 | } | - | ||||||||||||||||||
| 1497 | - | |||||||||||||||||||
| 1498 | default: /* QT_FT_CURVE_TAG_CUBIC */ never executed: default: | 0 | ||||||||||||||||||
| 1499 | { | - | ||||||||||||||||||
| 1500 | QT_FT_Vector vec1, vec2; | - | ||||||||||||||||||
| 1501 | - | |||||||||||||||||||
| 1502 | - | |||||||||||||||||||
| 1503 | if ( point + 1 > limit ||
| 0 | ||||||||||||||||||
| 1504 | QT_FT_CURVE_TAG( tags[1] ) != QT_FT_CURVE_TAG_CUBIC )
| 0 | ||||||||||||||||||
| 1505 | goto Invalid_Outline; never executed: goto Invalid_Outline; | 0 | ||||||||||||||||||
| 1506 | - | |||||||||||||||||||
| 1507 | point += 2; | - | ||||||||||||||||||
| 1508 | tags += 2; | - | ||||||||||||||||||
| 1509 | - | |||||||||||||||||||
| 1510 | vec1.x = SCALED( point[-2].x ); | - | ||||||||||||||||||
| 1511 | vec1.y = SCALED( point[-2].y ); | - | ||||||||||||||||||
| 1512 | - | |||||||||||||||||||
| 1513 | vec2.x = SCALED( point[-1].x ); | - | ||||||||||||||||||
| 1514 | vec2.y = SCALED( point[-1].y ); | - | ||||||||||||||||||
| 1515 | - | |||||||||||||||||||
| 1516 | if ( point <= limit )
| 0 | ||||||||||||||||||
| 1517 | { | - | ||||||||||||||||||
| 1518 | QT_FT_Vector vec; | - | ||||||||||||||||||
| 1519 | - | |||||||||||||||||||
| 1520 | - | |||||||||||||||||||
| 1521 | vec.x = SCALED( point->x ); | - | ||||||||||||||||||
| 1522 | vec.y = SCALED( point->y ); | - | ||||||||||||||||||
| 1523 | - | |||||||||||||||||||
| 1524 | gray_render_cubic(user, &vec1, &vec2, &vec); | - | ||||||||||||||||||
| 1525 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 1526 | } | - | ||||||||||||||||||
| 1527 | - | |||||||||||||||||||
| 1528 | gray_render_cubic(user, &vec1, &vec2, &v_start); | - | ||||||||||||||||||
| 1529 | goto Close; never executed: goto Close; | 0 | ||||||||||||||||||
| 1530 | } | - | ||||||||||||||||||
| 1531 | } | - | ||||||||||||||||||
| 1532 | } | - | ||||||||||||||||||
| 1533 | - | |||||||||||||||||||
| 1534 | /* close the contour with a line segment */ | - | ||||||||||||||||||
| 1535 | gray_render_line(user, UPSCALE(v_start.x), UPSCALE(v_start.y)); | - | ||||||||||||||||||
| 1536 | - | |||||||||||||||||||
| 1537 | Close: code before this statement never executed: Close: | 0 | ||||||||||||||||||
| 1538 | first = last + 1; | - | ||||||||||||||||||
| 1539 | } never executed: end of block | 0 | ||||||||||||||||||
| 1540 | - | |||||||||||||||||||
| 1541 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 1542 | - | |||||||||||||||||||
| 1543 | Exit: | - | ||||||||||||||||||
| 1544 | return error; never executed: return error; | 0 | ||||||||||||||||||
| 1545 | - | |||||||||||||||||||
| 1546 | Invalid_Outline: | - | ||||||||||||||||||
| 1547 | return ErrRaster_Invalid_Outline; never executed: return -1; | 0 | ||||||||||||||||||
| 1548 | } | - | ||||||||||||||||||
| 1549 | - | |||||||||||||||||||
| 1550 | typedef struct TBand_ | - | ||||||||||||||||||
| 1551 | { | - | ||||||||||||||||||
| 1552 | TPos min, max; | - | ||||||||||||||||||
| 1553 | - | |||||||||||||||||||
| 1554 | } TBand; | - | ||||||||||||||||||
| 1555 | - | |||||||||||||||||||
| 1556 | - | |||||||||||||||||||
| 1557 | static int | - | ||||||||||||||||||
| 1558 | gray_convert_glyph_inner( RAS_ARG ) | - | ||||||||||||||||||
| 1559 | { | - | ||||||||||||||||||
| 1560 | volatile int error = 0; | - | ||||||||||||||||||
| 1561 | - | |||||||||||||||||||
| 1562 | if ( qt_ft_setjmp( ras.jump_buffer ) == 0 )
| 0 | ||||||||||||||||||
| 1563 | { | - | ||||||||||||||||||
| 1564 | error = QT_FT_Outline_Decompose( &ras.outline, &ras ); | - | ||||||||||||||||||
| 1565 | gray_record_cell( RAS_VAR ); | - | ||||||||||||||||||
| 1566 | } never executed: end of block | 0 | ||||||||||||||||||
| 1567 | else | - | ||||||||||||||||||
| 1568 | { | - | ||||||||||||||||||
| 1569 | error = ErrRaster_Memory_Overflow; | - | ||||||||||||||||||
| 1570 | } never executed: end of block | 0 | ||||||||||||||||||
| 1571 | - | |||||||||||||||||||
| 1572 | return error; never executed: return error; | 0 | ||||||||||||||||||
| 1573 | } | - | ||||||||||||||||||
| 1574 | - | |||||||||||||||||||
| 1575 | - | |||||||||||||||||||
| 1576 | static int | - | ||||||||||||||||||
| 1577 | gray_convert_glyph( RAS_ARG ) | - | ||||||||||||||||||
| 1578 | { | - | ||||||||||||||||||
| 1579 | TBand bands[40]; | - | ||||||||||||||||||
| 1580 | TBand* volatile band; | - | ||||||||||||||||||
| 1581 | int volatile n, num_bands; | - | ||||||||||||||||||
| 1582 | TPos volatile min, max, max_y; | - | ||||||||||||||||||
| 1583 | QT_FT_BBox* clip; | - | ||||||||||||||||||
| 1584 | int skip; | - | ||||||||||||||||||
| 1585 | - | |||||||||||||||||||
| 1586 | ras.num_gray_spans = 0; | - | ||||||||||||||||||
| 1587 | - | |||||||||||||||||||
| 1588 | /* Set up state in the raster object */ | - | ||||||||||||||||||
| 1589 | gray_compute_cbox( RAS_VAR ); | - | ||||||||||||||||||
| 1590 | - | |||||||||||||||||||
| 1591 | /* clip to target bitmap, exit if nothing to do */ | - | ||||||||||||||||||
| 1592 | clip = &ras.clip_box; | - | ||||||||||||||||||
| 1593 | - | |||||||||||||||||||
| 1594 | if ( ras.max_ex <= clip->xMin || ras.min_ex >= clip->xMax ||
| 0 | ||||||||||||||||||
| 1595 | ras.max_ey <= clip->yMin || ras.min_ey >= clip->yMax )
| 0 | ||||||||||||||||||
| 1596 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 1597 | - | |||||||||||||||||||
| 1598 | if ( ras.min_ex < clip->xMin ) ras.min_ex = clip->xMin; never executed: (*worker).min_ex = clip->xMin;
| 0 | ||||||||||||||||||
| 1599 | if ( ras.min_ey < clip->yMin ) ras.min_ey = clip->yMin; never executed: (*worker).min_ey = clip->yMin;
| 0 | ||||||||||||||||||
| 1600 | - | |||||||||||||||||||
| 1601 | if ( ras.max_ex > clip->xMax ) ras.max_ex = clip->xMax; never executed: (*worker).max_ex = clip->xMax;
| 0 | ||||||||||||||||||
| 1602 | if ( ras.max_ey > clip->yMax ) ras.max_ey = clip->yMax; never executed: (*worker).max_ey = clip->yMax;
| 0 | ||||||||||||||||||
| 1603 | - | |||||||||||||||||||
| 1604 | ras.count_ex = ras.max_ex - ras.min_ex; | - | ||||||||||||||||||
| 1605 | ras.count_ey = ras.max_ey - ras.min_ey; | - | ||||||||||||||||||
| 1606 | - | |||||||||||||||||||
| 1607 | /* simple heuristic used to speed-up the bezier decomposition -- see */ | - | ||||||||||||||||||
| 1608 | /* the code in gray_render_conic() and gray_render_cubic() for more */ | - | ||||||||||||||||||
| 1609 | /* details */ | - | ||||||||||||||||||
| 1610 | ras.conic_level = 32; | - | ||||||||||||||||||
| 1611 | ras.cubic_level = 16; | - | ||||||||||||||||||
| 1612 | - | |||||||||||||||||||
| 1613 | { | - | ||||||||||||||||||
| 1614 | int level = 0; | - | ||||||||||||||||||
| 1615 | - | |||||||||||||||||||
| 1616 | - | |||||||||||||||||||
| 1617 | if ( ras.count_ex > 24 || ras.count_ey > 24 )
| 0 | ||||||||||||||||||
| 1618 | level++; never executed: level++; | 0 | ||||||||||||||||||
| 1619 | if ( ras.count_ex > 120 || ras.count_ey > 120 )
| 0 | ||||||||||||||||||
| 1620 | level++; never executed: level++; | 0 | ||||||||||||||||||
| 1621 | - | |||||||||||||||||||
| 1622 | ras.conic_level <<= level; | - | ||||||||||||||||||
| 1623 | ras.cubic_level <<= level; | - | ||||||||||||||||||
| 1624 | } | - | ||||||||||||||||||
| 1625 | - | |||||||||||||||||||
| 1626 | /* setup vertical bands */ | - | ||||||||||||||||||
| 1627 | num_bands = (int)( ( ras.max_ey - ras.min_ey ) / ras.band_size ); | - | ||||||||||||||||||
| 1628 | if ( num_bands == 0 ) num_bands = 1; never executed: num_bands = 1;
| 0 | ||||||||||||||||||
| 1629 | if ( num_bands >= 39 ) num_bands = 39; never executed: num_bands = 39;
| 0 | ||||||||||||||||||
| 1630 | - | |||||||||||||||||||
| 1631 | ras.band_shoot = 0; | - | ||||||||||||||||||
| 1632 | - | |||||||||||||||||||
| 1633 | min = ras.min_ey; | - | ||||||||||||||||||
| 1634 | max_y = ras.max_ey; | - | ||||||||||||||||||
| 1635 | - | |||||||||||||||||||
| 1636 | for ( n = 0; n < num_bands; n++, min = max )
| 0 | ||||||||||||||||||
| 1637 | { | - | ||||||||||||||||||
| 1638 | max = min + ras.band_size; | - | ||||||||||||||||||
| 1639 | if ( n == num_bands - 1 || max > max_y )
| 0 | ||||||||||||||||||
| 1640 | max = max_y; never executed: max = max_y; | 0 | ||||||||||||||||||
| 1641 | - | |||||||||||||||||||
| 1642 | bands[0].min = min; | - | ||||||||||||||||||
| 1643 | bands[0].max = max; | - | ||||||||||||||||||
| 1644 | band = bands; | - | ||||||||||||||||||
| 1645 | - | |||||||||||||||||||
| 1646 | while ( band >= bands )
| 0 | ||||||||||||||||||
| 1647 | { | - | ||||||||||||||||||
| 1648 | TPos bottom, top, middle; | - | ||||||||||||||||||
| 1649 | int error; | - | ||||||||||||||||||
| 1650 | - | |||||||||||||||||||
| 1651 | { | - | ||||||||||||||||||
| 1652 | PCell cells_max; | - | ||||||||||||||||||
| 1653 | int yindex; | - | ||||||||||||||||||
| 1654 | int cell_start, cell_end, cell_mod; | - | ||||||||||||||||||
| 1655 | - | |||||||||||||||||||
| 1656 | - | |||||||||||||||||||
| 1657 | ras.ycells = (PCell*)ras.buffer; | - | ||||||||||||||||||
| 1658 | ras.ycount = band->max - band->min; | - | ||||||||||||||||||
| 1659 | - | |||||||||||||||||||
| 1660 | cell_start = sizeof ( PCell ) * ras.ycount; | - | ||||||||||||||||||
| 1661 | cell_mod = cell_start % sizeof ( TCell ); | - | ||||||||||||||||||
| 1662 | if ( cell_mod > 0 )
| 0 | ||||||||||||||||||
| 1663 | cell_start += sizeof ( TCell ) - cell_mod; never executed: cell_start += sizeof ( TCell ) - cell_mod; | 0 | ||||||||||||||||||
| 1664 | - | |||||||||||||||||||
| 1665 | cell_end = ras.buffer_size; | - | ||||||||||||||||||
| 1666 | cell_end -= cell_end % sizeof( TCell ); | - | ||||||||||||||||||
| 1667 | - | |||||||||||||||||||
| 1668 | cells_max = (PCell)( (char*)ras.buffer + cell_end ); | - | ||||||||||||||||||
| 1669 | ras.cells = (PCell)( (char*)ras.buffer + cell_start ); | - | ||||||||||||||||||
| 1670 | if ( ras.cells >= cells_max )
| 0 | ||||||||||||||||||
| 1671 | goto ReduceBands; never executed: goto ReduceBands; | 0 | ||||||||||||||||||
| 1672 | - | |||||||||||||||||||
| 1673 | ras.max_cells = (int)(cells_max - ras.cells); | - | ||||||||||||||||||
| 1674 | if ( ras.max_cells < 2 )
| 0 | ||||||||||||||||||
| 1675 | goto ReduceBands; never executed: goto ReduceBands; | 0 | ||||||||||||||||||
| 1676 | - | |||||||||||||||||||
| 1677 | for ( yindex = 0; yindex < ras.ycount; yindex++ )
| 0 | ||||||||||||||||||
| 1678 | ras.ycells[yindex] = NULL; never executed: (*worker).ycells[yindex] = ((void *)0); | 0 | ||||||||||||||||||
| 1679 | } | - | ||||||||||||||||||
| 1680 | - | |||||||||||||||||||
| 1681 | ras.num_cells = 0; | - | ||||||||||||||||||
| 1682 | ras.invalid = 1; | - | ||||||||||||||||||
| 1683 | ras.min_ey = band->min; | - | ||||||||||||||||||
| 1684 | ras.max_ey = band->max; | - | ||||||||||||||||||
| 1685 | ras.count_ey = band->max - band->min; | - | ||||||||||||||||||
| 1686 | - | |||||||||||||||||||
| 1687 | error = gray_convert_glyph_inner( RAS_VAR ); | - | ||||||||||||||||||
| 1688 | - | |||||||||||||||||||
| 1689 | if ( !error )
| 0 | ||||||||||||||||||
| 1690 | { | - | ||||||||||||||||||
| 1691 | gray_sweep( RAS_VAR_ &ras.target ); | - | ||||||||||||||||||
| 1692 | band--; | - | ||||||||||||||||||
| 1693 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 1694 | } | - | ||||||||||||||||||
| 1695 | else if ( error != ErrRaster_Memory_Overflow )
| 0 | ||||||||||||||||||
| 1696 | return 1; never executed: return 1; | 0 | ||||||||||||||||||
| 1697 | - | |||||||||||||||||||
| 1698 | ReduceBands: code before this statement never executed: ReduceBands: | 0 | ||||||||||||||||||
| 1699 | /* render pool overflow; we will reduce the render band by half */ | - | ||||||||||||||||||
| 1700 | bottom = band->min; | - | ||||||||||||||||||
| 1701 | top = band->max; | - | ||||||||||||||||||
| 1702 | middle = bottom + ( ( top - bottom ) >> 1 ); | - | ||||||||||||||||||
| 1703 | - | |||||||||||||||||||
| 1704 | /* This is too complex for a single scanline; there must */ | - | ||||||||||||||||||
| 1705 | /* be some problems. */ | - | ||||||||||||||||||
| 1706 | if ( middle == bottom )
| 0 | ||||||||||||||||||
| 1707 | { | - | ||||||||||||||||||
| 1708 | #ifdef DEBUG_GRAYS | - | ||||||||||||||||||
| 1709 | fprintf( stderr, "Rotten glyph!\n" ); | - | ||||||||||||||||||
| 1710 | #endif | - | ||||||||||||||||||
| 1711 | return ErrRaster_OutOfMemory; never executed: return -6; | 0 | ||||||||||||||||||
| 1712 | } | - | ||||||||||||||||||
| 1713 | - | |||||||||||||||||||
| 1714 | if ( bottom-top >= ras.band_size )
| 0 | ||||||||||||||||||
| 1715 | ras.band_shoot++; never executed: (*worker).band_shoot++; | 0 | ||||||||||||||||||
| 1716 | - | |||||||||||||||||||
| 1717 | band[1].min = bottom; | - | ||||||||||||||||||
| 1718 | band[1].max = middle; | - | ||||||||||||||||||
| 1719 | band[0].min = middle; | - | ||||||||||||||||||
| 1720 | band[0].max = top; | - | ||||||||||||||||||
| 1721 | band++; | - | ||||||||||||||||||
| 1722 | } never executed: end of block | 0 | ||||||||||||||||||
| 1723 | } never executed: end of block | 0 | ||||||||||||||||||
| 1724 | - | |||||||||||||||||||
| 1725 | if ( ras.render_span && ras.num_gray_spans > ras.skip_spans )
| 0 | ||||||||||||||||||
| 1726 | { | - | ||||||||||||||||||
| 1727 | skip = ras.skip_spans > 0 ? ras.skip_spans : 0;
| 0 | ||||||||||||||||||
| 1728 | ras.render_span( ras.num_gray_spans - skip, | - | ||||||||||||||||||
| 1729 | ras.gray_spans + skip, | - | ||||||||||||||||||
| 1730 | ras.render_span_data ); | - | ||||||||||||||||||
| 1731 | } never executed: end of block | 0 | ||||||||||||||||||
| 1732 | - | |||||||||||||||||||
| 1733 | ras.skip_spans -= ras.num_gray_spans; | - | ||||||||||||||||||
| 1734 | - | |||||||||||||||||||
| 1735 | if ( ras.band_shoot > 8 && ras.band_size > 16 )
| 0 | ||||||||||||||||||
| 1736 | ras.band_size = ras.band_size / 2; never executed: (*worker).band_size = (*worker).band_size / 2; | 0 | ||||||||||||||||||
| 1737 | - | |||||||||||||||||||
| 1738 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 1739 | } | - | ||||||||||||||||||
| 1740 | - | |||||||||||||||||||
| 1741 | - | |||||||||||||||||||
| 1742 | static int | - | ||||||||||||||||||
| 1743 | gray_raster_render( QT_FT_Raster raster, | - | ||||||||||||||||||
| 1744 | const QT_FT_Raster_Params* params ) | - | ||||||||||||||||||
| 1745 | { | - | ||||||||||||||||||
| 1746 | const QT_FT_Outline* outline = (const QT_FT_Outline*)params->source; | - | ||||||||||||||||||
| 1747 | const QT_FT_Bitmap* target_map = params->target; | - | ||||||||||||||||||
| 1748 | PWorker worker; | - | ||||||||||||||||||
| 1749 | - | |||||||||||||||||||
| 1750 | - | |||||||||||||||||||
| 1751 | if ( !raster || !raster->buffer || !raster->buffer_size )
| 0 | ||||||||||||||||||
| 1752 | return ErrRaster_Invalid_Argument; never executed: return -3; | 0 | ||||||||||||||||||
| 1753 | - | |||||||||||||||||||
| 1754 | if ( raster->worker )
| 0 | ||||||||||||||||||
| 1755 | raster->worker->skip_spans = params->skip_spans; never executed: raster->worker->skip_spans = params->skip_spans; | 0 | ||||||||||||||||||
| 1756 | - | |||||||||||||||||||
| 1757 | /* If raster object and raster buffer are allocated, but */ | - | ||||||||||||||||||
| 1758 | /* raster size isn't of the minimum size, indicate out of */ | - | ||||||||||||||||||
| 1759 | /* memory. */ | - | ||||||||||||||||||
| 1760 | if (raster->buffer_allocated_size < MINIMUM_POOL_SIZE )
| 0 | ||||||||||||||||||
| 1761 | return ErrRaster_OutOfMemory; never executed: return -6; | 0 | ||||||||||||||||||
| 1762 | - | |||||||||||||||||||
| 1763 | /* return immediately if the outline is empty */ | - | ||||||||||||||||||
| 1764 | if ( outline->n_points == 0 || outline->n_contours <= 0 )
| 0 | ||||||||||||||||||
| 1765 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 1766 | - | |||||||||||||||||||
| 1767 | if ( !outline || !outline->contours || !outline->points )
| 0 | ||||||||||||||||||
| 1768 | return ErrRaster_Invalid_Outline; never executed: return -1; | 0 | ||||||||||||||||||
| 1769 | - | |||||||||||||||||||
| 1770 | if ( outline->n_points !=
| 0 | ||||||||||||||||||
| 1771 | outline->contours[outline->n_contours - 1] + 1 )
| 0 | ||||||||||||||||||
| 1772 | return ErrRaster_Invalid_Outline; never executed: return -1; | 0 | ||||||||||||||||||
| 1773 | - | |||||||||||||||||||
| 1774 | worker = raster->worker; | - | ||||||||||||||||||
| 1775 | - | |||||||||||||||||||
| 1776 | /* if direct mode is not set, we must have a target bitmap */ | - | ||||||||||||||||||
| 1777 | if ( ( params->flags & QT_FT_RASTER_FLAG_DIRECT ) == 0 )
| 0 | ||||||||||||||||||
| 1778 | { | - | ||||||||||||||||||
| 1779 | if ( !target_map )
| 0 | ||||||||||||||||||
| 1780 | return ErrRaster_Invalid_Argument; never executed: return -3; | 0 | ||||||||||||||||||
| 1781 | - | |||||||||||||||||||
| 1782 | /* nothing to do */ | - | ||||||||||||||||||
| 1783 | if ( !target_map->width || !target_map->rows )
| 0 | ||||||||||||||||||
| 1784 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 1785 | - | |||||||||||||||||||
| 1786 | if ( !target_map->buffer )
| 0 | ||||||||||||||||||
| 1787 | return ErrRaster_Invalid_Argument; never executed: return -3; | 0 | ||||||||||||||||||
| 1788 | } never executed: end of block | 0 | ||||||||||||||||||
| 1789 | - | |||||||||||||||||||
| 1790 | /* this version does not support monochrome rendering */ | - | ||||||||||||||||||
| 1791 | if ( !( params->flags & QT_FT_RASTER_FLAG_AA ) )
| 0 | ||||||||||||||||||
| 1792 | return ErrRaster_Invalid_Mode; never executed: return -2; | 0 | ||||||||||||||||||
| 1793 | - | |||||||||||||||||||
| 1794 | /* compute clipping box */ | - | ||||||||||||||||||
| 1795 | if ( ( params->flags & QT_FT_RASTER_FLAG_DIRECT ) == 0 )
| 0 | ||||||||||||||||||
| 1796 | { | - | ||||||||||||||||||
| 1797 | /* compute clip box from target pixmap */ | - | ||||||||||||||||||
| 1798 | ras.clip_box.xMin = 0; | - | ||||||||||||||||||
| 1799 | ras.clip_box.yMin = 0; | - | ||||||||||||||||||
| 1800 | ras.clip_box.xMax = target_map->width; | - | ||||||||||||||||||
| 1801 | ras.clip_box.yMax = target_map->rows; | - | ||||||||||||||||||
| 1802 | } never executed: end of block | 0 | ||||||||||||||||||
| 1803 | else if ( params->flags & QT_FT_RASTER_FLAG_CLIP )
| 0 | ||||||||||||||||||
| 1804 | { | - | ||||||||||||||||||
| 1805 | ras.clip_box = params->clip_box; | - | ||||||||||||||||||
| 1806 | } never executed: end of block | 0 | ||||||||||||||||||
| 1807 | else | - | ||||||||||||||||||
| 1808 | { | - | ||||||||||||||||||
| 1809 | ras.clip_box.xMin = -32768L; | - | ||||||||||||||||||
| 1810 | ras.clip_box.yMin = -32768L; | - | ||||||||||||||||||
| 1811 | ras.clip_box.xMax = 32767L; | - | ||||||||||||||||||
| 1812 | ras.clip_box.yMax = 32767L; | - | ||||||||||||||||||
| 1813 | } never executed: end of block | 0 | ||||||||||||||||||
| 1814 | - | |||||||||||||||||||
| 1815 | gray_init_cells( worker, raster->buffer, raster->buffer_size ); | - | ||||||||||||||||||
| 1816 | - | |||||||||||||||||||
| 1817 | ras.outline = *outline; | - | ||||||||||||||||||
| 1818 | ras.num_cells = 0; | - | ||||||||||||||||||
| 1819 | ras.invalid = 1; | - | ||||||||||||||||||
| 1820 | ras.band_size = raster->band_size; | - | ||||||||||||||||||
| 1821 | - | |||||||||||||||||||
| 1822 | if ( target_map )
| 0 | ||||||||||||||||||
| 1823 | ras.target = *target_map; never executed: (*worker).target = *target_map; | 0 | ||||||||||||||||||
| 1824 | - | |||||||||||||||||||
| 1825 | ras.render_span = (QT_FT_Raster_Span_Func)gray_render_span; | - | ||||||||||||||||||
| 1826 | ras.render_span_data = &ras; | - | ||||||||||||||||||
| 1827 | - | |||||||||||||||||||
| 1828 | if ( params->flags & QT_FT_RASTER_FLAG_DIRECT )
| 0 | ||||||||||||||||||
| 1829 | { | - | ||||||||||||||||||
| 1830 | ras.render_span = (QT_FT_Raster_Span_Func)params->gray_spans; | - | ||||||||||||||||||
| 1831 | ras.render_span_data = params->user; | - | ||||||||||||||||||
| 1832 | } never executed: end of block | 0 | ||||||||||||||||||
| 1833 | - | |||||||||||||||||||
| 1834 | return gray_convert_glyph( worker ); never executed: return gray_convert_glyph( worker ); | 0 | ||||||||||||||||||
| 1835 | } | - | ||||||||||||||||||
| 1836 | - | |||||||||||||||||||
| 1837 | - | |||||||||||||||||||
| 1838 | /**** RASTER OBJECT CREATION: In standalone mode, we simply use *****/ | - | ||||||||||||||||||
| 1839 | /**** a static object. *****/ | - | ||||||||||||||||||
| 1840 | - | |||||||||||||||||||
| 1841 | static int | - | ||||||||||||||||||
| 1842 | gray_raster_new( QT_FT_Raster* araster ) | - | ||||||||||||||||||
| 1843 | { | - | ||||||||||||||||||
| 1844 | *araster = malloc(sizeof(TRaster)); | - | ||||||||||||||||||
| 1845 | if (!*araster) {
| 0 | ||||||||||||||||||
| 1846 | *araster = 0; | - | ||||||||||||||||||
| 1847 | return ErrRaster_Memory_Overflow; never executed: return -4; | 0 | ||||||||||||||||||
| 1848 | } | - | ||||||||||||||||||
| 1849 | QT_FT_MEM_ZERO(*araster, sizeof(TRaster)); | - | ||||||||||||||||||
| 1850 | - | |||||||||||||||||||
| 1851 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 1852 | } | - | ||||||||||||||||||
| 1853 | - | |||||||||||||||||||
| 1854 | - | |||||||||||||||||||
| 1855 | static void | - | ||||||||||||||||||
| 1856 | gray_raster_done( QT_FT_Raster raster ) | - | ||||||||||||||||||
| 1857 | { | - | ||||||||||||||||||
| 1858 | free(raster); | - | ||||||||||||||||||
| 1859 | } never executed: end of block | 0 | ||||||||||||||||||
| 1860 | - | |||||||||||||||||||
| 1861 | - | |||||||||||||||||||
| 1862 | static void | - | ||||||||||||||||||
| 1863 | gray_raster_reset( QT_FT_Raster raster, | - | ||||||||||||||||||
| 1864 | char* pool_base, | - | ||||||||||||||||||
| 1865 | long pool_size ) | - | ||||||||||||||||||
| 1866 | { | - | ||||||||||||||||||
| 1867 | PRaster rast = (PRaster)raster; | - | ||||||||||||||||||
| 1868 | - | |||||||||||||||||||
| 1869 | if ( raster )
| 0 | ||||||||||||||||||
| 1870 | { | - | ||||||||||||||||||
| 1871 | if ( pool_base && ( pool_size >= MINIMUM_POOL_SIZE ) )
| 0 | ||||||||||||||||||
| 1872 | { | - | ||||||||||||||||||
| 1873 | PWorker worker = (PWorker)pool_base; | - | ||||||||||||||||||
| 1874 | - | |||||||||||||||||||
| 1875 | - | |||||||||||||||||||
| 1876 | rast->worker = worker; | - | ||||||||||||||||||
| 1877 | rast->buffer = pool_base + | - | ||||||||||||||||||
| 1878 | ( ( sizeof ( TWorker ) + sizeof ( TCell ) - 1 ) & | - | ||||||||||||||||||
| 1879 | ~( sizeof ( TCell ) - 1 ) ); | - | ||||||||||||||||||
| 1880 | rast->buffer_size = (long)( ( pool_base + pool_size ) - | - | ||||||||||||||||||
| 1881 | (char*)rast->buffer ) & | - | ||||||||||||||||||
| 1882 | ~( sizeof ( TCell ) - 1 ); | - | ||||||||||||||||||
| 1883 | rast->band_size = (int)( rast->buffer_size / | - | ||||||||||||||||||
| 1884 | ( sizeof ( TCell ) * 8 ) ); | - | ||||||||||||||||||
| 1885 | } never executed: end of block | 0 | ||||||||||||||||||
| 1886 | else if ( pool_base)
| 0 | ||||||||||||||||||
| 1887 | { /* Case when there is a raster pool allocated, but it */ | - | ||||||||||||||||||
| 1888 | /* doesn't have the minimum size (and so memory will be reallocated) */ | - | ||||||||||||||||||
| 1889 | rast->buffer = pool_base; | - | ||||||||||||||||||
| 1890 | rast->worker = NULL; | - | ||||||||||||||||||
| 1891 | rast->buffer_size = pool_size; | - | ||||||||||||||||||
| 1892 | } never executed: end of block | 0 | ||||||||||||||||||
| 1893 | else | - | ||||||||||||||||||
| 1894 | { | - | ||||||||||||||||||
| 1895 | rast->buffer = NULL; | - | ||||||||||||||||||
| 1896 | rast->buffer_size = 0; | - | ||||||||||||||||||
| 1897 | rast->worker = NULL; | - | ||||||||||||||||||
| 1898 | } never executed: end of block | 0 | ||||||||||||||||||
| 1899 | rast->buffer_allocated_size = pool_size; | - | ||||||||||||||||||
| 1900 | } never executed: end of block | 0 | ||||||||||||||||||
| 1901 | } never executed: end of block | 0 | ||||||||||||||||||
| 1902 | - | |||||||||||||||||||
| 1903 | const QT_FT_Raster_Funcs qt_ft_grays_raster = | - | ||||||||||||||||||
| 1904 | { | - | ||||||||||||||||||
| 1905 | QT_FT_GLYPH_FORMAT_OUTLINE, | - | ||||||||||||||||||
| 1906 | - | |||||||||||||||||||
| 1907 | (QT_FT_Raster_New_Func) gray_raster_new, | - | ||||||||||||||||||
| 1908 | (QT_FT_Raster_Reset_Func) gray_raster_reset, | - | ||||||||||||||||||
| 1909 | (QT_FT_Raster_Set_Mode_Func)0, | - | ||||||||||||||||||
| 1910 | (QT_FT_Raster_Render_Func) gray_raster_render, | - | ||||||||||||||||||
| 1911 | (QT_FT_Raster_Done_Func) gray_raster_done | - | ||||||||||||||||||
| 1912 | }; | - | ||||||||||||||||||
| 1913 | - | |||||||||||||||||||
| 1914 | /* END */ | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |