125 #define xxxGRAYS_USE_GAMMA 134 #undef QT_FT_COMPONENT 135 #define QT_FT_COMPONENT trace_smooth 138 #define ErrRaster_MemoryOverflow -4 141 # include <vxWorksCommon.h> 147 #define QT_FT_UINT_MAX UINT_MAX 149 #define qt_ft_memset memset 151 #define qt_ft_setjmp setjmp 152 #define qt_ft_longjmp longjmp 153 #define qt_ft_jmp_buf jmp_buf 155 #define ErrRaster_Invalid_Mode -2 156 #define ErrRaster_Invalid_Outline -1 157 #define ErrRaster_Invalid_Argument -3 158 #define ErrRaster_Memory_Overflow -4 159 #define ErrRaster_OutOfMemory -6 161 #define QT_FT_BEGIN_HEADER 162 #define QT_FT_END_HEADER 164 #include <private/qrasterdefs_p.h> 165 #include <private/qgrayraster_p.h> 174 #define QT_FT_UNUSED( x ) (x) = (x) 179 #define QT_FT_ERROR( x ) do ; while ( 0 ) 183 #define QT_FT_TRACE( x ) do ; while ( 0 ) 186 #ifndef QT_FT_MEM_SET 187 #define QT_FT_MEM_SET( d, s, c ) qt_ft_memset( d, s, c ) 190 #ifndef QT_FT_MEM_ZERO 191 #define QT_FT_MEM_ZERO( dest, count ) QT_FT_MEM_SET( dest, 0, count ) 195 #define xxxDEBUG_GRAYS 198 #define RAS_ARG PWorker worker 199 #define RAS_ARG_ PWorker worker, 201 #define RAS_VAR worker 202 #define RAS_VAR_ worker, 204 #define ras (*worker) 210 #define ONE_PIXEL ( 1L << PIXEL_BITS ) 211 #define PIXEL_MASK ( -1L << PIXEL_BITS ) 212 #define TRUNC( x ) ( (TCoord)( (x) >> PIXEL_BITS ) ) 213 #define SUBPIXELS( x ) ( (TPos)(x) << PIXEL_BITS ) 214 #define FLOOR( x ) ( (x) & -ONE_PIXEL ) 215 #define CEILING( x ) ( ( (x) + ONE_PIXEL - 1 ) & -ONE_PIXEL ) 216 #define ROUND( x ) ( ( (x) + ONE_PIXEL / 2 ) & -ONE_PIXEL ) 219 #define UPSCALE( x ) ( (x) << ( PIXEL_BITS - 6 ) ) 220 #define DOWNSCALE( x ) ( (x) >> ( PIXEL_BITS - 6 ) ) 222 #define UPSCALE( x ) ( (x) >> ( 6 - PIXEL_BITS ) ) 223 #define DOWNSCALE( x ) ( (x) << ( 6 - PIXEL_BITS ) ) 249 #if QT_FT_UINT_MAX == 0xFFFFU 259 #define QT_FT_MAX_GRAY_SPANS 256 337 if ( raster && raster->
worker )
351 ras.buffer_size = byte_size;
353 ras.ycells = (PCell*) buffer;
377 ras.min_ex =
ras.max_ex = 0;
378 ras.min_ey =
ras.max_ey = 0;
382 ras.min_ex =
ras.max_ex = vec->
x;
383 ras.min_ey =
ras.max_ey = vec->
y;
387 for ( ; vec < limit; vec++ )
393 if ( x <
ras.min_ex )
ras.min_ex =
x;
394 if ( x >
ras.max_ex )
ras.max_ex =
x;
395 if ( y <
ras.min_ey )
ras.min_ey = y;
396 if ( y >
ras.max_ey )
ras.max_ey = y;
400 ras.min_ex =
ras.min_ex >> 6;
401 ras.min_ey =
ras.min_ey >> 6;
402 ras.max_ex = (
ras.max_ex + 63 ) >> 6;
403 ras.max_ey = (
ras.max_ey + 63 ) >> 6;
417 if (
ras.invalid || !(
ras.area |
ras.cover ) )
420 if ( x >
ras.max_ex )
423 pcell = &
ras.ycells[
ras.ey];
428 if ( cell == NULL || cell->
x > x )
431 if ( cell->
x == x ) {
440 if (
ras.num_cells >=
ras.max_cells )
443 cell =
ras.cells +
ras.num_cells++;
475 if ( ex >
ras.max_ex )
483 if ( ex !=
ras.ex || ey !=
ras.ey )
495 ras.invalid = ( (unsigned)ey >= (
unsigned)
ras.count_ey ||
496 ex >=
ras.count_ex );
508 if ( ex >
ras.max_ex )
511 if ( ex <
ras.min_ex )
536 TCoord ex1, ex2, fx1, fx2, delta;
538 int incr, lift, mod, rem;
560 ras.area += (
TArea)( fx1 + fx2 ) * delta;
574 p = fx1 * ( y2 - y1 );
580 delta = (
TCoord)( p / dx );
588 ras.area += (
TArea)( fx1 + first ) * delta;
598 lift = (
TCoord)( p / dx );
640 TCoord ey1, ey2, fy1, fy2;
643 int delta, rem, mod, lift, incr;
669 if ( min >=
ras.max_ey || max <
ras.min_ey )
697 delta = (int)( first - fy1 );
704 delta = (int)( first + first -
ONE_PIXEL );
705 area = (
TArea)two_fx * delta;
715 delta = (int)( fy2 -
ONE_PIXEL + first );
735 delta = (int)( p / dy );
736 mod = (int)( p % dy );
752 lift = (int)( p / dy );
753 rem = (int)( p % dy );
799 base[4].
x = base[2].
x;
801 a = base[3].
x = ( base[2].
x + b ) / 2;
802 b = base[1].
x = ( base[0].
x + b ) / 2;
803 base[2].
x = ( a + b ) / 2;
805 base[4].
y = base[2].
y;
807 a = base[3].
y = ( base[2].
y + b ) / 2;
808 b = base[1].
y = ( base[0].
y + b ) / 2;
809 base[2].
y = ( a + b ) / 2;
833 dx = dx /
ras.conic_level;
845 TPos to_x, to_y, mid_x, mid_y;
850 mid_x = (
ras.x + to_x + 2 *
UPSCALE( control->x ) ) / 4;
851 mid_y = (
ras.y + to_y + 2 *
UPSCALE( control->y ) ) / 4;
860 levels =
ras.lev_stack;
880 min = max = arc[0].
y;
883 if ( y < min ) min = y;
884 if ( y > max ) max = y;
887 if ( y < min ) min = y;
888 if ( y > max ) max = y;
896 levels[top] = levels[top - 1] = level - 1;
902 TPos to_x, to_y, mid_x, mid_y;
907 mid_x = (
ras.x + to_x + 2 * arc[1].
x ) / 4;
908 mid_y = (
ras.y + to_y + 2 * arc[1].
y ) / 4;
928 base[6].
x = base[3].
x;
931 base[1].
x = a = ( base[0].
x +
c ) / 2;
932 base[5].
x = b = ( base[3].
x +
d ) / 2;
934 base[2].
x = a = ( a +
c ) / 2;
935 base[4].
x = b = ( b +
c ) / 2;
936 base[3].
x = ( a + b ) / 2;
938 base[6].
y = base[3].
y;
941 base[1].
y = a = ( base[0].
y +
c ) / 2;
942 base[5].
y = b = ( base[3].
y +
d ) / 2;
944 base[2].
y = a = ( a +
c ) / 2;
945 base[4].
y = b = ( b +
c ) / 2;
946 base[3].
y = ( a + b ) / 2;
971 dx =
DOWNSCALE(
ras.x ) + to->
x - 3 * ( control1->x + control2->
x );
974 dy =
DOWNSCALE(
ras.y ) + to->
y - 3 * ( control1->y + control2->
y );
982 da = da /
ras.cubic_level;
983 db = db /
ras.conic_level;
984 while ( da > 0 || db > 0 )
993 TPos to_x, to_y, mid_x, mid_y;
998 mid_x = (
ras.x + to_x +
999 3 *
UPSCALE( control1->x + control2->
x ) ) / 8;
1000 mid_y = (
ras.y + to_y +
1001 3 *
UPSCALE( control1->y + control2->
y ) ) / 8;
1008 arc =
ras.bez_stack;
1018 levels =
ras.lev_stack;
1024 level = levels[top];
1031 min = max = arc[0].
y;
1033 if ( y < min ) min = y;
1034 if ( y > max ) max = y;
1036 if ( y < min ) min = y;
1037 if ( y > max ) max = y;
1039 if ( y < min ) min = y;
1040 if ( y > max ) max = y;
1046 levels[top] = levels[top - 1] = level - 1;
1052 TPos to_x, to_y, mid_x, mid_y;
1057 mid_x = (
ras.x + to_x + 3 * ( arc[1].
x + arc[2].
x ) ) / 8;
1058 mid_y = (
ras.y + to_y + 3 * ( arc[1].
y + arc[2].
y ) ) / 8;
1132 for ( ; count > 0; count--, spans++ )
1134 unsigned char coverage = spans->
coverage;
1137 p = (
unsigned char*)map->
buffer - spans->
y * map->
pitch;
1148 if ( spans->
len >= 8 )
1152 unsigned char* q = p + spans->
x;
1155 switch ( spans->
len )
1157 case 7: *q++ = (
unsigned char)coverage;
1158 case 6: *q++ = (
unsigned char)coverage;
1159 case 5: *q++ = (
unsigned char)coverage;
1160 case 4: *q++ = (
unsigned char)coverage;
1161 case 3: *q++ = (
unsigned char)coverage;
1162 case 2: *q++ = (
unsigned char)coverage;
1163 case 1: *q = (
unsigned char)coverage;
1189 coverage = (int)( area >> (
PIXEL_BITS * 2 + 1 - 8 ) );
1192 coverage = -coverage;
1198 if ( coverage > 256 )
1199 coverage = 512 - coverage;
1200 else if ( coverage == 256 )
1206 if ( coverage >= 256 )
1220 span =
ras.gray_spans +
ras.num_gray_spans - 1;
1221 if (
ras.num_gray_spans > 0 &&
1223 (
int)span->
x + span->
len == (int)x &&
1226 span->
len = (
unsigned short)( span->
len + acount );
1232 if (
ras.render_span &&
ras.num_gray_spans >
ras.skip_spans )
1234 skip =
ras.skip_spans > 0 ?
ras.skip_spans : 0;
1235 ras.render_span(
ras.num_gray_spans - skip,
1236 ras.gray_spans + skip,
1237 ras.render_span_data );
1240 ras.skip_spans -=
ras.num_gray_spans;
1251 fprintf( stderr,
"y=%3d ", y );
1252 span =
ras.gray_spans;
1253 for ( n = 0; n < count; n++, span++ )
1254 fprintf( stderr,
"[%d..%d]:%02x ",
1256 fprintf( stderr,
"\n" );
1261 ras.num_gray_spans = 0;
1263 span =
ras.gray_spans;
1270 span->
len = (
unsigned short)acount;
1272 span->
coverage = (
unsigned char)coverage;
1274 ras.num_gray_spans++;
1287 for ( yindex = 0; yindex <
ras.ycount; yindex++ )
1292 printf(
"%3d:", yindex );
1294 for ( cell =
ras.ycells[yindex]; cell != NULL; cell = cell->
next )
1295 printf(
" (%3d, c:%4d, a:%6d)", cell->
x, cell->
cover, cell->
area );
1311 if (
ras.num_cells == 0 )
1314 for ( yindex = 0; yindex <
ras.ycount; yindex++ )
1316 PCell cell =
ras.ycells[yindex];
1321 for ( ; cell != NULL; cell = cell->
next )
1326 if ( cell->
x > x && cover != 0 )
1330 cover += cell->
cover;
1333 if ( area != 0 && cell->
x >= 0 )
1339 if (
ras.count_ex > x && cover != 0 )
1379 #define SCALED( x ) (x) 1402 limit = outline->
points + last;
1404 v_start = outline->
points[first];
1405 v_last = outline->
points[last];
1413 v_control = v_start;
1415 point = outline->
points + first;
1416 tags = outline->
tags + first;
1421 goto Invalid_Outline;
1438 v_start.
x = ( v_start.
x + v_last.
x ) / 2;
1439 v_start.
y = ( v_start.
y + v_last.
y ) / 2;
1451 while ( point < limit )
1479 if ( point < limit )
1502 goto Invalid_Outline;
1504 v_middle.
x = ( v_control.
x + vec.
x ) / 2;
1505 v_middle.
y = ( v_control.
y + vec.
y ) / 2;
1526 if ( point + 1 > limit ||
1528 goto Invalid_Outline;
1534 vec1.
y =
SCALED( point[-2].y );
1537 vec2.
y =
SCALED( point[-1].y );
1539 if ( point <= limit )
1588 volatile int error = 0;
1608 TBand*
volatile band;
1609 int volatile n, num_bands;
1610 TPos volatile min, max, max_y;
1614 ras.num_gray_spans = 0;
1620 clip = &
ras.clip_box;
1638 ras.conic_level = 32;
1639 ras.cubic_level = 16;
1645 if (
ras.count_ex > 24 ||
ras.count_ey > 24 )
1647 if (
ras.count_ex > 120 ||
ras.count_ey > 120 )
1650 ras.conic_level <<= level;
1651 ras.cubic_level <<= level;
1655 num_bands = (int)( (
ras.max_ey -
ras.min_ey ) /
ras.band_size );
1656 if ( num_bands == 0 ) num_bands = 1;
1657 if ( num_bands >= 39 ) num_bands = 39;
1664 for ( n = 0; n < num_bands; n++, min = max )
1666 max = min +
ras.band_size;
1667 if ( n == num_bands - 1 || max > max_y )
1674 while ( band >= bands )
1676 TPos bottom, top, middle;
1682 int cell_start, cell_end, cell_mod;
1685 ras.ycells = (PCell*)
ras.buffer;
1688 cell_start = sizeof ( PCell ) *
ras.ycount;
1689 cell_mod = cell_start %
sizeof (
TCell );
1691 cell_start +=
sizeof (
TCell ) - cell_mod;
1693 cell_end =
ras.buffer_size;
1694 cell_end -= cell_end %
sizeof(
TCell );
1696 cells_max = (
PCell)( (
char*)
ras.buffer + cell_end );
1697 ras.cells = (
PCell)( (
char*)
ras.buffer + cell_start );
1698 if (
ras.cells >= cells_max )
1701 ras.max_cells = (int)(cells_max -
ras.cells);
1702 if (
ras.max_cells < 2 )
1705 for ( yindex = 0; yindex <
ras.ycount; yindex++ )
1706 ras.ycells[yindex] = NULL;
1730 middle = bottom + ( ( top - bottom ) >> 1 );
1734 if ( middle == bottom )
1737 fprintf( stderr,
"Rotten glyph!\n" );
1742 if ( bottom-top >=
ras.band_size )
1745 band[1].
min = bottom;
1746 band[1].
max = middle;
1747 band[0].
min = middle;
1753 if (
ras.render_span &&
ras.num_gray_spans >
ras.skip_spans )
1755 skip =
ras.skip_spans > 0 ?
ras.skip_spans : 0;
1756 ras.render_span(
ras.num_gray_spans - skip,
1757 ras.gray_spans + skip,
1758 ras.render_span_data );
1761 ras.skip_spans -=
ras.num_gray_spans;
1763 if (
ras.band_shoot > 8 &&
ras.band_size > 16 )
1764 ras.band_size =
ras.band_size / 2;
1811 if ( !target_map->width || !target_map->rows )
1814 if ( !target_map->buffer )
1826 ras.clip_box.xMin = 0;
1827 ras.clip_box.yMin = 0;
1828 ras.clip_box.xMax = target_map->width;
1829 ras.clip_box.yMax = target_map->rows;
1837 ras.clip_box.xMin = -32768L;
1838 ras.clip_box.yMin = -32768L;
1839 ras.clip_box.xMax = 32767L;
1840 ras.clip_box.yMax = 32767L;
1845 ras.outline = *outline;
1851 ras.target = *target_map;
1854 ras.render_span_data = &
ras;
1859 ras.render_span_data = params->
user;
1872 *araster = malloc(
sizeof(
TRaster));
1895 PRaster rast = (
PRaster)raster;
1901 PWorker worker = (
PWorker)pool_base;
1905 rast->
buffer = pool_base +
1907 ~(
sizeof (
TCell ) - 1 ) );
1908 rast->
buffer_size = (long)( ( pool_base + pool_size ) -
1910 ~(
sizeof (
TCell ) - 1 );
1912 ( sizeof (
TCell ) * 8 ) );
1914 else if ( pool_base)
1917 rast->
buffer = pool_base;
1933 QT_FT_GLYPH_FORMAT_OUTLINE,
#define ErrRaster_Memory_Overflow
static int gray_convert_glyph_inner(RAS_ARG)
const QT_FT_Raster_Funcs qt_ft_grays_raster
#define QT_FT_CURVE_TAG_CONIC
#define QT_FT_OUTLINE_EVEN_ODD_FILL
#define QT_FT_MEM_SET(d, s, c)
#define QT_FT_CURVE_TAG_CUBIC
#define QT_FT_MAX_GRAY_SPANS
#define QT_FT_CURVE_TAG_ON
static void gray_render_line(RAS_ARG_ TPos to_x, TPos to_y)
#define QT_FT_CURVE_TAG(flag)
static void gray_split_conic(QT_FT_Vector *base)
#define QT_FT_Raster_Set_Mode_Func
int q_gray_rendered_spans(TRaster *raster)
QT_FT_SpanFunc gray_spans
static void gray_start_cell(RAS_ARG_ TCoord ex, TCoord ey)
struct TRaster_ * PRaster
long ASN1_INTEGER_get ASN1_INTEGER * a
static void gray_render_cubic(RAS_ARG_ const QT_FT_Vector *control1, const QT_FT_Vector *control2, const QT_FT_Vector *to)
static void gray_render_span(int count, const QT_FT_Span *spans, PWorker worker)
#define QT_FT_RASTER_FLAG_CLIP
static void gray_set_cell(RAS_ARG_ TCoord ex, TCoord ey)
static void gray_raster_done(QT_FT_Raster raster)
#define ErrRaster_Invalid_Mode
qt_ft_jmp_buf jump_buffer
#define ErrRaster_Invalid_Argument
static void gray_record_cell(RAS_ARG)
static int gray_convert_glyph(RAS_ARG)
static void gray_split_cubic(QT_FT_Vector *base)
static int QT_FT_Outline_Decompose(const QT_FT_Outline *outline, void *user)
static void gray_render_conic(RAS_ARG_ const QT_FT_Vector *control, const QT_FT_Vector *to)
static void gray_raster_reset(QT_FT_Raster raster, char *pool_base, long pool_size)
#define QT_FT_RASTER_FLAG_DIRECT
static void gray_render_scanline(RAS_ARG_ TCoord ey, TPos x1, TCoord y1, TPos x2, TCoord y2)
static int gray_conic_to(const QT_FT_Vector *control, const QT_FT_Vector *to, PWorker worker)
static void gray_compute_cbox(RAS_ARG)
static void gray_init_cells(RAS_ARG_ void *buffer, long byte_size)
#define QT_FT_MEM_ZERO(dest, count)
QT_FT_Raster_Span_Func render_span
#define QT_FT_Raster_Render_Func
static void gray_sweep(RAS_ARG_ const QT_FT_Bitmap *target)
#define ErrRaster_Invalid_Outline
static void gray_hline(RAS_ARG_ TCoord x, TCoord y, TPos area, int acount)
#define QT_FT_Raster_Reset_Func
if(void) toggleToolbarShown
#define QT_FT_Raster_New_Func
#define MINIMUM_POOL_SIZE
static int gray_raster_new(QT_FT_Raster *araster)
long buffer_allocated_size
#define ErrRaster_OutOfMemory
static int gray_move_to(const QT_FT_Vector *to, PWorker worker)
#define QT_FT_Raster_Done_Func
static int gray_line_to(const QT_FT_Vector *to, PWorker worker)
struct TWorker_ * PWorker
static int gray_cubic_to(const QT_FT_Vector *control1, const QT_FT_Vector *control2, const QT_FT_Vector *to, PWorker worker)
virtual IFMETHOD End(void)=0
#define QT_FT_RASTER_FLAG_AA
static int gray_raster_render(QT_FT_Raster raster, const QT_FT_Raster_Params *params)
#define QT_FT_Raster_Span_Func