ReactOS  0.4.14-dev-342-gdc047f9
init.c File Reference
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winnls.h"
#include "gdi_private.h"
#include "enhmfdrv/enhmetafiledrv.h"
#include "wine/debug.h"
Include dependency graph for init.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (enhmetafile)
 
static BOOL EMFDRV_DeleteDC (PHYSDEV dev)
 
BOOL EMFDRV_WriteRecord (PHYSDEV dev, EMR *emr)
 
void EMFDRV_UpdateBBox (PHYSDEV dev, RECTL *rect)
 
HDC WINAPI CreateEnhMetaFileA (HDC hdc, LPCSTR filename, const RECT *rect, LPCSTR description)
 
HDC WINAPI CreateEnhMetaFileW (HDC hdc, LPCWSTR filename, const RECT *rect, LPCWSTR description)
 
HENHMETAFILE WINAPI CloseEnhMetaFile (HDC hdc)
 

Variables

static const struct gdi_dc_funcs emfdrv_driver
 

Function Documentation

◆ CloseEnhMetaFile()

HENHMETAFILE WINAPI CloseEnhMetaFile ( HDC  hdc)

Definition at line 432 of file init.c.

433 {
434  HENHMETAFILE hmf;
435  EMFDRV_PDEVICE *physDev;
436  DC *dc;
437  EMREOF emr;
438  HANDLE hMapping = 0;
439 
440  TRACE("(%p)\n", hdc );
441 
442  if (!(dc = get_dc_ptr( hdc ))) return NULL;
443  if (GetObjectType( hdc ) != OBJ_ENHMETADC)
444  {
445  release_dc_ptr( dc );
446  return NULL;
447  }
448  if (dc->refcount != 1)
449  {
450  FIXME( "not deleting busy DC %p refcount %u\n", hdc, dc->refcount );
451  release_dc_ptr( dc );
452  return NULL;
453  }
455 
456  if(dc->saveLevel)
457  RestoreDC(hdc, 1);
458 
459  if (physDev->dc_brush) DeleteObject( physDev->dc_brush );
460  if (physDev->dc_pen) DeleteObject( physDev->dc_pen );
461  if (physDev->screen_dc) DeleteDC( physDev->screen_dc );
462 
463  emr.emr.iType = EMR_EOF;
464  emr.emr.nSize = sizeof(emr);
465  emr.nPalEntries = 0;
466  emr.offPalEntries = FIELD_OFFSET(EMREOF, nSizeLast);
467  emr.nSizeLast = emr.emr.nSize;
468  EMFDRV_WriteRecord( &physDev->dev, &emr.emr );
469 
470  /* Update rclFrame if not initialized in CreateEnhMetaFile */
471  if(physDev->emh->rclFrame.left > physDev->emh->rclFrame.right) {
472  physDev->emh->rclFrame.left = physDev->emh->rclBounds.left *
473  physDev->emh->szlMillimeters.cx * 100 / physDev->emh->szlDevice.cx;
474  physDev->emh->rclFrame.top = physDev->emh->rclBounds.top *
475  physDev->emh->szlMillimeters.cy * 100 / physDev->emh->szlDevice.cy;
476  physDev->emh->rclFrame.right = physDev->emh->rclBounds.right *
477  physDev->emh->szlMillimeters.cx * 100 / physDev->emh->szlDevice.cx;
478  physDev->emh->rclFrame.bottom = physDev->emh->rclBounds.bottom *
479  physDev->emh->szlMillimeters.cy * 100 / physDev->emh->szlDevice.cy;
480  }
481 
482  if (physDev->hFile) /* disk based metafile */
483  {
484  if (SetFilePointer(physDev->hFile, 0, NULL, FILE_BEGIN) != 0)
485  {
486  CloseHandle( physDev->hFile );
487  free_dc_ptr( dc );
488  return 0;
489  }
490 
491  if (!WriteFile(physDev->hFile, physDev->emh, sizeof(*physDev->emh),
492  NULL, NULL))
493  {
494  CloseHandle( physDev->hFile );
495  free_dc_ptr( dc );
496  return 0;
497  }
498  HeapFree( GetProcessHeap(), 0, physDev->emh );
499  hMapping = CreateFileMappingA(physDev->hFile, NULL, PAGE_READONLY, 0,
500  0, NULL);
501  TRACE("hMapping = %p\n", hMapping );
502  physDev->emh = MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0);
503  TRACE("view = %p\n", physDev->emh );
504  CloseHandle( hMapping );
505  CloseHandle( physDev->hFile );
506  }
507 
508  hmf = EMF_Create_HENHMETAFILE( physDev->emh, (physDev->hFile != 0) );
509  physDev->emh = NULL; /* So it won't be deleted */
510  free_dc_ptr( dc );
511  return hmf;
512 }
HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, BOOL on_disk)
Definition: enhmetafile.c:249
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
DWORD offPalEntries
Definition: wingdi.h:1856
BOOL EMFDRV_WriteRecord(PHYSDEV dev, EMR *emr)
Definition: init.c:194
#define CloseHandle
Definition: compat.h:406
static PHYSDEV find_dc_driver(DC *dc, const struct gdi_dc_funcs *funcs)
Definition: gdi_private.h:155
SIZEL szlDevice
Definition: wingdi.h:2328
#define MapViewOfFile
Definition: compat.h:410
SIZEL szlMillimeters
Definition: wingdi.h:2329
static EMFDRV_PDEVICE * get_emf_physdev(PHYSDEV dev)
long bottom
Definition: polytest.cpp:53
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC dc
Definition: cylfrac.c:34
void release_dc_ptr(DC *dc) DECLSPEC_HIDDEN
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
long right
Definition: polytest.cpp:53
#define EMR_EOF
Definition: wingdi.h:88
long top
Definition: polytest.cpp:53
#define FIXME(fmt,...)
Definition: debug.h:110
EMR emr
Definition: wingdi.h:1854
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:319
#define FILE_MAP_READ
Definition: compat.h:435
long left
Definition: polytest.cpp:53
DWORD nPalEntries
Definition: wingdi.h:1855
struct gdi_physdev dev
#define TRACE(s)
Definition: solgame.cpp:4
Definition: polytest.cpp:40
RECTL rclFrame
Definition: wingdi.h:2318
#define GetProcessHeap()
Definition: compat.h:403
#define OBJ_ENHMETADC
Definition: objidl.idl:1420
ENHMETAHEADER * emh
DWORD nSize
Definition: wingdi.h:1686
void free_dc_ptr(DC *dc) DECLSPEC_HIDDEN
HDC hdc
Definition: main.c:9
RECTL rclBounds
Definition: wingdi.h:2317
DWORD iType
Definition: wingdi.h:1685
#define FILE_BEGIN
Definition: winbase.h:112
BOOL WINAPI DeleteDC(_In_ HDC)
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define PAGE_READONLY
Definition: compat.h:127
DC * get_dc_ptr(HDC hdc) DECLSPEC_HIDDEN
Definition: rosglue.c:378
static POBJECT_TYPE GetObjectType(IN PCWSTR TypeName)
Definition: ObTypes.c:15
static const struct gdi_dc_funcs emfdrv_driver
Definition: init.c:37
DWORD nSizeLast
Definition: wingdi.h:1857
BOOL WINAPI RestoreDC(_In_ HDC, _In_ int)
LONG cy
Definition: windef.h:320
#define HeapFree(x, y, z)
Definition: compat.h:402
HANDLE NTAPI CreateFileMappingA(IN HANDLE hFile, IN LPSECURITY_ATTRIBUTES lpFileMappingAttributes, IN DWORD flProtect, IN DWORD dwMaximumSizeHigh, IN DWORD dwMaximumSizeLow, IN LPCSTR lpName)
Definition: filemap.c:23

