gdi32: Use POINT and SIZE to hold positions and extents.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2016-07-27 09:59:25 +01:00 committed by Alexandre Julliard
parent 82ca87bc2d
commit 6a8cfea99b
9 changed files with 159 additions and 186 deletions

View File

@ -394,12 +394,10 @@ BOOL WINAPI SetBrushOrgEx( HDC hdc, INT x, INT y, LPPOINT oldorg )
if (!dc) return FALSE; if (!dc) return FALSE;
if (oldorg) if (oldorg)
{ *oldorg = dc->brush_org;
oldorg->x = dc->brushOrgX;
oldorg->y = dc->brushOrgY; dc->brush_org.x = x;
} dc->brush_org.y = y;
dc->brushOrgX = x;
dc->brushOrgY = y;
release_dc_ptr( dc ); release_dc_ptr( dc );
return TRUE; return TRUE;
} }

View File

@ -233,8 +233,8 @@ INT nulldrv_OffsetClipRgn( PHYSDEV dev, INT x, INT y )
if (dc->hClipRgn) if (dc->hClipRgn)
{ {
x = MulDiv( x, dc->vportExtX, dc->wndExtX ); x = MulDiv( x, dc->vport_ext.cx, dc->wnd_ext.cx );
y = MulDiv( y, dc->vportExtY, dc->wndExtY ); y = MulDiv( y, dc->vport_ext.cy, dc->wnd_ext.cy );
if (dc->layout & LAYOUT_RTL) x = -x; if (dc->layout & LAYOUT_RTL) x = -x;
ret = OffsetRgn( dc->hClipRgn, x, y ); ret = OffsetRgn( dc->hClipRgn, x, y );
update_dc_clipping( dc ); update_dc_clipping( dc );

View File

@ -76,14 +76,14 @@ static inline DC *get_dc_obj( HDC hdc )
*/ */
static void set_initial_dc_state( DC *dc ) static void set_initial_dc_state( DC *dc )
{ {
dc->wndOrgX = 0; dc->wnd_org.x = 0;
dc->wndOrgY = 0; dc->wnd_org.y = 0;
dc->wndExtX = 1; dc->wnd_ext.cx = 1;
dc->wndExtY = 1; dc->wnd_ext.cy = 1;
dc->vportOrgX = 0; dc->vport_org.x = 0;
dc->vportOrgY = 0; dc->vport_org.y = 0;
dc->vportExtX = 1; dc->vport_ext.cx = 1;
dc->vportExtY = 1; dc->vport_ext.cy = 1;
dc->miterLimit = 10.0f; /* 10.0 is the default, from MSDN */ dc->miterLimit = 10.0f; /* 10.0 is the default, from MSDN */
dc->layout = 0; dc->layout = 0;
dc->font_code_page = CP_ACP; dc->font_code_page = CP_ACP;
@ -96,8 +96,8 @@ static void set_initial_dc_state( DC *dc )
dc->dcBrushColor = RGB( 255, 255, 255 ); dc->dcBrushColor = RGB( 255, 255, 255 );
dc->dcPenColor = RGB( 0, 0, 0 ); dc->dcPenColor = RGB( 0, 0, 0 );
dc->textColor = RGB( 0, 0, 0 ); dc->textColor = RGB( 0, 0, 0 );
dc->brushOrgX = 0; dc->brush_org.x = 0;
dc->brushOrgY = 0; dc->brush_org.y = 0;
dc->mapperFlags = 0; dc->mapperFlags = 0;
dc->textAlign = TA_LEFT | TA_TOP | TA_NOUPDATECP; dc->textAlign = TA_LEFT | TA_TOP | TA_NOUPDATECP;
dc->charExtra = 0; dc->charExtra = 0;
@ -105,8 +105,8 @@ static void set_initial_dc_state( DC *dc )
dc->breakRem = 0; dc->breakRem = 0;
dc->MapMode = MM_TEXT; dc->MapMode = MM_TEXT;
dc->GraphicsMode = GM_COMPATIBLE; dc->GraphicsMode = GM_COMPATIBLE;
dc->CursPosX = 0; dc->cur_pos.x = 0;
dc->CursPosY = 0; dc->cur_pos.y = 0;
dc->ArcDirection = AD_COUNTERCLOCKWISE; dc->ArcDirection = AD_COUNTERCLOCKWISE;
dc->xformWorld2Wnd.eM11 = 1.0f; dc->xformWorld2Wnd.eM11 = 1.0f;
dc->xformWorld2Wnd.eM12 = 0.0f; dc->xformWorld2Wnd.eM12 = 0.0f;
@ -311,16 +311,16 @@ static BOOL DC_InvertXform( const XFORM *xformSrc, XFORM *xformDest )
static void construct_window_to_viewport(DC *dc, XFORM *xform) static void construct_window_to_viewport(DC *dc, XFORM *xform)
{ {
double scaleX, scaleY; double scaleX, scaleY;
scaleX = (double)dc->vportExtX / (double)dc->wndExtX; scaleX = (double)dc->vport_ext.cx / (double)dc->wnd_ext.cx;
scaleY = (double)dc->vportExtY / (double)dc->wndExtY; scaleY = (double)dc->vport_ext.cy / (double)dc->wnd_ext.cy;
if (dc->layout & LAYOUT_RTL) scaleX = -scaleX; if (dc->layout & LAYOUT_RTL) scaleX = -scaleX;
xform->eM11 = scaleX; xform->eM11 = scaleX;
xform->eM12 = 0.0; xform->eM12 = 0.0;
xform->eM21 = 0.0; xform->eM21 = 0.0;
xform->eM22 = scaleY; xform->eM22 = scaleY;
xform->eDx = (double)dc->vportOrgX - scaleX * (double)dc->wndOrgX; xform->eDx = (double)dc->vport_org.x - scaleX * (double)dc->wnd_org.x;
xform->eDy = (double)dc->vportOrgY - scaleY * (double)dc->wndOrgY; xform->eDy = (double)dc->vport_org.y - scaleY * (double)dc->wnd_org.y;
if (dc->layout & LAYOUT_RTL) xform->eDx = dc->vis_rect.right - dc->vis_rect.left - 1 - xform->eDx; if (dc->layout & LAYOUT_RTL) xform->eDx = dc->vis_rect.right - dc->vis_rect.left - 1 - xform->eDx;
} }
@ -383,8 +383,7 @@ INT nulldrv_SaveDC( PHYSDEV dev )
newdc->textColor = dc->textColor; newdc->textColor = dc->textColor;
newdc->dcBrushColor = dc->dcBrushColor; newdc->dcBrushColor = dc->dcBrushColor;
newdc->dcPenColor = dc->dcPenColor; newdc->dcPenColor = dc->dcPenColor;
newdc->brushOrgX = dc->brushOrgX; newdc->brush_org = dc->brush_org;
newdc->brushOrgY = dc->brushOrgY;
newdc->mapperFlags = dc->mapperFlags; newdc->mapperFlags = dc->mapperFlags;
newdc->textAlign = dc->textAlign; newdc->textAlign = dc->textAlign;
newdc->charExtra = dc->charExtra; newdc->charExtra = dc->charExtra;
@ -392,21 +391,16 @@ INT nulldrv_SaveDC( PHYSDEV dev )
newdc->breakRem = dc->breakRem; newdc->breakRem = dc->breakRem;
newdc->MapMode = dc->MapMode; newdc->MapMode = dc->MapMode;
newdc->GraphicsMode = dc->GraphicsMode; newdc->GraphicsMode = dc->GraphicsMode;
newdc->CursPosX = dc->CursPosX; newdc->cur_pos = dc->cur_pos;
newdc->CursPosY = dc->CursPosY;
newdc->ArcDirection = dc->ArcDirection; newdc->ArcDirection = dc->ArcDirection;
newdc->xformWorld2Wnd = dc->xformWorld2Wnd; newdc->xformWorld2Wnd = dc->xformWorld2Wnd;
newdc->xformWorld2Vport = dc->xformWorld2Vport; newdc->xformWorld2Vport = dc->xformWorld2Vport;
newdc->xformVport2World = dc->xformVport2World; newdc->xformVport2World = dc->xformVport2World;
newdc->vport2WorldValid = dc->vport2WorldValid; newdc->vport2WorldValid = dc->vport2WorldValid;
newdc->wndOrgX = dc->wndOrgX; newdc->wnd_org = dc->wnd_org;
newdc->wndOrgY = dc->wndOrgY; newdc->wnd_ext = dc->wnd_ext;
newdc->wndExtX = dc->wndExtX; newdc->vport_org = dc->vport_org;
newdc->wndExtY = dc->wndExtY; newdc->vport_ext = dc->vport_ext;
newdc->vportOrgX = dc->vportOrgX;
newdc->vportOrgY = dc->vportOrgY;
newdc->vportExtX = dc->vportExtX;
newdc->vportExtY = dc->vportExtY;
newdc->virtual_res = dc->virtual_res; newdc->virtual_res = dc->virtual_res;
newdc->virtual_size = dc->virtual_size; newdc->virtual_size = dc->virtual_size;
@ -466,8 +460,7 @@ BOOL nulldrv_RestoreDC( PHYSDEV dev, INT level )
dc->textColor = dcs->textColor; dc->textColor = dcs->textColor;
dc->dcBrushColor = dcs->dcBrushColor; dc->dcBrushColor = dcs->dcBrushColor;
dc->dcPenColor = dcs->dcPenColor; dc->dcPenColor = dcs->dcPenColor;
dc->brushOrgX = dcs->brushOrgX; dc->brush_org = dcs->brush_org;
dc->brushOrgY = dcs->brushOrgY;
dc->mapperFlags = dcs->mapperFlags; dc->mapperFlags = dcs->mapperFlags;
dc->textAlign = dcs->textAlign; dc->textAlign = dcs->textAlign;
dc->charExtra = dcs->charExtra; dc->charExtra = dcs->charExtra;
@ -475,21 +468,16 @@ BOOL nulldrv_RestoreDC( PHYSDEV dev, INT level )
dc->breakRem = dcs->breakRem; dc->breakRem = dcs->breakRem;
dc->MapMode = dcs->MapMode; dc->MapMode = dcs->MapMode;
dc->GraphicsMode = dcs->GraphicsMode; dc->GraphicsMode = dcs->GraphicsMode;
dc->CursPosX = dcs->CursPosX; dc->cur_pos = dcs->cur_pos;
dc->CursPosY = dcs->CursPosY;
dc->ArcDirection = dcs->ArcDirection; dc->ArcDirection = dcs->ArcDirection;
dc->xformWorld2Wnd = dcs->xformWorld2Wnd; dc->xformWorld2Wnd = dcs->xformWorld2Wnd;
dc->xformWorld2Vport = dcs->xformWorld2Vport; dc->xformWorld2Vport = dcs->xformWorld2Vport;
dc->xformVport2World = dcs->xformVport2World; dc->xformVport2World = dcs->xformVport2World;
dc->vport2WorldValid = dcs->vport2WorldValid; dc->vport2WorldValid = dcs->vport2WorldValid;
dc->wndOrgX = dcs->wndOrgX; dc->wnd_org = dcs->wnd_org;
dc->wndOrgY = dcs->wndOrgY; dc->wnd_ext = dcs->wnd_ext;
dc->wndExtX = dcs->wndExtX; dc->vport_org = dcs->vport_org;
dc->wndExtY = dcs->wndExtY; dc->vport_ext = dcs->vport_ext;
dc->vportOrgX = dcs->vportOrgX;
dc->vportOrgY = dcs->vportOrgY;
dc->vportExtX = dcs->vportExtX;
dc->vportExtY = dcs->vportExtY;
dc->virtual_res = dcs->virtual_res; dc->virtual_res = dcs->virtual_res;
dc->virtual_size = dcs->virtual_size; dc->virtual_size = dcs->virtual_size;
@ -1792,8 +1780,7 @@ BOOL WINAPI GetBrushOrgEx( HDC hdc, LPPOINT pt )
{ {
DC * dc = get_dc_ptr( hdc ); DC * dc = get_dc_ptr( hdc );
if (!dc) return FALSE; if (!dc) return FALSE;
pt->x = dc->brushOrgX; *pt = dc->brush_org;
pt->y = dc->brushOrgY;
release_dc_ptr( dc ); release_dc_ptr( dc );
return TRUE; return TRUE;
} }
@ -1806,8 +1793,7 @@ BOOL WINAPI GetCurrentPositionEx( HDC hdc, LPPOINT pt )
{ {
DC * dc = get_dc_ptr( hdc ); DC * dc = get_dc_ptr( hdc );
if (!dc) return FALSE; if (!dc) return FALSE;
pt->x = dc->CursPosX; *pt = dc->cur_pos;
pt->y = dc->CursPosY;
release_dc_ptr( dc ); release_dc_ptr( dc );
return TRUE; return TRUE;
} }
@ -1820,8 +1806,7 @@ BOOL WINAPI GetViewportExtEx( HDC hdc, LPSIZE size )
{ {
DC * dc = get_dc_ptr( hdc ); DC * dc = get_dc_ptr( hdc );
if (!dc) return FALSE; if (!dc) return FALSE;
size->cx = dc->vportExtX; *size = dc->vport_ext;
size->cy = dc->vportExtY;
release_dc_ptr( dc ); release_dc_ptr( dc );
return TRUE; return TRUE;
} }
@ -1834,8 +1819,7 @@ BOOL WINAPI GetViewportOrgEx( HDC hdc, LPPOINT pt )
{ {
DC * dc = get_dc_ptr( hdc ); DC * dc = get_dc_ptr( hdc );
if (!dc) return FALSE; if (!dc) return FALSE;
pt->x = dc->vportOrgX; *pt = dc->vport_org;
pt->y = dc->vportOrgY;
release_dc_ptr( dc ); release_dc_ptr( dc );
return TRUE; return TRUE;
} }
@ -1848,8 +1832,7 @@ BOOL WINAPI GetWindowExtEx( HDC hdc, LPSIZE size )
{ {
DC * dc = get_dc_ptr( hdc ); DC * dc = get_dc_ptr( hdc );
if (!dc) return FALSE; if (!dc) return FALSE;
size->cx = dc->wndExtX; *size = dc->wnd_ext;
size->cy = dc->wndExtY;
release_dc_ptr( dc ); release_dc_ptr( dc );
return TRUE; return TRUE;
} }
@ -1862,8 +1845,7 @@ BOOL WINAPI GetWindowOrgEx( HDC hdc, LPPOINT pt )
{ {
DC * dc = get_dc_ptr( hdc ); DC * dc = get_dc_ptr( hdc );
if (!dc) return FALSE; if (!dc) return FALSE;
pt->x = dc->wndOrgX; *pt = dc->wnd_org;
pt->y = dc->wndOrgY;
release_dc_ptr( dc ); release_dc_ptr( dc );
return TRUE; return TRUE;
} }

View File

@ -1029,7 +1029,7 @@ BOOL WINAPI SetTextJustification( HDC hdc, INT extra, INT breaks )
ret = physdev->funcs->pSetTextJustification( physdev, extra, breaks ); ret = physdev->funcs->pSetTextJustification( physdev, extra, breaks );
if (ret) if (ret)
{ {
extra = abs((extra * dc->vportExtX + dc->wndExtX / 2) / dc->wndExtX); extra = abs((extra * dc->vport_ext.cx + dc->wnd_ext.cx / 2) / dc->wnd_ext.cx);
if (!extra) breaks = 0; if (!extra) breaks = 0;
if (breaks) if (breaks)
{ {

View File

@ -72,14 +72,10 @@ typedef struct tagDC
BOOL bounds_enabled:1; /* bounds tracking is enabled */ BOOL bounds_enabled:1; /* bounds tracking is enabled */
BOOL path_open:1; /* path is currently open (only for saved DCs) */ BOOL path_open:1; /* path is currently open (only for saved DCs) */
INT wndOrgX; /* Window origin */ POINT wnd_org; /* Window origin */
INT wndOrgY; SIZE wnd_ext; /* Window extent */
INT wndExtX; /* Window extent */ POINT vport_org; /* Viewport origin */
INT wndExtY; SIZE vport_ext; /* Viewport extent */
INT vportOrgX; /* Viewport origin */
INT vportOrgY;
INT vportExtX; /* Viewport extent */
INT vportExtY;
SIZE virtual_res; /* Initially HORZRES,VERTRES. Changed by SetVirtualResolution */ SIZE virtual_res; /* Initially HORZRES,VERTRES. Changed by SetVirtualResolution */
SIZE virtual_size; /* Initially HORZSIZE,VERTSIZE. Changed by SetVirtualResolution */ SIZE virtual_size; /* Initially HORZSIZE,VERTSIZE. Changed by SetVirtualResolution */
RECT vis_rect; /* visible rectangle in screen coords */ RECT vis_rect; /* visible rectangle in screen coords */
@ -112,8 +108,7 @@ typedef struct tagDC
COLORREF textColor; COLORREF textColor;
COLORREF dcBrushColor; COLORREF dcBrushColor;
COLORREF dcPenColor; COLORREF dcPenColor;
short brushOrgX; POINT brush_org;
short brushOrgY;
DWORD mapperFlags; /* Font mapper flags */ DWORD mapperFlags; /* Font mapper flags */
WORD textAlign; /* Text alignment from SetTextAlign() */ WORD textAlign; /* Text alignment from SetTextAlign() */
@ -123,8 +118,7 @@ typedef struct tagDC
INT MapMode; INT MapMode;
INT GraphicsMode; /* Graphics mode */ INT GraphicsMode; /* Graphics mode */
ABORTPROC pAbortProc; /* AbortProc for Printing */ ABORTPROC pAbortProc; /* AbortProc for Printing */
INT CursPosX; /* Current position */ POINT cur_pos; /* Current position */
INT CursPosY;
INT ArcDirection; INT ArcDirection;
XFORM xformWorld2Wnd; /* World-to-window transformation */ XFORM xformWorld2Wnd; /* World-to-window transformation */
XFORM xformWorld2Vport; /* World-to-viewport transformation */ XFORM xformWorld2Vport; /* World-to-viewport transformation */

View File

@ -62,20 +62,20 @@ static void MAPPING_FixIsotropic( DC * dc )
{ {
SIZE virtual_size = get_dc_virtual_size( dc ); SIZE virtual_size = get_dc_virtual_size( dc );
SIZE virtual_res = get_dc_virtual_res( dc ); SIZE virtual_res = get_dc_virtual_res( dc );
double xdim = fabs((double)dc->vportExtX * virtual_size.cx / (virtual_res.cx * dc->wndExtX)); double xdim = fabs((double)dc->vport_ext.cx * virtual_size.cx / (virtual_res.cx * dc->wnd_ext.cx));
double ydim = fabs((double)dc->vportExtY * virtual_size.cy / (virtual_res.cy * dc->wndExtY)); double ydim = fabs((double)dc->vport_ext.cy * virtual_size.cy / (virtual_res.cy * dc->wnd_ext.cy));
if (xdim > ydim) if (xdim > ydim)
{ {
INT mincx = (dc->vportExtX >= 0) ? 1 : -1; INT mincx = (dc->vport_ext.cx >= 0) ? 1 : -1;
dc->vportExtX = floor(dc->vportExtX * ydim / xdim + 0.5); dc->vport_ext.cx = floor(dc->vport_ext.cx * ydim / xdim + 0.5);
if (!dc->vportExtX) dc->vportExtX = mincx; if (!dc->vport_ext.cx) dc->vport_ext.cx = mincx;
} }
else else
{ {
INT mincy = (dc->vportExtY >= 0) ? 1 : -1; INT mincy = (dc->vport_ext.cy >= 0) ? 1 : -1;
dc->vportExtY = floor(dc->vportExtY * xdim / ydim + 0.5); dc->vport_ext.cy = floor(dc->vport_ext.cy * xdim / ydim + 0.5);
if (!dc->vportExtY) dc->vportExtY = mincy; if (!dc->vport_ext.cy) dc->vport_ext.cy = mincy;
} }
} }
@ -89,12 +89,10 @@ BOOL nulldrv_OffsetViewportOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt )
DC *dc = get_nulldrv_dc( dev ); DC *dc = get_nulldrv_dc( dev );
if (pt) if (pt)
{ *pt = dc->vport_org;
pt->x = dc->vportOrgX;
pt->y = dc->vportOrgY; dc->vport_org.x += x;
} dc->vport_org.y += y;
dc->vportOrgX += x;
dc->vportOrgY += y;
DC_UpdateXforms( dc ); DC_UpdateXforms( dc );
return TRUE; return TRUE;
} }
@ -104,12 +102,10 @@ BOOL nulldrv_OffsetWindowOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt )
DC *dc = get_nulldrv_dc( dev ); DC *dc = get_nulldrv_dc( dev );
if (pt) if (pt)
{ *pt = dc->wnd_org;
pt->x = dc->wndOrgX;
pt->y = dc->wndOrgY; dc->wnd_org.x += x;
} dc->wnd_org.y += y;
dc->wndOrgX += x;
dc->wndOrgY += y;
DC_UpdateXforms( dc ); DC_UpdateXforms( dc );
return TRUE; return TRUE;
} }
@ -119,17 +115,15 @@ BOOL nulldrv_ScaleViewportExtEx( PHYSDEV dev, INT x_num, INT x_denom, INT y_num,
DC *dc = get_nulldrv_dc( dev ); DC *dc = get_nulldrv_dc( dev );
if (size) if (size)
{ *size = dc->vport_ext;
size->cx = dc->vportExtX;
size->cy = dc->vportExtY;
}
if (dc->MapMode != MM_ISOTROPIC && dc->MapMode != MM_ANISOTROPIC) return TRUE; if (dc->MapMode != MM_ISOTROPIC && dc->MapMode != MM_ANISOTROPIC) return TRUE;
if (!x_num || !x_denom || !y_num || !y_denom) return FALSE; if (!x_num || !x_denom || !y_num || !y_denom) return FALSE;
dc->vportExtX = (dc->vportExtX * x_num) / x_denom; dc->vport_ext.cx = (dc->vport_ext.cx * x_num) / x_denom;
dc->vportExtY = (dc->vportExtY * y_num) / y_denom; dc->vport_ext.cy = (dc->vport_ext.cy * y_num) / y_denom;
if (dc->vportExtX == 0) dc->vportExtX = 1; if (dc->vport_ext.cx == 0) dc->vport_ext.cx = 1;
if (dc->vportExtY == 0) dc->vportExtY = 1; if (dc->vport_ext.cy == 0) dc->vport_ext.cy = 1;
if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc ); if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc );
DC_UpdateXforms( dc ); DC_UpdateXforms( dc );
return TRUE; return TRUE;
@ -140,17 +134,15 @@ BOOL nulldrv_ScaleWindowExtEx( PHYSDEV dev, INT x_num, INT x_denom, INT y_num, I
DC *dc = get_nulldrv_dc( dev ); DC *dc = get_nulldrv_dc( dev );
if (size) if (size)
{ *size = dc->wnd_ext;
size->cx = dc->wndExtX;
size->cy = dc->wndExtY;
}
if (dc->MapMode != MM_ISOTROPIC && dc->MapMode != MM_ANISOTROPIC) return TRUE; if (dc->MapMode != MM_ISOTROPIC && dc->MapMode != MM_ANISOTROPIC) return TRUE;
if (!x_num || !x_denom || !y_num || !y_denom) return FALSE; if (!x_num || !x_denom || !y_num || !y_denom) return FALSE;
dc->wndExtX = (dc->wndExtX * x_num) / x_denom; dc->wnd_ext.cx = (dc->wnd_ext.cx * x_num) / x_denom;
dc->wndExtY = (dc->wndExtY * y_num) / y_denom; dc->wnd_ext.cy = (dc->wnd_ext.cy * y_num) / y_denom;
if (dc->wndExtX == 0) dc->wndExtX = 1; if (dc->wnd_ext.cx == 0) dc->wnd_ext.cx = 1;
if (dc->wndExtY == 0) dc->wndExtY = 1; if (dc->wnd_ext.cy == 0) dc->wnd_ext.cy = 1;
if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc ); if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc );
DC_UpdateXforms( dc ); DC_UpdateXforms( dc );
return TRUE; return TRUE;
@ -169,41 +161,41 @@ INT nulldrv_SetMapMode( PHYSDEV dev, INT mode )
switch (mode) switch (mode)
{ {
case MM_TEXT: case MM_TEXT:
dc->wndExtX = 1; dc->wnd_ext.cx = 1;
dc->wndExtY = 1; dc->wnd_ext.cy = 1;
dc->vportExtX = 1; dc->vport_ext.cx = 1;
dc->vportExtY = 1; dc->vport_ext.cy = 1;
break; break;
case MM_LOMETRIC: case MM_LOMETRIC:
case MM_ISOTROPIC: case MM_ISOTROPIC:
dc->wndExtX = virtual_size.cx * 10; dc->wnd_ext.cx = virtual_size.cx * 10;
dc->wndExtY = virtual_size.cy * 10; dc->wnd_ext.cy = virtual_size.cy * 10;
dc->vportExtX = virtual_res.cx; dc->vport_ext.cx = virtual_res.cx;
dc->vportExtY = -virtual_res.cy; dc->vport_ext.cy = -virtual_res.cy;
break; break;
case MM_HIMETRIC: case MM_HIMETRIC:
dc->wndExtX = virtual_size.cx * 100; dc->wnd_ext.cx = virtual_size.cx * 100;
dc->wndExtY = virtual_size.cy * 100; dc->wnd_ext.cy = virtual_size.cy * 100;
dc->vportExtX = virtual_res.cx; dc->vport_ext.cx = virtual_res.cx;
dc->vportExtY = -virtual_res.cy; dc->vport_ext.cy = -virtual_res.cy;
break; break;
case MM_LOENGLISH: case MM_LOENGLISH:
dc->wndExtX = MulDiv(1000, virtual_size.cx, 254); dc->wnd_ext.cx = MulDiv(1000, virtual_size.cx, 254);
dc->wndExtY = MulDiv(1000, virtual_size.cy, 254); dc->wnd_ext.cy = MulDiv(1000, virtual_size.cy, 254);
dc->vportExtX = virtual_res.cx; dc->vport_ext.cx = virtual_res.cx;
dc->vportExtY = -virtual_res.cy; dc->vport_ext.cy = -virtual_res.cy;
break; break;
case MM_HIENGLISH: case MM_HIENGLISH:
dc->wndExtX = MulDiv(10000, virtual_size.cx, 254); dc->wnd_ext.cx = MulDiv(10000, virtual_size.cx, 254);
dc->wndExtY = MulDiv(10000, virtual_size.cy, 254); dc->wnd_ext.cy = MulDiv(10000, virtual_size.cy, 254);
dc->vportExtX = virtual_res.cx; dc->vport_ext.cx = virtual_res.cx;
dc->vportExtY = -virtual_res.cy; dc->vport_ext.cy = -virtual_res.cy;
break; break;
case MM_TWIPS: case MM_TWIPS:
dc->wndExtX = MulDiv(14400, virtual_size.cx, 254); dc->wnd_ext.cx = MulDiv(14400, virtual_size.cx, 254);
dc->wndExtY = MulDiv(14400, virtual_size.cy, 254); dc->wnd_ext.cy = MulDiv(14400, virtual_size.cy, 254);
dc->vportExtX = virtual_res.cx; dc->vport_ext.cx = virtual_res.cx;
dc->vportExtY = -virtual_res.cy; dc->vport_ext.cy = -virtual_res.cy;
break; break;
case MM_ANISOTROPIC: case MM_ANISOTROPIC:
break; break;
@ -221,14 +213,12 @@ BOOL nulldrv_SetViewportExtEx( PHYSDEV dev, INT cx, INT cy, SIZE *size )
DC *dc = get_nulldrv_dc( dev ); DC *dc = get_nulldrv_dc( dev );
if (size) if (size)
{ *size = dc->vport_ext;
size->cx = dc->vportExtX;
size->cy = dc->vportExtY;
}
if (dc->MapMode != MM_ISOTROPIC && dc->MapMode != MM_ANISOTROPIC) return TRUE; if (dc->MapMode != MM_ISOTROPIC && dc->MapMode != MM_ANISOTROPIC) return TRUE;
if (!cx || !cy) return FALSE; if (!cx || !cy) return FALSE;
dc->vportExtX = cx; dc->vport_ext.cx = cx;
dc->vportExtY = cy; dc->vport_ext.cy = cy;
if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc ); if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc );
DC_UpdateXforms( dc ); DC_UpdateXforms( dc );
return TRUE; return TRUE;
@ -239,12 +229,10 @@ BOOL nulldrv_SetViewportOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt )
DC *dc = get_nulldrv_dc( dev ); DC *dc = get_nulldrv_dc( dev );
if (pt) if (pt)
{ *pt = dc->vport_org;
pt->x = dc->vportOrgX;
pt->y = dc->vportOrgY; dc->vport_org.x = x;
} dc->vport_org.y = y;
dc->vportOrgX = x;
dc->vportOrgY = y;
DC_UpdateXforms( dc ); DC_UpdateXforms( dc );
return TRUE; return TRUE;
} }
@ -254,14 +242,12 @@ BOOL nulldrv_SetWindowExtEx( PHYSDEV dev, INT cx, INT cy, SIZE *size )
DC *dc = get_nulldrv_dc( dev ); DC *dc = get_nulldrv_dc( dev );
if (size) if (size)
{ *size = dc->wnd_ext;
size->cx = dc->wndExtX;
size->cy = dc->wndExtY;
}
if (dc->MapMode != MM_ISOTROPIC && dc->MapMode != MM_ANISOTROPIC) return TRUE; if (dc->MapMode != MM_ISOTROPIC && dc->MapMode != MM_ANISOTROPIC) return TRUE;
if (!cx || !cy) return FALSE; if (!cx || !cy) return FALSE;
dc->wndExtX = cx; dc->wnd_ext.cx = cx;
dc->wndExtY = cy; dc->wnd_ext.cy = cy;
/* The API docs say that you should call SetWindowExtEx before /* The API docs say that you should call SetWindowExtEx before
SetViewportExtEx. This advice does not imply that Windows SetViewportExtEx. This advice does not imply that Windows
doesn't ensure the isotropic mapping after SetWindowExtEx! */ doesn't ensure the isotropic mapping after SetWindowExtEx! */
@ -275,12 +261,10 @@ BOOL nulldrv_SetWindowOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt )
DC *dc = get_nulldrv_dc( dev ); DC *dc = get_nulldrv_dc( dev );
if (pt) if (pt)
{ *pt = dc->wnd_org;
pt->x = dc->wndOrgX;
pt->y = dc->wndOrgY; dc->wnd_org.x = x;
} dc->wnd_org.y = y;
dc->wndOrgX = x;
dc->wndOrgY = y;
DC_UpdateXforms( dc ); DC_UpdateXforms( dc );
return TRUE; return TRUE;
} }

View File

@ -240,9 +240,10 @@ BOOL WINAPI LineTo( HDC hdc, INT x, INT y )
physdev = GET_DC_PHYSDEV( dc, pLineTo ); physdev = GET_DC_PHYSDEV( dc, pLineTo );
ret = physdev->funcs->pLineTo( physdev, x, y ); ret = physdev->funcs->pLineTo( physdev, x, y );
if(ret) { if(ret)
dc->CursPosX = x; {
dc->CursPosY = y; dc->cur_pos.x = x;
dc->cur_pos.y = y;
} }
release_dc_ptr( dc ); release_dc_ptr( dc );
return ret; return ret;
@ -260,12 +261,11 @@ BOOL WINAPI MoveToEx( HDC hdc, INT x, INT y, LPPOINT pt )
if(!dc) return FALSE; if(!dc) return FALSE;
if(pt) { if(pt)
pt->x = dc->CursPosX; *pt = dc->cur_pos;
pt->y = dc->CursPosY;
} dc->cur_pos.x = x;
dc->CursPosX = x; dc->cur_pos.y = y;
dc->CursPosY = y;
physdev = GET_DC_PHYSDEV( dc, pMoveTo ); physdev = GET_DC_PHYSDEV( dc, pMoveTo );
ret = physdev->funcs->pMoveTo( physdev, x, y ); ret = physdev->funcs->pMoveTo( physdev, x, y );
@ -318,11 +318,12 @@ BOOL WINAPI ArcTo( HDC hdc,
physdev = GET_DC_PHYSDEV( dc, pArcTo ); physdev = GET_DC_PHYSDEV( dc, pArcTo );
result = physdev->funcs->pArcTo( physdev, left, top, right, bottom, xstart, ystart, xend, yend ); result = physdev->funcs->pArcTo( physdev, left, top, right, bottom, xstart, ystart, xend, yend );
if (result) { if (result)
{
angle = atan2(((yend-ycenter)/height), angle = atan2(((yend-ycenter)/height),
((xend-xcenter)/width)); ((xend-xcenter)/width));
dc->CursPosX = GDI_ROUND(xcenter+(cos(angle)*xradius)); dc->cur_pos.x = GDI_ROUND( xcenter + (cos( angle ) * xradius) );
dc->CursPosY = GDI_ROUND(ycenter+(sin(angle)*yradius)); dc->cur_pos.y = GDI_ROUND( ycenter + (sin( angle ) * yradius) );
} }
release_dc_ptr( dc ); release_dc_ptr( dc );
return result; return result;
@ -627,10 +628,8 @@ BOOL WINAPI PolylineTo( HDC hdc, const POINT* pt, DWORD cCount )
ret = physdev->funcs->pPolylineTo( physdev, pt, cCount ); ret = physdev->funcs->pPolylineTo( physdev, pt, cCount );
if (ret && cCount) if (ret && cCount)
{ dc->cur_pos = pt[cCount - 1];
dc->CursPosX = pt[cCount-1].x;
dc->CursPosY = pt[cCount-1].y;
}
release_dc_ptr( dc ); release_dc_ptr( dc );
return ret; return ret;
} }
@ -779,10 +778,9 @@ BOOL WINAPI PolyBezierTo( HDC hdc, const POINT* lppt, DWORD cPoints )
physdev = GET_DC_PHYSDEV( dc, pPolyBezierTo ); physdev = GET_DC_PHYSDEV( dc, pPolyBezierTo );
ret = physdev->funcs->pPolyBezierTo( physdev, lppt, cPoints ); ret = physdev->funcs->pPolyBezierTo( physdev, lppt, cPoints );
if(ret) { if(ret)
dc->CursPosX = lppt[cPoints-1].x; dc->cur_pos = lppt[cPoints - 1];
dc->CursPosY = lppt[cPoints-1].y;
}
release_dc_ptr( dc ); release_dc_ptr( dc );
return ret; return ret;
} }
@ -806,9 +804,10 @@ BOOL WINAPI AngleArc(HDC hdc, INT x, INT y, DWORD dwRadius, FLOAT eStartAngle, F
physdev = GET_DC_PHYSDEV( dc, pAngleArc ); physdev = GET_DC_PHYSDEV( dc, pAngleArc );
result = physdev->funcs->pAngleArc( physdev, x, y, dwRadius, eStartAngle, eSweepAngle ); result = physdev->funcs->pAngleArc( physdev, x, y, dwRadius, eStartAngle, eSweepAngle );
if (result) { if (result)
dc->CursPosX = GDI_ROUND( x + cos((eStartAngle+eSweepAngle)*M_PI/180) * dwRadius ); {
dc->CursPosY = GDI_ROUND( y - sin((eStartAngle+eSweepAngle)*M_PI/180) * dwRadius ); 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 );
} }
release_dc_ptr( dc ); release_dc_ptr( dc );
return result; return result;
@ -830,10 +829,8 @@ BOOL WINAPI PolyDraw(HDC hdc, const POINT *lppt, const BYTE *lpbTypes,
physdev = GET_DC_PHYSDEV( dc, pPolyDraw ); physdev = GET_DC_PHYSDEV( dc, pPolyDraw );
result = physdev->funcs->pPolyDraw( physdev, lppt, lpbTypes, cCount ); result = physdev->funcs->pPolyDraw( physdev, lppt, lpbTypes, cCount );
if (result && cCount) if (result && cCount)
{ dc->cur_pos = lppt[cCount - 1];
dc->CursPosX = lppt[cCount - 1].x;
dc->CursPosY = lppt[cCount - 1].y;
}
release_dc_ptr( dc ); release_dc_ptr( dc );
return result; return result;
} }

