[GDI] fix for tests/metafile.c
Felix Nawothnig
felix.nawothnig at t-online.de
Tue Jun 21 22:05:30 CDT 2005
Depending on the current resolution this test often failed on Windows
(all versions) due to rounding-errors in native GDI (we also have
them... but different ones). I don't think we should care about that
since the rounding-errors result in differences being in subpixel-range
when mapped back to DP.
I tested the patch on Wine, Win98 and WinXP with different screen
resolutions and although some tests still fail on Wine and Win98 due to
wrong mapping semantics (I'll fix that with another patch) the
calculated coordinates match now.
ChangeLog:
- Use smaller numbers as coordinates for mapping tests to avoid
rounding-errors.
- Simplify calculation of mapped coordinates for MM_TEXT.
-------------- next part --------------
Index: metafile.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/tests/metafile.c,v
retrieving revision 1.10
diff -u -r1.10 metafile.c
--- metafile.c 21 Jun 2005 20:53:14 -0000 1.10
+++ metafile.c 22 Jun 2005 03:03:33 -0000
@@ -445,26 +445,15 @@
static INT CALLBACK EmfMmTextEnumProc(HDC hdc, HANDLETABLE *lpHTable, const ENHMETARECORD *lpEMFR, INT nObj, LPARAM lpData)
{
- POINT mapping[2] = { { 0, 0 }, { 1000, 1000 } };
+ POINT mapping[2] = { { 0, 0 }, { 10, 10 } };
LPtoDP(hdc, mapping, 2);
trace("Meta record: iType = %ld, (%ld,%ld)-(%ld,%ld)\n", lpEMFR->iType, mapping[0].x, mapping[0].y, mapping[1].x, mapping[1].y);
if (lpEMFR->iType == EMR_LINETO)
{
- FLOAT xSrcPixSize, ySrcPixSize, xscale, yscale;
- INT xframe = LINE_X * (float)GetDeviceCaps(hdc, HORZSIZE) * 100.0f / (float)GetDeviceCaps(hdc, HORZRES);
- INT yframe = LINE_Y * (float)GetDeviceCaps(hdc, VERTSIZE) * 100.0f / (float)GetDeviceCaps(hdc, VERTRES);
INT x0 = 0;
INT y0 = 0;
- INT x1;
- INT y1;
- xSrcPixSize = (FLOAT) GetDeviceCaps(hdc, HORZSIZE) / GetDeviceCaps(hdc, HORZRES);
- ySrcPixSize = (FLOAT) GetDeviceCaps(hdc, VERTSIZE) / GetDeviceCaps(hdc, VERTRES);
- xscale = (FLOAT) 1000 * 100.0 /
- xframe * xSrcPixSize;
- yscale = (FLOAT) 1000 * 100.0 /
- yframe * ySrcPixSize;
- x1 = (INT)floor(xscale * 100.0 + 0.5f);
- y1 = (INT)floor(yscale * 100.0 + 0.5f);
+ INT x1 = (INT)floor(10 * 100.0 / LINE_X + 0.5);
+ INT y1 = (INT)floor(10 * 100.0 / LINE_Y + 0.5);
ok(mapping[0].x == x0 && mapping[0].y == y0 && mapping[1].x == x1 && mapping[1].y == y1,
"(%ld,%ld)->(%ld,%ld), expected (%d,%d)->(%d,%d)\n",
mapping[0].x, mapping[0].y, mapping[1].x, mapping[1].y,
@@ -476,15 +465,15 @@
static INT CALLBACK EmfMmAnisotropicEnumProc(HDC hdc, HANDLETABLE *lpHTable, const ENHMETARECORD *lpEMFR, INT nObj, LPARAM lpData)
{
- POINT mapping[2] = { { 0, 0 }, { 1000, 1000 } };
+ POINT mapping[2] = { { 0, 0 }, { 10, 10 } };
LPtoDP(hdc, mapping, 2);
trace("Meta record: iType = %ld, (%ld,%ld)-(%ld,%ld)\n", lpEMFR->iType, mapping[0].x, mapping[0].y, mapping[1].x, mapping[1].y);
if (lpEMFR->iType == EMR_LINETO)
{
INT x0 = MulDiv(0, GetDeviceCaps(hdc, HORZSIZE) * 100, GetDeviceCaps(hdc, HORZRES));
INT y0 = MulDiv(0, GetDeviceCaps(hdc, VERTSIZE) * 100, GetDeviceCaps(hdc, VERTRES));
- INT x1 = MulDiv(1000, GetDeviceCaps(hdc, HORZSIZE) * 100, GetDeviceCaps(hdc, HORZRES));
- INT y1 = MulDiv(1000, GetDeviceCaps(hdc, VERTSIZE) * 100, GetDeviceCaps(hdc, VERTRES));
+ INT x1 = MulDiv(10, GetDeviceCaps(hdc, HORZSIZE) * 100, GetDeviceCaps(hdc, HORZRES));
+ INT y1 = MulDiv(10, GetDeviceCaps(hdc, VERTSIZE) * 100, GetDeviceCaps(hdc, VERTRES));
ok(mapping[0].x == x0 && mapping[0].y == y0 && mapping[1].x == x1 && mapping[1].y == y1,
"(%ld,%ld)->(%ld,%ld), expected (%d,%d)->(%d,%d)\n",
mapping[0].x, mapping[0].y, mapping[1].x, mapping[1].y,
More information about the wine-patches
mailing list