◆ CreateEnhMetaFileA()

HDC WINAPI CreateEnhMetaFileA ( HDC  hdc,
LPCSTR  filename,
const RECT rect,
LPCSTR  description 
)

Definition at line 271 of file init.c.

277 {
280  HDC hReturnDC;
281  DWORD len1, len2, total;
282 
283  if(filename)
284  {
285  total = MultiByteToWideChar( CP_ACP, 0, filename, -1, NULL, 0 );
286  filenameW = HeapAlloc( GetProcessHeap(), 0, total * sizeof(WCHAR) );
287  MultiByteToWideChar( CP_ACP, 0, filename, -1, filenameW, total );
288  }
289  if(description) {
290  len1 = strlen(description);
291  len2 = strlen(description + len1 + 1);
292  total = MultiByteToWideChar( CP_ACP, 0, description, len1 + len2 + 3, NULL, 0 );
293  descriptionW = HeapAlloc( GetProcessHeap(), 0, total * sizeof(WCHAR) );
294  MultiByteToWideChar( CP_ACP, 0, description, len1 + len2 + 3, descriptionW, total );
295  }
296 
298 
301 
302  return hReturnDC;
303 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define CP_ACP
Definition: compat.h:99
static HDC
Definition: imagelist.c:92
const char * description
Definition: directx.c:2497
const char * filename
Definition: ioapi.h:135
& rect
Definition: startmenu.cpp:1413
static const WCHAR filenameW[]
Definition: amstream.c:41
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
HDC WINAPI CreateEnhMetaFileW(HDC hdc, LPCWSTR filename, const RECT *rect, LPCWSTR description)
Definition: init.c:308
HDC hdc
Definition: main.c:9
#define MultiByteToWideChar
Definition: compat.h:100
static const WCHAR descriptionW[]
Definition: error.c:32
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:402

◆ CreateEnhMetaFileW()

HDC WINAPI CreateEnhMetaFileW ( HDC  hdc,
LPCWSTR  filename,
const RECT rect,
LPCWSTR  description 
)

Definition at line 308 of file init.c.

314 {
315  static const WCHAR displayW[] = {'D','I','S','P','L','A','Y',0};
316  HDC ret;
317  DC *dc;
318  EMFDRV_PDEVICE *physDev;
319  HANDLE hFile;
320  DWORD size = 0, length = 0;
321  DWORD bytes_written;
322 
324 
325  if (!(dc = alloc_dc_ptr( OBJ_ENHMETADC ))) return 0;
326 
327  physDev = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physDev));
328  if (!physDev) {
329  free_dc_ptr( dc );
330  return 0;
331  }
332  if(description) { /* App name\0Title\0\0 */
334  length += lstrlenW(description + length + 1);
335  length += 3;
336  length *= 2;
337  }
338  size = sizeof(ENHMETAHEADER) + (length + 3) / 4 * 4;
339 
340  if (!(physDev->emh = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size))) {
341  HeapFree( GetProcessHeap(), 0, physDev );
342  free_dc_ptr( dc );
343  return 0;
344  }
345 
346  push_dc_driver( &dc->physDev, &physDev->dev, &emfdrv_driver );
347 
348  physDev->handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, HANDLE_LIST_INC * sizeof(physDev->handles[0]));
349  physDev->handles_size = HANDLE_LIST_INC;
350  physDev->cur_handles = 1;
351  physDev->hFile = 0;
352  physDev->dc_brush = 0;
353  physDev->dc_pen = 0;
354  physDev->screen_dc = 0;
355  physDev->restoring = 0;
356  physDev->path = FALSE;
357  if (hdc) /* if no ref, use current display */
358  physDev->ref_dc = hdc;
359  else
360  physDev->ref_dc = physDev->screen_dc = CreateDCW( displayW, NULL, NULL, NULL );
361 
362  SetVirtualResolution(physDev->dev.hdc, 0, 0, 0, 0);
363 
364  physDev->emh->iType = EMR_HEADER;
365  physDev->emh->nSize = size;
366 
367  physDev->emh->rclBounds.left = physDev->emh->rclBounds.top = 0;
368  physDev->emh->rclBounds.right = physDev->emh->rclBounds.bottom = -1;
369 
370  if(rect) {
371  physDev->emh->rclFrame.left = rect->left;
372  physDev->emh->rclFrame.top = rect->top;
373  physDev->emh->rclFrame.right = rect->right;
374  physDev->emh->rclFrame.bottom = rect->bottom;
375  } else { /* Set this to {0,0 - -1,-1} and update it at the end */
376  physDev->emh->rclFrame.left = physDev->emh->rclFrame.top = 0;
377  physDev->emh->rclFrame.right = physDev->emh->rclFrame.bottom = -1;
378  }
379 
380  physDev->emh->dSignature = ENHMETA_SIGNATURE;
381  physDev->emh->nVersion = 0x10000;
382  physDev->emh->nBytes = physDev->emh->nSize;
383  physDev->emh->nRecords = 1;
384  physDev->emh->nHandles = 1;
385 
386  physDev->emh->sReserved = 0; /* According to docs, this is reserved and must be 0 */
387  physDev->emh->nDescription = length / 2;
388 
389  physDev->emh->offDescription = length ? sizeof(ENHMETAHEADER) : 0;
390 
391  physDev->emh->nPalEntries = 0; /* I guess this should start at 0 */
392 
393  /* Size in pixels */
394  physDev->emh->szlDevice.cx = GetDeviceCaps( physDev->ref_dc, HORZRES );
395  physDev->emh->szlDevice.cy = GetDeviceCaps( physDev->ref_dc, VERTRES );
396 
397  /* Size in millimeters */
398  physDev->emh->szlMillimeters.cx = GetDeviceCaps( physDev->ref_dc, HORZSIZE );
399  physDev->emh->szlMillimeters.cy = GetDeviceCaps( physDev->ref_dc, VERTSIZE );
400 
401  /* Size in micrometers */
402  physDev->emh->szlMicrometers.cx = physDev->emh->szlMillimeters.cx * 1000;
403  physDev->emh->szlMicrometers.cy = physDev->emh->szlMillimeters.cy * 1000;
404 
405  memcpy((char *)physDev->emh + sizeof(ENHMETAHEADER), description, length);
406 
407  if (filename) /* disk based metafile */
408  {
411  free_dc_ptr( dc );
412  return 0;
413  }
414  if (!WriteFile( hFile, physDev->emh, size, &bytes_written, NULL )) {
415  free_dc_ptr( dc );
416  CloseHandle( hFile );
417  return 0;
418  }
419  physDev->hFile = hFile;
420  }
421 
422  TRACE("returning %p\n", physDev->dev.hdc);
423  ret = physDev->dev.hdc;
424  release_dc_ptr( dc );
425 
426  return ret;
427 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define HORZRES
Definition: wingdi.h:715
#define push_dc_driver
Definition: gdi_private.h:200
struct tagENHMETAHEADER ENHMETAHEADER
#define CloseHandle
Definition: compat.h:406
SIZEL szlDevice
Definition: wingdi.h:2328
SIZEL szlMillimeters
Definition: wingdi.h:2329
static HDC
Definition: imagelist.c:92
long bottom
Definition: polytest.cpp:53
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
HDC dc
Definition: cylfrac.c:34
const char * description
Definition: directx.c:2497
DWORD offDescription
Definition: wingdi.h:2326
const char * filename
Definition: ioapi.h:135
#define lstrlenW
Definition: compat.h:415
void release_dc_ptr(DC *dc) DECLSPEC_HIDDEN
& rect
Definition: startmenu.cpp:1413
long right
Definition: polytest.cpp:53
#define GENERIC_WRITE
Definition: nt_native.h:90
long top
Definition: polytest.cpp:53
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:319
long left
Definition: polytest.cpp:53
DC * alloc_dc_ptr(WORD magic) DECLSPEC_HIDDEN
Definition: rosglue.c:295
DWORD dSignature
Definition: wingdi.h:2319
struct gdi_physdev dev
#define TRACE(s)
Definition: solgame.cpp:4
Definition: polytest.cpp:40
GLsizeiptr size
Definition: glext.h:5919
RECTL rclFrame
Definition: wingdi.h:2318
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR displayW[]
Definition: icm.c:30
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define OBJ_ENHMETADC
Definition: objidl.idl:1420
ENHMETAHEADER * emh
const char * wine_dbgstr_rect(const RECT *rect)
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
void free_dc_ptr(DC *dc) DECLSPEC_HIDDEN
HDC hdc
Definition: main.c:9
#define EMR_HEADER
Definition: wingdi.h:75
DWORD nRecords
Definition: wingdi.h:2322
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
BOOL WINAPI SetVirtualResolution(HDC hdc, DWORD horz_res, DWORD vert_res, DWORD horz_size, DWORD vert_size)
Definition: rosglue.c:523
#define GENERIC_READ
Definition: compat.h:124
_In_ HANDLE hFile
Definition: mswsock.h:90
#define ENHMETA_SIGNATURE
Definition: wingdi.h:204
#define HORZSIZE
Definition: wingdi.h:713
RECTL rclBounds
Definition: wingdi.h:2317
#define CREATE_ALWAYS
Definition: disk.h:72
#define VERTSIZE
Definition: wingdi.h:714
#define VERTRES
Definition: wingdi.h:716
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
HDC WINAPI CreateDCW(_In_opt_ LPCWSTR pszDriver, _In_opt_ LPCWSTR pszDevice, _In_opt_ LPCWSTR psz, _In_opt_ const DEVMODEW *pdmInit)
#define CreateFileW
Definition: compat.h:408
DWORD nVersion
Definition: wingdi.h:2320
static const struct gdi_dc_funcs emfdrv_driver
Definition: init.c:37
DWORD nDescription
Definition: wingdi.h:2325
HGDIOBJ * handles
#define HANDLE_LIST_INC
Definition: gdi32p.h:74
DWORD nPalEntries
Definition: wingdi.h:2327
LONG cy
Definition: windef.h:320
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by CreateEnhMetaFileA().

