Commit 81dbf2db authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

gdi32: Store viewport extent in DC_ATTR.

parent 3c6075e4
......@@ -233,8 +233,8 @@ INT CDECL nulldrv_OffsetClipRgn( PHYSDEV dev, INT x, INT y )
if (dc->hClipRgn)
{
x = MulDiv( x, dc->vport_ext.cx, dc->wnd_ext.cx );
y = MulDiv( y, dc->vport_ext.cy, dc->wnd_ext.cy );
x = MulDiv( x, dc->attr->vport_ext.cx, dc->wnd_ext.cx );
y = MulDiv( y, dc->attr->vport_ext.cy, dc->wnd_ext.cy );
if (dc->attr->layout & LAYOUT_RTL) x = -x;
ret = NtGdiOffsetRgn( dc->hClipRgn, x, y );
update_dc_clipping( dc );
......
......@@ -77,8 +77,8 @@ static void set_initial_dc_state( DC *dc )
dc->wnd_ext.cy = 1;
dc->vport_org.x = 0;
dc->vport_org.y = 0;
dc->vport_ext.cx = 1;
dc->vport_ext.cy = 1;
dc->attr->vport_ext.cx = 1;
dc->attr->vport_ext.cy = 1;
dc->attr->miter_limit = 10.0f; /* 10.0 is the default, from MSDN */
dc->attr->layout = 0;
dc->font_code_page = CP_ACP;
......@@ -319,8 +319,8 @@ static BOOL DC_InvertXform( const XFORM *xformSrc, XFORM *xformDest )
static void construct_window_to_viewport(DC *dc, XFORM *xform)
{
double scaleX, scaleY;
scaleX = (double)dc->vport_ext.cx / (double)dc->wnd_ext.cx;
scaleY = (double)dc->vport_ext.cy / (double)dc->wnd_ext.cy;
scaleX = (double)dc->attr->vport_ext.cx / (double)dc->wnd_ext.cx;
scaleY = (double)dc->attr->vport_ext.cy / (double)dc->wnd_ext.cy;
if (dc->attr->layout & LAYOUT_RTL) scaleX = -scaleX;
xform->eM11 = scaleX;
......@@ -427,7 +427,7 @@ BOOL CDECL nulldrv_RestoreDC( PHYSDEV dev, INT level )
dc->wnd_org = dcs->wnd_org;
dc->wnd_ext = dcs->wnd_ext;
dc->vport_org = dcs->vport_org;
dc->vport_ext = dcs->vport_ext;
dc->attr->vport_ext = dcs->attr->vport_ext;
dc->virtual_res = dcs->virtual_res;
dc->virtual_size = dcs->virtual_size;
......@@ -556,7 +556,6 @@ INT WINAPI NtGdiSaveDC( HDC hdc )
newdc->wnd_org = dc->wnd_org;
newdc->wnd_ext = dc->wnd_ext;
newdc->vport_org = dc->vport_org;
newdc->vport_ext = dc->vport_ext;
newdc->virtual_res = dc->virtual_res;
newdc->virtual_size = dc->virtual_size;
......@@ -1292,19 +1291,6 @@ BOOL WINAPI GetBrushOrgEx( HDC hdc, LPPOINT pt )
/***********************************************************************
* GetViewportExtEx (GDI32.@)
*/
BOOL WINAPI GetViewportExtEx( HDC hdc, LPSIZE size )
{
DC * dc = get_dc_ptr( hdc );
if (!dc) return FALSE;
*size = dc->vport_ext;
release_dc_ptr( dc );
return TRUE;
}
/***********************************************************************
* GetViewportOrgEx (GDI32.@)
*/
BOOL WINAPI GetViewportOrgEx( HDC hdc, LPPOINT pt )
......
......@@ -4791,7 +4791,7 @@ BOOL WINAPI SetTextJustification( HDC hdc, INT extra, INT breaks )
ret = physdev->funcs->pSetTextJustification( physdev, extra, breaks );
if (ret)
{
extra = abs((extra * dc->vport_ext.cx + dc->wnd_ext.cx / 2) / dc->wnd_ext.cx);
extra = abs((extra * dc->attr->vport_ext.cx + dc->wnd_ext.cx / 2) / dc->wnd_ext.cx);
if (!extra) breaks = 0;
if (breaks)
{
......
......@@ -343,6 +343,17 @@ BOOL WINAPI GetDCOrgEx( HDC hdc, POINT *point )
}
/***********************************************************************
* GetViewportExtEx (GDI32.@)
*/
BOOL WINAPI GetViewportExtEx( HDC hdc, SIZE *size )
{
DC_ATTR *dc_attr;
if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
*size = dc_attr->vport_ext;
return TRUE;
}
/***********************************************************************
* SetStretchBltMode (GDI32.@)
*/
INT WINAPI SetStretchBltMode( HDC hdc, INT mode )
......
......@@ -62,20 +62,22 @@ static void MAPPING_FixIsotropic( DC * dc )
{
SIZE virtual_size = get_dc_virtual_size( dc );
SIZE virtual_res = get_dc_virtual_res( dc );
double xdim = fabs((double)dc->vport_ext.cx * virtual_size.cx / (virtual_res.cx * dc->wnd_ext.cx));
double ydim = fabs((double)dc->vport_ext.cy * virtual_size.cy / (virtual_res.cy * dc->wnd_ext.cy));
double xdim = fabs((double)dc->attr->vport_ext.cx * virtual_size.cx /
(virtual_res.cx * dc->wnd_ext.cx));
double ydim = fabs((double)dc->attr->vport_ext.cy * virtual_size.cy /
(virtual_res.cy * dc->wnd_ext.cy));
if (xdim > ydim)
{
INT mincx = (dc->vport_ext.cx >= 0) ? 1 : -1;
dc->vport_ext.cx = floor(dc->vport_ext.cx * ydim / xdim + 0.5);
if (!dc->vport_ext.cx) dc->vport_ext.cx = mincx;
INT mincx = (dc->attr->vport_ext.cx >= 0) ? 1 : -1;
dc->attr->vport_ext.cx = floor(dc->attr->vport_ext.cx * ydim / xdim + 0.5);
if (!dc->attr->vport_ext.cx) dc->attr->vport_ext.cx = mincx;
}
else
{
INT mincy = (dc->vport_ext.cy >= 0) ? 1 : -1;
dc->vport_ext.cy = floor(dc->vport_ext.cy * xdim / ydim + 0.5);
if (!dc->vport_ext.cy) dc->vport_ext.cy = mincy;
INT mincy = (dc->attr->vport_ext.cy >= 0) ? 1 : -1;
dc->attr->vport_ext.cy = floor(dc->attr->vport_ext.cy * xdim / ydim + 0.5);
if (!dc->attr->vport_ext.cy) dc->attr->vport_ext.cy = mincy;
}
}
......@@ -115,15 +117,15 @@ BOOL CDECL nulldrv_ScaleViewportExtEx( PHYSDEV dev, INT x_num, INT x_denom, INT
DC *dc = get_nulldrv_dc( dev );
if (size)
*size = dc->vport_ext;
*size = dc->attr->vport_ext;
if (dc->attr->map_mode != MM_ISOTROPIC && dc->attr->map_mode != MM_ANISOTROPIC) return TRUE;
if (!x_num || !x_denom || !y_num || !y_denom) return FALSE;
dc->vport_ext.cx = (dc->vport_ext.cx * x_num) / x_denom;
dc->vport_ext.cy = (dc->vport_ext.cy * y_num) / y_denom;
if (dc->vport_ext.cx == 0) dc->vport_ext.cx = 1;
if (dc->vport_ext.cy == 0) dc->vport_ext.cy = 1;
dc->attr->vport_ext.cx = (dc->attr->vport_ext.cx * x_num) / x_denom;
dc->attr->vport_ext.cy = (dc->attr->vport_ext.cy * y_num) / y_denom;
if (dc->attr->vport_ext.cx == 0) dc->attr->vport_ext.cx = 1;
if (dc->attr->vport_ext.cy == 0) dc->attr->vport_ext.cy = 1;
if (dc->attr->map_mode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc );
DC_UpdateXforms( dc );
return TRUE;
......@@ -163,39 +165,39 @@ INT CDECL nulldrv_SetMapMode( PHYSDEV dev, INT mode )
case MM_TEXT:
dc->wnd_ext.cx = 1;
dc->wnd_ext.cy = 1;
dc->vport_ext.cx = 1;
dc->vport_ext.cy = 1;
dc->attr->vport_ext.cx = 1;
dc->attr->vport_ext.cy = 1;
break;
case MM_LOMETRIC:
case MM_ISOTROPIC:
dc->wnd_ext.cx = virtual_size.cx * 10;
dc->wnd_ext.cy = virtual_size.cy * 10;
dc->vport_ext.cx = virtual_res.cx;
dc->vport_ext.cy = -virtual_res.cy;
dc->attr->vport_ext.cx = virtual_res.cx;
dc->attr->vport_ext.cy = -virtual_res.cy;
break;
case MM_HIMETRIC:
dc->wnd_ext.cx = virtual_size.cx * 100;
dc->wnd_ext.cy = virtual_size.cy * 100;
dc->vport_ext.cx = virtual_res.cx;
dc->vport_ext.cy = -virtual_res.cy;
dc->attr->vport_ext.cx = virtual_res.cx;
dc->attr->vport_ext.cy = -virtual_res.cy;
break;
case MM_LOENGLISH:
dc->wnd_ext.cx = MulDiv(1000, virtual_size.cx, 254);
dc->wnd_ext.cy = MulDiv(1000, virtual_size.cy, 254);
dc->vport_ext.cx = virtual_res.cx;
dc->vport_ext.cy = -virtual_res.cy;
dc->attr->vport_ext.cx = virtual_res.cx;
dc->attr->vport_ext.cy = -virtual_res.cy;
break;
case MM_HIENGLISH:
dc->wnd_ext.cx = MulDiv(10000, virtual_size.cx, 254);
dc->wnd_ext.cy = MulDiv(10000, virtual_size.cy, 254);
dc->vport_ext.cx = virtual_res.cx;
dc->vport_ext.cy = -virtual_res.cy;
dc->attr->vport_ext.cx = virtual_res.cx;
dc->attr->vport_ext.cy = -virtual_res.cy;
break;
case MM_TWIPS:
dc->wnd_ext.cx = MulDiv(14400, virtual_size.cx, 254);
dc->wnd_ext.cy = MulDiv(14400, virtual_size.cy, 254);
dc->vport_ext.cx = virtual_res.cx;
dc->vport_ext.cy = -virtual_res.cy;
dc->attr->vport_ext.cx = virtual_res.cx;
dc->attr->vport_ext.cy = -virtual_res.cy;
break;
case MM_ANISOTROPIC:
break;
......@@ -213,12 +215,12 @@ BOOL CDECL nulldrv_SetViewportExtEx( PHYSDEV dev, INT cx, INT cy, SIZE *size )
DC *dc = get_nulldrv_dc( dev );
if (size)
*size = dc->vport_ext;
*size = dc->attr->vport_ext;
if (dc->attr->map_mode != MM_ISOTROPIC && dc->attr->map_mode != MM_ANISOTROPIC) return TRUE;
if (!cx || !cy) return FALSE;
dc->vport_ext.cx = cx;
dc->vport_ext.cy = cy;
dc->attr->vport_ext.cx = cx;
dc->attr->vport_ext.cy = cy;
if (dc->attr->map_mode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc );
DC_UpdateXforms( dc );
return TRUE;
......
......@@ -90,7 +90,6 @@ typedef struct tagDC
POINT wnd_org; /* Window origin */
SIZE wnd_ext; /* Window extent */
POINT vport_org; /* Viewport origin */
SIZE vport_ext; /* Viewport extent */
SIZE virtual_res; /* Initially HORZRES,VERTRES. Changed by SetVirtualResolution */
SIZE virtual_size; /* Initially HORZSIZE,VERTSIZE. Changed by SetVirtualResolution */
RECT device_rect; /* rectangle for the whole device */
......
......@@ -865,7 +865,7 @@ static void test_mf_SaveDC(void)
ret = GetViewportOrgEx(hdcMetafile, &pt);
todo_wine ok (!ret, "GetViewportOrgEx should fail\n");
ret = GetViewportExtEx(hdcMetafile, &size);
todo_wine ok (!ret, "GetViewportExtEx should fail\n");
ok(!ret, "GetViewportExtEx should fail\n");
ret = SaveDC(hdcMetafile);
ok(ret == 1, "ret = %d\n", ret);
......
......@@ -116,6 +116,7 @@ typedef struct DC_ATTR
INT map_mode;
RECT vis_rect; /* visible rectangle in screen coords */
FLOAT miter_limit;
SIZE vport_ext; /* viewport extent */
void *emf;
} DC_ATTR;
......
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