954 static void |
954 static void |
955 gray_render_cubic( RAS_ARG_ const QT_FT_Vector* control1, |
955 gray_render_cubic( RAS_ARG_ const QT_FT_Vector* control1, |
956 const QT_FT_Vector* control2, |
956 const QT_FT_Vector* control2, |
957 const QT_FT_Vector* to ) |
957 const QT_FT_Vector* to ) |
958 { |
958 { |
959 TPos dx, dy, da, db; |
|
960 int top, level; |
959 int top, level; |
961 int* levels; |
960 int* levels; |
962 QT_FT_Vector* arc; |
961 QT_FT_Vector* arc; |
963 |
962 int mid_x = ( DOWNSCALE( ras.x ) + to->x + |
964 |
963 3 * (control1->x + control2->x ) ) / 8; |
965 dx = DOWNSCALE( ras.x ) + to->x - ( control1->x << 1 ); |
964 int mid_y = ( DOWNSCALE( ras.y ) + to->y + |
|
965 3 * (control1->y + control2->y ) ) / 8; |
|
966 TPos dx = DOWNSCALE( ras.x ) + to->x - ( mid_x << 1 ); |
|
967 TPos dy = DOWNSCALE( ras.y ) + to->y - ( mid_y << 1 ); |
|
968 |
|
969 |
966 if ( dx < 0 ) |
970 if ( dx < 0 ) |
967 dx = -dx; |
971 dx = -dx; |
968 dy = DOWNSCALE( ras.y ) + to->y - ( control1->y << 1 ); |
|
969 if ( dy < 0 ) |
972 if ( dy < 0 ) |
970 dy = -dy; |
973 dy = -dy; |
971 if ( dx < dy ) |
974 if ( dx < dy ) |
972 dx = dy; |
975 dx = dy; |
973 da = dx; |
|
974 |
|
975 dx = DOWNSCALE( ras.x ) + to->x - 3 * ( control1->x + control2->x ); |
|
976 if ( dx < 0 ) |
|
977 dx = -dx; |
|
978 dy = DOWNSCALE( ras.y ) + to->y - 3 * ( control1->x + control2->y ); |
|
979 if ( dy < 0 ) |
|
980 dy = -dy; |
|
981 if ( dx < dy ) |
|
982 dx = dy; |
|
983 db = dx; |
|
984 |
976 |
985 level = 1; |
977 level = 1; |
986 da = da / ras.cubic_level; |
978 dx /= ras.cubic_level; |
987 db = db / ras.conic_level; |
979 while ( dx > 0 ) |
988 while ( da > 0 || db > 0 ) |
980 { |
989 { |
981 dx >>= 2; |
990 da >>= 2; |
|
991 db >>= 3; |
|
992 level++; |
982 level++; |
993 } |
983 } |
994 |
984 |
995 if ( level <= 1 ) |
985 if ( level <= 1 ) |
996 { |
986 { |
997 TPos to_x, to_y, mid_x, mid_y; |
987 TPos to_x, to_y; |
998 |
988 |
999 |
989 |
1000 to_x = UPSCALE( to->x ); |
990 to_x = UPSCALE( to->x ); |
1001 to_y = UPSCALE( to->y ); |
991 to_y = UPSCALE( to->y ); |
|
992 |
|
993 /* Recalculation of midpoint is needed only if */ |
|
994 /* UPSCALE and DOWNSCALE have any effect. */ |
|
995 |
|
996 #if ( PIXEL_BITS != 6 ) |
1002 mid_x = ( ras.x + to_x + |
997 mid_x = ( ras.x + to_x + |
1003 3 * UPSCALE( control1->x + control2->x ) ) / 8; |
998 3 * UPSCALE( control1->x + control2->x ) ) / 8; |
1004 mid_y = ( ras.y + to_y + |
999 mid_y = ( ras.y + to_y + |
1005 3 * UPSCALE( control1->y + control2->y ) ) / 8; |
1000 3 * UPSCALE( control1->y + control2->y ) ) / 8; |
|
1001 #endif |
1006 |
1002 |
1007 gray_render_line( RAS_VAR_ mid_x, mid_y ); |
1003 gray_render_line( RAS_VAR_ mid_x, mid_y ); |
1008 gray_render_line( RAS_VAR_ to_x, to_y ); |
1004 gray_render_line( RAS_VAR_ to_x, to_y ); |
1009 return; |
1005 return; |
1010 } |
1006 } |
1357 /* of new contours in the outline. */ |
1353 /* of new contours in the outline. */ |
1358 /* */ |
1354 /* */ |
1359 /* <Input> */ |
1355 /* <Input> */ |
1360 /* outline :: A pointer to the source target. */ |
1356 /* outline :: A pointer to the source target. */ |
1361 /* */ |
1357 /* */ |
1362 /* func_interface :: A table of `emitters', i.e,. function pointers */ |
|
1363 /* called during decomposition to indicate path */ |
|
1364 /* operations. */ |
|
1365 /* */ |
|
1366 /* user :: A typeless pointer which is passed to each */ |
1358 /* user :: A typeless pointer which is passed to each */ |
1367 /* emitter during the decomposition. It can be */ |
1359 /* emitter during the decomposition. It can be */ |
1368 /* used to store the state during the */ |
1360 /* used to store the state during the */ |
1369 /* decomposition. */ |
1361 /* decomposition. */ |
1370 /* */ |
1362 /* */ |
1371 /* <Return> */ |
1363 /* <Return> */ |
1372 /* Error code. 0 means success. */ |
1364 /* Error code. 0 means success. */ |
1373 /* */ |
1365 /* */ |
1374 static |
1366 static |
1375 int QT_FT_Outline_Decompose( const QT_FT_Outline* outline, |
1367 int QT_FT_Outline_Decompose( const QT_FT_Outline* outline, |
1376 const QT_FT_Outline_Funcs* func_interface, |
|
1377 void* user ) |
1368 void* user ) |
1378 { |
1369 { |
1379 #undef SCALED |
1370 #undef SCALED |
1380 #if 0 |
|
1381 #define SCALED( x ) ( ( (x) << shift ) - delta ) |
|
1382 #else |
|
1383 #define SCALED( x ) (x) |
1371 #define SCALED( x ) (x) |
1384 #endif |
|
1385 |
1372 |
1386 QT_FT_Vector v_last; |
1373 QT_FT_Vector v_last; |
1387 QT_FT_Vector v_control; |
1374 QT_FT_Vector v_control; |
1388 QT_FT_Vector v_start; |
1375 QT_FT_Vector v_start; |
1389 |
1376 |
1393 |
1380 |
1394 int n; /* index of contour in outline */ |
1381 int n; /* index of contour in outline */ |
1395 int first; /* index of first point in contour */ |
1382 int first; /* index of first point in contour */ |
1396 int error; |
1383 int error; |
1397 char tag; /* current point's state */ |
1384 char tag; /* current point's state */ |
1398 |
|
1399 #if 0 |
|
1400 int shift = func_interface->shift; |
|
1401 TPos delta = func_interface->delta; |
|
1402 #endif |
|
1403 |
|
1404 |
1385 |
1405 first = 0; |
1386 first = 0; |
1406 |
1387 |
1407 for ( n = 0; n < outline->n_contours; n++ ) |
1388 for ( n = 0; n < outline->n_contours; n++ ) |
1408 { |
1389 { |
1513 goto Invalid_Outline; |
1494 goto Invalid_Outline; |
1514 |
1495 |
1515 v_middle.x = ( v_control.x + vec.x ) / 2; |
1496 v_middle.x = ( v_control.x + vec.x ) / 2; |
1516 v_middle.y = ( v_control.y + vec.y ) / 2; |
1497 v_middle.y = ( v_control.y + vec.y ) / 2; |
1517 |
1498 |
1518 error = func_interface->conic_to( &v_control, &v_middle, |
1499 error = gray_conic_to( &v_control, &v_middle, |
1519 user ); |
1500 user ); |
1520 if ( error ) |
1501 if ( error ) |
1521 goto Exit; |
1502 goto Exit; |
1522 |
1503 |
1523 v_control = vec; |
1504 v_control = vec; |
1524 goto Do_Conic; |
1505 goto Do_Conic; |
1525 } |
1506 } |
1526 |
1507 |
1527 error = func_interface->conic_to( &v_control, &v_start, |
1508 error = gray_conic_to( &v_control, &v_start, |
1528 user ); |
1509 user ); |
1529 goto Close; |
1510 goto Close; |
1530 } |
1511 } |
1531 |
1512 |
1532 default: /* QT_FT_CURVE_TAG_CUBIC */ |
1513 default: /* QT_FT_CURVE_TAG_CUBIC */ |
1553 |
1534 |
1554 |
1535 |
1555 vec.x = SCALED( point->x ); |
1536 vec.x = SCALED( point->x ); |
1556 vec.y = SCALED( point->y ); |
1537 vec.y = SCALED( point->y ); |
1557 |
1538 |
1558 error = func_interface->cubic_to( &vec1, &vec2, &vec, user ); |
1539 error = gray_cubic_to( &vec1, &vec2, &vec, user ); |
1559 if ( error ) |
1540 if ( error ) |
1560 goto Exit; |
1541 goto Exit; |
1561 continue; |
1542 continue; |
1562 } |
1543 } |
1563 |
1544 |
1564 error = func_interface->cubic_to( &vec1, &vec2, &v_start, user ); |
1545 error = gray_cubic_to( &vec1, &vec2, &v_start, user ); |
1565 goto Close; |
1546 goto Close; |
1566 } |
1547 } |
1567 } |
1548 } |
1568 } |
1549 } |
1569 |
1550 |
1570 /* close the contour with a line segment */ |
1551 /* close the contour with a line segment */ |
1571 error = func_interface->line_to( &v_start, user ); |
1552 error = gray_line_to( &v_start, user ); |
1572 |
1553 |
1573 Close: |
1554 Close: |
1574 if ( error ) |
1555 if ( error ) |
1575 goto Exit; |
1556 goto Exit; |
1576 |
1557 |
1594 |
1575 |
1595 |
1576 |
1596 static int |
1577 static int |
1597 gray_convert_glyph_inner( RAS_ARG ) |
1578 gray_convert_glyph_inner( RAS_ARG ) |
1598 { |
1579 { |
1599 static |
|
1600 const QT_FT_Outline_Funcs func_interface = |
|
1601 { |
|
1602 (QT_FT_Outline_MoveTo_Func) gray_move_to, |
|
1603 (QT_FT_Outline_LineTo_Func) gray_line_to, |
|
1604 (QT_FT_Outline_ConicTo_Func)gray_conic_to, |
|
1605 (QT_FT_Outline_CubicTo_Func)gray_cubic_to, |
|
1606 0, |
|
1607 0 |
|
1608 }; |
|
1609 |
|
1610 volatile int error = 0; |
1580 volatile int error = 0; |
1611 |
1581 |
1612 if ( qt_ft_setjmp( ras.jump_buffer ) == 0 ) |
1582 if ( qt_ft_setjmp( ras.jump_buffer ) == 0 ) |
1613 { |
1583 { |
1614 error = QT_FT_Outline_Decompose( &ras.outline, &func_interface, &ras ); |
1584 error = QT_FT_Outline_Decompose( &ras.outline, &ras ); |
1615 gray_record_cell( RAS_VAR ); |
1585 gray_record_cell( RAS_VAR ); |
1616 } |
1586 } |
1617 else |
1587 else |
1618 { |
1588 { |
1619 error = ErrRaster_Memory_Overflow; |
1589 error = ErrRaster_Memory_Overflow; |