OpenCoverage

qgrayraster.c

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

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9