Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
787ead80
Commit
787ead80
authored
Jul 07, 2009
by
Huw Davies
Committed by
Alexandre Julliard
Jul 07, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdi32: Use a modified version of MulDiv to match native behaviour.
parent
0ed10bf6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
33 deletions
+92
-33
metafile.c
dlls/gdi32/metafile.c
+33
-13
metafile.c
dlls/gdi32/tests/metafile.c
+59
-20
No files found.
dlls/gdi32/metafile.c
View file @
787ead80
...
@@ -1222,6 +1222,26 @@ end:
...
@@ -1222,6 +1222,26 @@ end:
return
ret
;
return
ret
;
}
}
/*******************************************************************
* muldiv
*
* Behaves somewhat differently to MulDiv when the answer is -ve
* and also rounds n.5 towards zero
*/
static
INT
muldiv
(
INT
m1
,
INT
m2
,
INT
d
)
{
LONGLONG
ret
;
ret
=
((
LONGLONG
)
m1
*
m2
+
d
/
2
)
/
d
;
/* Always add d/2 even if ret will be -ve */
if
((
LONGLONG
)
m1
*
m2
*
2
==
(
2
*
ret
-
1
)
*
d
)
/* If the answer is exactly n.5 round towards zero */
{
if
(
ret
>
0
)
ret
--
;
else
ret
++
;
}
return
ret
;
}
/******************************************************************
/******************************************************************
* set_window
* set_window
*
*
...
@@ -1247,28 +1267,28 @@ static BOOL set_window(HDC hdc, HENHMETAFILE emf, HDC ref_dc, INT map_mode)
...
@@ -1247,28 +1267,28 @@ static BOOL set_window(HDC hdc, HENHMETAFILE emf, HDC ref_dc, INT map_mode)
case
MM_TEXT
:
case
MM_TEXT
:
case
MM_ISOTROPIC
:
case
MM_ISOTROPIC
:
case
MM_ANISOTROPIC
:
case
MM_ANISOTROPIC
:
pt
.
y
=
MulD
iv
(
header
.
rclFrame
.
top
,
vert_res
,
vert_size
*
100
);
pt
.
y
=
muld
iv
(
header
.
rclFrame
.
top
,
vert_res
,
vert_size
*
100
);
pt
.
x
=
MulD
iv
(
header
.
rclFrame
.
left
,
horz_res
,
horz_size
*
100
);
pt
.
x
=
muld
iv
(
header
.
rclFrame
.
left
,
horz_res
,
horz_size
*
100
);
break
;
break
;
case
MM_LOMETRIC
:
case
MM_LOMETRIC
:
pt
.
y
=
MulD
iv
(
-
header
.
rclFrame
.
top
,
1
,
10
)
+
1
;
pt
.
y
=
muld
iv
(
-
header
.
rclFrame
.
top
,
1
,
10
)
+
1
;
pt
.
x
=
MulD
iv
(
header
.
rclFrame
.
left
,
1
,
10
);
pt
.
x
=
muld
iv
(
header
.
rclFrame
.
left
,
1
,
10
);
break
;
break
;
case
MM_HIMETRIC
:
case
MM_HIMETRIC
:
pt
.
y
=
-
header
.
rclFrame
.
top
+
1
;
pt
.
y
=
-
header
.
rclFrame
.
top
+
1
;
pt
.
x
=
header
.
rclFrame
.
left
;
pt
.
x
=
(
header
.
rclFrame
.
left
>=
0
)
?
header
.
rclFrame
.
left
:
header
.
rclFrame
.
left
+
1
;
/* See the tests */
break
;
break
;
case
MM_LOENGLISH
:
case
MM_LOENGLISH
:
pt
.
y
=
MulD
iv
(
-
header
.
rclFrame
.
top
,
10
,
254
)
+
1
;
pt
.
y
=
muld
iv
(
-
header
.
rclFrame
.
top
,
10
,
254
)
+
1
;
pt
.
x
=
MulD
iv
(
header
.
rclFrame
.
left
,
10
,
254
);
pt
.
x
=
muld
iv
(
header
.
rclFrame
.
left
,
10
,
254
);
break
;
break
;
case
MM_HIENGLISH
:
case
MM_HIENGLISH
:
pt
.
y
=
MulD
iv
(
-
header
.
rclFrame
.
top
,
100
,
254
)
+
1
;
pt
.
y
=
muld
iv
(
-
header
.
rclFrame
.
top
,
100
,
254
)
+
1
;
pt
.
x
=
MulD
iv
(
header
.
rclFrame
.
left
,
100
,
254
);
pt
.
x
=
muld
iv
(
header
.
rclFrame
.
left
,
100
,
254
);
break
;
break
;
case
MM_TWIPS
:
case
MM_TWIPS
:
pt
.
y
=
MulD
iv
(
-
header
.
rclFrame
.
top
,
72
*
20
,
2540
)
+
1
;
pt
.
y
=
muld
iv
(
-
header
.
rclFrame
.
top
,
72
*
20
,
2540
)
+
1
;
pt
.
x
=
MulD
iv
(
header
.
rclFrame
.
left
,
72
*
20
,
2540
);
pt
.
x
=
muld
iv
(
header
.
rclFrame
.
left
,
72
*
20
,
2540
);
break
;
break
;
default:
default:
WARN
(
"Unknown map mode %d
\n
"
,
map_mode
);
WARN
(
"Unknown map mode %d
\n
"
,
map_mode
);
...
@@ -1276,8 +1296,8 @@ static BOOL set_window(HDC hdc, HENHMETAFILE emf, HDC ref_dc, INT map_mode)
...
@@ -1276,8 +1296,8 @@ static BOOL set_window(HDC hdc, HENHMETAFILE emf, HDC ref_dc, INT map_mode)
}
}
SetWindowOrgEx
(
hdc
,
pt
.
x
,
pt
.
y
,
NULL
);
SetWindowOrgEx
(
hdc
,
pt
.
x
,
pt
.
y
,
NULL
);
pt
.
x
=
MulD
iv
(
header
.
rclFrame
.
right
-
header
.
rclFrame
.
left
,
horz_res
,
horz_size
*
100
);
pt
.
x
=
muld
iv
(
header
.
rclFrame
.
right
-
header
.
rclFrame
.
left
,
horz_res
,
horz_size
*
100
);
pt
.
y
=
MulD
iv
(
header
.
rclFrame
.
bottom
-
header
.
rclFrame
.
top
,
vert_res
,
vert_size
*
100
);
pt
.
y
=
muld
iv
(
header
.
rclFrame
.
bottom
-
header
.
rclFrame
.
top
,
vert_res
,
vert_size
*
100
);
SetWindowExtEx
(
hdc
,
pt
.
x
,
pt
.
y
,
NULL
);
SetWindowExtEx
(
hdc
,
pt
.
x
,
pt
.
y
,
NULL
);
return
TRUE
;
return
TRUE
;
}
}
...
...
dlls/gdi32/tests/metafile.c
View file @
787ead80
...
@@ -2308,11 +2308,25 @@ static void test_SetWinMetaFileBits(void)
...
@@ -2308,11 +2308,25 @@ static void test_SetWinMetaFileBits(void)
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
}
}
static
void
getwinmetafilebits
(
UINT
mode
,
int
scale
)
/* This is somewhat different to MulDiv, but appears to be how native behaves */
static
INT
muldiv
(
INT
m1
,
INT
m2
,
INT
d
)
{
LONGLONG
ret
;
ret
=
((
LONGLONG
)
m1
*
m2
+
d
/
2
)
/
d
;
/* Always add d/2 even if ret will be -ve */
if
((
LONGLONG
)
m1
*
m2
*
2
==
(
2
*
ret
-
1
)
*
d
)
/* If the answer is exactly n.5 round towards zero */
{
if
(
ret
>
0
)
ret
--
;
else
ret
++
;
}
return
ret
;
}
static
void
getwinmetafilebits
(
UINT
mode
,
int
scale
,
RECT
*
rc
)
{
{
HENHMETAFILE
emf
;
HENHMETAFILE
emf
;
HDC
display_dc
,
emf_dc
;
HDC
display_dc
,
emf_dc
;
RECT
rc
;
ENHMETAHEADER
*
enh_header
;
ENHMETAHEADER
*
enh_header
;
UINT
size
,
emf_size
,
i
;
UINT
size
,
emf_size
,
i
;
WORD
check
=
0
;
WORD
check
=
0
;
...
@@ -2322,17 +2336,19 @@ static void getwinmetafilebits(UINT mode, int scale)
...
@@ -2322,17 +2336,19 @@ static void getwinmetafilebits(UINT mode, int scale)
INT
horz_res
,
vert_res
,
horz_size
,
vert_size
;
INT
horz_res
,
vert_res
,
horz_size
,
vert_size
;
display_dc
=
GetDC
(
NULL
);
display_dc
=
GetDC
(
NULL
);
ok
(
display_dc
!=
NULL
,
"display_dc is NULL
\n
"
);
horz_res
=
GetDeviceCaps
(
display_dc
,
HORZRES
);
horz_res
=
GetDeviceCaps
(
display_dc
,
HORZRES
);
vert_res
=
GetDeviceCaps
(
display_dc
,
VERTRES
);
vert_res
=
GetDeviceCaps
(
display_dc
,
VERTRES
);
horz_size
=
GetDeviceCaps
(
display_dc
,
HORZSIZE
);
horz_size
=
GetDeviceCaps
(
display_dc
,
HORZSIZE
);
vert_size
=
GetDeviceCaps
(
display_dc
,
VERTSIZE
);
vert_size
=
GetDeviceCaps
(
display_dc
,
VERTSIZE
);
SetRect
(
&
rc
,
1000
,
2000
,
3000
,
6000
);
emf_dc
=
CreateEnhMetaFileA
(
display_dc
,
NULL
,
rc
,
NULL
);
emf_dc
=
CreateEnhMetaFileA
(
display_dc
,
NULL
,
&
rc
,
NULL
);
ok
(
emf_dc
!=
NULL
,
"emf_dc is NULL
\n
"
);
for
(
i
=
0
;
i
<
3000
;
i
++
)
/* This is enough to take emf_size > 0xffff */
for
(
i
=
0
;
i
<
3000
;
i
++
)
/* This is enough to take emf_size > 0xffff */
Rectangle
(
emf_dc
,
0
,
0
,
1000
,
20
);
Rectangle
(
emf_dc
,
0
,
0
,
1000
,
20
);
emf
=
CloseEnhMetaFile
(
emf_dc
);
emf
=
CloseEnhMetaFile
(
emf_dc
);
ok
(
emf
!=
NULL
,
"emf is NULL
\n
"
);
emf_size
=
GetEnhMetaFileBits
(
emf
,
0
,
NULL
);
emf_size
=
GetEnhMetaFileBits
(
emf
,
0
,
NULL
);
enh_header
=
HeapAlloc
(
GetProcessHeap
(),
0
,
emf_size
);
enh_header
=
HeapAlloc
(
GetProcessHeap
(),
0
,
emf_size
);
...
@@ -2342,6 +2358,8 @@ static void getwinmetafilebits(UINT mode, int scale)
...
@@ -2342,6 +2358,8 @@ static void getwinmetafilebits(UINT mode, int scale)
have different resolutions */
have different resolutions */
enh_header
->
szlDevice
.
cx
*=
scale
;
enh_header
->
szlDevice
.
cx
*=
scale
;
emf
=
SetEnhMetaFileBits
(
emf_size
,
(
BYTE
*
)
enh_header
);
emf
=
SetEnhMetaFileBits
(
emf_size
,
(
BYTE
*
)
enh_header
);
ok
(
emf
!=
NULL
,
"emf is NULL
\n
"
);
ok
(
EqualRect
((
RECT
*
)
&
enh_header
->
rclFrame
,
rc
),
"Frame rectangles differ
\n
"
);
size
=
GetWinMetaFileBits
(
emf
,
0
,
NULL
,
mode
,
display_dc
);
size
=
GetWinMetaFileBits
(
emf
,
0
,
NULL
,
mode
,
display_dc
);
ok
(
size
,
"GetWinMetaFileBits returns 0
\n
"
);
ok
(
size
,
"GetWinMetaFileBits returns 0
\n
"
);
...
@@ -2403,28 +2421,28 @@ static void getwinmetafilebits(UINT mode, int scale)
...
@@ -2403,28 +2421,28 @@ static void getwinmetafilebits(UINT mode, int scale)
case
MM_TEXT
:
case
MM_TEXT
:
case
MM_ISOTROPIC
:
case
MM_ISOTROPIC
:
case
MM_ANISOTROPIC
:
case
MM_ANISOTROPIC
:
pt
.
y
=
MulDiv
(
rc
.
top
,
vert_res
,
vert_size
*
100
);
pt
.
y
=
muldiv
(
rc
->
top
,
vert_res
,
vert_size
*
100
);
pt
.
x
=
MulDiv
(
rc
.
left
,
horz_res
,
horz_size
*
100
);
pt
.
x
=
muldiv
(
rc
->
left
,
horz_res
,
horz_size
*
100
);
break
;
break
;
case
MM_LOMETRIC
:
case
MM_LOMETRIC
:
pt
.
y
=
MulDiv
(
-
rc
.
top
,
1
,
10
)
+
1
;
pt
.
y
=
muldiv
(
-
rc
->
top
,
1
,
10
)
+
1
;
pt
.
x
=
MulDiv
(
rc
.
left
,
1
,
10
);
pt
.
x
=
muldiv
(
rc
->
left
,
1
,
10
);
break
;
break
;
case
MM_HIMETRIC
:
case
MM_HIMETRIC
:
pt
.
y
=
-
rc
.
top
+
1
;
pt
.
y
=
-
rc
->
top
+
1
;
pt
.
x
=
rc
.
left
;
pt
.
x
=
(
rc
->
left
>=
0
)
?
rc
->
left
:
rc
->
left
+
1
;
/* strange but true */
break
;
break
;
case
MM_LOENGLISH
:
case
MM_LOENGLISH
:
pt
.
y
=
MulDiv
(
-
rc
.
top
,
10
,
254
)
+
1
;
pt
.
y
=
muldiv
(
-
rc
->
top
,
10
,
254
)
+
1
;
pt
.
x
=
MulDiv
(
rc
.
left
,
10
,
254
);
pt
.
x
=
muldiv
(
rc
->
left
,
10
,
254
);
break
;
break
;
case
MM_HIENGLISH
:
case
MM_HIENGLISH
:
pt
.
y
=
MulDiv
(
-
rc
.
top
,
100
,
254
)
+
1
;
pt
.
y
=
muldiv
(
-
rc
->
top
,
100
,
254
)
+
1
;
pt
.
x
=
MulDiv
(
rc
.
left
,
100
,
254
);
pt
.
x
=
muldiv
(
rc
->
left
,
100
,
254
);
break
;
break
;
case
MM_TWIPS
:
case
MM_TWIPS
:
pt
.
y
=
MulDiv
(
-
rc
.
top
,
72
*
20
,
2540
)
+
1
;
pt
.
y
=
muldiv
(
-
rc
->
top
,
72
*
20
,
2540
)
+
1
;
pt
.
x
=
MulDiv
(
rc
.
left
,
72
*
20
,
2540
);
pt
.
x
=
muldiv
(
rc
->
left
,
72
*
20
,
2540
);
break
;
break
;
default:
default:
pt
.
x
=
pt
.
y
=
0
;
pt
.
x
=
pt
.
y
=
0
;
...
@@ -2437,8 +2455,9 @@ static void getwinmetafilebits(UINT mode, int scale)
...
@@ -2437,8 +2455,9 @@ static void getwinmetafilebits(UINT mode, int scale)
if
(
rec_num
==
mfcomment_chunks
+
2
)
if
(
rec_num
==
mfcomment_chunks
+
2
)
{
{
ok
(
rec
->
rdFunction
==
META_SETWINDOWEXT
,
"got %04x
\n
"
,
rec
->
rdFunction
);
ok
(
rec
->
rdFunction
==
META_SETWINDOWEXT
,
"got %04x
\n
"
,
rec
->
rdFunction
);
ok
((
short
)
rec
->
rdParm
[
0
]
==
MulDiv
(
rc
.
bottom
-
rc
.
top
,
vert_res
,
vert_size
*
100
),
"got %d
\n
"
,
(
short
)
rec
->
rdParm
[
0
]);
ok
((
short
)
rec
->
rdParm
[
0
]
==
muldiv
(
rc
->
bottom
-
rc
->
top
,
vert_res
,
vert_size
*
100
),
"got %d
\n
"
,
(
short
)
rec
->
rdParm
[
0
]);
ok
((
short
)
rec
->
rdParm
[
1
]
==
MulDiv
(
rc
.
right
-
rc
.
left
,
horz_res
,
horz_size
*
100
),
"got %d
\n
"
,
(
short
)
rec
->
rdParm
[
1
]);
ok
((
short
)
rec
->
rdParm
[
1
]
==
muldiv
(
rc
->
right
-
rc
->
left
,
horz_res
,
horz_size
*
100
),
"got %d
\n
"
,
(
short
)
rec
->
rdParm
[
1
]);
}
}
rec_num
++
;
rec_num
++
;
...
@@ -2455,11 +2474,31 @@ static void getwinmetafilebits(UINT mode, int scale)
...
@@ -2455,11 +2474,31 @@ static void getwinmetafilebits(UINT mode, int scale)
static
void
test_GetWinMetaFileBits
(
void
)
static
void
test_GetWinMetaFileBits
(
void
)
{
{
UINT
mode
;
UINT
mode
;
RECT
frames
[]
=
{
{
1000
,
2000
,
3000
,
6000
},
{
-
1000
,
2000
,
3000
,
6000
},
{
1000
,
-
2000
,
3000
,
6000
},
{
1005
,
2005
,
3000
,
6000
},
{
-
1005
,
-
2005
,
3000
,
6000
},
{
-
1005
,
-
2010
,
3000
,
6000
},
{
-
1005
,
2010
,
3000
,
6000
},
{
0
,
0
,
1
,
1
},
{
-
1
,
-
1
,
1
,
1
},
{
0
,
0
,
0
,
0
}
};
for
(
mode
=
MM_MIN
;
mode
<=
MM_MAX
;
mode
++
)
for
(
mode
=
MM_MIN
;
mode
<=
MM_MAX
;
mode
++
)
{
{
getwinmetafilebits
(
mode
,
1
);
RECT
*
rc
;
getwinmetafilebits
(
mode
,
2
);
trace
(
"mode %d
\n
"
,
mode
);
for
(
rc
=
frames
;
rc
->
right
-
rc
->
left
>
0
;
rc
++
)
{
trace
(
"frame %d,%d - %d,%d
\n
"
,
rc
->
left
,
rc
->
top
,
rc
->
right
,
rc
->
bottom
);
getwinmetafilebits
(
mode
,
1
,
rc
);
getwinmetafilebits
(
mode
,
2
,
rc
);
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment