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
3964aa4a
Commit
3964aa4a
authored
Oct 17, 2012
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdi32: Get rid of the METAFILEOBJ type, instead store a pointer to the metafile data.
parent
89ecf02c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
100 deletions
+58
-100
metafile.c
dlls/gdi32/metafile.c
+58
-100
No files found.
dlls/gdi32/metafile.c
View file @
3964aa4a
...
...
@@ -71,12 +71,6 @@ typedef struct
}
METAHEADERDISK
;
#include "poppack.h"
typedef
struct
{
GDIOBJHDR
header
;
METAHEADER
*
mh
;
}
METAFILEOBJ
;
/******************************************************************
* MF_AddHandle
...
...
@@ -108,31 +102,7 @@ static int MF_AddHandle(HANDLETABLE *ht, UINT htlen, HGDIOBJ hobj)
*/
HMETAFILE
MF_Create_HMETAFILE
(
METAHEADER
*
mh
)
{
HMETAFILE
hmf
;
METAFILEOBJ
*
metaObj
;
if
(
!
(
metaObj
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
metaObj
)
)))
return
0
;
metaObj
->
mh
=
mh
;
if
(
!
(
hmf
=
alloc_gdi_handle
(
&
metaObj
->
header
,
OBJ_METAFILE
,
NULL
)))
HeapFree
(
GetProcessHeap
(),
0
,
metaObj
);
return
hmf
;
}
/******************************************************************
* MF_GetMetaHeader
*
* Returns ptr to METAHEADER associated with HMETAFILE
*/
static
METAHEADER
*
MF_GetMetaHeader
(
HMETAFILE
hmf
)
{
METAHEADER
*
ret
=
NULL
;
METAFILEOBJ
*
metaObj
=
GDI_GetObjPtr
(
hmf
,
OBJ_METAFILE
);
if
(
metaObj
)
{
ret
=
metaObj
->
mh
;
GDI_ReleaseObj
(
hmf
);
}
return
ret
;
return
alloc_gdi_handle
(
mh
,
OBJ_METAFILE
,
NULL
);
}
/******************************************************************
...
...
@@ -164,10 +134,9 @@ static POINT *convert_points( UINT count, const POINTS *pts )
BOOL
WINAPI
DeleteMetaFile
(
HMETAFILE
hmf
)
{
METAFILEOBJ
*
metaObj
=
free_gdi_handle
(
hmf
);
if
(
!
metaObj
)
return
FALSE
;
HeapFree
(
GetProcessHeap
(),
0
,
metaObj
->
mh
);
return
HeapFree
(
GetProcessHeap
(),
0
,
metaObj
);
METAHEADER
*
mh
=
free_gdi_handle
(
hmf
);
if
(
!
mh
)
return
FALSE
;
return
HeapFree
(
GetProcessHeap
(),
0
,
mh
);
}
/******************************************************************
...
...
@@ -312,6 +281,24 @@ METAHEADER *MF_CreateMetaHeaderDisk(METAHEADER *mh, LPCVOID filename, BOOL uni )
return
mh
;
}
/* return a copy of the metafile bits, to be freed with HeapFree */
static
METAHEADER
*
get_metafile_bits
(
HMETAFILE
hmf
)
{
METAHEADER
*
ret
,
*
mh
=
GDI_GetObjPtr
(
hmf
,
OBJ_METAFILE
);
if
(
!
mh
)
return
NULL
;
if
(
mh
->
mtType
!=
METAFILE_DISK
)
{
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
mh
->
mtSize
*
2
);
if
(
ret
)
memcpy
(
ret
,
mh
,
mh
->
mtSize
*
2
);
}
else
ret
=
MF_LoadDiskBasedMetaFile
(
mh
);
GDI_ReleaseObj
(
hmf
);
return
ret
;
}
/******************************************************************
* CopyMetaFileW (GDI32.@)
*
...
...
@@ -331,33 +318,25 @@ METAHEADER *MF_CreateMetaHeaderDisk(METAHEADER *mh, LPCVOID filename, BOOL uni )
*/
HMETAFILE
WINAPI
CopyMetaFileW
(
HMETAFILE
hSrcMetaFile
,
LPCWSTR
lpFilename
)
{
METAHEADER
*
mh
=
MF_GetMetaHeader
(
hSrcMetaFile
);
METAHEADER
*
mh2
=
NULL
;
METAHEADER
*
mh
=
get_metafile_bits
(
hSrcMetaFile
);
HANDLE
hFile
;
TRACE
(
"(%p,%s)
\n
"
,
hSrcMetaFile
,
debugstr_w
(
lpFilename
));
if
(
!
mh
)
return
0
;
if
(
mh
->
mtType
==
METAFILE_DISK
)
mh2
=
MF_LoadDiskBasedMetaFile
(
mh
);
else
{
mh2
=
HeapAlloc
(
GetProcessHeap
(),
0
,
mh
->
mtSize
*
2
);
memcpy
(
mh2
,
mh
,
mh
->
mtSize
*
2
);
}
if
(
lpFilename
)
{
/* disk based metafile */
DWORD
w
;
if
((
hFile
=
CreateFileW
(
lpFilename
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
))
==
INVALID_HANDLE_VALUE
)
{
HeapFree
(
GetProcessHeap
(),
0
,
mh
2
);
HeapFree
(
GetProcessHeap
(),
0
,
mh
);
return
0
;
}
WriteFile
(
hFile
,
mh
2
,
mh2
->
mtSize
*
2
,
&
w
,
NULL
);
WriteFile
(
hFile
,
mh
,
mh
->
mtSize
*
2
,
&
w
,
NULL
);
CloseHandle
(
hFile
);
}
return
MF_Create_HMETAFILE
(
mh
2
);
return
MF_Create_HMETAFILE
(
mh
);
}
...
...
@@ -380,14 +359,23 @@ HMETAFILE WINAPI CopyMetaFileA( HMETAFILE hSrcMetaFile, LPCSTR lpFilename )
return
ret
;
}
/*******************************************************************
* MF_PlayMetaFile
/******************************************************************
* PlayMetaFile (GDI32.@)
*
* Renders the metafile specified by hmf in the DC specified by
* hdc. Returns FALSE on failure, TRUE on success.
*
* PARAMS
* hdc [I] handle of DC to render in
* hmf [I] handle of metafile to render
*
* Helper for PlayMetaFile
* RETURNS
* Success: TRUE
* Failure: FALSE
*/
static
BOOL
MF_PlayMetaFile
(
HDC
hdc
,
METAHEADER
*
mh
)
BOOL
WINAPI
PlayMetaFile
(
HDC
hdc
,
HMETAFILE
hmf
)
{
METAHEADER
*
mh
=
get_metafile_bits
(
hmf
);
METARECORD
*
mr
;
HANDLETABLE
*
ht
;
unsigned
int
offset
=
0
;
...
...
@@ -396,14 +384,8 @@ static BOOL MF_PlayMetaFile( HDC hdc, METAHEADER *mh)
HBRUSH
hBrush
;
HPALETTE
hPal
;
HRGN
hRgn
;
BOOL
loaded
=
FALSE
;
if
(
!
mh
)
return
FALSE
;
if
(
mh
->
mtType
==
METAFILE_DISK
)
{
/* Create a memory-based copy */
mh
=
MF_LoadDiskBasedMetaFile
(
mh
);
if
(
!
mh
)
return
FALSE
;
loaded
=
TRUE
;
}
/* save DC */
hPen
=
GetCurrentObject
(
hdc
,
OBJ_PEN
);
...
...
@@ -420,7 +402,11 @@ static BOOL MF_PlayMetaFile( HDC hdc, METAHEADER *mh)
/* create the handle table */
ht
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
HANDLETABLE
)
*
mh
->
mtNoObjects
);
if
(
!
ht
)
return
FALSE
;
if
(
!
ht
)
{
HeapFree
(
GetProcessHeap
(),
0
,
mh
);
return
FALSE
;
}
/* loop through metafile playing records */
offset
=
mh
->
mtHeaderSize
*
2
;
...
...
@@ -455,34 +441,12 @@ static BOOL MF_PlayMetaFile( HDC hdc, METAHEADER *mh)
if
(
*
(
ht
->
objectHandle
+
i
)
!=
0
)
DeleteObject
(
*
(
ht
->
objectHandle
+
i
));
/* free handle table */
HeapFree
(
GetProcessHeap
(),
0
,
ht
);
if
(
loaded
)
HeapFree
(
GetProcessHeap
(),
0
,
mh
);
HeapFree
(
GetProcessHeap
(),
0
,
mh
);
return
TRUE
;
}
/******************************************************************
* PlayMetaFile (GDI32.@)
*
* Renders the metafile specified by hmf in the DC specified by
* hdc. Returns FALSE on failure, TRUE on success.
*
* PARAMS
* hdc [I] handle of DC to render in
* hmf [I] handle of metafile to render
*
* RETURNS
* Success: TRUE
* Failure: FALSE
*/
BOOL
WINAPI
PlayMetaFile
(
HDC
hdc
,
HMETAFILE
hmf
)
{
METAHEADER
*
mh
=
MF_GetMetaHeader
(
hmf
);
return
MF_PlayMetaFile
(
hdc
,
mh
);
}
/******************************************************************
* EnumMetaFile (GDI32.@)
*
* Loop through the metafile records in hmf, calling the user-specified
...
...
@@ -495,7 +459,7 @@ BOOL WINAPI PlayMetaFile( HDC hdc, HMETAFILE hmf )
*/
BOOL
WINAPI
EnumMetaFile
(
HDC
hdc
,
HMETAFILE
hmf
,
MFENUMPROC
lpEnumFunc
,
LPARAM
lpData
)
{
METAHEADER
*
mh
Temp
=
NULL
,
*
mh
=
MF_GetMetaHeader
(
hmf
);
METAHEADER
*
mh
=
get_metafile_bits
(
hmf
);
METARECORD
*
mr
;
HANDLETABLE
*
ht
;
BOOL
result
=
TRUE
;
...
...
@@ -505,14 +469,9 @@ BOOL WINAPI EnumMetaFile(HDC hdc, HMETAFILE hmf, MFENUMPROC lpEnumFunc, LPARAM l
HBRUSH
hBrush
;
HFONT
hFont
;
TRACE
(
"(%p,%p,%p,%p)
\n
"
,
hdc
,
hmf
,
lpEnumFunc
,
(
void
*
)
lpData
);
TRACE
(
"(%p,%p,%p,%lx)
\n
"
,
hdc
,
hmf
,
lpEnumFunc
,
lpData
);
if
(
!
mh
)
return
0
;
if
(
mh
->
mtType
==
METAFILE_DISK
)
{
/* Create a memory-based copy */
if
(
!
(
mhTemp
=
MF_LoadDiskBasedMetaFile
(
mh
)))
return
FALSE
;
mh
=
mhTemp
;
}
/* save the current pen, brush and font */
hPen
=
GetCurrentObject
(
hdc
,
OBJ_PEN
);
...
...
@@ -534,7 +493,7 @@ BOOL WINAPI EnumMetaFile(HDC hdc, HMETAFILE hmf, MFENUMPROC lpEnumFunc, LPARAM l
}
TRACE
(
"Calling EnumFunc with record type %x
\n
"
,
mr
->
rdFunction
);
if
(
!
lpEnumFunc
(
hdc
,
ht
,
mr
,
mh
->
mtNoObjects
,
(
LONG
)
lpData
))
if
(
!
lpEnumFunc
(
hdc
,
ht
,
mr
,
mh
->
mtNoObjects
,
lpData
))
{
result
=
FALSE
;
break
;
...
...
@@ -553,10 +512,8 @@ BOOL WINAPI EnumMetaFile(HDC hdc, HMETAFILE hmf, MFENUMPROC lpEnumFunc, LPARAM l
if
(
*
(
ht
->
objectHandle
+
i
)
!=
0
)
DeleteObject
(
*
(
ht
->
objectHandle
+
i
));
/* free handle table */
HeapFree
(
GetProcessHeap
(),
0
,
ht
);
/* free a copy of metafile */
HeapFree
(
GetProcessHeap
(),
0
,
mhTemp
);
HeapFree
(
GetProcessHeap
(),
0
,
mh
);
return
result
;
}
...
...
@@ -1129,7 +1086,7 @@ HMETAFILE WINAPI SetMetaFileBitsEx( UINT size, const BYTE *lpData )
*/
UINT
WINAPI
GetMetaFileBitsEx
(
HMETAFILE
hmf
,
UINT
nSize
,
LPVOID
buf
)
{
METAHEADER
*
mh
=
MF_GetMetaHeader
(
hmf
);
METAHEADER
*
mh
=
GDI_GetObjPtr
(
hmf
,
OBJ_METAFILE
);
UINT
mfSize
;
TRACE
(
"(%p,%d,%p)
\n
"
,
hmf
,
nSize
,
buf
);
...
...
@@ -1137,12 +1094,13 @@ UINT WINAPI GetMetaFileBitsEx( HMETAFILE hmf, UINT nSize, LPVOID buf )
if
(
mh
->
mtType
==
METAFILE_DISK
)
FIXME
(
"Disk-based metafile?
\n
"
);
mfSize
=
mh
->
mtSize
*
2
;
if
(
!
buf
)
{
TRACE
(
"returning size %d
\n
"
,
mfSize
);
return
mfSize
;
if
(
buf
)
{
if
(
mfSize
>
nSize
)
mfSize
=
nSize
;
memmove
(
buf
,
mh
,
mfSize
);
}
if
(
mfSize
>
nSize
)
mfSize
=
nSize
;
memmove
(
buf
,
mh
,
mfSize
);
GDI_ReleaseObj
(
hmf
)
;
TRACE
(
"returning size %d
\n
"
,
mfSize
);
return
mfSize
;
}
...
...
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