Commit 3f779e47 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

gdi32: Introduce DC_ATTR struct and use it to store current position.

parent b7899923
......@@ -30,6 +30,7 @@
#include "winternl.h"
#include "winerror.h"
#include "ntgdi_private.h"
#include "gdi_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(dc);
......@@ -99,8 +100,8 @@ static void set_initial_dc_state( DC *dc )
dc->breakRem = 0;
dc->MapMode = MM_TEXT;
dc->GraphicsMode = GM_COMPATIBLE;
dc->cur_pos.x = 0;
dc->cur_pos.y = 0;
dc->attr->cur_pos.x = 0;
dc->attr->cur_pos.y = 0;
dc->ArcDirection = AD_COUNTERCLOCKWISE;
dc->xformWorld2Wnd.eM11 = 1.0f;
dc->xformWorld2Wnd.eM12 = 0.0f;
......@@ -123,6 +124,11 @@ DC *alloc_dc_ptr( WORD magic )
DC *dc;
if (!(dc = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dc) ))) return NULL;
if (!(dc->attr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dc->attr))))
{
HeapFree( GetProcessHeap(), 0, dc->attr );
return NULL;
}
dc->nulldrv.funcs = &null_driver;
dc->physDev = &dc->nulldrv;
......@@ -137,10 +143,12 @@ DC *alloc_dc_ptr( WORD magic )
if (!(dc->hSelf = alloc_gdi_handle( &dc->obj, magic, &dc_funcs )))
{
HeapFree( GetProcessHeap(), 0, dc->attr );
HeapFree( GetProcessHeap(), 0, dc );
return NULL;
}
dc->nulldrv.hdc = dc->hSelf;
set_gdi_client_ptr( dc->hSelf, dc->attr );
if (!font_driver.pCreateDC( &dc->physDev, NULL, NULL, NULL, NULL ))
{
......@@ -162,6 +170,7 @@ static void free_dc_state( DC *dc )
if (dc->hVisRgn) DeleteObject( dc->hVisRgn );
if (dc->region) DeleteObject( dc->region );
if (dc->path) free_gdi_path( dc->path );
HeapFree( GetProcessHeap(), 0, dc->attr );
HeapFree( GetProcessHeap(), 0, dc );
}
......@@ -378,6 +387,11 @@ INT CDECL nulldrv_SaveDC( PHYSDEV dev )
DC *newdc, *dc = get_nulldrv_dc( dev );
if (!(newdc = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*newdc )))) return 0;
if (!(newdc->attr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*newdc->attr) )))
{
HeapFree( GetProcessHeap(), 0, newdc );
return 0;
}
newdc->layout = dc->layout;
newdc->hPen = dc->hPen;
newdc->hBrush = dc->hBrush;
......@@ -401,7 +415,7 @@ INT CDECL nulldrv_SaveDC( PHYSDEV dev )
newdc->breakRem = dc->breakRem;
newdc->MapMode = dc->MapMode;
newdc->GraphicsMode = dc->GraphicsMode;
newdc->cur_pos = dc->cur_pos;
newdc->attr->cur_pos = dc->attr->cur_pos;
newdc->ArcDirection = dc->ArcDirection;
newdc->xformWorld2Wnd = dc->xformWorld2Wnd;
newdc->xformWorld2Vport = dc->xformWorld2Vport;
......@@ -478,7 +492,7 @@ BOOL CDECL nulldrv_RestoreDC( PHYSDEV dev, INT level )
dc->breakRem = dcs->breakRem;
dc->MapMode = dcs->MapMode;
dc->GraphicsMode = dcs->GraphicsMode;
dc->cur_pos = dcs->cur_pos;
dc->attr->cur_pos = dcs->attr->cur_pos;
dc->ArcDirection = dcs->ArcDirection;
dc->xformWorld2Wnd = dcs->xformWorld2Wnd;
dc->xformWorld2Vport = dcs->xformWorld2Vport;
......@@ -1826,7 +1840,7 @@ BOOL WINAPI GetCurrentPositionEx( HDC hdc, LPPOINT pt )
{
DC * dc = get_dc_ptr( hdc );
if (!dc) return FALSE;
*pt = dc->cur_pos;
*pt = dc->attr->cur_pos;
release_dc_ptr( dc );
return TRUE;
}
......
......@@ -345,7 +345,7 @@ static BOOL draw_arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
if (extra_lines == -1)
{
points[0] = dc->cur_pos;
points[0] = dc->attr->cur_pos;
lp_to_dp( dc, points, 1 );
count = 1 + get_arc_points( dc->ArcDirection, &rect, pt[0], pt[1], points + 1 );
}
......@@ -1140,7 +1140,7 @@ BOOL CDECL dibdrv_LineTo( PHYSDEV dev, INT x, INT y )
HRGN region = 0;
BOOL ret;
pts[0] = dc->cur_pos;
pts[0] = dc->attr->cur_pos;
pts[1].x = x;
pts[1].y = y;
......
......@@ -72,8 +72,8 @@ static void get_points_bounds( RECTL *bounds, const POINT *pts, UINT count, DC *
if (dc)
{
bounds->left = bounds->right = dc->cur_pos.x;
bounds->top = bounds->bottom = dc->cur_pos.y;
bounds->left = bounds->right = dc->attr->cur_pos.x;
bounds->top = bounds->bottom = dc->attr->cur_pos.y;
}
else if (count)
{
......@@ -151,7 +151,7 @@ BOOL CDECL EMFDRV_LineTo( PHYSDEV dev, INT x, INT y )
if(!EMFDRV_WriteRecord( dev, &emr.emr ))
return FALSE;
pt = dc->cur_pos;
pt = dc->attr->cur_pos;
bounds.left = min(x, pt.x);
bounds.top = min(y, pt.y);
......@@ -266,7 +266,7 @@ EMFDRV_ArcChordPie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
if (iType == EMR_ARCTO)
{
POINT pt;
pt = dc->cur_pos;
pt = dc->attr->cur_pos;
bounds.left = min( bounds.left, pt.x );
bounds.top = min( bounds.top, pt.y );
bounds.right = max( bounds.right, pt.x );
......
......@@ -6004,7 +6004,7 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
if(align & TA_UPDATECP)
{
pt = dc->cur_pos;
pt = dc->attr->cur_pos;
x = pt.x;
y = pt.y;
}
......
......@@ -81,6 +81,7 @@ typedef struct tagDC
LONG dirty; /* dirty flag */
LONG disabled; /* get_dc_ptr() will return NULL. Controlled by DCHF_(DISABLE|ENABLE)DC */
INT saveLevel;
DC_ATTR *attr; /* DC attributes accessible by client */
struct tagDC *saved_dc;
DWORD_PTR dwHookData;
DCHOOKPROC hookProc; /* DC hook */
......@@ -136,7 +137,6 @@ typedef struct tagDC
INT MapMode;
INT GraphicsMode; /* Graphics mode */
ABORTPROC pAbortProc; /* AbortProc for Printing */
POINT cur_pos; /* Current position */
INT ArcDirection;
XFORM xformWorld2Wnd; /* World-to-window transformation */
XFORM xformWorld2Vport; /* World-to-viewport transformation */
......
......@@ -127,7 +127,7 @@ BOOL CDECL nulldrv_PolyBezierTo( PHYSDEV dev, const POINT *points, DWORD count )
if (pts)
{
pts[0] = dc->cur_pos;
pts[0] = dc->attr->cur_pos;
memcpy( pts + 1, points, sizeof(POINT) * count );
ret = PolyBezier( dev->hdc, pts, count + 1 );
HeapFree( GetProcessHeap(), 0, pts );
......@@ -166,7 +166,7 @@ BOOL CDECL nulldrv_PolyDraw( PHYSDEV dev, const POINT *points, const BYTE *types
line_pts = HeapAlloc( GetProcessHeap(), 0, space * sizeof(POINT) );
num_pts = 1;
line_pts[0] = dc->cur_pos;
line_pts[0] = dc->attr->cur_pos;
for (i = 0; i < count; i++)
{
switch (types[i])
......@@ -217,7 +217,7 @@ BOOL CDECL nulldrv_PolylineTo( PHYSDEV dev, const POINT *points, INT count )
if (!count) return FALSE;
if ((pts = HeapAlloc( GetProcessHeap(), 0, sizeof(POINT) * (count + 1) )))
{
pts[0] = dc->cur_pos;
pts[0] = dc->attr->cur_pos;
memcpy( pts + 1, points, sizeof(POINT) * count );
ret = Polyline( dev->hdc, pts, count + 1 );
HeapFree( GetProcessHeap(), 0, pts );
......@@ -242,8 +242,8 @@ BOOL WINAPI NtGdiLineTo( HDC hdc, INT x, INT y )
if(ret)
{
dc->cur_pos.x = x;
dc->cur_pos.y = y;
dc->attr->cur_pos.x = x;
dc->attr->cur_pos.y = y;
}
release_dc_ptr( dc );
return ret;
......@@ -262,10 +262,10 @@ BOOL WINAPI NtGdiMoveTo( HDC hdc, INT x, INT y, POINT *pt )
if(!dc) return FALSE;
if(pt)
*pt = dc->cur_pos;
*pt = dc->attr->cur_pos;
dc->cur_pos.x = x;
dc->cur_pos.y = y;
dc->attr->cur_pos.x = x;
dc->attr->cur_pos.y = y;
physdev = GET_DC_PHYSDEV( dc, pMoveTo );
ret = physdev->funcs->pMoveTo( physdev, x, y );
......@@ -310,8 +310,8 @@ BOOL WINAPI NtGdiArcInternal( UINT type, HDC hdc, INT left, INT top, INT right,
{
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) );
dc->attr->cur_pos.x = GDI_ROUND( xcenter + (cos( angle ) * xradius) );
dc->attr->cur_pos.y = GDI_ROUND( ycenter + (sin( angle ) * yradius) );
}
break;
}
......@@ -614,7 +614,7 @@ BOOL WINAPI PolylineTo( HDC hdc, const POINT* pt, DWORD cCount )
ret = physdev->funcs->pPolylineTo( physdev, pt, cCount );
if (ret && cCount)
dc->cur_pos = pt[cCount - 1];
dc->attr->cur_pos = pt[cCount - 1];
release_dc_ptr( dc );
return ret;
......@@ -777,7 +777,7 @@ BOOL WINAPI PolyBezierTo( HDC hdc, const POINT* lppt, DWORD cPoints )
ret = physdev->funcs->pPolyBezierTo( physdev, lppt, cPoints );
if(ret)
dc->cur_pos = lppt[cPoints - 1];
dc->attr->cur_pos = lppt[cPoints - 1];
release_dc_ptr( dc );
return ret;
......@@ -806,8 +806,8 @@ BOOL WINAPI AngleArc(HDC hdc, INT x, INT y, DWORD dwRadius, FLOAT eStartAngle, F
if (result)
{
dc->cur_pos.x = GDI_ROUND( x + cos( (eStartAngle + eSweepAngle) * M_PI / 180 ) * dwRadius );
dc->cur_pos.y = GDI_ROUND( y - sin( (eStartAngle + eSweepAngle) * M_PI / 180 ) * dwRadius );
dc->attr->cur_pos.x = GDI_ROUND( x + cos( (eStartAngle + eSweepAngle) * M_PI / 180 ) * dwRadius );
dc->attr->cur_pos.y = GDI_ROUND( y - sin( (eStartAngle + eSweepAngle) * M_PI / 180 ) * dwRadius );
}
release_dc_ptr( dc );
return result;
......@@ -831,7 +831,7 @@ BOOL WINAPI PolyDraw(HDC hdc, const POINT *lppt, const BYTE *lpbTypes,
physdev = GET_DC_PHYSDEV( dc, pPolyDraw );
result = physdev->funcs->pPolyDraw( physdev, lppt, lpbTypes, cCount );
if (result && cCount)
dc->cur_pos = lppt[cCount - 1];
dc->attr->cur_pos = lppt[cCount - 1];
release_dc_ptr( dc );
return result;
......
......@@ -2024,7 +2024,7 @@ BOOL CDECL nulldrv_BeginPath( PHYSDEV dev )
}
physdev = get_path_physdev( find_dc_driver( dc, &path_driver ));
physdev->path = path;
path->pos = dc->cur_pos;
path->pos = dc->attr->cur_pos;
lp_to_dp( dc, &path->pos, 1 );
if (dc->path) free_gdi_path( dc->path );
dc->path = NULL;
......
......@@ -83,6 +83,16 @@ enum
NtGdiPie,
};
/* structs not compatible with native Windows */
#ifdef __WINESRC__
typedef struct DC_ATTR
{
POINT cur_pos;
} DC_ATTR;
#endif /* __WINESRC__ */
INT WINAPI NtGdiAbortDoc( HDC hdc );
BOOL WINAPI NtGdiAbortPath( HDC hdc );
BOOL WINAPI NtGdiAngleArc( HDC hdc, INT x, INT y, DWORD radius, FLOAT start_angle,
......
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