gdi32: Replace DC_GetDCUpdate by get_dc_ptr+update_dc in the painting functions.

This commit is contained in:
Alexandre Julliard 2007-09-17 16:48:27 +02:00
parent f486f24b96
commit f3f792d064
1 changed files with 148 additions and 83 deletions

View File

@ -42,11 +42,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdi);
*/ */
BOOL WINAPI LineTo( HDC hdc, INT x, INT y ) BOOL WINAPI LineTo( HDC hdc, INT x, INT y )
{ {
DC * dc = DC_GetDCUpdate( hdc ); DC * dc = get_dc_ptr( hdc );
BOOL ret; BOOL ret;
if(!dc) return FALSE; if(!dc) return FALSE;
update_dc( dc );
if(PATH_IsPathOpen(dc->path)) if(PATH_IsPathOpen(dc->path))
ret = PATH_LineTo(dc, x, y); ret = PATH_LineTo(dc, x, y);
else else
@ -55,7 +56,7 @@ BOOL WINAPI LineTo( HDC hdc, INT x, INT y )
dc->CursPosX = x; dc->CursPosX = x;
dc->CursPosY = y; dc->CursPosY = y;
} }
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
return ret; return ret;
} }
@ -92,14 +93,16 @@ BOOL WINAPI Arc( HDC hdc, INT left, INT top, INT right,
INT xend, INT yend ) INT xend, INT yend )
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
DC * dc = DC_GetDCUpdate( hdc ); DC * dc = get_dc_ptr( hdc );
if (dc) if (dc)
{ {
if(PATH_IsPathOpen(dc->path)) update_dc( dc );
if(PATH_IsPathOpen(dc->path))
ret = PATH_Arc(dc, left, top, right, bottom, xstart, ystart, xend, yend,0); ret = PATH_Arc(dc, left, top, right, bottom, xstart, ystart, xend, yend,0);
else if (dc->funcs->pArc) else if (dc->funcs->pArc)
ret = dc->funcs->pArc(dc->physDev,left,top,right,bottom,xstart,ystart,xend,yend); ret = dc->funcs->pArc(dc->physDev,left,top,right,bottom,xstart,ystart,xend,yend);
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
} }
return ret; return ret;
} }
@ -121,9 +124,10 @@ BOOL WINAPI ArcTo( HDC hdc,
ycenter = bottom > top ? top+yradius : bottom+yradius, ycenter = bottom > top ? top+yradius : bottom+yradius,
angle; angle;
BOOL result; BOOL result;
DC * dc = DC_GetDCUpdate( hdc ); DC * dc = get_dc_ptr( hdc );
if(!dc) return FALSE; if(!dc) return FALSE;
update_dc( dc );
if(PATH_IsPathOpen(dc->path)) if(PATH_IsPathOpen(dc->path))
result = PATH_Arc(dc,left,top,right,bottom,xstart,ystart,xend,yend,-1); result = PATH_Arc(dc,left,top,right,bottom,xstart,ystart,xend,yend,-1);
else if(dc->funcs->pArcTo) else if(dc->funcs->pArcTo)
@ -143,7 +147,7 @@ BOOL WINAPI ArcTo( HDC hdc,
dc->CursPosX = GDI_ROUND(xcenter+(cos(angle)*xradius)); dc->CursPosX = GDI_ROUND(xcenter+(cos(angle)*xradius));
dc->CursPosY = GDI_ROUND(ycenter+(sin(angle)*yradius)); dc->CursPosY = GDI_ROUND(ycenter+(sin(angle)*yradius));
} }
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
return result; return result;
} }
@ -156,15 +160,16 @@ BOOL WINAPI Pie( HDC hdc, INT left, INT top,
INT xend, INT yend ) INT xend, INT yend )
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
DC * dc = DC_GetDCUpdate( hdc ); DC * dc = get_dc_ptr( hdc );
if (!dc) return FALSE; if (!dc) return FALSE;
update_dc( dc );
if(PATH_IsPathOpen(dc->path)) if(PATH_IsPathOpen(dc->path))
ret = PATH_Arc(dc,left,top,right,bottom,xstart,ystart,xend,yend,2); ret = PATH_Arc(dc,left,top,right,bottom,xstart,ystart,xend,yend,2);
else if(dc->funcs->pPie) else if(dc->funcs->pPie)
ret = dc->funcs->pPie(dc->physDev,left,top,right,bottom,xstart,ystart,xend,yend); ret = dc->funcs->pPie(dc->physDev,left,top,right,bottom,xstart,ystart,xend,yend);
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
return ret; return ret;
} }
@ -177,15 +182,16 @@ BOOL WINAPI Chord( HDC hdc, INT left, INT top,
INT xend, INT yend ) INT xend, INT yend )
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
DC * dc = DC_GetDCUpdate( hdc ); DC * dc = get_dc_ptr( hdc );
if (!dc) return FALSE; if (!dc) return FALSE;
update_dc( dc );
if(PATH_IsPathOpen(dc->path)) if(PATH_IsPathOpen(dc->path))
ret = PATH_Arc(dc,left,top,right,bottom,xstart,ystart,xend,yend,1); ret = PATH_Arc(dc,left,top,right,bottom,xstart,ystart,xend,yend,1);
else if(dc->funcs->pChord) else if(dc->funcs->pChord)
ret = dc->funcs->pChord(dc->physDev,left,top,right,bottom,xstart,ystart,xend,yend); ret = dc->funcs->pChord(dc->physDev,left,top,right,bottom,xstart,ystart,xend,yend);
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
return ret; return ret;
} }
@ -197,15 +203,16 @@ BOOL WINAPI Ellipse( HDC hdc, INT left, INT top,
INT right, INT bottom ) INT right, INT bottom )
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
DC * dc = DC_GetDCUpdate( hdc ); DC * dc = get_dc_ptr( hdc );
if (!dc) return FALSE; if (!dc) return FALSE;
update_dc( dc );
if(PATH_IsPathOpen(dc->path)) if(PATH_IsPathOpen(dc->path))
ret = PATH_Ellipse(dc,left,top,right,bottom); ret = PATH_Ellipse(dc,left,top,right,bottom);
else if (dc->funcs->pEllipse) else if (dc->funcs->pEllipse)
ret = dc->funcs->pEllipse(dc->physDev,left,top,right,bottom); ret = dc->funcs->pEllipse(dc->physDev,left,top,right,bottom);
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
return ret; return ret;
} }
@ -217,14 +224,16 @@ BOOL WINAPI Rectangle( HDC hdc, INT left, INT top,
INT right, INT bottom ) INT right, INT bottom )
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
DC * dc = DC_GetDCUpdate( hdc ); DC * dc = get_dc_ptr( hdc );
if (dc) if (dc)
{ {
if(PATH_IsPathOpen(dc->path)) update_dc( dc );
if(PATH_IsPathOpen(dc->path))
ret = PATH_Rectangle(dc, left, top, right, bottom); ret = PATH_Rectangle(dc, left, top, right, bottom);
else if (dc->funcs->pRectangle) else if (dc->funcs->pRectangle)
ret = dc->funcs->pRectangle(dc->physDev,left,top,right,bottom); ret = dc->funcs->pRectangle(dc->physDev,left,top,right,bottom);
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
} }
return ret; return ret;
} }
@ -237,15 +246,16 @@ BOOL WINAPI RoundRect( HDC hdc, INT left, INT top, INT right,
INT bottom, INT ell_width, INT ell_height ) INT bottom, INT ell_width, INT ell_height )
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
DC *dc = DC_GetDCUpdate( hdc ); DC *dc = get_dc_ptr( hdc );
if (dc) if (dc)
{ {
update_dc( dc );
if(PATH_IsPathOpen(dc->path)) if(PATH_IsPathOpen(dc->path))
ret = PATH_RoundRect(dc,left,top,right,bottom,ell_width,ell_height); ret = PATH_RoundRect(dc,left,top,right,bottom,ell_width,ell_height);
else if (dc->funcs->pRoundRect) else if (dc->funcs->pRoundRect)
ret = dc->funcs->pRoundRect(dc->physDev,left,top,right,bottom,ell_width,ell_height); ret = dc->funcs->pRoundRect(dc->physDev,left,top,right,bottom,ell_width,ell_height);
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
} }
return ret; return ret;
} }
@ -256,11 +266,13 @@ BOOL WINAPI RoundRect( HDC hdc, INT left, INT top, INT right,
COLORREF WINAPI SetPixel( HDC hdc, INT x, INT y, COLORREF color ) COLORREF WINAPI SetPixel( HDC hdc, INT x, INT y, COLORREF color )
{ {
COLORREF ret = 0; COLORREF ret = 0;
DC * dc = DC_GetDCUpdate( hdc ); DC * dc = get_dc_ptr( hdc );
if (dc) if (dc)
{ {
update_dc( dc );
if (dc->funcs->pSetPixel) ret = dc->funcs->pSetPixel(dc->physDev,x,y,color); if (dc->funcs->pSetPixel) ret = dc->funcs->pSetPixel(dc->physDev,x,y,color);
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
} }
return ret; return ret;
} }
@ -271,15 +283,17 @@ COLORREF WINAPI SetPixel( HDC hdc, INT x, INT y, COLORREF color )
BOOL WINAPI SetPixelV( HDC hdc, INT x, INT y, COLORREF color ) BOOL WINAPI SetPixelV( HDC hdc, INT x, INT y, COLORREF color )
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
DC * dc = DC_GetDCUpdate( hdc ); DC * dc = get_dc_ptr( hdc );
if (dc) if (dc)
{ {
update_dc( dc );
if (dc->funcs->pSetPixel) if (dc->funcs->pSetPixel)
{ {
dc->funcs->pSetPixel(dc->physDev,x,y,color); dc->funcs->pSetPixel(dc->physDev,x,y,color);
ret = TRUE; ret = TRUE;
} }
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
} }
return ret; return ret;
} }
@ -290,16 +304,17 @@ BOOL WINAPI SetPixelV( HDC hdc, INT x, INT y, COLORREF color )
COLORREF WINAPI GetPixel( HDC hdc, INT x, INT y ) COLORREF WINAPI GetPixel( HDC hdc, INT x, INT y )
{ {
COLORREF ret = CLR_INVALID; COLORREF ret = CLR_INVALID;
DC * dc = DC_GetDCUpdate( hdc ); DC * dc = get_dc_ptr( hdc );
if (dc) if (dc)
{ {
/* FIXME: should this be in the graphics driver? */ update_dc( dc );
/* FIXME: should this be in the graphics driver? */
if (PtVisible( hdc, x, y )) if (PtVisible( hdc, x, y ))
{ {
if (dc->funcs->pGetPixel) ret = dc->funcs->pGetPixel(dc->physDev,x,y); if (dc->funcs->pGetPixel) ret = dc->funcs->pGetPixel(dc->physDev,x,y);
} }
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
} }
return ret; return ret;
} }
@ -469,11 +484,13 @@ BOOL WINAPI SwapBuffers( HDC hdc )
BOOL WINAPI PaintRgn( HDC hdc, HRGN hrgn ) BOOL WINAPI PaintRgn( HDC hdc, HRGN hrgn )
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
DC * dc = DC_GetDCUpdate( hdc ); DC * dc = get_dc_ptr( hdc );
if (dc) if (dc)
{ {
update_dc( dc );
if (dc->funcs->pPaintRgn) ret = dc->funcs->pPaintRgn(dc->physDev,hrgn); if (dc->funcs->pPaintRgn) ret = dc->funcs->pPaintRgn(dc->physDev,hrgn);
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
} }
return ret; return ret;
} }
@ -486,17 +503,20 @@ BOOL WINAPI FillRgn( HDC hdc, HRGN hrgn, HBRUSH hbrush )
{ {
BOOL retval = FALSE; BOOL retval = FALSE;
HBRUSH prevBrush; HBRUSH prevBrush;
DC * dc = DC_GetDCUpdate( hdc ); DC * dc = get_dc_ptr( hdc );
if (!dc) return FALSE; if (!dc) return FALSE;
if(dc->funcs->pFillRgn) if(dc->funcs->pFillRgn)
{
update_dc( dc );
retval = dc->funcs->pFillRgn(dc->physDev, hrgn, hbrush); retval = dc->funcs->pFillRgn(dc->physDev, hrgn, hbrush);
}
else if ((prevBrush = SelectObject( hdc, hbrush ))) else if ((prevBrush = SelectObject( hdc, hbrush )))
{ {
retval = PaintRgn( hdc, hrgn ); retval = PaintRgn( hdc, hrgn );
SelectObject( hdc, prevBrush ); SelectObject( hdc, prevBrush );
} }
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
return retval; return retval;
} }
@ -508,11 +528,15 @@ BOOL WINAPI FrameRgn( HDC hdc, HRGN hrgn, HBRUSH hbrush,
INT nWidth, INT nHeight ) INT nWidth, INT nHeight )
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
DC *dc = DC_GetDCUpdate( hdc ); DC *dc = get_dc_ptr( hdc );
if (!dc) return FALSE; if (!dc) return FALSE;
if(dc->funcs->pFrameRgn) if(dc->funcs->pFrameRgn)
{
update_dc( dc );
ret = dc->funcs->pFrameRgn( dc->physDev, hrgn, hbrush, nWidth, nHeight ); ret = dc->funcs->pFrameRgn( dc->physDev, hrgn, hbrush, nWidth, nHeight );
}
else else
{ {
HRGN tmp = CreateRectRgn( 0, 0, 0, 0 ); HRGN tmp = CreateRectRgn( 0, 0, 0, 0 );
@ -526,7 +550,7 @@ BOOL WINAPI FrameRgn( HDC hdc, HRGN hrgn, HBRUSH hbrush,
DeleteObject( tmp ); DeleteObject( tmp );
} }
} }
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
return ret; return ret;
} }
@ -539,20 +563,23 @@ BOOL WINAPI InvertRgn( HDC hdc, HRGN hrgn )
HBRUSH prevBrush; HBRUSH prevBrush;
INT prevROP; INT prevROP;
BOOL retval; BOOL retval;
DC *dc = DC_GetDCUpdate( hdc ); DC *dc = get_dc_ptr( hdc );
if (!dc) return FALSE; if (!dc) return FALSE;
if(dc->funcs->pInvertRgn) if(dc->funcs->pInvertRgn)
{
update_dc( dc );
retval = dc->funcs->pInvertRgn( dc->physDev, hrgn ); retval = dc->funcs->pInvertRgn( dc->physDev, hrgn );
}
else else
{ {
prevBrush = SelectObject( hdc, GetStockObject(BLACK_BRUSH) ); prevBrush = SelectObject( hdc, GetStockObject(BLACK_BRUSH) );
prevROP = SetROP2( hdc, R2_NOT ); prevROP = SetROP2( hdc, R2_NOT );
retval = PaintRgn( hdc, hrgn ); retval = PaintRgn( hdc, hrgn );
SelectObject( hdc, prevBrush ); SelectObject( hdc, prevBrush );
SetROP2( hdc, prevROP ); SetROP2( hdc, prevROP );
} }
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
return retval; return retval;
} }
@ -563,12 +590,14 @@ BOOL WINAPI InvertRgn( HDC hdc, HRGN hrgn )
BOOL WINAPI Polyline( HDC hdc, const POINT* pt, INT count ) BOOL WINAPI Polyline( HDC hdc, const POINT* pt, INT count )
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
DC * dc = DC_GetDCUpdate( hdc ); DC * dc = get_dc_ptr( hdc );
if (dc) if (dc)
{ {
update_dc( dc );
if (PATH_IsPathOpen(dc->path)) ret = PATH_Polyline(dc, pt, count); if (PATH_IsPathOpen(dc->path)) ret = PATH_Polyline(dc, pt, count);
else if (dc->funcs->pPolyline) ret = dc->funcs->pPolyline(dc->physDev,pt,count); else if (dc->funcs->pPolyline) ret = dc->funcs->pPolyline(dc->physDev,pt,count);
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
} }
return ret; return ret;
} }
@ -578,34 +607,39 @@ BOOL WINAPI Polyline( HDC hdc, const POINT* pt, INT count )
*/ */
BOOL WINAPI PolylineTo( HDC hdc, const POINT* pt, DWORD cCount ) BOOL WINAPI PolylineTo( HDC hdc, const POINT* pt, DWORD cCount )
{ {
DC * dc = DC_GetDCUpdate( hdc ); DC * dc = get_dc_ptr( hdc );
BOOL ret = FALSE; BOOL ret = FALSE;
if(!dc) return FALSE; if(!dc) return FALSE;
if(PATH_IsPathOpen(dc->path)) if(PATH_IsPathOpen(dc->path))
{
update_dc( dc );
ret = PATH_PolylineTo(dc, pt, cCount); ret = PATH_PolylineTo(dc, pt, cCount);
}
else if(dc->funcs->pPolylineTo) else if(dc->funcs->pPolylineTo)
{
update_dc( dc );
ret = dc->funcs->pPolylineTo(dc->physDev, pt, cCount); ret = dc->funcs->pPolylineTo(dc->physDev, pt, cCount);
}
else { /* do it using Polyline */ else /* do it using Polyline */
{
POINT *pts = HeapAlloc( GetProcessHeap(), 0, POINT *pts = HeapAlloc( GetProcessHeap(), 0,
sizeof(POINT) * (cCount + 1) ); sizeof(POINT) * (cCount + 1) );
if (pts) if (pts)
{ {
pts[0].x = dc->CursPosX; pts[0].x = dc->CursPosX;
pts[0].y = dc->CursPosY; pts[0].y = dc->CursPosY;
memcpy( pts + 1, pt, sizeof(POINT) * cCount ); memcpy( pts + 1, pt, sizeof(POINT) * cCount );
ret = Polyline( hdc, pts, cCount + 1 ); ret = Polyline( hdc, pts, cCount + 1 );
HeapFree( GetProcessHeap(), 0, pts ); HeapFree( GetProcessHeap(), 0, pts );
} }
} }
if(ret) { if(ret) {
dc->CursPosX = pt[cCount-1].x; dc->CursPosX = pt[cCount-1].x;
dc->CursPosY = pt[cCount-1].y; dc->CursPosY = pt[cCount-1].y;
} }
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
return ret; return ret;
} }
@ -616,12 +650,14 @@ BOOL WINAPI PolylineTo( HDC hdc, const POINT* pt, DWORD cCount )
BOOL WINAPI Polygon( HDC hdc, const POINT* pt, INT count ) BOOL WINAPI Polygon( HDC hdc, const POINT* pt, INT count )
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
DC * dc = DC_GetDCUpdate( hdc ); DC * dc = get_dc_ptr( hdc );
if (dc) if (dc)
{ {
update_dc( dc );
if (PATH_IsPathOpen(dc->path)) ret = PATH_Polygon(dc, pt, count); if (PATH_IsPathOpen(dc->path)) ret = PATH_Polygon(dc, pt, count);
else if (dc->funcs->pPolygon) ret = dc->funcs->pPolygon(dc->physDev,pt,count); else if (dc->funcs->pPolygon) ret = dc->funcs->pPolygon(dc->physDev,pt,count);
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
} }
return ret; return ret;
} }
@ -634,12 +670,14 @@ BOOL WINAPI PolyPolygon( HDC hdc, const POINT* pt, const INT* counts,
UINT polygons ) UINT polygons )
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
DC * dc = DC_GetDCUpdate( hdc ); DC * dc = get_dc_ptr( hdc );
if (dc) if (dc)
{ {
update_dc( dc );
if (PATH_IsPathOpen(dc->path)) ret = PATH_PolyPolygon(dc, pt, counts, polygons); if (PATH_IsPathOpen(dc->path)) ret = PATH_PolyPolygon(dc, pt, counts, polygons);
else if (dc->funcs->pPolyPolygon) ret = dc->funcs->pPolyPolygon(dc->physDev,pt,counts,polygons); else if (dc->funcs->pPolyPolygon) ret = dc->funcs->pPolyPolygon(dc->physDev,pt,counts,polygons);
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
} }
return ret; return ret;
} }
@ -651,12 +689,14 @@ BOOL WINAPI PolyPolyline( HDC hdc, const POINT* pt, const DWORD* counts,
DWORD polylines ) DWORD polylines )
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
DC * dc = DC_GetDCUpdate( hdc ); DC * dc = get_dc_ptr( hdc );
if (dc) if (dc)
{ {
update_dc( dc );
if (PATH_IsPathOpen(dc->path)) ret = PATH_PolyPolyline(dc, pt, counts, polylines); if (PATH_IsPathOpen(dc->path)) ret = PATH_PolyPolyline(dc, pt, counts, polylines);
else if (dc->funcs->pPolyPolyline) ret = dc->funcs->pPolyPolyline(dc->physDev,pt,counts,polylines); else if (dc->funcs->pPolyPolyline) ret = dc->funcs->pPolyPolyline(dc->physDev,pt,counts,polylines);
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
} }
return ret; return ret;
} }
@ -668,11 +708,13 @@ BOOL WINAPI ExtFloodFill( HDC hdc, INT x, INT y, COLORREF color,
UINT fillType ) UINT fillType )
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
DC * dc = DC_GetDCUpdate( hdc ); DC * dc = get_dc_ptr( hdc );
if (dc) if (dc)
{ {
update_dc( dc );
if (dc->funcs->pExtFloodFill) ret = dc->funcs->pExtFloodFill(dc->physDev,x,y,color,fillType); if (dc->funcs->pExtFloodFill) ret = dc->funcs->pExtFloodFill(dc->physDev,x,y,color,fillType);
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
} }
return ret; return ret;
} }
@ -708,13 +750,19 @@ BOOL WINAPI PolyBezier( HDC hdc, const POINT* lppt, DWORD cPoints )
/* cPoints must be 3 * n + 1 (where n>=1) */ /* cPoints must be 3 * n + 1 (where n>=1) */
if (cPoints == 1 || (cPoints % 3) != 1) return FALSE; if (cPoints == 1 || (cPoints % 3) != 1) return FALSE;
dc = DC_GetDCUpdate( hdc ); dc = get_dc_ptr( hdc );
if(!dc) return FALSE; if(!dc) return FALSE;
if(PATH_IsPathOpen(dc->path)) if(PATH_IsPathOpen(dc->path))
{
update_dc( dc );
ret = PATH_PolyBezier(dc, lppt, cPoints); ret = PATH_PolyBezier(dc, lppt, cPoints);
}
else if (dc->funcs->pPolyBezier) else if (dc->funcs->pPolyBezier)
{
update_dc( dc );
ret = dc->funcs->pPolyBezier(dc->physDev, lppt, cPoints); ret = dc->funcs->pPolyBezier(dc->physDev, lppt, cPoints);
}
else /* We'll convert it into line segments and draw them using Polyline */ else /* We'll convert it into line segments and draw them using Polyline */
{ {
POINT *Pts; POINT *Pts;
@ -723,12 +771,12 @@ BOOL WINAPI PolyBezier( HDC hdc, const POINT* lppt, DWORD cPoints )
if ((Pts = GDI_Bezier( lppt, cPoints, &nOut ))) if ((Pts = GDI_Bezier( lppt, cPoints, &nOut )))
{ {
TRACE("Pts = %p, no = %d\n", Pts, nOut); TRACE("Pts = %p, no = %d\n", Pts, nOut);
ret = Polyline( dc->hSelf, Pts, nOut ); ret = Polyline( hdc, Pts, nOut );
HeapFree( GetProcessHeap(), 0, Pts ); HeapFree( GetProcessHeap(), 0, Pts );
} }
} }
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
return ret; return ret;
} }
@ -748,33 +796,41 @@ BOOL WINAPI PolyBezier( HDC hdc, const POINT* lppt, DWORD cPoints )
BOOL WINAPI PolyBezierTo( HDC hdc, const POINT* lppt, DWORD cPoints ) BOOL WINAPI PolyBezierTo( HDC hdc, const POINT* lppt, DWORD cPoints )
{ {
DC * dc; DC * dc;
BOOL ret; BOOL ret = FALSE;
/* cbPoints must be 3 * n (where n>=1) */ /* cbPoints must be 3 * n (where n>=1) */
if (!cPoints || (cPoints % 3) != 0) return FALSE; if (!cPoints || (cPoints % 3) != 0) return FALSE;
dc = DC_GetDCUpdate( hdc ); dc = get_dc_ptr( hdc );
if(!dc) return FALSE; if(!dc) return FALSE;
if(PATH_IsPathOpen(dc->path)) if(PATH_IsPathOpen(dc->path))
{
update_dc( dc );
ret = PATH_PolyBezierTo(dc, lppt, cPoints); ret = PATH_PolyBezierTo(dc, lppt, cPoints);
}
else if(dc->funcs->pPolyBezierTo) else if(dc->funcs->pPolyBezierTo)
{
update_dc( dc );
ret = dc->funcs->pPolyBezierTo(dc->physDev, lppt, cPoints); ret = dc->funcs->pPolyBezierTo(dc->physDev, lppt, cPoints);
else { /* We'll do it using PolyBezier */ }
POINT *pt; else /* We'll do it using PolyBezier */
pt = HeapAlloc( GetProcessHeap(), 0, sizeof(POINT) * (cPoints + 1) ); {
if(!pt) return FALSE; POINT *pt = HeapAlloc( GetProcessHeap(), 0, sizeof(POINT) * (cPoints + 1) );
pt[0].x = dc->CursPosX; if(pt)
pt[0].y = dc->CursPosY; {
memcpy(pt + 1, lppt, sizeof(POINT) * cPoints); pt[0].x = dc->CursPosX;
ret = PolyBezier(dc->hSelf, pt, cPoints+1); pt[0].y = dc->CursPosY;
HeapFree( GetProcessHeap(), 0, pt ); memcpy(pt + 1, lppt, sizeof(POINT) * cPoints);
ret = PolyBezier(hdc, pt, cPoints+1);
HeapFree( GetProcessHeap(), 0, pt );
}
} }
if(ret) { if(ret) {
dc->CursPosX = lppt[cPoints-1].x; dc->CursPosX = lppt[cPoints-1].x;
dc->CursPosY = lppt[cPoints-1].y; dc->CursPosY = lppt[cPoints-1].y;
} }
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
return ret; return ret;
} }
@ -790,7 +846,7 @@ BOOL WINAPI AngleArc(HDC hdc, INT x, INT y, DWORD dwRadius, FLOAT eStartAngle, F
if( (signed int)dwRadius < 0 ) if( (signed int)dwRadius < 0 )
return FALSE; return FALSE;
dc = DC_GetDCUpdate( hdc ); dc = get_dc_ptr( hdc );
if(!dc) return FALSE; if(!dc) return FALSE;
/* Calculate the end point */ /* Calculate the end point */
@ -798,7 +854,10 @@ BOOL WINAPI AngleArc(HDC hdc, INT x, INT y, DWORD dwRadius, FLOAT eStartAngle, F
y2 = y - sin((eStartAngle+eSweepAngle)*M_PI/180) * dwRadius; y2 = y - sin((eStartAngle+eSweepAngle)*M_PI/180) * dwRadius;
if(!PATH_IsPathOpen(dc->path) && dc->funcs->pAngleArc) if(!PATH_IsPathOpen(dc->path) && dc->funcs->pAngleArc)
{
update_dc( dc );
result = dc->funcs->pAngleArc( dc->physDev, x, y, dwRadius, eStartAngle, eSweepAngle ); result = dc->funcs->pAngleArc( dc->physDev, x, y, dwRadius, eStartAngle, eSweepAngle );
}
else { /* do it using ArcTo */ else { /* do it using ArcTo */
x1 = x + cos(eStartAngle*M_PI/180) * dwRadius; x1 = x + cos(eStartAngle*M_PI/180) * dwRadius;
y1 = y - sin(eStartAngle*M_PI/180) * dwRadius; y1 = y - sin(eStartAngle*M_PI/180) * dwRadius;
@ -812,7 +871,7 @@ BOOL WINAPI AngleArc(HDC hdc, INT x, INT y, DWORD dwRadius, FLOAT eStartAngle, F
dc->CursPosX = x2; dc->CursPosX = x2;
dc->CursPosY = y2; dc->CursPosY = y2;
} }
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
return result; return result;
} }
@ -827,13 +886,19 @@ BOOL WINAPI PolyDraw(HDC hdc, const POINT *lppt, const BYTE *lpbTypes,
POINT * line_pts = NULL, * bzr_pts = NULL, bzr[4]; POINT * line_pts = NULL, * bzr_pts = NULL, bzr[4];
INT i, num_pts, num_bzr_pts, space, size; INT i, num_pts, num_bzr_pts, space, size;
dc = DC_GetDCUpdate( hdc ); dc = get_dc_ptr( hdc );
if(!dc) return FALSE; if(!dc) return FALSE;
if( PATH_IsPathOpen( dc->path ) ) if( PATH_IsPathOpen( dc->path ) )
{
update_dc( dc );
result = PATH_PolyDraw(dc, lppt, lpbTypes, cCount); result = PATH_PolyDraw(dc, lppt, lpbTypes, cCount);
}
else if(dc->funcs->pPolyDraw) else if(dc->funcs->pPolyDraw)
{
update_dc( dc );
result = dc->funcs->pPolyDraw( dc->physDev, lppt, lpbTypes, cCount ); result = dc->funcs->pPolyDraw( dc->physDev, lppt, lpbTypes, cCount );
}
else { else {
/* check for valid point types */ /* check for valid point types */
for(i = 0; i < cCount; i++) { for(i = 0; i < cCount; i++) {
@ -864,7 +929,7 @@ BOOL WINAPI PolyDraw(HDC hdc, const POINT *lppt, const BYTE *lpbTypes,
switch(lpbTypes[i]) { switch(lpbTypes[i]) {
case PT_MOVETO: case PT_MOVETO:
if(num_pts >= 2) if(num_pts >= 2)
Polyline(dc->hSelf, line_pts, num_pts); Polyline(hdc, line_pts, num_pts);
num_pts = 0; num_pts = 0;
line_pts[num_pts++] = lppt[i]; line_pts[num_pts++] = lppt[i];
break; break;
@ -900,15 +965,15 @@ BOOL WINAPI PolyDraw(HDC hdc, const POINT *lppt, const BYTE *lpbTypes,
} }
if(num_pts >= 2) if(num_pts >= 2)
Polyline(dc->hSelf, line_pts, num_pts); Polyline(hdc, line_pts, num_pts);
MoveToEx(dc->hSelf, line_pts[num_pts - 1].x, line_pts[num_pts - 1].y, NULL); MoveToEx(hdc, line_pts[num_pts - 1].x, line_pts[num_pts - 1].y, NULL);
result = TRUE; result = TRUE;
} }
end: end:
DC_ReleaseDCPtr( dc ); release_dc_ptr( dc );
return result; return result;
} }