Commit 920b050a authored by Misha Koshelev's avatar Misha Koshelev Committed by Alexandre Julliard

gdi32: Emulate AngleArc using ArcTo.

parent ce8e6d16
......@@ -793,34 +793,25 @@ BOOL WINAPI AngleArc(HDC hdc, INT x, INT y, DWORD dwRadius, FLOAT eStartAngle, F
dc = DC_GetDCUpdate( hdc );
if(!dc) return FALSE;
if(dc->funcs->pAngleArc)
{
result = dc->funcs->pAngleArc( dc->physDev, x, y, dwRadius, eStartAngle, eSweepAngle );
GDI_ReleaseObj( hdc );
return result;
}
GDI_ReleaseObj( hdc );
/* AngleArc always works counterclockwise */
arcdir = GetArcDirection( hdc );
SetArcDirection( hdc, AD_COUNTERCLOCKWISE );
x1 = x + cos(eStartAngle*M_PI/180) * dwRadius;
y1 = y - sin(eStartAngle*M_PI/180) * dwRadius;
/* Calculate the end point */
x2 = x + cos((eStartAngle+eSweepAngle)*M_PI/180) * dwRadius;
y2 = y - sin((eStartAngle+eSweepAngle)*M_PI/180) * dwRadius;
LineTo( hdc, x1, y1 );
if( eSweepAngle >= 0 )
result = Arc( hdc, x-dwRadius, y-dwRadius, x+dwRadius, y+dwRadius,
x1, y1, x2, y2 );
else
result = Arc( hdc, x-dwRadius, y-dwRadius, x+dwRadius, y+dwRadius,
x2, y2, x1, y1 );
if( result ) MoveToEx( hdc, x2, y2, NULL );
SetArcDirection( hdc, arcdir );
if(!PATH_IsPathOpen(dc->path) && dc->funcs->pAngleArc)
result = dc->funcs->pAngleArc( dc->physDev, x, y, dwRadius, eStartAngle, eSweepAngle );
else { /* do it using ArcTo */
x1 = x + cos(eStartAngle*M_PI/180) * dwRadius;
y1 = y - sin(eStartAngle*M_PI/180) * dwRadius;
arcdir = SetArcDirection( hdc, eSweepAngle >= 0 ? AD_COUNTERCLOCKWISE : AD_CLOCKWISE);
result = ArcTo( hdc, x-dwRadius, y-dwRadius, x+dwRadius, y+dwRadius,
x1, y1, x2, y2 );
SetArcDirection( hdc, arcdir );
}
if (result) {
dc->CursPosX = x2;
dc->CursPosY = y2;
}
return result;
}
......
......@@ -252,7 +252,7 @@ done:
static const path_test_t anglearc_path[] = {
{0, 0, PT_MOVETO, 0, 0}, /* 0 */
{371, 229, PT_LINETO, 0, 0}, /* 1 */
{352, 211, PT_BEZIERTO, 1, 0}, /* 2 */
{352, 211, PT_BEZIERTO, 0, 0}, /* 2 */
{327, 200, PT_BEZIERTO, 0, 0}, /* 3 */
{300, 200, PT_BEZIERTO, 0, 0}, /* 4 */
{245, 200, PT_BEZIERTO, 0, 0}, /* 5 */
......@@ -261,16 +261,16 @@ static const path_test_t anglearc_path[] = {
{200, 300, PT_BEZIERTO, 0, 2}, /* 8 */
{200, 300, PT_BEZIERTO, 0, 2}, /* 9 */
{200, 300, PT_BEZIERTO, 0, 2}, /* 10 */
{231, 260, PT_LINETO, 1, 0}, /* 11 */
{245, 235, PT_BEZIERTO, 1, 1}, /* 12 */
{271, 220, PT_BEZIERTO, 0, 1}, /* 13 */
{300, 220, PT_BEZIERTO, 0, 1}, /* 14 */
{344, 220, PT_BEZIERTO, 0, 1}, /* 15 */
{380, 256, PT_BEZIERTO, 0, 1}, /* 16 */
{380, 300, PT_BEZIERTO, 0, 1}, /* 17 */
{380, 314, PT_BEZIERTO, 0, 1}, /* 18 */
{376, 328, PT_BEZIERTO, 0, 1}, /* 19 */
{369, 340, PT_BEZIERTO | PT_CLOSEFIGURE, 0, 1}}; /* 20 */
{231, 260, PT_LINETO, 0, 0}, /* 11 */
{245, 235, PT_BEZIERTO, 0, 0}, /* 12 */
{271, 220, PT_BEZIERTO, 0, 0}, /* 13 */
{300, 220, PT_BEZIERTO, 0, 0}, /* 14 */
{344, 220, PT_BEZIERTO, 0, 0}, /* 15 */
{380, 256, PT_BEZIERTO, 0, 0}, /* 16 */
{380, 300, PT_BEZIERTO, 0, 0}, /* 17 */
{380, 314, PT_BEZIERTO, 0, 0}, /* 18 */
{376, 328, PT_BEZIERTO, 0, 0}, /* 19 */
{369, 340, PT_BEZIERTO | PT_CLOSEFIGURE, 0, 0}}; /* 20 */
static void test_anglearc(void)
{
......@@ -287,7 +287,7 @@ static void test_anglearc(void)
CloseFigure(hdc);
EndPath(hdc);
ok_path(hdc, "anglearc_path", anglearc_path, sizeof(anglearc_path)/sizeof(path_test_t), 0);
ok_path(hdc, "anglearc_path", anglearc_path, sizeof(anglearc_path)/sizeof(path_test_t), 1);
done:
ReleaseDC(0, hdc);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment