diff --git a/dlls/gdi32/gdidc.c b/dlls/gdi32/gdidc.c index 2fc74d7685b..98269cb7582 100644 --- a/dlls/gdi32/gdidc.c +++ b/dlls/gdi32/gdidc.c @@ -54,3 +54,16 @@ BOOL WINAPI Arc( HDC hdc, INT left, INT top, INT right, INT bottom, return NtGdiArcInternal( NtGdiArc, hdc, left, top, right, bottom, xstart, ystart, xend, yend ); } + +/*********************************************************************** + * ArcTo (GDI32.@) + */ +BOOL WINAPI ArcTo( HDC hdc, INT left, INT top, INT right, INT bottom, + INT xstart, INT ystart, INT xend, INT yend ) +{ + TRACE( "%p, (%d, %d)-(%d, %d), (%d, %d), (%d, %d)\n", hdc, left, top, + right, bottom, xstart, ystart, xend, yend ); + + return NtGdiArcInternal( NtGdiArcTo, hdc, left, top, right, bottom, + xstart, ystart, xend, yend ); +} diff --git a/dlls/gdi32/painting.c b/dlls/gdi32/painting.c index b235480dacb..4fc7f98d9b8 100644 --- a/dlls/gdi32/painting.c +++ b/dlls/gdi32/painting.c @@ -293,6 +293,29 @@ BOOL WINAPI NtGdiArcInternal( UINT type, HDC hdc, INT left, INT top, INT right, physdev = GET_DC_PHYSDEV( dc, pArc ); ret = physdev->funcs->pArc( physdev, left, top, right, bottom, xstart, ystart, xend, yend ); break; + + case NtGdiArcTo: + { + double width = abs( right - left ); + double height = abs( bottom - top ); + double xradius = width / 2; + double yradius = height / 2; + double xcenter = right > left ? left + xradius : right + xradius; + double ycenter = bottom > top ? top + yradius : bottom + yradius; + + physdev = GET_DC_PHYSDEV( dc, pArcTo ); + ret = physdev->funcs->pArcTo( physdev, left, top, right, bottom, + xstart, ystart, xend, yend ); + if (ret) + { + double angle = atan2(((yend - ycenter) / height), + ((xend - xcenter) / width)); + dc->cur_pos.x = GDI_ROUND( xcenter + (cos( angle ) * xradius) ); + dc->cur_pos.y = GDI_ROUND( ycenter + (sin( angle ) * yradius) ); + } + break; + } + default: WARN( "invalid arc type %u\n", type ); ret = FALSE; @@ -302,44 +325,6 @@ BOOL WINAPI NtGdiArcInternal( UINT type, HDC hdc, INT left, INT top, INT right, return ret; } -/*********************************************************************** - * ArcTo (GDI32.@) - */ -BOOL WINAPI ArcTo( HDC hdc, - INT left, INT top, - INT right, INT bottom, - INT xstart, INT ystart, - INT xend, INT yend ) -{ - double width = abs( right - left ), - height = abs( bottom - top ), - xradius = width/2, - yradius = height/2, - xcenter = right > left ? left+xradius : right+xradius, - ycenter = bottom > top ? top+yradius : bottom+yradius, - angle; - PHYSDEV physdev; - BOOL result; - DC * dc = get_dc_ptr( hdc ); - - TRACE( "%p, (%d, %d)-(%d, %d), (%d, %d), (%d, %d)\n", hdc, left, top, right, bottom, xstart, ystart, xend, yend ); - - if(!dc) return FALSE; - update_dc( dc ); - physdev = GET_DC_PHYSDEV( dc, pArcTo ); - result = physdev->funcs->pArcTo( physdev, left, top, right, bottom, xstart, ystart, xend, yend ); - - if (result) - { - angle = atan2(((yend-ycenter)/height), - ((xend-xcenter)/width)); - dc->cur_pos.x = GDI_ROUND( xcenter + (cos( angle ) * xradius) ); - dc->cur_pos.y = GDI_ROUND( ycenter + (sin( angle ) * yradius) ); - } - release_dc_ptr( dc ); - return result; -} - /*********************************************************************** * Pie (GDI32.@)