diff --git a/dlls/gdi32/dibdrv/graphics.c b/dlls/gdi32/dibdrv/graphics.c index 2c865c0..b222610 100644 --- a/dlls/gdi32/dibdrv/graphics.c +++ b/dlls/gdi32/dibdrv/graphics.c @@ -172,40 +172,33 @@ static void add_pen_lines_bounds( dibdrv_physdev *dev, int count, const POINT *p add_clipped_bounds( dev, &bounds, dev->clip ); } -/* compute the points for the first quadrant of an ellipse, counterclockwise from the x axis */ +/* compute the points for the first quadrant of an ellipse */ /* 'data' must contain enough space, (width+height)/2 is a reasonable upper bound */ static int ellipse_first_quadrant( int width, int height, POINT *data ) { - const int a = width - 1; - const int b = height - 1; - const INT64 asq = (INT64)8 * a * a; - const INT64 bsq = (INT64)8 * b * b; - INT64 dx = (INT64)4 * b * b * (1 - a); - INT64 dy = (INT64)4 * a * a * (1 + (b % 2)); - INT64 err = dx + dy + a * a * (b % 2); - int pos = 0; POINT pt; + const int a = width/2; + const int b = height/2; + int pos = 0; + INT64 de, dx, dy, err; - pt.x = a; - pt.y = height / 2; + de = b; + pt.x = -a; + pt.y = 0; + dx = ( 1 + 2 * pt.x) * de * de; + dy = pt.x * pt.x; + err = dx + dy ; - /* based on an algorithm by Alois Zingl */ + do{ + data[ pos++ ] = pt; + data[ pos-1 ].x = a - data[ pos-1 ].x; + data[ pos-1 ].y = b + data[ pos-1 ].y; + de = 2 * err; + + if(de >= dx) { pt.x ++; err += dx += 2 * b * b; } + if(de <= dy) { pt.y ++; err += dy += 2 * a * a; } + }while( pt.x <= 0); - while (pt.x >= width / 2) - { - INT64 e2 = 2 * err; - data[pos++] = pt; - if (e2 >= dx) - { - pt.x--; - err += dx += bsq; - } - if (e2 <= dy) - { - pt.y++; - err += dy += asq; - } - } return pos; }