◆ EMFDRV_DeleteDC()

static BOOL EMFDRV_DeleteDC ( PHYSDEV  dev)
static

Definition at line 174 of file init.c.

175 {
176  EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
177  UINT index;
178 
179  HeapFree( GetProcessHeap(), 0, physDev->emh );
180  for(index = 0; index < physDev->handles_size; index++)
181  if(physDev->handles[index])
182  GDI_hdc_not_using_object(physDev->handles[index], dev->hdc);
183  HeapFree( GetProcessHeap(), 0, physDev->handles );
184  HeapFree( GetProcessHeap(), 0, physDev );
185  return TRUE;
186 }
#define TRUE
Definition: types.h:120
static EMFDRV_PDEVICE * get_emf_physdev(PHYSDEV dev)
GLuint index
Definition: glext.h:6031
#define GetProcessHeap()
Definition: compat.h:403
ENHMETAHEADER * emh
#define index(s, c)
Definition: various.h:29
unsigned int UINT
Definition: ndis.h:50
void GDI_hdc_not_using_object(HGDIOBJ obj, HDC hdc) DECLSPEC_HIDDEN
Definition: rosglue.c:432
HGDIOBJ * handles
#define HeapFree(x, y, z)
Definition: compat.h:402

◆ EMFDRV_UpdateBBox()

