@@ -1329,7 +1329,6 @@ draw_aaline(SDL_Surface *surf, Uint32 color, float from_x, float from_y,
1329
1329
Uint32 pixel_color ;
1330
1330
float x_gap , y_endpoint , clip_left , clip_right , clip_top , clip_bottom ;
1331
1331
int steep , y ;
1332
- int line_inverted ;
1333
1332
1334
1333
dx = to_x - from_x ;
1335
1334
dy = to_y - from_y ;
@@ -1362,7 +1361,6 @@ draw_aaline(SDL_Surface *surf, Uint32 color, float from_x, float from_y,
1362
1361
swap (& clip_right , & clip_bottom );
1363
1362
}
1364
1363
if (dx < 0 ) {
1365
- line_inverted = 1 ;
1366
1364
swap (& from_x , & to_x );
1367
1365
swap (& from_y , & to_y );
1368
1366
dx = - dx ;
@@ -1427,9 +1425,11 @@ draw_aaline(SDL_Surface *surf, Uint32 color, float from_x, float from_y,
1427
1425
1428
1426
/* Handle endpoints separately.
1429
1427
* The line is not a mathematical line of thickness zero. The same
1430
- * goes for the endpoints. The have a height and width of one pixel. */
1428
+ * goes for the endpoints. The have a height and width of one pixel.
1429
+ * Extra pixel drawing is requested externally from aalines.
1430
+ * It is drawn only when one line is steep and other is not.*/
1431
1431
/* First endpoint */
1432
- if (!disable_first_endpoint ) {
1432
+ if (!disable_first_endpoint || extra_pixel_for_aalines ) {
1433
1433
x_pixel_start = (int )from_x ;
1434
1434
y_endpoint = intersect_y =
1435
1435
from_y + gradient * (x_pixel_start - from_x );
@@ -1463,38 +1463,14 @@ draw_aaline(SDL_Surface *surf, Uint32 color, float from_x, float from_y,
1463
1463
x_pixel_start ++ ;
1464
1464
}
1465
1465
}
1466
- else {
1467
- /* Handle extra pixel for aalines.
1468
- * It is drawn only when one line is steep and other is not.*/
1469
- if (extra_pixel_for_aalines && !line_inverted ) {
1470
- x_pixel_start = (int )from_x ;
1471
- y_endpoint = intersect_y =
1472
- from_y + gradient * (x_pixel_start - from_x );
1473
- if (to_x > clip_left + 1.0f ) {
1474
- x_gap = 1 + x_pixel_start - from_x ;
1475
- brightness = y_endpoint - (int )y_endpoint ;
1476
- if (steep ) {
1477
- x = (int )y_endpoint ;
1478
- y = x_pixel_start ;
1479
- }
1480
- else {
1481
- x = x_pixel_start ;
1482
- y = (int )y_endpoint ;
1483
- }
1484
- if ((int )y_endpoint < y_endpoint ) {
1485
- pixel_color = get_antialiased_color (surf , x , y , color ,
1486
- brightness * x_gap );
1487
- set_and_check_rect (surf , x , y , pixel_color , drawn_area );
1488
- }
1489
- }
1490
- }
1491
- /* To be sure main loop skips first endpoint.*/
1466
+ /* To be sure main loop skips first endpoint.*/
1467
+ if (disable_first_endpoint ) {
1492
1468
x_pixel_start = (int )ceil (from_x );
1493
1469
intersect_y = from_y + gradient * (x_pixel_start - from_x );
1494
1470
}
1495
1471
/* Second endpoint */
1496
1472
x_pixel_end = (int )ceil (to_x );
1497
- if (!disable_second_endpoint ) {
1473
+ if (!disable_second_endpoint || extra_pixel_for_aalines ) {
1498
1474
if (from_x < clip_right - 1.0f ) {
1499
1475
y_endpoint = to_y + gradient * (x_pixel_end - to_x );
1500
1476
x_gap = 1 - x_pixel_end + to_x ;
@@ -1524,29 +1500,6 @@ draw_aaline(SDL_Surface *surf, Uint32 color, float from_x, float from_y,
1524
1500
set_and_check_rect (surf , x , y , pixel_color , drawn_area );
1525
1501
}
1526
1502
}
1527
- else {
1528
- /* Handle extra pixel for aalines.
1529
- * It is drawn only when one line is steep and other is not.*/
1530
- if (extra_pixel_for_aalines && line_inverted ) {
1531
- if (from_x < clip_right - 1.0f ) {
1532
- y_endpoint = to_y + gradient * (x_pixel_end - to_x );
1533
- x_gap = 1 - x_pixel_end + to_x ;
1534
- brightness = y_endpoint - (int )y_endpoint ;
1535
- if (steep ) {
1536
- x = (int )y_endpoint - 1 ;
1537
- y = x_pixel_end ;
1538
- }
1539
- else {
1540
- x = x_pixel_end ;
1541
- y = (int )y_endpoint - 1 ;
1542
- }
1543
- brightness = 1 - brightness ;
1544
- pixel_color = get_antialiased_color (surf , x , y , color ,
1545
- brightness * x_gap );
1546
- set_and_check_rect (surf , x , y , pixel_color , drawn_area );
1547
- }
1548
- }
1549
- }
1550
1503
1551
1504
/* main line drawing loop */
1552
1505
for (x = x_pixel_start ; x < x_pixel_end ; x ++ ) {
0 commit comments