View File

@ -2016,8 +2016,7 @@ BOOL nulldrv_BeginPath( PHYSDEV dev )
} }
physdev = get_path_physdev( find_dc_driver( dc, &path_driver )); physdev = get_path_physdev( find_dc_driver( dc, &path_driver ));
physdev->path = path; physdev->path = path;
path->pos.x = dc->CursPosX; path->pos = dc->cur_pos;
path->pos.y = dc->CursPosY;
LPtoDP( dev->hdc, &path->pos, 1 ); LPtoDP( dev->hdc, &path->pos, 1 );
if (dc->path) free_gdi_path( dc->path ); if (dc->path) free_gdi_path( dc->path );
dc->path = NULL; dc->path = NULL;

View File

@ -23,6 +23,7 @@
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "wingdi.h" #include "wingdi.h"
#include "winuser.h"
#include "wine/test.h" #include "wine/test.h"
@ -343,10 +344,28 @@ static void test_palette_brush(void)
DeleteObject( palette2 ); DeleteObject( palette2 );
} }
static void test_brush_org( void )
{
HDC hdc = GetDC( 0 );
POINT old, pt;
SetBrushOrgEx( hdc, 0, 0, &old );
SetBrushOrgEx( hdc, 1, 1, &pt );
ok( pt.x == 0 && pt.y == 0, "got %d,%d\n", pt.x, pt.y );
SetBrushOrgEx( hdc, 0x10000, -1, &pt );
ok( pt.x == 1 && pt.y == 1, "got %d,%d\n", pt.x, pt.y );
SetBrushOrgEx( hdc, old.x, old.y, &pt );
ok( pt.x == 0x10000 && pt.y == -1, "got %d,%d\n", pt.x, pt.y );
ReleaseDC( 0, hdc );
}
START_TEST(brush) START_TEST(brush)
{ {
test_solidbrush(); test_solidbrush();
test_hatch_brush(); test_hatch_brush();
test_pattern_brush(); test_pattern_brush();
test_palette_brush(); test_palette_brush();
test_brush_org();
} }