void EMFDRV_UpdateBBox ( PHYSDEV  dev,
RECTL rect 
)

Definition at line 231 of file init.c.

232 {
233  EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
234  RECTL *bounds = &physDev->emh->rclBounds;
235  RECTL vportRect = *rect;
236 
237  LPtoDP( dev->hdc, (LPPOINT)&vportRect, 2 );
238 
239  /* The coordinate systems may be mirrored
240  (LPtoDP handles points, not rectangles) */
241  if (vportRect.left > vportRect.right)
242  {
243  LONG temp = vportRect.right;
244  vportRect.right = vportRect.left;
245  vportRect.left = temp;
246  }
247  if (vportRect.top > vportRect.bottom)
248  {
249  LONG temp = vportRect.bottom;
250  vportRect.bottom = vportRect.top;
251  vportRect.top = temp;
252  }
253 
254  if (bounds->left > bounds->right)
255  {
256  /* first bounding rectangle */
257  *bounds = vportRect;
258  }
259  else
260  {
261  bounds->left = min(bounds->left, vportRect.left);
262  bounds->top = min(bounds->top, vportRect.top);
263  bounds->right = max(bounds->right, vportRect.right);
264  bounds->bottom = max(bounds->bottom, vportRect.bottom);
265  }
266 }
#define max(a, b)
Definition: svc.c:63
BOOL WINAPI LPtoDP(_In_ HDC hdc, _Inout_updates_(c) LPPOINT lppt, _In_ int c)
static EMFDRV_PDEVICE * get_emf_physdev(PHYSDEV dev)
long bottom
Definition: polytest.cpp:53
& rect
Definition: startmenu.cpp:1413
long right
Definition: polytest.cpp:53
long LONG
Definition: pedump.c:60
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
ENHMETAHEADER * emh
RECTL rclBounds
Definition: wingdi.h:2317
static calc_node_t temp
Definition: rpn_ieee.c:38
#define min(a, b)
Definition: monoChain.cc:55

Referenced by EMFDRV_ArcChordPie(), EMFDRV_Ellipse(), EMFDRV_ExtTextOut(), EMFDRV_FillRgn(), EMFDRV_FrameRgn(), EMFDRV_GradientFill(), EMFDRV_LineTo(), EMFDRV_PaintInvertRgn(), EMFDRV_PatBlt(), EMFDRV_PolyDraw(), EMFDRV_Polylinegon(), EMFDRV_PolyPolylinegon(), EMFDRV_Rectangle(), EMFDRV_RoundRect(), EMFDRV_SetDIBitsToDevice(), EMFDRV_SetPixel(), EMFDRV_StretchBlt(), EMFDRV_StretchDIBits(), and emfdrv_stroke_and_fill_path().

◆ EMFDRV_WriteRecord()

BOOL EMFDRV_WriteRecord ( PHYSDEV  dev,
EMR emr 
)

Definition at line 194 of file init.c.

195 {
196  DWORD len;
197  DWORD bytes_written;
198  ENHMETAHEADER *emh;
199  EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
200 
201  TRACE("record %d, size %d %s\n",
202  emr->iType, emr->nSize, physDev->hFile ? "(to disk)" : "");
203 
204  assert( !(emr->nSize & 3) );
205 
206  physDev->emh->nBytes += emr->nSize;
207  physDev->emh->nRecords++;
208 
209  if(physDev->hFile) {
210  if (!WriteFile(physDev->hFile, emr, emr->nSize, &bytes_written, NULL))
211  return FALSE;
212  } else {
213  DWORD nEmfSize = HeapSize(GetProcessHeap(), 0, physDev->emh);
214  len = physDev->emh->nBytes;
215  if (len > nEmfSize) {
216  nEmfSize += (nEmfSize / 2) + emr->nSize;
217  emh = HeapReAlloc(GetProcessHeap(), 0, physDev->emh, nEmfSize);
218  if (!emh) return FALSE;
219  physDev->emh = emh;
220  }
221  memcpy((CHAR *)physDev->emh + physDev->emh->nBytes - emr->nSize, emr,
222  emr->nSize);
223  }
224  return TRUE;
225 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define TRUE
Definition: types.h:120
char CHAR
Definition: xmlstorage.h:175
static EMFDRV_PDEVICE * get_emf_physdev(PHYSDEV dev)
#define assert(x)
Definition: debug.h:53
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
ENHMETAHEADER * emh
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD nSize
Definition: wingdi.h:1686
DWORD nRecords
Definition: wingdi.h:2322
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
DWORD iType
Definition: wingdi.h:1685
#define HeapReAlloc
Definition: compat.h:401

Referenced by CloseEnhMetaFile(), EMFDRV_AbortPath(), EMFDRV_AngleArc(), EMFDRV_ArcChordPie(), EMFDRV_BeginPath(), EMFDRV_CloseFigure(), EMFDRV_CreateBrushIndirect(), EMFDRV_CreateFontIndirect(), EMFDRV_CreatePalette(), EMFDRV_CreatePenIndirect(), EMFDRV_DeleteObject(), EMFDRV_Ellipse(), EMFDRV_EndPath(), EMFDRV_ExcludeClipRect(), EMFDRV_ExtFloodFill(), EMFDRV_ExtSelectClipRgn(), EMFDRV_ExtTextOut(), EMFDRV_FillRgn(), EMFDRV_FlattenPath(), EMFDRV_FrameRgn(), EMFDRV_GdiComment(), EMFDRV_GradientFill(), EMFDRV_IntersectClipRect(), EMFDRV_LineTo(), EMFDRV_ModifyWorldTransform(), EMFDRV_MoveTo(), EMFDRV_OffsetClipRgn(), EMFDRV_OffsetViewportOrgEx(), EMFDRV_OffsetWindowOrgEx(), EMFDRV_PaintInvertRgn(), EMFDRV_PatBlt(), EMFDRV_PolyDraw(), EMFDRV_Polylinegon(), EMFDRV_PolyPolylinegon(), EMFDRV_Rectangle(), EMFDRV_RestoreDC(), EMFDRV_RoundRect(), EMFDRV_SaveDC(), EMFDRV_ScaleViewportExtEx(), EMFDRV_ScaleWindowExtEx(), EMFDRV_SelectBrush(), EMFDRV_SelectClipPath(), EMFDRV_SelectFont(), EMFDRV_SelectPalette(), EMFDRV_SelectPen(), EMFDRV_SetArcDirection(), EMFDRV_SetBkColor(), EMFDRV_SetBkMode(), EMFDRV_SetDCBrushColor(), EMFDRV_SetDCPenColor(), EMFDRV_SetDIBitsToDevice(), EMFDRV_SetLayout(), EMFDRV_SetMapMode(), EMFDRV_SetMapperFlags(), EMFDRV_SetPixel(), EMFDRV_SetPolyFillMode(), EMFDRV_SetROP2(), EMFDRV_SetStretchBltMode(), EMFDRV_SetTextAlign(), EMFDRV_SetTextColor(), EMFDRV_SetTextJustification(), EMFDRV_SetViewportExtEx(), EMFDRV_SetViewportOrgEx(), EMFDRV_SetWindowExtEx(), EMFDRV_SetWindowOrgEx(), EMFDRV_SetWorldTransform(), EMFDRV_StretchBlt(), EMFDRV_StretchDIBits(), emfdrv_stroke_and_fill_path(), and EMFDRV_WidenPath().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( enhmetafile  )

Variable Documentation

◆ emfdrv_driver

const struct gdi_dc_funcs emfdrv_driver
static

Definition at line 37 of file init.c.

Referenced by CloseEnhMetaFile(), and CreateEnhMetaFileW().