ReactOS 0.4.15-dev-8235-gcd88a97
metafile.c File Reference
#include <assert.h>
#include <stdio.h>
#include <math.h>
#include "wine/test.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winerror.h"
Include dependency graph for metafile.c:

Go to the source code of this file.

Classes

struct  eto_scale_test_record
 
struct  emf_WorldTransform_test_data
 

Macros

#define M_PI   3.14159265358979323846
 
#define LINE_X   55.0f
 
#define LINE_Y   15.0f
 
#define GDI_GET_PROC(func)
 
#define MF_BUFSIZE   1024
 
#define BMP_DIM   4
 

Functions

static INT (WINAPI *pGetRelAbs)(HDC
 
static COLORREF (WINAPI *pSetDCBrushColor)(HDC
 
static void init_function_pointers (void)
 
static DWORD rgn_rect_count (HRGN hrgn)
 
static int CALLBACK eto_emf_enum_proc (HDC hdc, HANDLETABLE *handle_table, const ENHMETARECORD *emr, int n_objs, LPARAM param)
 
static void test_ExtTextOut (void)
 
static int CALLBACK eto_scale_enum_proc (HDC hdc, HANDLETABLE *handle_table, const ENHMETARECORD *emr, int n_objs, LPARAM param)
 
static void test_ExtTextOutScale (void)
 
static void check_dc_state (HDC hdc, int restore_no, int wnd_org_x, int wnd_org_y, int wnd_ext_x, int wnd_ext_y, int vp_org_x, int vp_org_y, int vp_ext_x, int vp_ext_y)
 
static int CALLBACK savedc_emf_enum_proc (HDC hdc, HANDLETABLE *handle_table, const ENHMETARECORD *emr, int n_objs, LPARAM param)
 
static void test_SaveDC (void)
 
static void test_mf_SaveDC (void)
 
static INT CALLBACK mf_enum_proc (HDC hdc, HANDLETABLE *ht, METARECORD *mr, INT nobj, LPARAM param)
 
static void dump_mf_bits (const HMETAFILE mf, const char *desc)
 
static int compare_mf_bits (const HMETAFILE mf, const unsigned char *bits, UINT bsize, const char *desc)
 
static int compare_mf_disk_bits (LPCSTR name, const BYTE *bits, UINT bsize, const char *desc)
 
static void dump_emf_bits (const HENHMETAFILE mf, const char *desc)
 
static void dump_emf_records (const HENHMETAFILE mf, const char *desc)
 
static void dump_emf_record (const ENHMETARECORD *emr, const char *desc)
 
static void dump_EMREXTTEXTOUT (const EMREXTTEXTOUTW *eto)
 
static BOOL match_emf_record (const ENHMETARECORD *emr1, const ENHMETARECORD *emr2, const char *desc, BOOL ignore_scaling)
 
static int compare_emf_bits (const HENHMETAFILE mf, const unsigned char *bits, UINT bsize, const char *desc, BOOL ignore_scaling)
 
static void test_emf_BitBlt (void)
 
static void test_emf_DCBrush (void)
 
static void test_mf_Blank (void)
 
static void test_CopyMetaFile (void)
 
static void test_SetMetaFileBits (void)
 
static void test_mf_Graphics (void)
 
static void test_mf_PatternBrush (void)
 
static void test_mf_DCBrush (void)
 
static void test_mf_ExtTextOut_on_path (void)
 
static void test_emf_ExtTextOut_on_path (void)
 
static void translate (POINT *pt, UINT count, const XFORM *xform)
 
static BOOL is_equal_rect (const RECT *rc1, const RECT *rc2)
 
static int CALLBACK clip_emf_enum_proc (HDC hdc, HANDLETABLE *handle_table, const ENHMETARECORD *emr, int n_objs, LPARAM param)
 
static void test_emf_clipping (void)
 
static int CALLBACK clip_mf_enum_proc (HDC hdc, HANDLETABLE *handle_table, METARECORD *mr, int n_objs, LPARAM param)
 
static void test_mf_clipping (void)
 
static void test_mf_GetPath (void)
 
static INT CALLBACK EmfEnumProc (HDC hdc, HANDLETABLE *lpHTable, const ENHMETARECORD *lpEMFR, INT nObj, LPARAM lpData)
 
static HENHMETAFILE create_converted_emf (const METAFILEPICT *mfp)
 
static void test_mf_conversions (void)
 
static BOOL getConvertedFrameAndBounds (UINT buffer_size, BYTE *buffer, BOOL mfpIsNull, LONG mm, LONG xExt, LONG yExt, RECTL *rclBounds, RECTL *rclFrame)
 
static void checkConvertedFrameAndBounds (UINT buffer_size, BYTE *buffer, BOOL mfpIsNull, LONG mm, LONG xExt, LONG yExt, RECTL *rclBoundsExpected, RECTL *rclFrameExpected)
 
static void test_SetWinMetaFileBits (void)
 
static BOOL near_match (int x, int y)
 
static void getwinmetafilebits (UINT mode, int scale, RECT *rc)
 
static void test_GetWinMetaFileBits (void)
 
static BOOL (WINAPI *pGdiIsMetaPrintDC)(HDC)
 
static void test_gdiis (void)
 
static void test_SetEnhMetaFileBits (void)
 
static void test_emf_polybezier (void)
 
static void test_emf_paths (void)
 
static void test_emf_PolyPolyline (void)
 
static void test_emf_GradientFill (void)
 
static void set_rotation_xform (XFORM *out, float rad, int dx, int dy)
 
static BOOL xform_eq (const XFORM *a, const XFORM *b)
 
static INT CALLBACK enum_emf_WorldTransform (HDC hdc, HANDLETABLE *ht, const ENHMETARECORD *emr, INT nobj, LPARAM param)
 
static void test_emf_WorldTransform (void)
 
 START_TEST (metafile)
 

Variables

static LOGFONTA orig_lf
 
static BOOL emr_processed = FALSE
 
static DWORD
 
static INT
 
static COLORREF
 
static const unsigned char SAMPLE_PATTERN_BRUSH []
 
static const unsigned char MF_BLANK_BITS []
 
static const unsigned char MF_GRAPHICS_BITS []
 
static const unsigned char MF_PATTERN_BRUSH_BITS []
 
static const unsigned char MF_DCBRUSH_BITS []
 
static const unsigned char MF_TEXTOUT_ON_PATH_BITS []
 
static const unsigned char EMF_TEXTOUT_ON_PATH_BITS []
 
static const unsigned char EMF_TEXTOUT_OUTLINE_ON_PATH_BITS []
 
static const unsigned char MF_LINETO_BITS []
 
static const unsigned char EMF_LINETO_BITS []
 
static const unsigned char EMF_LINETO_MM_ANISOTROPIC_BITS []
 
static const unsigned char EMF_LINETO_MM_TEXT_BITS []
 
static const unsigned char EMF_BITBLT []
 
static const unsigned char EMF_DCBRUSH_BITS []
 
static const unsigned char EMF_BEZIER_BITS []
 
static const unsigned char EMF_POLYPOLYLINE_BITS []
 
static const unsigned char EMF_GRADIENTFILL_BITS []
 
static const unsigned char EMF_CLIPPING []
 
static const unsigned char MF_CLIP_BITS []
 
static int clip_mf_enum_proc_seen_selectclipregion
 
static int clip_mf_enum_proc_seen_selectobject
 
static const unsigned char MF_PATH_BITS []
 
static const unsigned char EMF_PATH_BITS []
 
static const unsigned char EMF_EMPTY_PATH_BITS []
 

Macro Definition Documentation

◆ BMP_DIM

#define BMP_DIM   4

◆ GDI_GET_PROC

#define GDI_GET_PROC (   func)
Value:
p ## func = (void *)GetProcAddress(hGDI, #func); \
if(!p ## func) \
trace("GetProcAddress(hGDI, \"%s\") failed\n", #func); \
#define GetProcAddress(x, y)
Definition: compat.h:753
GLenum func
Definition: glext.h:6028
GLfloat GLfloat p
Definition: glext.h:8902

Definition at line 47 of file metafile.c.

◆ LINE_X

#define LINE_X   55.0f

Definition at line 39 of file metafile.c.

◆ LINE_Y

#define LINE_Y   15.0f

Definition at line 40 of file metafile.c.

◆ M_PI

#define M_PI   3.14159265358979323846

Definition at line 32 of file metafile.c.

◆ MF_BUFSIZE

#define MF_BUFSIZE   1024

Definition at line 1017 of file metafile.c.

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pGdiIsMetaPrintDC)
static

◆ check_dc_state()

static void check_dc_state ( HDC  hdc,
int  restore_no,
int  wnd_org_x,
int  wnd_org_y,
int  wnd_ext_x,
int  wnd_ext_y,
int  vp_org_x,
int  vp_org_y,
int  vp_ext_x,
int  vp_ext_y 
)
static

Definition at line 438 of file metafile.c.

441{
442 BOOL ret;
443 XFORM xform;
444 POINT vp_org, win_org;
445 SIZE vp_size, win_size;
446 FLOAT xscale, yscale, edx, edy;
447
448 SetLastError(0xdeadbeef);
449 ret = GetWorldTransform(hdc, &xform);
450 if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) goto win9x_here;
451 ok(ret, "GetWorldTransform error %u\n", GetLastError());
452
453 trace("%d: eM11 %f, eM22 %f, eDx %f, eDy %f\n", restore_no, xform.eM11, xform.eM22, xform.eDx, xform.eDy);
454
455 ok(xform.eM12 == 0.0, "%d: expected eM12 0.0, got %f\n", restore_no, xform.eM12);
456 ok(xform.eM21 == 0.0, "%d: expected eM21 0.0, got %f\n", restore_no, xform.eM21);
457
458 xscale = (FLOAT)vp_ext_x / (FLOAT)wnd_ext_x;
459 trace("x scale %f\n", xscale);
460 ok(fabs(xscale - xform.eM11) < 0.01, "%d: vp_ext_x %d, wnd_ext_cx %d, eM11 %f\n",
461 restore_no, vp_ext_x, wnd_ext_x, xform.eM11);
462
463 yscale = (FLOAT)vp_ext_y / (FLOAT)wnd_ext_y;
464 trace("y scale %f\n", yscale);
465 ok(fabs(yscale - xform.eM22) < 0.01, "%d: vp_ext_y %d, wnd_ext_y %d, eM22 %f\n",
466 restore_no, vp_ext_y, wnd_ext_y, xform.eM22);
467
468 edx = (FLOAT)vp_org_x - xform.eM11 * (FLOAT)wnd_org_x;
469 ok(fabs(edx - xform.eDx) < 0.01, "%d: edx %f != eDx %f\n", restore_no, edx, xform.eDx);
470 edy = (FLOAT)vp_org_y - xform.eM22 * (FLOAT)wnd_org_y;
471 ok(fabs(edy - xform.eDy) < 0.01, "%d: edy %f != eDy %f\n", restore_no, edy, xform.eDy);
472
473 return;
474
475win9x_here:
476
477 GetWindowOrgEx(hdc, &win_org);
478 GetViewportOrgEx(hdc, &vp_org);
479 GetWindowExtEx(hdc, &win_size);
480 GetViewportExtEx(hdc, &vp_size);
481
482 ok(wnd_org_x == win_org.x, "%d: wnd_org_x: %d != %d\n", restore_no, wnd_org_x, win_org.x);
483 ok(wnd_org_y == win_org.y, "%d: wnd_org_y: %d != %d\n", restore_no, wnd_org_y, win_org.y);
484
485 ok(vp_org_x == vp_org.x, "%d: vport_org_x: %d != %d\n", restore_no, vp_org_x, vp_org.x);
486 ok(vp_org_y == vp_org.y, "%d: vport_org_y: %d != %d\n", restore_no, vp_org_y, vp_org.y);
487
488 ok(wnd_ext_x == win_size.cx, "%d: wnd_ext_x: %d != %d\n", restore_no, wnd_ext_x, win_size.cx);
489 ok(wnd_ext_y == win_size.cy, "%d: wnd_ext_y: %d != %d\n", restore_no, wnd_ext_y, win_size.cy);
490
491 ok(vp_ext_x == vp_size.cx, "%d: vport_ext_x: %d != %d\n", restore_no, vp_ext_x, vp_size.cx);
492 ok(vp_ext_y == vp_size.cy, "%d: vport_ext_y: %d != %d\n", restore_no, vp_ext_y, vp_size.cy);
493}
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define SetLastError(x)
Definition: compat.h:752
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FLOAT
Definition: i386-dis.c:525
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
Definition: fabs.c:17
HDC hdc
Definition: main.c:9
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
FLOAT eDy
Definition: wingdi.h:1726
FLOAT eM11
Definition: wingdi.h:1721
FLOAT eM21
Definition: wingdi.h:1723
FLOAT eM22
Definition: wingdi.h:1724
FLOAT eM12
Definition: wingdi.h:1722
FLOAT eDx
Definition: wingdi.h:1725
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
ecx edi movl ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl edx
Definition: synth_sse3d.h:87
float FLOAT
Definition: typedefs.h:69
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
BOOL WINAPI GetWindowOrgEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:439
BOOL WINAPI GetWorldTransform(_In_ HDC, _Out_ LPXFORM)
Definition: coord.c:278
BOOL WINAPI GetWindowExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:411
BOOL WINAPI GetViewportExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:351
BOOL WINAPI GetViewportOrgEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:383

Referenced by savedc_emf_enum_proc().

◆ checkConvertedFrameAndBounds()

static void checkConvertedFrameAndBounds ( UINT  buffer_size,
BYTE buffer,
BOOL  mfpIsNull,
LONG  mm,
LONG  xExt,
LONG  yExt,
RECTL rclBoundsExpected,
RECTL rclFrameExpected 
)
static

Definition at line 3176 of file metafile.c.

3179{
3180 RECTL rclBounds, rclFrame;
3181
3182 if (getConvertedFrameAndBounds(buffer_size, buffer, mfpIsNull, mm, xExt, yExt, &rclBounds, &rclFrame))
3183 {
3184 const char * msg;
3185 char buf[64];
3186
3187 if (mfpIsNull)
3188 {
3189 msg = "mfp == NULL";
3190 }
3191 else
3192 {
3193 const char * mm_str;
3194 switch (mm)
3195 {
3196 case MM_ANISOTROPIC: mm_str = "MM_ANISOTROPIC"; break;
3197 case MM_ISOTROPIC: mm_str = "MM_ISOTROPIC"; break;
3198 default: mm_str = "Unexpected";
3199 }
3200 sprintf(buf, "mm=%s, xExt=%d, yExt=%d", mm_str, xExt, yExt);
3201 msg = buf;
3202 }
3203
3204 ok(rclBounds.left == rclBoundsExpected->left, "rclBounds.left: Expected %d, got %d (%s)\n", rclBoundsExpected->left, rclBounds.left, msg);
3205 ok(rclBounds.top == rclBoundsExpected->top, "rclBounds.top: Expected %d, got %d (%s)\n", rclBoundsExpected->top, rclBounds.top, msg);
3206 ok(rclBounds.right == rclBoundsExpected->right, "rclBounds.right: Expected %d, got %d (%s)\n", rclBoundsExpected->right, rclBounds.right, msg);
3207 ok(rclBounds.bottom == rclBoundsExpected->bottom, "rclBounds.bottom: Expected %d, got %d (%s)\n", rclBoundsExpected->bottom, rclBounds.bottom, msg);
3208 ok(rclFrame.left == rclFrameExpected->left, "rclFrame.left: Expected %d, got %d (%s)\n", rclFrameExpected->left, rclFrame.left, msg);
3209 ok(rclFrame.top == rclFrameExpected->top, "rclFrame.top: Expected %d, got %d (%s)\n", rclFrameExpected->top, rclFrame.top, msg);
3210 ok(rclFrame.right == rclFrameExpected->right, "rclFrame.right: Expected %d, got %d (%s)\n", rclFrameExpected->right, rclFrame.right, msg);
3211 ok(rclFrame.bottom == rclFrameExpected->bottom, "rclFrame.bottom: Expected %d, got %d (%s)\n", rclFrameExpected->bottom, rclFrame.bottom, msg);
3212 }
3213}
#define msg(x)
Definition: auth_time.c:54
GLuint buffer
Definition: glext.h:5915
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static BOOL getConvertedFrameAndBounds(UINT buffer_size, BYTE *buffer, BOOL mfpIsNull, LONG mm, LONG xExt, LONG yExt, RECTL *rclBounds, RECTL *rclFrame)
Definition: metafile.c:3145
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:888
#define MM_ANISOTROPIC
Definition: wingdi.h:867
#define MM_ISOTROPIC
Definition: wingdi.h:870

Referenced by test_SetWinMetaFileBits().

◆ clip_emf_enum_proc()

static int CALLBACK clip_emf_enum_proc ( HDC  hdc,
HANDLETABLE handle_table,
const ENHMETARECORD emr,
int  n_objs,
LPARAM  param 
)
static

Definition at line 2607 of file metafile.c.

2609{
2610 if (emr->iType == EMR_EXTSELECTCLIPRGN)
2611 {
2612 const EMREXTSELECTCLIPRGN *clip = (const EMREXTSELECTCLIPRGN *)emr;
2613 union _rgn
2614 {
2615 RGNDATA data;
2616 char buf[sizeof(RGNDATAHEADER) + sizeof(RECT)];
2617 };
2618 const union _rgn *rgn1;
2619 union _rgn rgn2;
2620 RECT rect, rc_transformed;
2621 const RECT *rc = (const RECT *)param;
2622 HRGN hrgn;
2623 XFORM xform;
2624 INT ret;
2625 BOOL is_win9x;
2626
2627 trace("EMR_EXTSELECTCLIPRGN: cbRgnData %#x, iMode %u\n",
2628 clip->cbRgnData, clip->iMode);
2629
2630 ok(clip->iMode == RGN_COPY, "expected RGN_COPY, got %u\n", clip->iMode);
2631 ok(clip->cbRgnData >= sizeof(RGNDATAHEADER) + sizeof(RECT),
2632 "too small data block: %u bytes\n", clip->cbRgnData);
2633 if (clip->cbRgnData < sizeof(RGNDATAHEADER) + sizeof(RECT))
2634 return 0;
2635
2636 rgn1 = (const union _rgn *)clip->RgnData;
2637
2638 trace("size %u, type %u, count %u, rgn size %u, bound %s\n",
2639 rgn1->data.rdh.dwSize, rgn1->data.rdh.iType,
2640 rgn1->data.rdh.nCount, rgn1->data.rdh.nRgnSize,
2641 wine_dbgstr_rect(&rgn1->data.rdh.rcBound));
2642
2643 ok(EqualRect(&rgn1->data.rdh.rcBound, rc), "rects don't match\n");
2644
2645 rect = *(const RECT *)rgn1->data.Buffer;
2646 trace("rect %s\n", wine_dbgstr_rect(&rect));
2647 ok(EqualRect(&rect, rc), "rects don't match\n");
2648
2649 ok(rgn1->data.rdh.dwSize == sizeof(rgn1->data.rdh), "expected sizeof(rdh), got %u\n", rgn1->data.rdh.dwSize);
2650 ok(rgn1->data.rdh.iType == RDH_RECTANGLES, "expected RDH_RECTANGLES, got %u\n", rgn1->data.rdh.iType);
2651 ok(rgn1->data.rdh.nCount == 1, "expected 1, got %u\n", rgn1->data.rdh.nCount);
2652 ok(rgn1->data.rdh.nRgnSize == sizeof(RECT) ||
2653 broken(rgn1->data.rdh.nRgnSize == 168), /* NT4 */
2654 "expected sizeof(RECT), got %u\n", rgn1->data.rdh.nRgnSize);
2655
2656 hrgn = CreateRectRgn(0, 0, 0, 0);
2657
2658 memset(&xform, 0, sizeof(xform));
2659 SetLastError(0xdeadbeef);
2660 ret = GetWorldTransform(hdc, &xform);
2662 if (!is_win9x)
2663 ok(ret, "GetWorldTransform error %u\n", GetLastError());
2664
2665 trace("xform.eM11 %f, xform.eM22 %f\n", xform.eM11, xform.eM22);
2666
2667 ret = GetClipRgn(hdc, hrgn);
2668 ok(ret == 0, "GetClipRgn returned %d, expected 0\n", ret);
2669
2670 PlayEnhMetaFileRecord(hdc, handle_table, emr, n_objs);
2671
2672 ret = GetClipRgn(hdc, hrgn);
2673 ok(ret == 1, "GetClipRgn returned %d, expected 1\n", ret);
2674
2675 /* Win9x returns empty clipping region */
2676 if (is_win9x) return 1;
2677
2678 ret = GetRegionData(hrgn, 0, NULL);
2679 ok(ret == sizeof(rgn2.data.rdh) + sizeof(RECT), "expected sizeof(rgn), got %u\n", ret);
2680
2681 ret = GetRegionData(hrgn, sizeof(rgn2), &rgn2.data);
2682 ok(ret == sizeof(rgn2), "expected sizeof(rgn2), got %u\n", ret);
2683
2684 trace("size %u, type %u, count %u, rgn size %u, bound %s\n", rgn2.data.rdh.dwSize,
2685 rgn2.data.rdh.iType, rgn2.data.rdh.nCount, rgn2.data.rdh.nRgnSize,
2686 wine_dbgstr_rect(&rgn2.data.rdh.rcBound));
2687
2688 rect = rgn2.data.rdh.rcBound;
2689 rc_transformed = *rc;
2690 translate((POINT *)&rc_transformed, 2, &xform);
2691 trace("transformed %s\n", wine_dbgstr_rect(&rc_transformed));
2692 ok(is_equal_rect(&rect, &rc_transformed), "rects don't match\n");
2693
2694 rect = *(const RECT *)rgn2.data.Buffer;
2695 trace("rect %s\n", wine_dbgstr_rect(&rect));
2696 rc_transformed = *rc;
2697 translate((POINT *)&rc_transformed, 2, &xform);
2698 trace("transformed %s\n", wine_dbgstr_rect(&rc_transformed));
2699 ok(is_equal_rect(&rect, &rc_transformed), "rects don't match\n");
2700
2701 ok(rgn2.data.rdh.dwSize == sizeof(rgn1->data.rdh), "expected sizeof(rdh), got %u\n", rgn2.data.rdh.dwSize);
2702 ok(rgn2.data.rdh.iType == RDH_RECTANGLES, "expected RDH_RECTANGLES, got %u\n", rgn2.data.rdh.iType);
2703 ok(rgn2.data.rdh.nCount == 1, "expected 1, got %u\n", rgn2.data.rdh.nCount);
2704 ok(rgn2.data.rdh.nRgnSize == sizeof(RECT) ||
2705 broken(rgn2.data.rdh.nRgnSize == 168), /* NT4 */
2706 "expected sizeof(RECT), got %u\n", rgn2.data.rdh.nRgnSize);
2707
2709 }
2710 return 1;
2711}
static HRGN hrgn
#define broken(x)
Definition: _sntprintf.h:21
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
struct _RGNDATAHEADER RGNDATAHEADER
#define NULL
Definition: types.h:112
pKey DeleteObject()
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLfloat param
Definition: glext.h:5796
static void translate(POINT *pt, UINT count, const XFORM *xform)
Definition: metafile.c:2586
static BOOL is_equal_rect(const RECT *rc1, const RECT *rc2)
Definition: metafile.c:2599
static BOOL is_win9x
Definition: diskspace.c:33
#define memset(x, y, z)
Definition: compat.h:39
& rect
Definition: startmenu.cpp:1413
int32_t INT
Definition: typedefs.h:58
#define EMR_EXTSELECTCLIPRGN
Definition: wingdi.h:148
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI PlayEnhMetaFileRecord(_In_ HDC hdc, _In_reads_(cht) LPHANDLETABLE pht, _In_ CONST ENHMETARECORD *pmr, _In_ UINT cht)
#define RDH_RECTANGLES
Definition: wingdi.h:669
int WINAPI GetClipRgn(_In_ HDC, _In_ HRGN)
#define RGN_COPY
Definition: wingdi.h:357
DWORD WINAPI GetRegionData(_In_ HRGN hrgn, _In_ DWORD nCount, _Out_writes_bytes_to_opt_(nCount, return) LPRGNDATA lpRgnData)
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)

Referenced by test_emf_clipping().

◆ clip_mf_enum_proc()

static int CALLBACK clip_mf_enum_proc ( HDC  hdc,
HANDLETABLE handle_table,
METARECORD mr,
int  n_objs,
LPARAM  param 
)
static

Definition at line 2875 of file metafile.c.

2877{
2878 switch (mr->rdFunction) {
2881 break;
2882 case META_SELECTOBJECT:
2884 break;
2885 }
2886 return 1;
2887}
static int clip_mf_enum_proc_seen_selectclipregion
Definition: metafile.c:2872
static int clip_mf_enum_proc_seen_selectobject
Definition: metafile.c:2873
WORD rdFunction
Definition: wingdi.h:2346
#define META_SELECTCLIPREGION
Definition: wingdi.h:254
#define META_SELECTOBJECT
Definition: wingdi.h:255

Referenced by test_mf_clipping().

◆ COLORREF()

static COLORREF ( WINAPI pSetDCBrushColor)
static

◆ compare_emf_bits()

static int compare_emf_bits ( const HENHMETAFILE  mf,
const unsigned char bits,
UINT  bsize,
const char desc,
BOOL  ignore_scaling 
)
static

Definition at line 1862 of file metafile.c.

1865{
1866 unsigned char buf[MF_BUFSIZE];
1867 UINT mfsize, offset1, offset2, diff_nt4, diff_9x;
1868 const ENHMETAHEADER *emh1, *emh2;
1869
1870 mfsize = GetEnhMetaFileBits(mf, MF_BUFSIZE, buf);
1871 ok (mfsize > 0, "%s: GetEnhMetaFileBits error %d\n", desc, GetLastError());
1872
1873 /* ENHMETAHEADER size could differ, depending on platform */
1874 diff_nt4 = sizeof(SIZEL);
1875 diff_9x = sizeof(SIZEL) + 3 * sizeof(DWORD);
1876
1877 if (mfsize < MF_BUFSIZE)
1878 {
1879 ok(mfsize == bsize ||
1880 broken(mfsize == bsize - diff_nt4) || /* NT4 */
1881 broken(mfsize == bsize - diff_9x), /* Win9x/WinME */
1882 "%s: mfsize=%d, bsize=%d\n", desc, mfsize, bsize);
1883 }
1884 else
1885 ok(bsize >= MF_BUFSIZE, "%s: mfsize > bufsize (%d bytes), bsize=%d\n",
1886 desc, mfsize, bsize);
1887
1888 /* basic things must match */
1889 emh1 = (const ENHMETAHEADER *)bits;
1890 emh2 = (const ENHMETAHEADER *)buf;
1891 ok(emh1->iType == EMR_HEADER, "expected EMR_HEADER, got %u\n", emh1->iType);
1892 ok(emh1->nSize == sizeof(ENHMETAHEADER), "expected sizeof(ENHMETAHEADER), got %u\n", emh1->nSize);
1893 ok(emh2->nBytes == mfsize, "expected emh->nBytes %u, got %u\n", mfsize, emh2->nBytes);
1894 ok(emh1->dSignature == ENHMETA_SIGNATURE, "expected ENHMETA_SIGNATURE, got %u\n", emh1->dSignature);
1895
1896 ok(emh1->iType == emh2->iType, "expected EMR_HEADER, got %u\n", emh2->iType);
1897 ok(emh1->nSize == emh2->nSize ||
1898 broken(emh1->nSize - diff_nt4 == emh2->nSize) ||
1899 broken(emh1->nSize - diff_9x == emh2->nSize),
1900 "expected nSize %u, got %u\n", emh1->nSize, emh2->nSize);
1901 ok(emh1->rclBounds.left == emh2->rclBounds.left, "%s: expected rclBounds.left = %d, got %d\n",
1902 desc, emh1->rclBounds.left, emh2->rclBounds.left);
1903 ok(emh1->rclBounds.top == emh2->rclBounds.top, "%s: expected rclBounds.top = %d, got %d\n",
1904 desc, emh1->rclBounds.top, emh2->rclBounds.top);
1905 ok(emh1->rclBounds.right == emh2->rclBounds.right, "%s: expected rclBounds.right = %d, got %d\n",
1906 desc, emh1->rclBounds.right, emh2->rclBounds.right);
1907 ok(emh1->rclBounds.bottom == emh2->rclBounds.bottom, "%s: expected rclBounds.bottom = %d, got %d\n",
1908 desc, emh1->rclBounds.bottom, emh2->rclBounds.bottom);
1909 ok(emh1->dSignature == emh2->dSignature, "expected dSignature %u, got %u\n", emh1->dSignature, emh2->dSignature);
1910 ok(emh1->nBytes == emh2->nBytes ||
1911 broken(emh1->nBytes - diff_nt4 == emh2->nBytes) ||
1912 broken(emh1->nBytes - diff_9x == emh2->nBytes),
1913 "expected nBytes %u, got %u\n", emh1->nBytes, emh2->nBytes);
1914 ok(emh1->nRecords == emh2->nRecords, "expected nRecords %u, got %u\n", emh1->nRecords, emh2->nRecords);
1915
1916 offset1 = emh1->nSize;
1917 offset2 = emh2->nSize; /* Needed for Win9x/WinME/NT4 */
1918 while (offset1 < emh1->nBytes)
1919 {
1920 const ENHMETARECORD *emr1 = (const ENHMETARECORD *)(bits + offset1);
1921 const ENHMETARECORD *emr2 = (const ENHMETARECORD *)(buf + offset2);
1922
1923 trace("%s: EMF record %u, size %u/record %u, size %u\n",
1924 desc, emr1->iType, emr1->nSize, emr2->iType, emr2->nSize);
1925
1926 if (!match_emf_record(emr1, emr2, desc, ignore_scaling)) return -1;
1927
1928 /* We have already bailed out if iType or nSize don't match */
1929 offset1 += emr1->nSize;
1930 offset2 += emr2->nSize;
1931 }
1932 return 0;
1933}
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
static const WCHAR desc[]
Definition: protectdata.c:36
#define MF_BUFSIZE
Definition: metafile.c:1017
static BOOL match_emf_record(const ENHMETARECORD *emr1, const ENHMETARECORD *emr2, const char *desc, BOOL ignore_scaling)
Definition: metafile.c:1754
unsigned int UINT
Definition: ndis.h:50
DWORD nRecords
Definition: wingdi.h:2327
DWORD dSignature
Definition: wingdi.h:2324
RECTL rclBounds
Definition: wingdi.h:2322
SIZE SIZEL
Definition: windef.h:338
UINT WINAPI GetEnhMetaFileBits(_In_ HENHMETAFILE hEMF, _In_ UINT nSize, _Out_writes_bytes_opt_(nSize) LPBYTE lpData)
#define ENHMETA_SIGNATURE
Definition: wingdi.h:204
#define EMR_HEADER
Definition: wingdi.h:75

Referenced by test_emf_BitBlt(), test_emf_clipping(), test_emf_DCBrush(), test_emf_ExtTextOut_on_path(), test_emf_GradientFill(), test_emf_paths(), test_emf_polybezier(), test_emf_PolyPolyline(), and test_mf_conversions().

◆ compare_mf_bits()

static int compare_mf_bits ( const HMETAFILE  mf,
const unsigned char bits,
UINT  bsize,
const char desc 
)
static

Definition at line 1599 of file metafile.c.

1601{
1602 unsigned char buf[MF_BUFSIZE];
1603 UINT mfsize, i;
1604 int diff;
1605
1606 mfsize = GetMetaFileBitsEx (mf, MF_BUFSIZE, buf);
1607 ok (mfsize > 0, "%s: GetMetaFileBitsEx failed.\n", desc);
1608 if (mfsize < MF_BUFSIZE)
1609 ok (mfsize == bsize, "%s: mfsize=%d, bsize=%d.\n",
1610 desc, mfsize, bsize);
1611 else
1612 ok (bsize >= MF_BUFSIZE, "%s: mfsize > bufsize (%d bytes), bsize=%d.\n",
1613 desc, mfsize, bsize);
1614 if (mfsize != bsize)
1615 return -1;
1616
1617 diff = 0;
1618 for (i=0; i<bsize; i++)
1619 {
1620 if (buf[i] != bits[i])
1621 diff++;
1622 }
1623 ok (diff == 0, "%s: mfsize=%d, bsize=%d, diff=%d\n",
1624 desc, mfsize, bsize, diff);
1625
1626 return diff;
1627}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
UINT WINAPI GetMetaFileBitsEx(_In_ HMETAFILE hMF, _In_ UINT cbBuffer, _Out_writes_bytes_opt_(cbBuffer) LPVOID lpData)

Referenced by create_converted_emf(), test_CopyMetaFile(), test_mf_Blank(), test_mf_clipping(), test_mf_DCBrush(), test_mf_ExtTextOut_on_path(), test_mf_GetPath(), test_mf_Graphics(), test_mf_PatternBrush(), and test_SetMetaFileBits().

◆ compare_mf_disk_bits()

static int compare_mf_disk_bits ( LPCSTR  name,
const BYTE bits,
UINT  bsize,
const char desc 
)
static

Definition at line 1629 of file metafile.c.

1630{
1631 unsigned char buf[MF_BUFSIZE];
1632 DWORD mfsize, rd_size, i;
1633 int diff;
1634 HANDLE hfile;
1635 BOOL ret;
1636
1638 assert(hfile != INVALID_HANDLE_VALUE);
1639
1640 mfsize = GetFileSize(hfile, NULL);
1641 assert(mfsize <= MF_BUFSIZE);
1642
1643 ret = ReadFile(hfile, buf, sizeof(buf), &rd_size, NULL);
1644 ok( ret && rd_size == mfsize, "ReadFile: error %d\n", GetLastError());
1645
1646 CloseHandle(hfile);
1647
1648 ok(mfsize == bsize, "%s: mfsize=%d, bsize=%d.\n", desc, mfsize, bsize);
1649
1650 if (mfsize != bsize)
1651 return -1;
1652
1653 diff = 0;
1654 for (i=0; i<bsize; i++)
1655 {
1656 if (buf[i] != bits[i])
1657 diff++;
1658 }
1659 ok(diff == 0, "%s: mfsize=%d, bsize=%d, diff=%d\n",
1660 desc, mfsize, bsize, diff);
1661
1662 return diff;
1663}
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define GENERIC_READ
Definition: compat.h:135
#define FILE_SHARE_READ
Definition: compat.h:136
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
#define assert(x)
Definition: debug.h:53
Definition: name.c:39

Referenced by test_CopyMetaFile().

◆ create_converted_emf()

static HENHMETAFILE create_converted_emf ( const METAFILEPICT mfp)
static

Definition at line 3040 of file metafile.c.

3041{
3042 HDC hdcMf;
3043 HMETAFILE hmf;
3044 HENHMETAFILE hemf;
3045 BOOL ret;
3046 UINT size;
3047 LPBYTE pBits;
3048
3049 hdcMf = CreateMetaFileA(NULL);
3050 ok(hdcMf != NULL, "CreateMetaFile failed with error %d\n", GetLastError());
3051 ret = LineTo(hdcMf, (INT)LINE_X, (INT)LINE_Y);
3052 ok(ret, "LineTo failed with error %d\n", GetLastError());
3053 hmf = CloseMetaFile(hdcMf);
3054 ok(hmf != NULL, "CloseMetaFile failed with error %d\n", GetLastError());
3055
3056 if (compare_mf_bits (hmf, MF_LINETO_BITS, sizeof(MF_LINETO_BITS), "mf_LineTo") != 0)
3057 {
3058 dump_mf_bits(hmf, "mf_LineTo");
3059 EnumMetaFile(0, hmf, mf_enum_proc, 0);
3060 }
3061
3062 size = GetMetaFileBitsEx(hmf, 0, NULL);
3063 ok(size, "GetMetaFileBitsEx failed with error %d\n", GetLastError());
3064 pBits = HeapAlloc(GetProcessHeap(), 0, size);
3065 GetMetaFileBitsEx(hmf, size, pBits);
3066 DeleteMetaFile(hmf);
3067 hemf = SetWinMetaFileBits(size, pBits, NULL, mfp);
3068 HeapFree(GetProcessHeap(), 0, pBits);
3069 return hemf;
3070}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
GLsizeiptr size
Definition: glext.h:5919
static HDC
Definition: imagelist.c:92
static const unsigned char MF_LINETO_BITS[]
Definition: metafile.c:1167
static void dump_mf_bits(const HMETAFILE mf, const char *desc)
Definition: metafile.c:1568
#define LINE_Y
Definition: metafile.c:40
static INT CALLBACK mf_enum_proc(HDC hdc, HANDLETABLE *ht, METARECORD *mr, INT nobj, LPARAM param)
Definition: metafile.c:1556
static int compare_mf_bits(const HMETAFILE mf, const unsigned char *bits, UINT bsize, const char *desc)
Definition: metafile.c:1599
#define LINE_X
Definition: metafile.c:39
unsigned char * LPBYTE
Definition: typedefs.h:53
BOOL WINAPI DeleteMetaFile(_In_ HMETAFILE)
HDC WINAPI CreateMetaFileA(_In_opt_ LPCSTR)
HMETAFILE WINAPI CloseMetaFile(_In_ HDC hdc)
BOOL WINAPI EnumMetaFile(_In_ HDC, _In_ HMETAFILE, _In_ MFENUMPROC, _In_opt_ LPARAM)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
HENHMETAFILE WINAPI SetWinMetaFileBits(_In_ UINT nSize, _In_reads_bytes_(nSize) const BYTE *lpMeta16Data, _In_opt_ HDC hdcRef, _In_opt_ const METAFILEPICT *lpMFP)

Referenced by test_mf_conversions().

◆ dump_emf_bits()

static void dump_emf_bits ( const HENHMETAFILE  mf,
const char desc 
)
static

Definition at line 1668 of file metafile.c.

1669{
1671 UINT mfsize, i;
1672
1673 if (!winetest_debug) return;
1674
1675 mfsize = GetEnhMetaFileBits(mf, MF_BUFSIZE, buf);
1676 ok (mfsize > 0, "%s: GetEnhMetaFileBits failed\n", desc);
1677
1678 printf("EMF %s has bits:\n{\n ", desc);
1679 for (i = 0; i < mfsize; i++)
1680 {
1681 printf ("0x%02x", buf[i]);
1682 if (i == mfsize-1)
1683 printf ("\n");
1684 else if (i % 8 == 7)
1685 printf (",\n ");
1686 else
1687 printf (", ");
1688 }
1689 printf ("};\n");
1690}
#define printf
Definition: freeldr.h:97
int winetest_debug
unsigned char BYTE
Definition: xxhash.c:193

Referenced by test_emf_BitBlt(), test_emf_clipping(), test_emf_DCBrush(), test_emf_ExtTextOut_on_path(), test_emf_GradientFill(), test_emf_paths(), test_emf_polybezier(), test_emf_PolyPolyline(), and test_mf_conversions().

◆ dump_emf_record()

static void dump_emf_record ( const ENHMETARECORD emr,
const char desc 
)
static

Definition at line 1716 of file metafile.c.

1717{
1718 const BYTE *buf;
1719 DWORD i;
1720
1721 if (!winetest_debug) return;
1722
1723 printf ("%s: EMF record %u has bits:\n{\n", desc, emr->iType);
1724 buf = (const BYTE *)emr;
1725 for (i = 0; i < emr->nSize; i++)
1726 {
1727 printf ("0x%02x", buf[i]);
1728 if (i == emr->nSize - 1)
1729 printf ("\n");
1730 else if (i % 8 == 7)
1731 printf (",\n");
1732 else
1733 printf (", ");
1734 }
1735 printf ("};\n");
1736}

Referenced by match_emf_record().

◆ dump_emf_records()

static void dump_emf_records ( const HENHMETAFILE  mf,
const char desc 
)
static

Definition at line 1692 of file metafile.c.

1693{
1694 BYTE *emf;
1696 UINT mfsize, offset;
1697
1698 if (!winetest_debug) return;
1699
1700 mfsize = GetEnhMetaFileBits(mf, MF_BUFSIZE, buf);
1701 ok (mfsize > 0, "%s: GetEnhMetaFileBits error %d\n", desc, GetLastError());
1702
1703 printf("EMF %s has records:\n", desc);
1704
1705 emf = buf;
1706 offset = 0;
1707 while(offset < mfsize)
1708 {
1709 EMR *emr = (EMR *)(emf + offset);
1710 printf("emr->iType %d, emr->nSize %u\n", emr->iType, emr->nSize);
1711 /*trace("emr->iType 0x%04lx, emr->nSize 0x%04lx\n", emr->iType, emr->nSize);*/
1712 offset += emr->nSize;
1713 }
1714}
GLintptr offset
Definition: glext.h:5920
Definition: emfdc.c:45
DWORD iType
Definition: wingdi.h:1690
DWORD nSize
Definition: wingdi.h:1691

Referenced by test_emf_BitBlt(), test_emf_clipping(), test_emf_DCBrush(), test_emf_ExtTextOut_on_path(), test_emf_GradientFill(), test_emf_paths(), test_emf_polybezier(), test_emf_PolyPolyline(), and test_mf_conversions().

◆ dump_EMREXTTEXTOUT()

static void dump_EMREXTTEXTOUT ( const EMREXTTEXTOUTW eto)
static

Definition at line 1738 of file metafile.c.

1739{
1740 trace("rclBounds %d,%d - %d,%d\n", eto->rclBounds.left, eto->rclBounds.top,
1741 eto->rclBounds.right, eto->rclBounds.bottom);
1742 trace("iGraphicsMode %u\n", eto->iGraphicsMode);
1743 trace("exScale: %f\n", eto->exScale);
1744 trace("eyScale: %f\n", eto->eyScale);
1745 trace("emrtext.ptlReference %d,%d\n", eto->emrtext.ptlReference.x, eto->emrtext.ptlReference.y);
1746 trace("emrtext.nChars %u\n", eto->emrtext.nChars);
1747 trace("emrtext.offString %#x\n", eto->emrtext.offString);
1748 trace("emrtext.fOptions %#x\n", eto->emrtext.fOptions);
1749 trace("emrtext.rcl %d,%d - %d,%d\n", eto->emrtext.rcl.left, eto->emrtext.rcl.top,
1750 eto->emrtext.rcl.right, eto->emrtext.rcl.bottom);
1751 trace("emrtext.offDx %#x\n", eto->emrtext.offDx);
1752}
LONG y
Definition: windef.h:330
LONG x
Definition: windef.h:329
DWORD iGraphicsMode
Definition: wingdi.h:1982
EMRTEXT emrtext
Definition: wingdi.h:1985
DWORD fOptions
Definition: wingdi.h:1975
DWORD offDx
Definition: wingdi.h:1977
DWORD nChars
Definition: wingdi.h:1973
RECTL rcl
Definition: wingdi.h:1976
POINTL ptlReference
Definition: wingdi.h:1972
DWORD offString
Definition: wingdi.h:1974

Referenced by match_emf_record().

◆ dump_mf_bits()

static void dump_mf_bits ( const HMETAFILE  mf,
const char desc 
)
static

Definition at line 1568 of file metafile.c.

1569{
1571 UINT mfsize, i;
1572
1573 if (!winetest_debug) return;
1574
1575 mfsize = GetMetaFileBitsEx (mf, MF_BUFSIZE, buf);
1576 ok (mfsize > 0, "%s: GetMetaFileBitsEx failed.\n", desc);
1577
1578 printf ("MetaFile %s has bits:\n{\n ", desc);
1579 for (i=0; i<mfsize; i++)
1580 {
1581 printf ("0x%02x", buf[i]);
1582 if (i == mfsize-1)
1583 printf ("\n");
1584 else if (i % 8 == 7)
1585 printf (",\n ");
1586 else
1587 printf (", ");
1588 }
1589 printf ("};\n");
1590}

Referenced by create_converted_emf(), test_CopyMetaFile(), test_mf_Blank(), test_mf_clipping(), test_mf_DCBrush(), test_mf_ExtTextOut_on_path(), test_mf_GetPath(), test_mf_Graphics(), test_mf_PatternBrush(), and test_SetMetaFileBits().

◆ EmfEnumProc()

static INT CALLBACK EmfEnumProc ( HDC  hdc,
HANDLETABLE lpHTable,
const ENHMETARECORD lpEMFR,
INT  nObj,
LPARAM  lpData 
)
static

Definition at line 3001 of file metafile.c.

3002{
3003 LPMETAFILEPICT lpMFP = (LPMETAFILEPICT)lpData;
3004 POINT mapping[2] = { { 0, 0 }, { 10, 10 } };
3005 /* When using MM_TEXT Win9x does not update the mapping mode
3006 * until a record is played which actually outputs something */
3007 PlayEnhMetaFileRecord(hdc, lpHTable, lpEMFR, nObj);
3008 LPtoDP(hdc, mapping, 2);
3009 trace("EMF record: iType %d, nSize %d, (%d,%d)-(%d,%d)\n",
3010 lpEMFR->iType, lpEMFR->nSize,
3011 mapping[0].x, mapping[0].y, mapping[1].x, mapping[1].y);
3012
3013 if (lpEMFR->iType == EMR_LINETO)
3014 {
3015 INT x0, y0, x1, y1;
3016 if (!lpMFP || lpMFP->mm == MM_TEXT)
3017 {
3018 x0 = 0;
3019 y0 = 0;
3020 x1 = (INT)floor(10 * 100.0 / LINE_X + 0.5);
3021 y1 = (INT)floor(10 * 100.0 / LINE_Y + 0.5);
3022 }
3023 else
3024 {
3025 ok(lpMFP->mm == MM_ANISOTROPIC, "mm=%d\n", lpMFP->mm);
3026
3031 }
3032 ok(mapping[0].x == x0 && mapping[0].y == y0 && mapping[1].x == x1 && mapping[1].y == y1,
3033 "(%d,%d)->(%d,%d), expected (%d,%d)->(%d,%d)\n",
3034 mapping[0].x, mapping[0].y, mapping[1].x, mapping[1].y,
3035 x0, y0, x1, y1);
3036 }
3037 return TRUE;
3038}
#define TRUE
Definition: types.h:120
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
_Check_return_ _CRTIMP double __cdecl floor(_In_ double x)
GLint y0
Definition: linetemp.h:96
GLint x0
Definition: linetemp.h:95
static INT
Definition: metafile.c:43
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG y1
Definition: winddi.h:3709
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3708
#define HORZRES
Definition: wingdi.h:716
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define VERTSIZE
Definition: wingdi.h:715
#define EMR_LINETO
Definition: wingdi.h:128
BOOL WINAPI LPtoDP(_In_ HDC hdc, _Inout_updates_(c) LPPOINT lppt, _In_ int c)
struct tagMETAFILEPICT * LPMETAFILEPICT
#define HORZSIZE
Definition: wingdi.h:714
#define VERTRES
Definition: wingdi.h:717
#define MM_TEXT
Definition: wingdi.h:873

Referenced by test_mf_conversions().

◆ enum_emf_WorldTransform()

static INT CALLBACK enum_emf_WorldTransform ( HDC  hdc,
HANDLETABLE ht,
const ENHMETARECORD emr,
INT  nobj,
LPARAM  param 
)
static

Definition at line 4069 of file metafile.c.

4071{
4072 XFORM xform = {0};
4074 BOOL ret;
4075
4076 switch(emr->iType)
4077 {
4079 {
4080 const EMRSETWORLDTRANSFORM *lpXfrm = (const EMRSETWORLDTRANSFORM *)emr;
4081
4082 /* get scale factors with an identity world transform */
4084
4085 /* play back record */
4086 ret = PlayEnhMetaFileRecord(hdc, ht, emr, nobj);
4087 ok(ret == TRUE, "%s: PlayEnhMetaFileRecord failed\n", test_data->name);
4088
4089 test_data->stored = lpXfrm->xform;
4090 CombineTransform(&test_data->expected, &test_data->stored, &test_data->scale);
4091
4092 /* verify it is updated immediately */
4093 ret = GetWorldTransform(hdc, &xform);
4094 ok(ret == TRUE, "%s: GetWorldTransform failed\n", test_data->name);
4095 ok(xform_eq(&xform, &test_data->expected),
4096 "%s: After SWT playback, got wrong world transform: %f, %f; %f %f; %f %f; expected: %f, %f; %f %f; %f %f\n",
4097 test_data->name,
4098 xform.eM11, xform.eM12,
4099 xform.eM21, xform.eM22,
4100 xform.eDx, xform.eDy,
4101 test_data->expected.eM11, test_data->expected.eM12,
4102 test_data->expected.eM21, test_data->expected.eM22,
4103 test_data->expected.eDx, test_data->expected.eDy);
4104
4105 break;
4106 }
4107
4109 {
4110 const EMRMODIFYWORLDTRANSFORM *lpXfrm = (const EMRMODIFYWORLDTRANSFORM *)emr;
4111
4112 /* transform persists across calls */
4113 ret = GetWorldTransform(hdc, &xform);
4114 ok(ret == TRUE, "%s: GetWorldTransform failed\n", test_data->name);
4115 ok(xform_eq(&xform, &test_data->expected),
4116 "%s: On MWT entry, got wrong world transform: %f, %f; %f %f; %f %f; expected: %f, %f; %f %f; %f %f\n",
4117 test_data->name,
4118 xform.eM11, xform.eM12,
4119 xform.eM21, xform.eM22,
4120 xform.eDx, xform.eDy,
4121 test_data->expected.eM11, test_data->expected.eM12,
4122 test_data->expected.eM21, test_data->expected.eM22,
4123 test_data->expected.eDx, test_data->expected.eDy);
4124
4125 if(test_data->do_playback)
4126 {
4127 /* play back record */
4128 ret = PlayEnhMetaFileRecord(hdc, ht, emr, nobj);
4129 ok(ret == TRUE, "%s: PlayEnhMetaFileRecord failed\n", test_data->name);
4130
4131 if(lpXfrm->iMode == MWT_LEFTMULTIPLY)
4132 {
4133 /* left multiply does not discard direct modifications */
4134 CombineTransform(&test_data->expected, &lpXfrm->xform, &test_data->expected);
4135
4136 /* and updates the stored matrix separately */
4137 CombineTransform(&test_data->stored, &lpXfrm->xform, &test_data->stored);
4138
4139 }
4140 else if(lpXfrm->iMode == MWT_RIGHTMULTIPLY)
4141 {
4142 /* but right multiply does discard */
4143 CombineTransform(&test_data->stored, &test_data->stored, &lpXfrm->xform);
4144
4145 CombineTransform(&test_data->expected, &test_data->stored, &test_data->scale);
4146 }
4147
4148 /* verify it is updated immediately */
4149 ret = GetWorldTransform(hdc, &xform);
4150 ok(ret == TRUE, "%s: GetWorldTransform failed\n", test_data->name);
4151 ok(xform_eq(&xform, &test_data->expected),
4152 "%s: After MWT playback, got wrong world transform: %f, %f; %f %f; %f %f; expected: %f, %f; %f %f; %f %f\n",
4153 test_data->name,
4154 xform.eM11, xform.eM12,
4155 xform.eM21, xform.eM22,
4156 xform.eDx, xform.eDy,
4157 test_data->expected.eM11, test_data->expected.eM12,
4158 test_data->expected.eM21, test_data->expected.eM22,
4159 test_data->expected.eDx, test_data->expected.eDy);
4160 }
4161
4162 if(test_data->do_modify)
4163 {
4164 /* modify directly */
4165 set_rotation_xform(&xform, M_PI / 4.f, 1, -1);
4167 ok(ret == TRUE, "%s: ModifyWorldTransform failed\n", test_data->name);
4168
4169 /* the modified transform persists across callback calls */
4170 CombineTransform(&test_data->expected, &xform, &test_data->expected);
4171
4172 ret = GetWorldTransform(hdc, &xform);
4173 ok(ret == TRUE, "%s: GetWorldTransform failed\n", test_data->name);
4174 ok(xform_eq(&xform, &test_data->expected),
4175 "%s: After ModifyWT, got wrong world transform: %f, %f; %f %f; %f %f; expected: %f, %f; %f %f; %f %f\n",
4176 test_data->name,
4177 xform.eM11, xform.eM12,
4178 xform.eM21, xform.eM22,
4179 xform.eDx, xform.eDy,
4180 test_data->expected.eM11, test_data->expected.eM12,
4181 test_data->expected.eM21, test_data->expected.eM22,
4182 test_data->expected.eDx, test_data->expected.eDy);
4183 }
4184
4185 break;
4186 }
4187
4188 case EMR_LINETO:
4189 ret = GetWorldTransform(hdc, &xform);
4190 ok(ret == TRUE, "%s: GetWorldTransform failed\n", test_data->name);
4191 ok(xform_eq(&xform, &test_data->expected),
4192 "%s: Before LINETO playback, got wrong world transform: %f, %f; %f %f; %f %f; expected: %f, %f; %f %f; %f %f\n",
4193 test_data->name,
4194 xform.eM11, xform.eM12,
4195 xform.eM21, xform.eM22,
4196 xform.eDx, xform.eDy,
4197 test_data->expected.eM11, test_data->expected.eM12,
4198 test_data->expected.eM21, test_data->expected.eM22,
4199 test_data->expected.eDx, test_data->expected.eDy);
4200
4201 ret = PlayEnhMetaFileRecord(hdc, ht, emr, nobj);
4202 ok(ret == TRUE, "%s: PlayEnhMetaFileRecord failed\n", test_data->name);
4203
4204 /* transform doesn't change during LINETO playback */
4205 ret = GetWorldTransform(hdc, &xform);
4206 ok(ret == TRUE, "%s: GetWorldTransform failed\n", test_data->name);
4207 ok(xform_eq(&xform, &test_data->expected),
4208 "%s: After LINETO playback, got wrong world transform: %f, %f; %f %f; %f %f; expected: %f, %f; %f %f; %f %f\n",
4209 test_data->name,
4210 xform.eM11, xform.eM12,
4211 xform.eM21, xform.eM22,
4212 xform.eDx, xform.eDy,
4213 test_data->expected.eM11, test_data->expected.eM12,
4214 test_data->expected.eM21, test_data->expected.eM22,
4215 test_data->expected.eDx, test_data->expected.eDy);
4216
4217 break;
4218
4219 default:
4220 PlayEnhMetaFileRecord(hdc, ht, emr, nobj);
4221 break;
4222 }
4223
4224 return 1;
4225}
static const struct newhuff ht[]
Definition: huffman.h:296
static void set_rotation_xform(XFORM *out, float rad, int dx, int dy)
Definition: metafile.c:4037
static BOOL xform_eq(const XFORM *a, const XFORM *b)
Definition: metafile.c:4059
#define M_PI
Definition: metafile.c:32
#define MWT_LEFTMULTIPLY
Definition: wingdi.h:945
#define MWT_RIGHTMULTIPLY
Definition: wingdi.h:946
BOOL WINAPI CombineTransform(_Out_ LPXFORM pxformResult, _In_ const XFORM *pxform1, _In_ const XFORM *pxform2)
Definition: coord.c:64
#define EMR_MODIFYWORLDTRANSFORM
Definition: wingdi.h:110
#define EMR_SETWORLDTRANSFORM
Definition: wingdi.h:109
BOOL WINAPI ModifyWorldTransform(_In_ HDC, _In_opt_ const XFORM *, _In_ DWORD)

Referenced by test_emf_WorldTransform().

◆ eto_emf_enum_proc()

static int CALLBACK eto_emf_enum_proc ( HDC  hdc,
HANDLETABLE handle_table,
const ENHMETARECORD emr,
int  n_objs,
LPARAM  param 
)
static

Definition at line 81 of file metafile.c.

83{
84 static int n_record;
85 DWORD i;
86 const INT *dx;
87 INT *orig_dx = (INT *)param;
88 LOGFONTA device_lf;
89 INT ret;
90
91 if(!hdc) return 1;
92
94
95 switch (emr->iType)
96 {
97 case EMR_HEADER:
98 ok(GetTextAlign(hdc) == 0, "text align %08x\n", GetTextAlign(hdc));
99 ok(GetBkColor(hdc) == RGB(0xff, 0xff, 0xff), "bk color %08x\n", GetBkColor(hdc));
100 ok(GetTextColor(hdc) == RGB(0x0, 0x0, 0x0), "text color %08x\n", GetTextColor(hdc));
101 ok(GetROP2(hdc) == R2_COPYPEN, "rop %d\n", GetROP2(hdc));
103 ok(GetPolyFillMode(hdc) == ALTERNATE, "poly fill %d\n", GetPolyFillMode(hdc));
104 ok(GetStretchBltMode(hdc) == BLACKONWHITE, "stretchblt mode %d\n", GetStretchBltMode(hdc));
105
106 /* GetBkMode, GetRelAbs do not get reset to the default value */
107 ok(GetBkMode(hdc) == OPAQUE, "bk mode %d\n", GetBkMode(hdc));
108 if(pSetRelAbs && pGetRelAbs)
109 ok(pGetRelAbs(hdc, 0) == RELATIVE, "relabs %d\n", pGetRelAbs(hdc, 0));
110
111 n_record = 0;
112 break;
113
114 case EMR_EXTTEXTOUTA:
115 {
116 const EMREXTTEXTOUTA *emr_ExtTextOutA = (const EMREXTTEXTOUTA *)emr;
117 dx = (const INT *)((const char *)emr + emr_ExtTextOutA->emrtext.offDx);
118
119 ret = GetObjectA(GetCurrentObject(hdc, OBJ_FONT), sizeof(device_lf), &device_lf);
120 ok( ret == sizeof(device_lf), "GetObjectA error %d\n", GetLastError());
121
122 /* compare up to lfOutPrecision, other values are not interesting,
123 * and in fact sometimes arbitrary adapted by Win9x.
124 */
125 ok(!memcmp(&orig_lf, &device_lf, FIELD_OFFSET(LOGFONTA, lfOutPrecision)), "fonts don't match\n");
126 ok(!lstrcmpA(orig_lf.lfFaceName, device_lf.lfFaceName), "font names don't match\n");
127
128 for(i = 0; i < emr_ExtTextOutA->emrtext.nChars; i++)
129 {
130 ok(orig_dx[i] == dx[i], "pass %d: dx[%d] (%d) didn't match %d\n",
131 n_record, i, dx[i], orig_dx[i]);
132 }
133 n_record++;
135 break;
136 }
137
138 case EMR_EXTTEXTOUTW:
139 {
140 const EMREXTTEXTOUTW *emr_ExtTextOutW = (const EMREXTTEXTOUTW *)emr;
141 dx = (const INT *)((const char *)emr + emr_ExtTextOutW->emrtext.offDx);
142
143 SetLastError(0xdeadbeef);
144 ret = GetObjectA(GetCurrentObject(hdc, OBJ_FONT), sizeof(device_lf), &device_lf);
145 ok( ret == sizeof(device_lf) ||
146 broken(ret == (sizeof(device_lf) - LF_FACESIZE + strlen(device_lf.lfFaceName) + 1)), /* NT4 */
147 "GetObjectA error %d\n", GetLastError());
148
149 /* compare up to lfOutPrecision, other values are not interesting,
150 * and in fact sometimes arbitrary adapted by Win9x.
151 */
152 ok(!memcmp(&orig_lf, &device_lf, FIELD_OFFSET(LOGFONTA, lfOutPrecision)), "fonts don't match\n");
153 ok(!lstrcmpA(orig_lf.lfFaceName, device_lf.lfFaceName), "font names don't match\n");
154
155 ok(!emr_ExtTextOutW->rclBounds.left, "emr_ExtTextOutW->rclBounds.left = %d\n",
156 emr_ExtTextOutW->rclBounds.left);
157 ok(emr_ExtTextOutW->rclBounds.right != -1, "emr_ExtTextOutW->rclBounds.right = %d\n",
158 emr_ExtTextOutW->rclBounds.right);
159 ok(emr_ExtTextOutW->rclBounds.bottom != -1, "emr_ExtTextOutW->rclBounds.bottom = %d\n",
160 emr_ExtTextOutW->rclBounds.bottom);
161
162 for(i = 0; i < emr_ExtTextOutW->emrtext.nChars; i++)
163 {
164 ok(orig_dx[i] == dx[i], "pass %d: dx[%d] (%d) didn't match %d\n",
165 n_record, i, dx[i], orig_dx[i]);
166 }
167 n_record++;
169 break;
170 }
171
172 default:
173 break;
174 }
175
176 return 1;
177}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define ALTERNATE
Definition: constants.h:278
#define LF_FACESIZE
Definition: dimm.idl:39
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4194
#define RGB(r, g, b)
Definition: precomp.h:71
GLint dx
Definition: linetemp.h:97
static LOGFONTA orig_lf
Definition: metafile.c:35
static BOOL emr_processed
Definition: metafile.c:36
#define RELATIVE(wait)
Definition: nfs41_driver.c:113
#define OBJ_FONT
Definition: objidl.idl:1414
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
int WINAPI GetBkMode(_In_ HDC)
int WINAPI GetPolyFillMode(_In_ HDC)
#define EMR_EXTTEXTOUTA
Definition: wingdi.h:156
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
UINT WINAPI GetTextAlign(_In_ HDC)
Definition: text.c:838
COLORREF WINAPI GetTextColor(_In_ HDC)
Definition: text.c:861
#define EMR_EXTTEXTOUTW
Definition: wingdi.h:157
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:428
#define BLACKONWHITE
Definition: wingdi.h:952
COLORREF WINAPI GetBkColor(_In_ HDC)
Definition: dc.c:978
int WINAPI GetROP2(_In_ HDC)
Definition: dc.c:1086
int WINAPI GetStretchBltMode(_In_ HDC)
#define OPAQUE
Definition: wingdi.h:949
#define AD_COUNTERCLOCKWISE
Definition: wingdi.h:667
#define R2_COPYPEN
Definition: wingdi.h:339
int WINAPI GetArcDirection(_In_ HDC)
Definition: dc.c:358

Referenced by test_ExtTextOut().

◆ eto_scale_enum_proc()

static int CALLBACK eto_scale_enum_proc ( HDC  hdc,
HANDLETABLE handle_table,
const ENHMETARECORD emr,
int  n_objs,
LPARAM  param 
)
static

Definition at line 316 of file metafile.c.

318{
320
321 if (emr->iType == EMR_EXTTEXTOUTW)
322 {
323 const EMREXTTEXTOUTW *pExtTextOutW = (const EMREXTTEXTOUTW *)emr;
324 ok(fabs(test->ex_scale - pExtTextOutW->exScale) < 0.001,
325 "Got exScale %f, expected %f\n", pExtTextOutW->exScale, test->ex_scale);
326 ok(fabs(test->ey_scale - pExtTextOutW->eyScale) < 0.001,
327 "Got eyScale %f, expected %f\n", pExtTextOutW->eyScale, test->ey_scale);
328 test->processed = TRUE;
329 }
330
331 return 1;
332}
#define test
Definition: rosglue.h:37

Referenced by test_ExtTextOutScale().

◆ getConvertedFrameAndBounds()

static BOOL getConvertedFrameAndBounds ( UINT  buffer_size,
BYTE buffer,
BOOL  mfpIsNull,
LONG  mm,
LONG  xExt,
LONG  yExt,
RECTL rclBounds,
RECTL rclFrame 
)
static

Definition at line 3145 of file metafile.c.

3148{
3149 METAFILEPICT mfp;
3150 METAFILEPICT * mfpPtr = NULL;
3151 HENHMETAFILE emf;
3153 UINT res;
3154
3155 if (!mfpIsNull)
3156 {
3157 mfp.mm = mm;
3158 mfp.xExt = xExt;
3159 mfp.yExt = yExt;
3160 mfpPtr = &mfp;
3161 }
3162
3164 ok(emf != NULL, "SetWinMetaFileBits failed\n");
3165 if (!emf) return FALSE;
3167 ok(res != 0, "GetEnhMetaHeader failed\n");
3169 if (!res) return FALSE;
3170
3171 *rclBounds = header.rclBounds;
3172 *rclFrame = header.rclFrame;
3173 return TRUE;
3174}
#define FALSE
Definition: types.h:117
GLuint res
Definition: glext.h:9613
BOOL WINAPI DeleteEnhMetaFile(_In_opt_ HENHMETAFILE)
UINT WINAPI GetEnhMetaFileHeader(_In_ HENHMETAFILE hemf, _In_ UINT nSize, _Out_writes_bytes_opt_(nSize) LPENHMETAHEADER lpEnhMetaHeader)

Referenced by checkConvertedFrameAndBounds(), and test_SetWinMetaFileBits().

◆ getwinmetafilebits()

static void getwinmetafilebits ( UINT  mode,
int  scale,
RECT rc 
)
static

Definition at line 3370 of file metafile.c.

3371{
3372 HENHMETAFILE emf, emf2;
3373 HDC display_dc, emf_dc;
3374 ENHMETAHEADER *enh_header, *enh2_header;
3375 UINT size, emf_size, i, emf2_size;
3376 WORD check = 0;
3377 DWORD rec_num = 0;
3378 METAHEADER *mh = NULL;
3379 METARECORD *rec;
3380 INT horz_res, vert_res, horz_size, vert_size;
3381 INT curve_caps, line_caps, poly_caps;
3382 METAFILEPICT mfp;
3383
3385 ok(display_dc != NULL, "display_dc is NULL\n");
3386
3387 horz_res = GetDeviceCaps(display_dc, HORZRES);
3388 vert_res = GetDeviceCaps(display_dc, VERTRES);
3389 horz_size = GetDeviceCaps(display_dc, HORZSIZE);
3390 vert_size = GetDeviceCaps(display_dc, VERTSIZE);
3391
3392 emf_dc = CreateEnhMetaFileA(display_dc, NULL, rc, NULL);
3393 ok(emf_dc != NULL, "emf_dc is NULL\n");
3394
3395 curve_caps = GetDeviceCaps(emf_dc, CURVECAPS);
3396 ok(curve_caps == 511, "expect 511 got %d\n", curve_caps);
3397
3398 line_caps = GetDeviceCaps(emf_dc, LINECAPS);
3399 ok(line_caps == 254, "expect 254 got %d\n", line_caps);
3400
3401 poly_caps = GetDeviceCaps(emf_dc, POLYGONALCAPS);
3402 ok(poly_caps == 255, "expect 511 got %d\n", poly_caps);
3403
3404 for(i = 0; i < 3000; i++) /* This is enough to take emf_size > 0xffff */
3405 Rectangle(emf_dc, 0, 0, 1000, 20);
3406 emf = CloseEnhMetaFile(emf_dc);
3407 ok(emf != NULL, "emf is NULL\n");
3408
3409 emf_size = GetEnhMetaFileBits(emf, 0, NULL);
3410 enh_header = HeapAlloc(GetProcessHeap(), 0, emf_size);
3411 emf_size = GetEnhMetaFileBits(emf, emf_size, (BYTE*)enh_header);
3413 /* multiply szlDevice.cx by scale, when scale != 1 the recording and playback dcs
3414 have different resolutions */
3415 enh_header->szlDevice.cx *= scale;
3416 emf = SetEnhMetaFileBits(emf_size, (BYTE*)enh_header);
3417 ok(emf != NULL, "emf is NULL\n");
3418 ok(EqualRect((RECT*)&enh_header->rclFrame, rc), "Frame rectangles differ\n");
3419
3421 ok(size ||
3422 broken(size == 0), /* some versions of winxp fail for some reason */
3423 "GetWinMetaFileBits returns 0\n");
3424 if(!size) goto end;
3425 mh = HeapAlloc(GetProcessHeap(), 0, size);
3427
3428 for(i = 0; i < size / 2; i++) check += ((WORD*)mh)[i];
3429 ok(check == 0, "check %04x\n", check);
3430
3431 rec = (METARECORD*)(mh + 1);
3432
3433 while(rec->rdSize && rec->rdFunction)
3434 {
3435 const DWORD chunk_size = 0x2000;
3436 DWORD mfcomment_chunks = (emf_size + chunk_size - 1) / chunk_size;
3437
3438 if(rec_num < mfcomment_chunks)
3439 {
3440 DWORD this_chunk_size = chunk_size;
3441
3442 if(rec_num == mfcomment_chunks - 1)
3443 this_chunk_size = emf_size - rec_num * chunk_size;
3444
3445 ok(rec->rdSize == (this_chunk_size + 44) / 2, "%04x: got %04x expected %04x\n", rec_num, rec->rdSize, (this_chunk_size + 44) / 2);
3446 ok(rec->rdFunction == META_ESCAPE, "%04x: got %04x\n", rec_num, rec->rdFunction);
3447 if(rec->rdSize < (this_chunk_size + 44) / 2) break;
3448 ok(rec->rdParm[0] == MFCOMMENT, "got %04x\n", rec->rdParm[0]);
3449 ok(rec->rdParm[1] == this_chunk_size + 34, "got %04x %x\n", rec->rdParm[1], emf_size + 34);
3450 ok(rec->rdParm[2] == 0x4d57, "got %04x\n", rec->rdParm[2]); /* WMFC */
3451 ok(rec->rdParm[3] == 0x4346, "got %04x\n", rec->rdParm[3]); /* " */
3452 ok(rec->rdParm[4] == 1, "got %04x\n", rec->rdParm[4]);
3453 ok(rec->rdParm[5] == 0, "got %04x\n", rec->rdParm[5]);
3454 ok(rec->rdParm[6] == 0, "got %04x\n", rec->rdParm[6]);
3455 ok(rec->rdParm[7] == 1, "got %04x\n", rec->rdParm[7]);
3456 /* parm[8] is the checksum, tested above */
3457 if(rec_num > 0) ok(rec->rdParm[8] == 0, "got %04x\n", rec->rdParm[8]);
3458 ok(rec->rdParm[9] == 0, "got %04x\n", rec->rdParm[9]);
3459 ok(rec->rdParm[10] == 0, "got %04x\n", rec->rdParm[10]);
3460 ok(rec->rdParm[11] == mfcomment_chunks, "got %04x\n", rec->rdParm[11]); /* num chunks */
3461 ok(rec->rdParm[12] == 0, "got %04x\n", rec->rdParm[12]);
3462 ok(rec->rdParm[13] == this_chunk_size, "got %04x expected %04x\n", rec->rdParm[13], this_chunk_size);
3463 ok(rec->rdParm[14] == 0, "got %04x\n", rec->rdParm[14]);
3464 ok(*(DWORD*)(rec->rdParm + 15) == emf_size - this_chunk_size - rec_num * chunk_size, "got %08x\n", *(DWORD*)(rec->rdParm + 15)); /* DWORD size remaining after current chunk */
3465 ok(*(DWORD*)(rec->rdParm + 17) == emf_size, "got %08x emf_size %08x\n", *(DWORD*)(rec->rdParm + 17), emf_size);
3466 ok(!memcmp(rec->rdParm + 19, (char*)enh_header + rec_num * chunk_size, this_chunk_size), "bits mismatch\n");
3467 }
3468
3469 else if(rec_num == mfcomment_chunks)
3470 {
3471 ok(rec->rdFunction == META_SETMAPMODE, "got %04x\n", rec->rdFunction);
3472 ok(rec->rdParm[0] == mode, "got %04x\n", rec->rdParm[0]);
3473 }
3474 else if(rec_num == mfcomment_chunks + 1)
3475 {
3476 POINT pt;
3477 ok(rec->rdFunction == META_SETWINDOWORG, "got %04x\n", rec->rdFunction);
3478 switch(mode)
3479 {
3480 case MM_TEXT:
3481 case MM_ISOTROPIC:
3482 case MM_ANISOTROPIC:
3483 pt.y = MulDiv(rc->top, vert_res, vert_size * 100) + 1;
3484 pt.x = MulDiv(rc->left, horz_res, horz_size * 100);
3485 break;
3486 case MM_LOMETRIC:
3487 pt.y = MulDiv(-rc->top, 1, 10) + 1;
3488 pt.x = MulDiv( rc->left, 1, 10);
3489 break;
3490 case MM_HIMETRIC:
3491 pt.y = -rc->top + 1;
3492 pt.x = (rc->left >= 0) ? rc->left : rc->left + 1; /* strange but true */
3493 break;
3494 case MM_LOENGLISH:
3495 pt.y = MulDiv(-rc->top, 10, 254) + 1;
3496 pt.x = MulDiv( rc->left, 10, 254);
3497 break;
3498 case MM_HIENGLISH:
3499 pt.y = MulDiv(-rc->top, 100, 254) + 1;
3500 pt.x = MulDiv( rc->left, 100, 254);
3501 break;
3502 case MM_TWIPS:
3503 pt.y = MulDiv(-rc->top, 72 * 20, 2540) + 1;
3504 pt.x = MulDiv( rc->left, 72 * 20, 2540);
3505 break;
3506 default:
3507 pt.x = pt.y = 0;
3508 }
3509 ok(near_match((short)rec->rdParm[0], pt.y), "got %d expect %d\n", (short)rec->rdParm[0], pt.y);
3510 ok(near_match((short)rec->rdParm[1], pt.x), "got %d expect %d\n", (short)rec->rdParm[1], pt.x);
3511 }
3512 if(rec_num == mfcomment_chunks + 2)
3513 {
3514 ok(rec->rdFunction == META_SETWINDOWEXT, "got %04x\n", rec->rdFunction);
3515 ok(near_match((short)rec->rdParm[0], MulDiv(rc->bottom - rc->top, vert_res, vert_size * 100)),
3516 "got %d\n", (short)rec->rdParm[0]);
3517 ok(near_match((short)rec->rdParm[1], MulDiv(rc->right - rc->left, horz_res, horz_size * 100)),
3518 "got %d\n", (short)rec->rdParm[1]);
3519 }
3520
3521 rec_num++;
3522 rec = (METARECORD*)((WORD*)rec + rec->rdSize);
3523 }
3524
3525 /* Show that we get the original back when we do the reverse conversion.
3526 mfp is ignored in this case. */
3527 mfp.mm = MM_ISOTROPIC;
3528 mfp.xExt = 0xcafe;
3529 mfp.yExt = 0xbeef;
3530 emf2 = SetWinMetaFileBits( size, (BYTE*)mh, NULL, &mfp );
3531 ok( !!emf2, "got NULL\n" );
3532 emf2_size = GetEnhMetaFileBits( emf2, 0, NULL );
3533 enh2_header = HeapAlloc( GetProcessHeap(), 0, emf2_size );
3534 emf2_size = GetEnhMetaFileBits( emf2, emf2_size, (BYTE*)enh2_header );
3535 ok( emf_size == emf2_size, "%d %d\n", emf_size, emf2_size );
3536 ok( !memcmp( enh_header, enh2_header, emf_size ), "mismatch\n" );
3537 HeapFree( GetProcessHeap(), 0, enh2_header );
3538 DeleteEnhMetaFile( emf2 );
3539
3540end:
3541 HeapFree(GetProcessHeap(), 0, mh);
3542 HeapFree(GetProcessHeap(), 0, enh_header);
3544
3546}
static HDC display_dc
Definition: main.c:41
#define check(expected, result)
Definition: dplayx.c:32
#define pt(x, y)
Definition: drawing.c:79
unsigned short WORD
Definition: ntddk_ex.h:93
GLuint GLuint end
Definition: gl.h:1545
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
GLenum mode
Definition: glext.h:6217
#define near_match(a, b)
Definition: font.c:39
RECTL rclFrame
Definition: wingdi.h:2323
SIZEL szlDevice
Definition: wingdi.h:2333
DWORD rdSize
Definition: wingdi.h:2345
WORD rdParm[1]
Definition: wingdi.h:2347
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define MM_HIENGLISH
Definition: wingdi.h:868
#define MM_LOENGLISH
Definition: wingdi.h:871
#define META_ESCAPE
Definition: wingdi.h:248
#define MM_HIMETRIC
Definition: wingdi.h:869
#define META_SETMAPMODE
Definition: wingdi.h:212
#define POLYGONALCAPS
Definition: wingdi.h:779
UINT WINAPI GetWinMetaFileBits(_In_ HENHMETAFILE hemf, _In_ UINT cbData16, _Out_writes_bytes_opt_(cbData16) LPBYTE pData16, _In_ INT iMapMode, _In_ HDC hdcRef)
#define MM_TWIPS
Definition: wingdi.h:874
#define META_SETWINDOWORG
Definition: wingdi.h:221
HDC WINAPI CreateEnhMetaFileA(_In_opt_ HDC, _In_opt_ LPCSTR, _In_opt_ LPCRECT, _In_opt_ LPCSTR)
#define META_SETWINDOWEXT
Definition: wingdi.h:222
#define MM_LOMETRIC
Definition: wingdi.h:872
#define CURVECAPS
Definition: wingdi.h:759
HENHMETAFILE WINAPI CloseEnhMetaFile(_In_ HDC hdc)
HENHMETAFILE WINAPI SetEnhMetaFileBits(_In_ UINT nSize, _In_reads_bytes_(nSize) const BYTE *pb)
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define LINECAPS
Definition: wingdi.h:770
#define MFCOMMENT
Definition: wingdi.h:1008
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by test_GetWinMetaFileBits().

◆ init_function_pointers()

static void init_function_pointers ( void  )
static

Definition at line 52 of file metafile.c.

53{
54 HMODULE hGDI;
55
56 pGetRelAbs = NULL;
57 pSetRelAbs = NULL;
58
59 hGDI = GetModuleHandleA("gdi32.dll");
60 assert(hGDI);
65}
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define GDI_GET_PROC(func)
Definition: metafile.c:47
COLORREF WINAPI SetDCPenColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:941
DWORD WINAPI GetRelAbs(_In_ HDC hdc, _In_ DWORD dwIgnore)
Definition: dc.c:720
COLORREF WINAPI SetDCBrushColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:905
INT WINAPI SetRelAbs(HDC, INT)
Definition: dc.c:733

Referenced by START_TEST().

◆ INT()

static INT ( WINAPI pGetRelAbs)
static

◆ is_equal_rect()

static BOOL is_equal_rect ( const RECT rc1,
const RECT rc2 
)
static

Definition at line 2599 of file metafile.c.

2600{
2601 return abs(rc1->left - rc2->left) <= 1 &&
2602 abs(rc1->top - rc2->top) <= 1 &&
2603 abs(rc1->right - rc2->right) <= 1 &&
2604 abs(rc1->bottom - rc2->bottom) <= 1;
2605}
static const WCHAR rc2[]
Definition: oid.c:1216
#define abs(i)
Definition: fconv.c:206

Referenced by clip_emf_enum_proc().

◆ match_emf_record()

static BOOL match_emf_record ( const ENHMETARECORD emr1,
const ENHMETARECORD emr2,
const char desc,
BOOL  ignore_scaling 
)
static

Definition at line 1754 of file metafile.c.

1756{
1757 int diff;
1758
1759 ok(emr1->iType == emr2->iType, "%s: emr->iType %u != %u\n",
1760 desc, emr1->iType, emr2->iType);
1761
1762 ok(emr1->nSize == emr2->nSize, "%s: emr->nSize %u != %u\n",
1763 desc, emr1->nSize, emr2->nSize);
1764
1765 /* iType and nSize mismatches are fatal */
1766 if (emr1->iType != emr2->iType || emr1->nSize != emr2->nSize) return FALSE;
1767
1768 /* contents of EMR_GDICOMMENT are not interesting */
1769 if (emr1->iType == EMR_GDICOMMENT) return TRUE;
1770
1771 /* different Windows versions setup DC scaling differently when
1772 * converting an old style metafile to an EMF.
1773 */
1774 if (ignore_scaling && (emr1->iType == EMR_SETWINDOWEXTEX ||
1775 emr1->iType == EMR_SETVIEWPORTEXTEX))
1776 return TRUE;
1777
1778 if (emr1->iType == EMR_EXTTEXTOUTW || emr1->iType == EMR_EXTTEXTOUTA)
1779 {
1780 EMREXTTEXTOUTW *eto1, *eto2;
1781
1782 eto1 = HeapAlloc(GetProcessHeap(), 0, emr1->nSize);
1783 memcpy(eto1, emr1, emr1->nSize);
1784 eto2 = HeapAlloc(GetProcessHeap(), 0, emr2->nSize);
1785 memcpy(eto2, emr2, emr2->nSize);
1786
1787 /* different Windows versions setup DC scaling differently */
1788 eto1->exScale = eto1->eyScale = 0.0;
1789 eto2->exScale = eto2->eyScale = 0.0;
1790
1791 diff = memcmp(eto1, eto2, emr1->nSize);
1792 if (diff)
1793 {
1794 dump_EMREXTTEXTOUT(eto1);
1795 dump_EMREXTTEXTOUT(eto2);
1796 }
1797 HeapFree(GetProcessHeap(), 0, eto1);
1798 HeapFree(GetProcessHeap(), 0, eto2);
1799 }
1800 else if (emr1->iType == EMR_EXTSELECTCLIPRGN && !lstrcmpA(desc, "emf_clipping"))
1801 {
1802 /* We have to take care of NT4 differences here */
1803 diff = memcmp(emr1, emr2, emr1->nSize);
1804 if (diff)
1805 {
1806 ENHMETARECORD *emr_nt4;
1807
1808 emr_nt4 = HeapAlloc(GetProcessHeap(), 0, emr2->nSize);
1809 memcpy(emr_nt4, emr2, emr2->nSize);
1810 /* Correct the nRgnSize field */
1811 emr_nt4->dParm[5] = sizeof(RECT);
1812
1813 diff = memcmp(emr1, emr_nt4, emr1->nSize);
1814 if (!diff)
1815 win_skip("Catered for NT4 differences\n");
1816
1817 HeapFree(GetProcessHeap(), 0, emr_nt4);
1818 }
1819 }
1820 else if (emr1->iType == EMR_POLYBEZIERTO16 || emr1->iType == EMR_POLYBEZIER16)
1821 {
1822 EMRPOLYBEZIER16 *eto1, *eto2;
1823
1824 eto1 = (EMRPOLYBEZIER16*)emr1;
1825 eto2 = (EMRPOLYBEZIER16*)emr2;
1826
1827 diff = eto1->cpts != eto2->cpts;
1828 if(!diff)
1829 diff = memcmp(eto1->apts, eto2->apts, eto1->cpts * sizeof(POINTS));
1830 }
1831 else if (emr1->iType == EMR_POLYBEZIERTO || emr1->iType == EMR_POLYBEZIER)
1832 {
1833 EMRPOLYBEZIER *eto1, *eto2;
1834
1835 eto1 = (EMRPOLYBEZIER*)emr1;
1836 eto2 = (EMRPOLYBEZIER*)emr2;
1837
1838 diff = eto1->cptl != eto2->cptl;
1839 if(!diff)
1840 diff = memcmp(eto1->aptl, eto2->aptl, eto1->cptl * sizeof(POINTL));
1841 }
1842 else
1843 diff = memcmp(emr1, emr2, emr1->nSize);
1844
1845 ok(diff == 0, "%s: contents of record %u don't match\n", desc, emr1->iType);
1846
1847 if (diff)
1848 {
1849 dump_emf_record(emr1, "expected bits");
1850 dump_emf_record(emr2, "actual bits");
1851 }
1852
1853 return diff == 0; /* report all non-fatal record mismatches */
1854}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static void dump_emf_record(const ENHMETARECORD *emr, const char *desc)
Definition: metafile.c:1716
static void dump_EMREXTTEXTOUT(const EMREXTTEXTOUTW *eto)
Definition: metafile.c:1738
#define win_skip
Definition: test.h:163
POINTS apts[1]
Definition: wingdi.h:2117
DWORD cptl
Definition: wingdi.h:2110
POINTL aptl[1]
Definition: wingdi.h:2111
DWORD dParm[1]
Definition: wingdi.h:2352
#define RECT
Definition: precomp.h:26
#define EMR_SETWINDOWEXTEX
Definition: wingdi.h:83
#define EMR_SETVIEWPORTEXTEX
Definition: wingdi.h:85
#define EMR_POLYBEZIER16
Definition: wingdi.h:158
#define EMR_POLYBEZIERTO16
Definition: wingdi.h:161
#define EMR_POLYBEZIER
Definition: wingdi.h:76
#define EMR_POLYBEZIERTO
Definition: wingdi.h:79
#define EMR_GDICOMMENT
Definition: wingdi.h:143

Referenced by compare_emf_bits().

◆ mf_enum_proc()

static INT CALLBACK mf_enum_proc ( HDC  hdc,
HANDLETABLE ht,
METARECORD mr,
INT  nobj,
LPARAM  param 
)
static

Definition at line 1556 of file metafile.c.

1558{
1559 trace("hdc %p, mr->rdFunction %04x, mr->rdSize %u, param %p\n",
1560 hdc, mr->rdFunction, mr->rdSize, (void *)param);
1561 return TRUE;
1562}

Referenced by create_converted_emf(), test_CopyMetaFile(), test_mf_Blank(), test_mf_DCBrush(), test_mf_ExtTextOut_on_path(), test_mf_GetPath(), test_mf_Graphics(), test_mf_PatternBrush(), and test_SetMetaFileBits().

◆ near_match()

static BOOL near_match ( int  x,
int  y 
)
static

Definition at line 3360 of file metafile.c.

3361{
3362 int epsilon = min(abs(x), abs(y));
3363
3364 epsilon = max(epsilon/100, 2);
3365
3366 if(x < y - epsilon || x > y + epsilon) return FALSE;
3367 return TRUE;
3368}
#define min(a, b)
Definition: monoChain.cc:55
#define max(a, b)
Definition: svc.c:63

◆ rgn_rect_count()

static DWORD rgn_rect_count ( HRGN  hrgn)
static

Definition at line 67 of file metafile.c.

68{
69 DWORD size;
71
72 if (!hrgn) return 0;
73 if (!(size = GetRegionData(hrgn, 0, NULL))) return 0;
74 if (!(data = HeapAlloc(GetProcessHeap(), 0, size))) return 0;
76 size = data->rdh.nCount;
78 return size;
79}

Referenced by test_emf_clipping().

◆ savedc_emf_enum_proc()

static int CALLBACK savedc_emf_enum_proc ( HDC  hdc,
HANDLETABLE handle_table,
const ENHMETARECORD emr,
int  n_objs,
LPARAM  param 
)
static

Definition at line 495 of file metafile.c.

497{
498 BOOL ret;
499 XFORM xform;
500 POINT pt;
501 SIZE size;
502 static int save_state;
503 static int restore_no;
504 static int select_no;
505
506 trace("hdc %p, emr->iType %d, emr->nSize %d, param %p\n",
507 hdc, emr->iType, emr->nSize, (void *)param);
508
509 SetLastError(0xdeadbeef);
510 ret = GetWorldTransform(hdc, &xform);
512 {
514 ok(ret, "GetWindowOrgEx error %u\n", GetLastError());
515 trace("window org (%d,%d)\n", pt.x, pt.y);
517 ok(ret, "GetViewportOrgEx error %u\n", GetLastError());
518 trace("vport org (%d,%d)\n", pt.x, pt.y);
520 ok(ret, "GetWindowExtEx error %u\n", GetLastError());
521 trace("window ext (%d,%d)\n", size.cx, size.cy);
523 ok(ret, "GetViewportExtEx error %u\n", GetLastError());
524 trace("vport ext (%d,%d)\n", size.cx, size.cy);
525 }
526 else
527 {
528 ok(ret, "GetWorldTransform error %u\n", GetLastError());
529 trace("eM11 %f, eM22 %f, eDx %f, eDy %f\n", xform.eM11, xform.eM22, xform.eDx, xform.eDy);
530 }
531
533
534 switch (emr->iType)
535 {
536 case EMR_HEADER:
537 {
538 static RECT exp_bounds = { 0, 0, 150, 150 };
539 RECT bounds;
540 const ENHMETAHEADER *emf = (const ENHMETAHEADER *)emr;
541
542 trace("bounds %d,%d-%d,%d, frame %d,%d-%d,%d\n",
543 emf->rclBounds.left, emf->rclBounds.top, emf->rclBounds.right, emf->rclBounds.bottom,
544 emf->rclFrame.left, emf->rclFrame.top, emf->rclFrame.right, emf->rclFrame.bottom);
545 trace("mm %d x %d, device %d x %d\n", emf->szlMillimeters.cx, emf->szlMillimeters.cy,
546 emf->szlDevice.cx, emf->szlDevice.cy);
547
548 SetRect(&bounds, emf->rclBounds.left, emf->rclBounds.top, emf->rclBounds.right, emf->rclBounds.bottom);
549 ok(EqualRect(&bounds, &exp_bounds), "wrong bounds\n");
550
551 save_state = 0;
552 restore_no = 0;
553 select_no = 0;
554 check_dc_state(hdc, restore_no, 0, 0, 1, 1, 0, 0, 1, 1);
555 break;
556 }
557
558 case EMR_LINETO:
559 {
560 const EMRLINETO *line = (const EMRLINETO *)emr;
561 trace("EMR_LINETO %d,%d\n", line->ptl.x, line->ptl.x);
562 break;
563 }
565 {
566 const EMRSETWINDOWORGEX *org = (const EMRSETWINDOWORGEX *)emr;
567 trace("EMR_SETWINDOWORGEX: %d,%d\n", org->ptlOrigin.x, org->ptlOrigin.y);
568 break;
569 }
571 {
572 const EMRSETWINDOWEXTEX *ext = (const EMRSETWINDOWEXTEX *)emr;
573 trace("EMR_SETWINDOWEXTEX: %d,%d\n", ext->szlExtent.cx, ext->szlExtent.cy);
574 break;
575 }
577 {
578 const EMRSETVIEWPORTORGEX *org = (const EMRSETVIEWPORTORGEX *)emr;
579 trace("EMR_SETVIEWPORTORGEX: %d,%d\n", org->ptlOrigin.x, org->ptlOrigin.y);
580 break;
581 }
583 {
584 const EMRSETVIEWPORTEXTEX *ext = (const EMRSETVIEWPORTEXTEX *)emr;
585 trace("EMR_SETVIEWPORTEXTEX: %d,%d\n", ext->szlExtent.cx, ext->szlExtent.cy);
586 break;
587 }
588 case EMR_SAVEDC:
589 save_state++;
590 trace("EMR_SAVEDC\n");
591 break;
592
593 case EMR_RESTOREDC:
594 {
595 const EMRRESTOREDC *restoredc = (const EMRRESTOREDC *)emr;
596 trace("EMR_RESTOREDC: %d\n", restoredc->iRelative);
597
598 switch(++restore_no)
599 {
600 case 1:
601 ok(restoredc->iRelative == -1, "first restore %d\n", restoredc->iRelative);
602 check_dc_state(hdc, restore_no, -2, -2, 8192, 8192, 20, 20, 20479, 20478);
603 break;
604 case 2:
605 ok(restoredc->iRelative == -3, "second restore %d\n", restoredc->iRelative);
606 check_dc_state(hdc, restore_no, 0, 0, 16384, 16384, 0, 0, 17873, 17872);
607 break;
608 case 3:
609 ok(restoredc->iRelative == -2, "third restore %d\n", restoredc->iRelative);
610 check_dc_state(hdc, restore_no, -4, -4, 32767, 32767, 40, 40, 3276, 3276);
611 break;
612 }
613 ok(restore_no <= 3, "restore_no %d\n", restore_no);
614 save_state += restoredc->iRelative;
615 break;
616 }
617 case EMR_SELECTOBJECT:
618 {
619 const EMRSELECTOBJECT *selectobj = (const EMRSELECTOBJECT*)emr;
620 trace("EMR_SELECTOBJECT: %x\n",selectobj->ihObject);
621 select_no ++;
622 break;
623 }
624 case EMR_EOF:
625 ok(save_state == 0, "EOF save_state %d\n", save_state);
626 ok(select_no == 3, "Too many/few selects %i\n",select_no);
627 break;
628 }
629
630 SetLastError(0xdeadbeef);
631 ret = GetWorldTransform(hdc, &xform);
633 {
635 ok(ret, "GetWindowOrgEx error %u\n", GetLastError());
636 trace("window org (%d,%d)\n", pt.x, pt.y);
638 ok(ret, "GetViewportOrgEx error %u\n", GetLastError());
639 trace("vport org (%d,%d)\n", pt.x, pt.y);
641 ok(ret, "GetWindowExtEx error %u\n", GetLastError());
642 trace("window ext (%d,%d)\n", size.cx, size.cy);
644 ok(ret, "GetViewportExtEx error %u\n", GetLastError());
645 trace("vport ext (%d,%d)\n", size.cx, size.cy);
646 }
647 else
648 {
649 ok(ret, "GetWorldTransform error %u\n", GetLastError());
650 trace("eM11 %f, eM22 %f, eDx %f, eDy %f\n", xform.eM11, xform.eM22, xform.eDx, xform.eDy);
651 }
652
653 return 1;
654}
static const WCHAR *const ext[]
Definition: module.c:53
static char org[]
Definition: encode.c:7456
static void check_dc_state(HDC hdc, int restore_no, int wnd_org_x, int wnd_org_y, int wnd_ext_x, int wnd_ext_y, int vp_org_x, int vp_org_y, int vp_ext_x, int vp_ext_y)
Definition: metafile.c:438
Definition: parser.c:49
LONG iRelative
Definition: wingdi.h:2151
#define EMR_SAVEDC
Definition: wingdi.h:107
#define EMR_SELECTOBJECT
Definition: wingdi.h:111
#define EMR_RESTOREDC
Definition: wingdi.h:108
#define EMR_EOF
Definition: wingdi.h:88
#define EMR_SETWINDOWORGEX
Definition: wingdi.h:84
#define EMR_SETVIEWPORTORGEX
Definition: wingdi.h:86
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by test_SaveDC().

◆ set_rotation_xform()

static void set_rotation_xform ( XFORM out,
float  rad,
int  dx,
int  dy 
)
static

Definition at line 4037 of file metafile.c.

4038{
4039 out->eM11 = cosf(rad);
4040 out->eM12 = -1.f * sinf(rad);
4041 out->eM21 = sinf(rad);
4042 out->eM22 = cosf(rad);
4043 out->eDx = dx;
4044 out->eDy = dy;
4045}
_Check_return_ float __cdecl cosf(_In_ float x)
Definition: math.h:224
_Check_return_ float __cdecl sinf(_In_ float x)
Definition: math.h:233
GLint dy
Definition: linetemp.h:97
static FILE * out
Definition: regtests2xml.c:44

Referenced by enum_emf_WorldTransform(), and test_emf_WorldTransform().

◆ START_TEST()

START_TEST ( metafile  )

Definition at line 4289 of file metafile.c.

4290{
4292
4293 /* For enhanced metafiles (enhmfdrv) */
4296 test_SaveDC();
4306
4307 /* For win-format metafiles (mfdrv) */
4309 test_mf_Blank();
4318
4319 /* For metafile conversions */
4323
4324 test_gdiis();
4326}
static void test_mf_Graphics(void)
Definition: metafile.c:2251
static void test_emf_GradientFill(void)
Definition: metafile.c:3993
static void test_SetMetaFileBits(void)
Definition: metafile.c:2151
static void test_gdiis(void)
Definition: metafile.c:3580
static void test_ExtTextOutScale(void)
Definition: metafile.c:334
static void test_mf_Blank(void)
Definition: metafile.c:2068
static void test_mf_DCBrush(void)
Definition: metafile.c:2342
static void test_mf_GetPath(void)
Definition: metafile.c:2959
static void test_SetEnhMetaFileBits(void)
Definition: metafile.c:3626
static void test_SetWinMetaFileBits(void)
Definition: metafile.c:3215
static void test_CopyMetaFile(void)
Definition: metafile.c:2102
static void test_emf_WorldTransform(void)
Definition: metafile.c:4227
static void test_emf_paths(void)
Definition: metafile.c:3844
static void init_function_pointers(void)
Definition: metafile.c:52
static void test_emf_polybezier(void)
Definition: metafile.c:3677
static void test_ExtTextOut(void)
Definition: metafile.c:179
static void test_mf_conversions(void)
Definition: metafile.c:3072
static void test_emf_DCBrush(void)
Definition: metafile.c:2014
static void test_mf_ExtTextOut_on_path(void)
Definition: metafile.c:2389
static void test_emf_clipping(void)
Definition: metafile.c:2713
static void test_emf_BitBlt(void)
Definition: metafile.c:1937
static void test_GetWinMetaFileBits(void)
Definition: metafile.c:3548
static void test_mf_PatternBrush(void)
Definition: metafile.c:2296
static void test_mf_SaveDC(void)
Definition: metafile.c:865
static void test_mf_clipping(void)
Definition: metafile.c:2889
static void test_SaveDC(void)
Definition: metafile.c:656
static void test_emf_PolyPolyline(void)
Definition: metafile.c:3939
static void test_emf_ExtTextOut_on_path(void)
Definition: metafile.c:2423

◆ test_CopyMetaFile()

static void test_CopyMetaFile ( void  )
static

Definition at line 2102 of file metafile.c.

2103{
2104 HDC hdcMetafile;
2105 HMETAFILE hMetafile, hmf_copy;
2106 BOOL ret;
2107 char temp_path[MAX_PATH];
2108 char mf_name[MAX_PATH];
2109 INT type;
2110
2111 hdcMetafile = CreateMetaFileA(NULL);
2112 ok(hdcMetafile != 0, "CreateMetaFileA(NULL) error %d\n", GetLastError());
2113 trace("hdcMetafile %p\n", hdcMetafile);
2114
2115 hMetafile = CloseMetaFile(hdcMetafile);
2116 ok(hMetafile != 0, "CloseMetaFile error %d\n", GetLastError());
2117 type = GetObjectType(hMetafile);
2118 ok(type == OBJ_METAFILE, "CloseMetaFile created object with type %d\n", type);
2119
2120 if (compare_mf_bits (hMetafile, MF_BLANK_BITS, sizeof(MF_BLANK_BITS),
2121 "mf_blank") != 0)
2122 {
2123 dump_mf_bits(hMetafile, "mf_Blank");
2124 EnumMetaFile(0, hMetafile, mf_enum_proc, 0);
2125 }
2126
2128 GetTempFileNameA(temp_path, "wmf", 0, mf_name);
2129
2130 hmf_copy = CopyMetaFileA(hMetafile, mf_name);
2131 ok(hmf_copy != 0, "CopyMetaFile error %d\n", GetLastError());
2132
2133 type = GetObjectType(hmf_copy);
2134 ok(type == OBJ_METAFILE, "CopyMetaFile created object with type %d\n", type);
2135
2136 ret = DeleteMetaFile(hMetafile);
2137 ok( ret, "DeleteMetaFile(%p) error %d\n", hMetafile, GetLastError());
2138
2139 if (compare_mf_disk_bits(mf_name, MF_BLANK_BITS, sizeof(MF_BLANK_BITS), "mf_blank") != 0)
2140 {
2141 dump_mf_bits(hmf_copy, "mf_Blank");
2142 EnumMetaFile(0, hmf_copy, mf_enum_proc, 0);
2143 }
2144
2145 ret = DeleteMetaFile(hmf_copy);
2146 ok( ret, "DeleteMetaFile(%p) error %d\n", hmf_copy, GetLastError());
2147
2148 DeleteFileA(mf_name);
2149}
static POBJECT_TYPE GetObjectType(IN PCWSTR TypeName)
Definition: ObTypes.c:15
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2054
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static int compare_mf_disk_bits(LPCSTR name, const BYTE *bits, UINT bsize, const char *desc)
Definition: metafile.c:1629
static const unsigned char MF_BLANK_BITS[]
Definition: metafile.c:1031
char temp_path[MAX_PATH]
Definition: mspatcha.c:123
#define OBJ_METAFILE
Definition: objidl.idl:1417
HMETAFILE WINAPI CopyMetaFileA(_In_ HMETAFILE hmfSrc, _In_opt_ LPCSTR pszFile)

Referenced by START_TEST().

◆ test_emf_BitBlt()

static void test_emf_BitBlt ( void  )
static

Definition at line 1937 of file metafile.c.

1938{
1939 HDC hdcDisplay, hdcMetafile, hdcBitmap;
1940 HBITMAP hBitmap, hOldBitmap;
1941 HENHMETAFILE hMetafile;
1942#define BMP_DIM 4
1943 BITMAPINFOHEADER bmih =
1944 {
1945 sizeof(BITMAPINFOHEADER),
1946 BMP_DIM,/* biWidth */
1947 BMP_DIM,/* biHeight */
1948 1, /* biPlanes */
1949 24, /* biBitCount */
1950 BI_RGB, /* biCompression */
1951 0, /* biXPelsPerMeter */
1952 0, /* biYPelsPerMeter */
1953 0, /* biClrUsed */
1954 0, /* biClrImportant */
1955 };
1956 void *bits;
1957 XFORM xform;
1958 BOOL ret;
1959
1960 hdcDisplay = CreateDCA("DISPLAY", NULL, NULL, NULL);
1961 ok( hdcDisplay != 0, "CreateDCA error %d\n", GetLastError() );
1962
1963 hdcBitmap = CreateCompatibleDC(hdcDisplay);
1964 ok( hdcBitmap != 0, "CreateCompatibleDC failed\n" );
1965 ok(SetGraphicsMode(hdcBitmap, GM_ADVANCED), "SetGraphicsMode failed\n");
1966 bmih.biXPelsPerMeter = MulDiv(GetDeviceCaps(hdcDisplay, LOGPIXELSX), 100, 3937);
1967 bmih.biYPelsPerMeter = MulDiv(GetDeviceCaps(hdcDisplay, LOGPIXELSY), 100, 3937);
1968 hBitmap = CreateDIBSection(hdcDisplay, (const BITMAPINFO *)&bmih,
1969 DIB_RGB_COLORS, &bits, NULL, 0);
1970 hOldBitmap = SelectObject(hdcBitmap, hBitmap);
1971
1972 hdcMetafile = CreateEnhMetaFileA(hdcBitmap, NULL, NULL, NULL);
1973 ok( hdcMetafile != 0, "CreateEnhMetaFileA failed\n" );
1974
1975 /* First fill the bitmap DC with something recognizable, like BLACKNESS */
1976 ret = BitBlt(hdcBitmap, 0, 0, BMP_DIM, BMP_DIM, 0, 0, 0, BLACKNESS);
1977 ok( ret, "BitBlt(BLACKNESS) failed\n" );
1978
1979 ret = BitBlt(hdcMetafile, 0, 0, BMP_DIM, BMP_DIM, hdcBitmap, 0, 0, SRCCOPY);
1980 ok( ret, "BitBlt(SRCCOPY) failed\n" );
1981 ret = BitBlt(hdcMetafile, 0, 0, BMP_DIM, BMP_DIM, 0, 0, 0, WHITENESS);
1982 ok( ret, "BitBlt(WHITENESS) failed\n" );
1983
1984 ok(SetMapMode(hdcBitmap, MM_ANISOTROPIC), "SetMapMode failed\n");
1985 ok(SetWindowOrgEx(hdcBitmap, 0, 0, NULL), "SetWindowOrgEx failed\n");
1986 ok(SetWindowExtEx(hdcBitmap, 400, 400, NULL), "SetWindowExtEx failed\n");
1987 ok(SetViewportOrgEx(hdcBitmap, 0, 0, NULL), "SetViewportOrgEx failed\n");
1988 ok(SetViewportExtEx(hdcBitmap, BMP_DIM, BMP_DIM, NULL), "SetViewportExtEx failed\n");
1989 memset(&xform, 0, sizeof(xform));
1990 xform.eM11 = 0.5;
1991 xform.eM22 = 1.0;
1992 ok(SetWorldTransform(hdcBitmap, &xform), "SetWorldTransform failed\n");
1993
1994 ret = StretchBlt(hdcMetafile, 0, 0, BMP_DIM, BMP_DIM, hdcBitmap, 0, 0, 400, 400, SRCCOPY);
1995 ok( ret, "StretchBlt(SRCCOPY) failed\n" );
1996
1997 hMetafile = CloseEnhMetaFile(hdcMetafile);
1998 ok( hMetafile != 0, "CloseEnhMetaFile failed\n" );
1999
2000 if(compare_emf_bits(hMetafile, EMF_BITBLT, sizeof(EMF_BITBLT),
2001 "emf_BitBlt", FALSE) != 0)
2002 {
2003 dump_emf_bits(hMetafile, "emf_BitBlt");
2004 dump_emf_records(hMetafile, "emf_BitBlt");
2005 }
2006
2007 SelectObject(hdcBitmap, hOldBitmap);
2010 DeleteDC(hdcDisplay);
2011#undef BMP_DIM
2012}
static HBITMAP hBitmap
Definition: timezone.c:26
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
#define BI_RGB
Definition: precomp.h:56
#define bits
Definition: infblock.c:15
static HBITMAP
Definition: button.c:44
static const unsigned char EMF_BITBLT[]
Definition: metafile.c:1291
static void dump_emf_records(const HENHMETAFILE mf, const char *desc)
Definition: metafile.c:1692
static int compare_emf_bits(const HENHMETAFILE mf, const unsigned char *bits, UINT bsize, const char *desc, BOOL ignore_scaling)
Definition: metafile.c:1862
#define BMP_DIM
static void dump_emf_bits(const HENHMETAFILE mf, const char *desc)
Definition: metafile.c:1668
HDC hdcBitmap
Definition: solcreate.cpp:9
LONG biYPelsPerMeter
Definition: amvideo.idl:38
LONG biXPelsPerMeter
Definition: amvideo.idl:37
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
#define BLACKNESS
Definition: wingdi.h:323
int WINAPI SetMapMode(_In_ HDC, _In_ int)
#define DIB_RGB_COLORS
Definition: wingdi.h:367
int WINAPI SetGraphicsMode(_In_ HDC, _In_ int)
Definition: dc.c:1226
#define GM_ADVANCED
Definition: wingdi.h:865
#define WHITENESS
Definition: wingdi.h:337
BOOL WINAPI SetWindowOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:532
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:465
#define LOGPIXELSY
Definition: wingdi.h:719
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateDCA(_In_opt_ LPCSTR pszDriver, _In_opt_ LPCSTR pszDevice, _In_opt_ LPCSTR pszOutput, _In_opt_ const DEVMODEA *pdmInit)
BOOL WINAPI SetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:655
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI SetWindowExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define SRCCOPY
Definition: wingdi.h:333
#define LOGPIXELSX
Definition: wingdi.h:718
BOOL WINAPI SetWorldTransform(_In_ HDC, _In_ const XFORM *)
BOOL WINAPI DeleteDC(_In_ HDC)

Referenced by START_TEST().

◆ test_emf_clipping()

static void test_emf_clipping ( void  )
static

Definition at line 2713 of file metafile.c.

2714{
2715 static const RECT rc = { 0, 0, 100, 100 };
2716 RECT rc_clip = { 100, 100, 1024, 1024 };
2717 HWND hwnd;
2718 HDC hdc;
2719 HENHMETAFILE hemf;
2720 HRGN hrgn;
2721 INT ret;
2722 RECT rc_res, rc_sclip;
2723
2724 SetLastError(0xdeadbeef);
2726 ok(hdc != 0, "CreateEnhMetaFileA error %d\n", GetLastError());
2727
2728 /* Need to write something to the emf, otherwise Windows won't play it back */
2729 LineTo(hdc, 1, 1);
2730
2731 hrgn = CreateRectRgn(rc_clip.left, rc_clip.top, rc_clip.right, rc_clip.bottom);
2733 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
2734
2735 BeginPath(hdc);
2736 Rectangle(hdc, rc_clip.left, rc_clip.top, rc_clip.right, rc_clip.bottom);
2737 EndPath(hdc);
2739 ok(ret, "SelectClipPath error %d\n", GetLastError());
2740
2741 SetLastError(0xdeadbeef);
2742 hemf = CloseEnhMetaFile(hdc);
2743 ok(hemf != 0, "CloseEnhMetaFile error %d\n", GetLastError());
2744
2745 if (compare_emf_bits(hemf, EMF_CLIPPING, sizeof(EMF_CLIPPING),
2746 "emf_clipping", FALSE) != 0)
2747 {
2748 dump_emf_bits(hemf, "emf_clipping");
2749 dump_emf_records(hemf, "emf_clipping");
2750 }
2751
2753
2754 /* Win9x doesn't play EMFs on invisible windows */
2755 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP | WS_VISIBLE,
2756 0, 0, 200, 200, 0, 0, 0, NULL);
2757 ok(hwnd != 0, "CreateWindowExA error %d\n", GetLastError());
2758
2759 hdc = GetDC(hwnd);
2760
2761 ret = EnumEnhMetaFile(hdc, hemf, clip_emf_enum_proc, &rc_clip, &rc);
2762 ok(ret, "EnumEnhMetaFile error %d\n", GetLastError());
2763
2764 DeleteEnhMetaFile(hemf);
2765 ReleaseDC(hwnd, hdc);
2767
2769
2771 hrgn = CreateRectRgn(rc_sclip.left, rc_sclip.top, rc_sclip.right, rc_sclip.bottom);
2773 SetRect(&rc_res, -1, -1, -1, -1);
2774 ret = GetClipBox(hdc, &rc_res);
2775 ok(ret == SIMPLEREGION, "got %d\n", ret);
2776 ok(EqualRect(&rc_res, &rc_sclip), "expected %s, got %s\n", wine_dbgstr_rect(&rc_sclip),
2777 wine_dbgstr_rect(&rc_res));
2778
2779 OffsetRect(&rc_sclip, -100, -100);
2780 ret = OffsetClipRgn(hdc, -100, -100);
2781 ok(ret == SIMPLEREGION, "got %d\n", ret);
2782 SetRect(&rc_res, -1, -1, -1, -1);
2783 ret = GetClipBox(hdc, &rc_res);
2784 ok(ret == SIMPLEREGION, "got %d\n", ret);
2785 ok(EqualRect(&rc_res, &rc_sclip), "expected %s, got %s\n", wine_dbgstr_rect(&rc_sclip),
2786 wine_dbgstr_rect(&rc_res));
2787
2788 ret = IntersectClipRect(hdc, 0, 0, 100, 100);
2789 ok(ret == SIMPLEREGION || broken(ret == COMPLEXREGION) /* XP */, "got %d\n", ret);
2790 if (ret == COMPLEXREGION)
2791 {
2792 /* XP returns COMPLEXREGION although region contains only 1 rect */
2793 ret = GetClipRgn(hdc, hrgn);
2794 ok(ret == 1, "expected 1, got %d\n", ret);
2796 ok(ret == 1, "expected 1, got %d\n", ret);
2797 }
2798 SetRect(&rc_res, -1, -1, -1, -1);
2799 ret = GetClipBox(hdc, &rc_res);
2800 ok(ret == SIMPLEREGION, "got %d\n", ret);
2801 ok(EqualRect(&rc_res, &rc), "expected %s, got %s\n", wine_dbgstr_rect(&rc),
2802 wine_dbgstr_rect(&rc_res));
2803
2804 SetRect(&rc_sclip, 0, 0, 100, 50);
2805 ret = ExcludeClipRect(hdc, 0, 50, 100, 100);
2806 ok(ret == SIMPLEREGION || broken(ret == COMPLEXREGION) /* XP */, "got %d\n", ret);
2807 if (ret == COMPLEXREGION)
2808 {
2809 /* XP returns COMPLEXREGION although region contains only 1 rect */
2810 ret = GetClipRgn(hdc, hrgn);
2811 ok(ret == 1, "expected 1, got %d\n", ret);
2813 ok(ret == 1, "expected 1, got %d\n", ret);
2814 }
2815 SetRect(&rc_res, -1, -1, -1, -1);
2816 ret = GetClipBox(hdc, &rc_res);
2817 ok(ret == SIMPLEREGION, "got %d\n", ret);
2818 ok(EqualRect(&rc_res, &rc_sclip), "expected %s, got %s\n", wine_dbgstr_rect(&rc_sclip),
2819 wine_dbgstr_rect(&rc_res));
2820
2821 hemf = CloseEnhMetaFile(hdc);
2822 DeleteEnhMetaFile(hemf);
2824}
static int CALLBACK clip_emf_enum_proc(HDC hdc, HANDLETABLE *handle_table, const ENHMETARECORD *emr, int n_objs, LPARAM param)
Definition: metafile.c:2607
static const unsigned char EMF_CLIPPING[]
Definition: metafile.c:2549
static DWORD rgn_rect_count(HRGN hrgn)
Definition: metafile.c:67
#define WS_POPUP
Definition: pedump.c:616
#define WS_VISIBLE
Definition: pedump.c:620
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define COMPLEXREGION
Definition: wingdi.h:363
int WINAPI GetClipBox(_In_ HDC, _Out_ LPRECT)
int WINAPI IntersectClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI ExcludeClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI SelectClipPath(_In_ HDC, _In_ int)
#define RGN_AND
Definition: wingdi.h:356
#define SIMPLEREGION
Definition: wingdi.h:362
BOOL WINAPI EnumEnhMetaFile(_In_opt_ HDC, _In_ HENHMETAFILE, _In_ ENHMFENUMPROC, _In_opt_ PVOID, _In_opt_ LPCRECT)
int WINAPI OffsetClipRgn(_In_ HDC, _In_ int, _In_ int)
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
BOOL WINAPI EndPath(_In_ HDC)
BOOL WINAPI BeginPath(_In_ HDC hdc)
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define SM_CYSCREEN
Definition: winuser.h:960
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define SM_CXSCREEN
Definition: winuser.h:959
BOOL WINAPI DestroyWindow(_In_ HWND)
int WINAPI GetSystemMetrics(_In_ int)

Referenced by START_TEST().

◆ test_emf_DCBrush()

static void test_emf_DCBrush ( void  )
static

Definition at line 2014 of file metafile.c.

2015{
2016 HDC hdcMetafile;
2017 HENHMETAFILE hMetafile;
2018 HBRUSH hBrush;
2019 HPEN hPen;
2020 BOOL ret;
2022
2023 if (!pSetDCBrushColor || !pSetDCPenColor)
2024 {
2025 win_skip( "SetDCBrush/PenColor not supported\n" );
2026 return;
2027 }
2028
2029 hdcMetafile = CreateEnhMetaFileA(GetDC(0), NULL, NULL, NULL);
2030 ok( hdcMetafile != 0, "CreateEnhMetaFileA failed\n" );
2031
2032 hBrush = SelectObject(hdcMetafile, GetStockObject(DC_BRUSH));
2033 ok(hBrush != 0, "SelectObject error %d.\n", GetLastError());
2034
2035 hPen = SelectObject(hdcMetafile, GetStockObject(DC_PEN));
2036 ok(hPen != 0, "SelectObject error %d.\n", GetLastError());
2037
2038 color = pSetDCBrushColor( hdcMetafile, RGB(0x55,0x55,0x55) );
2039 ok( color == 0xffffff, "SetDCBrushColor returned %x\n", color );
2040
2041 color = pSetDCPenColor( hdcMetafile, RGB(0x33,0x44,0x55) );
2042 ok( color == 0, "SetDCPenColor returned %x\n", color );
2043
2044 Rectangle( hdcMetafile, 10, 10, 20, 20 );
2045
2046 color = pSetDCBrushColor( hdcMetafile, RGB(0x12,0x34,0x56) );
2047 ok( color == 0x555555, "SetDCBrushColor returned %x\n", color );
2048
2049 hMetafile = CloseEnhMetaFile(hdcMetafile);
2050 ok( hMetafile != 0, "CloseEnhMetaFile failed\n" );
2051
2052 if (compare_emf_bits (hMetafile, EMF_DCBRUSH_BITS, sizeof(EMF_DCBRUSH_BITS),
2053 "emf_DC_Brush", FALSE ) != 0)
2054 {
2055 dump_emf_bits(hMetafile, "emf_DC_Brush");
2056 dump_emf_records(hMetafile, "emf_DC_Brush");
2057 }
2058 ret = DeleteEnhMetaFile(hMetafile);
2059 ok( ret, "DeleteEnhMetaFile error %d\n", GetLastError());
2060 ret = DeleteObject(hBrush);
2061 ok( ret, "DeleteObject(HBRUSH) error %d\n", GetLastError());
2062 ret = DeleteObject(hPen);
2063 ok( ret, "DeleteObject(HPEN) error %d\n", GetLastError());
2064}
GLuint color
Definition: glext.h:6243
static const unsigned char EMF_DCBRUSH_BITS[]
Definition: metafile.c:1372
DWORD COLORREF
Definition: windef.h:300
HGDIOBJ WINAPI GetStockObject(_In_ int)

Referenced by START_TEST().

◆ test_emf_ExtTextOut_on_path()

static void test_emf_ExtTextOut_on_path ( void  )
static

Definition at line 2423 of file metafile.c.

2424{
2425 HWND hwnd;
2426 HDC hdcDisplay, hdcMetafile;
2427 HENHMETAFILE hMetafile;
2428 BOOL ret;
2429 LOGFONTA lf;
2430 HFONT hFont;
2431 static const INT dx[4] = { 3, 5, 8, 12 };
2432
2433 /* Win9x doesn't play EMFs on invisible windows */
2434 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP | WS_VISIBLE,
2435 0, 0, 200, 200, 0, 0, 0, NULL);
2436 ok(hwnd != 0, "CreateWindowExA error %d\n", GetLastError());
2437
2438 hdcDisplay = GetDC(hwnd);
2439 ok(hdcDisplay != 0, "GetDC error %d\n", GetLastError());
2440
2441 /* with default font */
2442 ret = BeginPath(hdcDisplay);
2443 ok(ret, "BeginPath error %d\n", GetLastError());
2444
2445 ret = ExtTextOutA(hdcDisplay, 11, 22, 0, NULL, "Test", 4, dx);
2446 ok(ret, "ExtTextOut error %d\n", GetLastError());
2447
2448 ret = EndPath(hdcDisplay);
2449 ok(ret, "EndPath error %d\n", GetLastError());
2450
2451 ret = GetPath(hdcDisplay, NULL, NULL, 0);
2452 ok(!ret, "expected 0, got %d\n", ret);
2453
2454 hdcMetafile = CreateEnhMetaFileA(hdcDisplay, NULL, NULL, NULL);
2455 ok(hdcMetafile != 0, "CreateEnhMetaFileA error %d\n", GetLastError());
2456
2457 ret = BeginPath(hdcMetafile);
2458 ok(ret, "BeginPath error %d\n", GetLastError());
2459
2460 ret = ExtTextOutA(hdcMetafile, 11, 22, 0, NULL, "Test", 4, dx);
2461 ok(ret, "ExtTextOut error %d\n", GetLastError());
2462
2463 ret = EndPath(hdcMetafile);
2464 ok(ret, "EndPath error %d\n", GetLastError());
2465
2466 ret = GetPath(hdcMetafile, NULL, NULL, 0);
2467 ok(!ret, "expected 0, got %d\n", ret);
2468
2469 hMetafile = CloseEnhMetaFile(hdcMetafile);
2470 ok(hMetafile != 0, "CloseEnhMetaFile error %d\n", GetLastError());
2471
2472 /* this doesn't succeed yet: EMF has correct size, all EMF records
2473 * are there, but their contents don't match for different reasons.
2474 */
2476 "emf_TextOut_on_path", FALSE) != 0)
2477 {
2478 dump_emf_bits(hMetafile, "emf_TextOut_on_path");
2479 dump_emf_records(hMetafile, "emf_TextOut_on_path");
2480 }
2481
2482 ret = DeleteEnhMetaFile(hMetafile);
2483 ok(ret, "DeleteEnhMetaFile error %d\n", GetLastError());
2484
2485 /* with outline font */
2486 memset(&lf, 0, sizeof(lf));
2489 lf.lfWeight = FW_DONTCARE;
2490 lf.lfHeight = 7;
2492 lstrcpyA(lf.lfFaceName, "Tahoma");
2494 ok(hFont != 0, "CreateFontIndirectA error %d\n", GetLastError());
2495 hFont = SelectObject(hdcDisplay, hFont);
2496
2497 ret = BeginPath(hdcDisplay);
2498 ok(ret, "BeginPath error %d\n", GetLastError());
2499
2500 ret = ExtTextOutA(hdcDisplay, 11, 22, 0, NULL, "Test", 4, dx);
2501 ok(ret, "ExtTextOut error %d\n", GetLastError());
2502
2503 ret = EndPath(hdcDisplay);
2504 ok(ret, "EndPath error %d\n", GetLastError());
2505
2506 ret = GetPath(hdcDisplay, NULL, NULL, 0);
2507 ok(ret != 0, "expected != 0\n");
2508
2509 SelectObject(hdcDisplay, hFont);
2510
2511 hdcMetafile = CreateEnhMetaFileA(hdcDisplay, NULL, NULL, NULL);
2512 ok(hdcMetafile != 0, "CreateEnhMetaFileA error %d\n", GetLastError());
2513
2514 hFont = SelectObject(hdcMetafile, hFont);
2515
2516 ret = BeginPath(hdcMetafile);
2517 ok(ret, "BeginPath error %d\n", GetLastError());
2518
2519 ret = ExtTextOutA(hdcMetafile, 11, 22, 0, NULL, "Test", 4, dx);
2520 ok(ret, "ExtTextOut error %d\n", GetLastError());
2521
2522 ret = EndPath(hdcMetafile);
2523 ok(ret, "EndPath error %d\n", GetLastError());
2524
2525 ret = GetPath(hdcMetafile, NULL, NULL, 0);
2526 ok(!ret, "expected 0, got %d\n", ret);
2527
2528 hFont = SelectObject(hdcMetafile, hFont);
2530
2531 hMetafile = CloseEnhMetaFile(hdcMetafile);
2532 ok(hMetafile != 0, "CloseEnhMetaFile error %d\n", GetLastError());
2533
2535 "emf_TextOut_on_path", FALSE) != 0)
2536 {
2537 dump_emf_bits(hMetafile, "emf_TextOut_outline_on_path");
2538 dump_emf_records(hMetafile, "emf_TextOut_outline_on_path");
2539 }
2540
2541 ret = DeleteEnhMetaFile(hMetafile);
2542 ok(ret, "DeleteEnhMetaFile error %d\n", GetLastError());
2543
2544 ret = ReleaseDC(hwnd, hdcDisplay);
2545 ok(ret, "ReleaseDC error %d\n", GetLastError());
2547}
HFONT hFont
Definition: main.c:53
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static const unsigned char EMF_TEXTOUT_ON_PATH_BITS[]
Definition: metafile.c:1094
static const unsigned char EMF_TEXTOUT_OUTLINE_ON_PATH_BITS[]
Definition: metafile.c:1129
BYTE lfClipPrecision
Definition: dimm.idl:52
BYTE lfQuality
Definition: dimm.idl:53
LONG lfHeight
Definition: dimm.idl:42
BYTE lfCharSet
Definition: dimm.idl:50
LONG lfWeight
Definition: dimm.idl:46
#define FW_DONTCARE
Definition: wingdi.h:368
HFONT WINAPI CreateFontIndirectA(_In_ const LOGFONTA *)
#define DEFAULT_QUALITY
Definition: wingdi.h:436
BOOL WINAPI ExtTextOutA(_In_ HDC hdc, _In_ int x, _In_ int y, _In_ UINT options, _In_opt_ const RECT *lprect, _In_reads_opt_(c) LPCSTR lpString, _In_ UINT c, _In_reads_opt_(c) const INT *lpDx)
#define ANSI_CHARSET
Definition: wingdi.h:383
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426
int WINAPI GetPath(_In_ HDC hdc, _Out_writes_opt_(cpt) LPPOINT apt, _Out_writes_opt_(cpt) LPBYTE aj, int cpt)

Referenced by START_TEST().

◆ test_emf_GradientFill()

static void test_emf_GradientFill ( void  )
static

Definition at line 3993 of file metafile.c.

3994{
3995 HDC mf;
3996 HENHMETAFILE hemf;
3997 TRIVERTEX v[] =
3998 {
3999 { 1, 10, 0xff00, 0x8000, 0x0000, 0x8001 },
4000 { 200, 210, 0x0000, 0x0000, 0xff00, 0xff00 },
4001 { 180, 190, 0x1234, 0x5678, 0x9abc, 0xdef0 },
4002 { 300, 310, 0xff00, 0xff00, 0xff00, 0x0000 },
4003 { 400, 410, 0xff00, 0xff00, 0xff00, 0x0000 }
4004 };
4005 GRADIENT_TRIANGLE tri[] = { { 0, 1, 2 }, { 3, 1, 0 } };
4006 BOOL ret;
4007
4008 mf = CreateEnhMetaFileA( GetDC( 0 ), NULL, NULL, NULL );
4009 ok( mf != 0, "CreateEnhMetaFileA error %d\n", GetLastError() );
4010
4011 /* Don't test the GRADIENT_FILL_RECT_ modes since a Windows bug
4012 * means it allocates three mesh indices rather than two per
4013 * rectangle. This results in uninitialised values being written
4014 * to the EMF which is rather difficult to test against.
4015 *
4016 * Note also that the final vertex here is not required, yet it is
4017 * written to the EMF, but is not considered in the bounds
4018 * calculation.
4019 */
4020 ret = GdiGradientFill( mf, v, sizeof(v) / sizeof(v[0]), tri, sizeof(tri) / sizeof(tri[0]),
4021 GRADIENT_FILL_TRIANGLE );
4022 ok( ret, "GradientFill\n" );
4023
4024 hemf = CloseEnhMetaFile( mf );
4025 ok( hemf != 0, "CloseEnhMetaFile error %d\n", GetLastError() );
4026
4028 "emf_GradientFill", FALSE ) != 0)
4029 {
4030 dump_emf_bits( hemf, "emf_GradientFill" );
4031 dump_emf_records( hemf, "emf_GradientFill" );
4032 }
4033
4034 DeleteEnhMetaFile( hemf );
4035}
const GLdouble * v
Definition: gl.h:2040
BOOL WINAPI GdiGradientFill(HDC hdc, TRIVERTEX *vert_array, ULONG nvert, void *grad_array, ULONG ngrad, ULONG mode)
static const unsigned char EMF_GRADIENTFILL_BITS[]
Definition: metafile.c:1515

Referenced by START_TEST().

◆ test_emf_paths()

static void test_emf_paths ( void  )
static

Definition at line 3844 of file metafile.c.

3845{
3846 POINT pts[9] = {{10, 10}, {20, 10}, {10, 20}, {20, 20}, {30, 30}, {40, 20}, {20, 30}, {20, 20}, {20, 10}};
3847 DWORD counts[2] = {2, 2};
3850 HDC hdcMetafile;
3851 HENHMETAFILE hemf;
3852 BOOL ret;
3853 int size;
3854
3855 SetLastError(0xdeadbeef);
3856 hdcMetafile = CreateEnhMetaFileA(GetDC(0), NULL, NULL, NULL);
3857 ok(hdcMetafile != 0, "CreateEnhMetaFileA error %d\n", GetLastError());
3858
3859 ret = BeginPath(hdcMetafile);
3860 ok(ret, "BeginPath error %d\n", GetLastError());
3861 ret = MoveToEx(hdcMetafile, 50, 50, NULL);
3862 ok( ret, "MoveToEx error %d.\n", GetLastError());
3863 ret = LineTo(hdcMetafile, 50, 150);
3864 ok( ret, "LineTo error %d.\n", GetLastError());
3865 ret = LineTo(hdcMetafile, 150, 150);
3866 ok( ret, "LineTo error %d.\n", GetLastError());
3867 ret = LineTo(hdcMetafile, 150, 50);
3868 ok( ret, "LineTo error %d.\n", GetLastError());
3869 ret = LineTo(hdcMetafile, 50, 50);
3870 ok( ret, "LineTo error %d.\n", GetLastError());
3871 Rectangle(hdcMetafile, 10, 10, 20, 20);
3872 Arc(hdcMetafile, 21, 21, 39, 29, 39, 29, 21, 21);
3873 ArcTo(hdcMetafile, 23, 23, 37, 27, 37, 27, 23, 23);
3874 Chord(hdcMetafile, 21, 21, 39, 29, 39, 29, 21, 21);
3875 Pie(hdcMetafile, 21, 21, 39, 29, 39, 29, 21, 21);
3876 Ellipse(hdcMetafile, 10, 10, 20, 20);
3877 RoundRect(hdcMetafile, 10, 10, 20, 20, 3, 5);
3878 Polyline(hdcMetafile, pts, 4);
3879 PolylineTo(hdcMetafile, pts, 4);
3880 PolyPolyline(hdcMetafile, pts, counts, 2);
3881 PolyDraw(hdcMetafile, pts, types, 9);
3882 AngleArc(hdcMetafile, 37, 36, 23, 90, 180);
3883 EndPath(hdcMetafile);
3884
3885 size = GetPath(hdcMetafile, NULL, NULL, 0);
3886 ok( size == 112, "GetPath returned %d.\n", size);
3887
3888 ret = StrokeAndFillPath( hdcMetafile );
3889 ok( ret, "StrokeAndFillPath failed err %d\n", GetLastError() );
3890 ret = StrokeAndFillPath( hdcMetafile );
3891 ok( !ret, "StrokeAndFillPath succeeded\n" );
3892
3893 hemf = CloseEnhMetaFile(hdcMetafile);
3894 ok(hemf != 0, "CloseEnhMetaFile error %d\n", GetLastError());
3895
3896 if (compare_emf_bits(hemf, EMF_PATH_BITS, sizeof(EMF_PATH_BITS), "test_emf_paths", FALSE) != 0)
3897 {
3898 dump_emf_bits(hemf, "test_emf_paths");
3899 dump_emf_records(hemf, "test_emf_paths");
3900 }
3901
3902 DeleteEnhMetaFile(hemf);
3903
3904 SetLastError(0xdeadbeef);
3905 hdcMetafile = CreateEnhMetaFileA(GetDC(0), NULL, NULL, NULL);
3906 ok(hdcMetafile != 0, "CreateEnhMetaFileA error %d\n", GetLastError());
3907
3908 ret = BeginPath(hdcMetafile);
3909 ok( ret, "BeginPath failed error %d\n", GetLastError() );
3910 ret = CloseFigure(hdcMetafile);
3911 ok( ret, "CloseFigure failed error %d\n", GetLastError() );
3912 ret = BeginPath(hdcMetafile);
3913 ok( ret, "BeginPath failed error %d\n", GetLastError() );
3914 ret = EndPath(hdcMetafile);
3915 ok( ret, "EndPath failed error %d\n", GetLastError() );
3916 ret = EndPath(hdcMetafile);
3917 ok( !ret, "EndPath succeeded\n" );
3918 ret = CloseFigure(hdcMetafile);
3919 ok( !ret, "CloseFigure succeeded\n" );
3920 ret = BeginPath(hdcMetafile);
3921 ok( ret, "BeginPath failed error %d\n", GetLastError() );
3922 ret = AbortPath(hdcMetafile);
3923 ok( ret, "AbortPath failed error %d\n", GetLastError() );
3924 ret = AbortPath(hdcMetafile);
3925 ok( ret, "AbortPath failed error %d\n", GetLastError() );
3926
3927 hemf = CloseEnhMetaFile(hdcMetafile);
3928 ok(hemf != 0, "CloseEnhMetaFile error %d\n", GetLastError());
3929
3930 if (compare_emf_bits(hemf, EMF_EMPTY_PATH_BITS, sizeof(EMF_EMPTY_PATH_BITS), "empty path", FALSE) != 0)
3931 {
3932 dump_emf_bits(hemf, "empty path");
3933 dump_emf_records(hemf, "empty path");
3934 }
3935
3936 DeleteEnhMetaFile(hemf);
3937}
Definition: arc.h:55
static const unsigned char EMF_PATH_BITS[]
Definition: metafile.c:3716
static const unsigned char EMF_EMPTY_PATH_BITS[]
Definition: metafile.c:3815
Definition: cmds.c:130
BOOL WINAPI ArcTo(_In_ HDC hdc, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom, _In_ INT xRadial1, _In_ INT yRadial1, _In_ INT xRadial2, _In_ INT yRadial2)
Definition: arc.c:79
BOOL WINAPI Chord(_In_ HDC hdc, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom, _In_ INT xRadial1, _In_ INT yRadial1, _In_ INT xRadial2, _In_ INT yRadial2)
Definition: arc.c:119
BOOL WINAPI Polyline(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_ int cpt)
BOOL WINAPI Ellipse(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI PolylineTo(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_ DWORD cpt)
Definition: painting.c:354
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
#define PT_LINETO
Definition: wingdi.h:885
#define PT_CLOSEFIGURE
Definition: wingdi.h:887
#define PT_MOVETO
Definition: wingdi.h:884
BOOL WINAPI StrokeAndFillPath(_In_ HDC)
#define PT_BEZIERTO
Definition: wingdi.h:886
BOOL WINAPI RoundRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI PolyDraw(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_reads_(cpt) const BYTE *aj, _In_ int cpt)
BOOL WINAPI AngleArc(_In_ HDC hdc, _In_ INT x, _In_ INT y, _In_ DWORD dwRadius, _In_ FLOAT eStartAngle, _In_ FLOAT eSweepAngle)
Definition: arc.c:49
BOOL WINAPI PolyPolyline(_In_ HDC hdc, _In_ const POINT *apt, _In_reads_(csz) const DWORD *asz, _In_ DWORD csz)
BOOL WINAPI CloseFigure(_In_ HDC hdc)
BOOL WINAPI AbortPath(_In_ HDC hdc)
BOOL WINAPI Pie(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by START_TEST().

◆ test_emf_polybezier()

static void test_emf_polybezier ( void  )
static

Definition at line 3677 of file metafile.c.

3678{
3679 HDC hdcMetafile;
3680 HENHMETAFILE hemf;
3681 POINT pts[4];
3682 BOOL ret;
3683
3684 SetLastError(0xdeadbeef);
3685 hdcMetafile = CreateEnhMetaFileA(GetDC(0), NULL, NULL, NULL);
3686 ok(hdcMetafile != 0, "CreateEnhMetaFileA error %d\n", GetLastError());
3687
3688 pts[0].x = pts[0].y = 10;
3689 pts[1].x = pts[1].y = 20;
3690 pts[2].x = pts[2].y = 15;
3691 pts[3].x = pts[3].y = 25;
3692 ret = PolyBezierTo(hdcMetafile, pts, 3); /* EMR_POLYBEZIERTO16 */
3693 ok( ret, "PolyBezierTo failed\n" );
3694 ret = PolyBezier(hdcMetafile, pts, 4); /* EMR_POLYBEZIER16 */
3695 ok( ret, "PolyBezier failed\n" );
3696
3697 pts[0].x = pts[0].y = 32769;
3698 ret = PolyBezier(hdcMetafile, pts, 4); /* EMR_POLYBEZIER */
3699 ok( ret, "PolyBezier failed\n" );
3700 ret = PolyBezierTo(hdcMetafile, pts, 3); /* EMR_POLYBEZIERTO */
3701 ok( ret, "PolyBezierTo failed\n" );
3702
3703 hemf = CloseEnhMetaFile(hdcMetafile);
3704 ok(hemf != 0, "CloseEnhMetaFile error %d\n", GetLastError());
3705
3707 "emf_Bezier", FALSE) != 0)
3708 {
3709 dump_emf_bits(hemf, "emf_Bezier");
3710 dump_emf_records(hemf, "emf_Bezier");
3711 }
3712
3713 DeleteEnhMetaFile(hemf);
3714}
static const unsigned char EMF_BEZIER_BITS[]
Definition: metafile.c:1417
BOOL WINAPI PolyBezier(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_ DWORD cpt)
Definition: painting.c:263
BOOL WINAPI PolyBezierTo(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_ DWORD cpt)
Definition: painting.c:281

Referenced by START_TEST().

◆ test_emf_PolyPolyline()

static void test_emf_PolyPolyline ( void  )
static

Definition at line 3939 of file metafile.c.

3940{
3941 HDC hdcMetafile;
3942 HENHMETAFILE hemf;
3943 POINT pts[4] = {{10, 20}, {100, 200}, {0x9000,300}, {400, 500}};
3944 DWORD counts[2];
3945 BOOL ret;
3946
3947 SetLastError(0xdeadbeef);
3948 hdcMetafile = CreateEnhMetaFileA(GetDC(0), NULL, NULL, NULL);
3949 ok(hdcMetafile != 0, "CreateEnhMetaFileA error %d\n", GetLastError());
3950
3951 ret = PolyPolyline(hdcMetafile, NULL, NULL, 0);
3952 ok( !ret, "PolyPolyline\n" );
3953
3954 SetLastError( 0xdeadbeef );
3955 counts[0] = 0;
3956 counts[1] = 1;
3957 ret = PolyPolyline(hdcMetafile, pts, counts, 2);
3958 ok( !ret, "PolyPolyline\n" );
3959 ok( GetLastError() == ERROR_INVALID_PARAMETER, "gle %d\n", GetLastError() );
3960
3961 SetLastError( 0xdeadbeef );
3962 counts[0] = 1;
3963 counts[1] = 1;
3964 ret = PolyPolyline(hdcMetafile, pts, counts, 2);
3965 ok( !ret, "PolyPolyline\n" );
3966 ok( GetLastError() == ERROR_INVALID_PARAMETER, "gle %d\n", GetLastError() );
3967
3968 SetLastError( 0xdeadbeef );
3969 counts[0] = 2;
3970 counts[1] = 1;
3971 ret = PolyPolyline(hdcMetafile, pts, counts, 2);
3972 ok( !ret, "PolyPolyline\n" );
3973 ok( GetLastError() == ERROR_INVALID_PARAMETER, "gle %d\n", GetLastError() );
3974
3975 counts[0] = 2;
3976 counts[1] = 2;
3977 ret = PolyPolyline(hdcMetafile, pts, counts, 2);
3978 ok( ret, "PolyPolyline\n" );
3979
3980 hemf = CloseEnhMetaFile(hdcMetafile);
3981 ok(hemf != 0, "CloseEnhMetaFile error %d\n", GetLastError());
3982
3984 "emf_PolyPolyline", FALSE) != 0)
3985 {
3986 dump_emf_bits(hemf, "emf_PolyPolyline");
3987 dump_emf_records(hemf, "emf_PolyPolyline");
3988 }
3989
3990 DeleteEnhMetaFile(hemf);
3991}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static const unsigned char EMF_POLYPOLYLINE_BITS[]
Definition: metafile.c:1462

Referenced by START_TEST().

◆ test_emf_WorldTransform()

static void test_emf_WorldTransform ( void  )
static

Definition at line 4227 of file metafile.c.

4228{
4229 HDC hdcMetafile, hdc;
4230 HWND hwnd;
4231 HENHMETAFILE hemf;
4232 XFORM xform;
4233 BOOL ret;
4234 RECT rect = { 0, 0, 100, 100 };
4235 int i;
4237 { "normal", FALSE, TRUE },
4238 { "playback and modify", TRUE, TRUE },
4239 { "manual modify", TRUE, FALSE }
4240 };
4241
4242 for(i = 0; i < sizeof(test_data) / sizeof(*test_data); ++i)
4243 {
4244 hdcMetafile = CreateEnhMetaFileA(GetDC(0), NULL, NULL, NULL);
4245 ok(hdcMetafile != 0, "CreateEnhMetaFileA error %d\n", GetLastError());
4246
4247 ret = SetGraphicsMode(hdcMetafile, GM_ADVANCED);
4248 ok(ret == TRUE, "SetGraphicsMode failed\n");
4249
4250 set_rotation_xform(&xform, M_PI / 4.f, 2, 3);
4251 ret = SetWorldTransform(hdcMetafile, &xform); /* EMR_SETWORLDTRANSFORM */
4252 ok(ret == TRUE, "SetWorldTransform failed\n");
4253
4254 set_rotation_xform(&xform, M_PI / 2.f, -2, -3);
4255 ret = ModifyWorldTransform(hdcMetafile, &xform, MWT_LEFTMULTIPLY); /* EMR_MODIFYWORLDTRANSFORM */
4256 ok(ret == TRUE, "ModifyWorldTransform failed\n");
4257
4258 set_rotation_xform(&xform, M_PI / 3.f, -2, 3);
4259 ret = ModifyWorldTransform(hdcMetafile, &xform, MWT_LEFTMULTIPLY); /* EMR_MODIFYWORLDTRANSFORM */
4260 ok(ret == TRUE, "ModifyWorldTransform failed\n");
4261
4262 set_rotation_xform(&xform, M_PI, 2, -3);
4263 ret = ModifyWorldTransform(hdcMetafile, &xform, MWT_RIGHTMULTIPLY); /* EMR_MODIFYWORLDTRANSFORM */
4264 ok(ret == TRUE, "ModifyWorldTransform failed\n");
4265
4266 ret = LineTo(hdcMetafile, 1, 1);
4267 ok(ret == TRUE, "LineTo failed\n");
4268
4269 hemf = CloseEnhMetaFile(hdcMetafile);
4270 ok(hemf != 0, "CloseEnhMetaFile error %d\n", GetLastError());
4271
4272 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP | WS_VISIBLE,
4273 0, 0, 200, 200, 0, 0, 0, NULL);
4274 ok(hwnd != 0, "CreateWindowExA error %d\n", GetLastError());
4275
4276 hdc = GetDC(hwnd);
4277 ok(hdc != 0, "GetDC failed\n");
4278
4280 ok(ret == TRUE, "EnumEnhMetaFile failed: %u\n", GetLastError());
4281
4282 ReleaseDC(hwnd, hdc);
4284
4285 DeleteEnhMetaFile(hemf);
4286 }
4287}
static INT CALLBACK enum_emf_WorldTransform(HDC hdc, HANDLETABLE *ht, const ENHMETARECORD *emr, INT nobj, LPARAM param)
Definition: metafile.c:4069

Referenced by START_TEST().

◆ test_ExtTextOut()

static void test_ExtTextOut ( void  )
static

Definition at line 179 of file metafile.c.

180{
181 HWND hwnd;
182 HDC hdcDisplay, hdcMetafile;
183 HENHMETAFILE hMetafile;
184 HFONT hFont;
185 static const char text[] = "Simple text to test ExtTextOut on metafiles";
186 INT i, len, dx[256];
187 static const RECT rc = { 0, 0, 100, 100 };
188 BOOL ret;
189
190 assert(sizeof(dx)/sizeof(dx[0]) >= lstrlenA(text));
191
192 /* Win9x doesn't play EMFs on invisible windows */
193 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP | WS_VISIBLE,
194 0, 0, 200, 200, 0, 0, 0, NULL);
195 ok(hwnd != 0, "CreateWindowExA error %d\n", GetLastError());
196
197 hdcDisplay = GetDC(hwnd);
198 ok(hdcDisplay != 0, "GetDC error %d\n", GetLastError());
199
200 trace("hdcDisplay %p\n", hdcDisplay);
201
202 SetMapMode(hdcDisplay, MM_TEXT);
203
204 memset(&orig_lf, 0, sizeof(orig_lf));
205
209 orig_lf.lfHeight = 7;
211 lstrcpyA(orig_lf.lfFaceName, "Arial");
213 ok(hFont != 0, "CreateFontIndirectA error %d\n", GetLastError());
214
215 hFont = SelectObject(hdcDisplay, hFont);
216
217 len = lstrlenA(text);
218 for (i = 0; i < len; i++)
219 {
220 ret = GetCharWidthA(hdcDisplay, text[i], text[i], &dx[i]);
221 ok( ret, "GetCharWidthA error %d\n", GetLastError());
222 }
223 hFont = SelectObject(hdcDisplay, hFont);
224
225 hdcMetafile = CreateEnhMetaFileA(hdcDisplay, NULL, NULL, NULL);
226 ok(hdcMetafile != 0, "CreateEnhMetaFileA error %d\n", GetLastError());
227
228 trace("hdcMetafile %p\n", hdcMetafile);
229
230 ok(GetDeviceCaps(hdcMetafile, TECHNOLOGY) == DT_RASDISPLAY,
231 "GetDeviceCaps(TECHNOLOGY) has to return DT_RASDISPLAY for a display based EMF\n");
232
233 hFont = SelectObject(hdcMetafile, hFont);
234
235 /* 1. pass NULL lpDx */
236 ret = ExtTextOutA(hdcMetafile, 0, 0, 0, &rc, text, lstrlenA(text), NULL);
237 ok( ret, "ExtTextOutA error %d\n", GetLastError());
238
239 /* 2. pass custom lpDx */
240 ret = ExtTextOutA(hdcMetafile, 0, 20, 0, &rc, text, lstrlenA(text), dx);
241 ok( ret, "ExtTextOutA error %d\n", GetLastError());
242
243 /* 3. pass NULL lprc */
244 ret = ExtTextOutA(hdcMetafile, 0, 40, 0, NULL, text, lstrlenA(text), NULL);
245 ok( ret, "ExtTextOutA error %d\n", GetLastError());
246
247 /* 4. test with unmatched BeginPath/EndPath calls */
248 ret = BeginPath(hdcMetafile);
249 ok( ret, "BeginPath error %d\n", GetLastError());
250 ret = BeginPath(hdcMetafile);
251 ok( ret, "BeginPath error %d\n", GetLastError());
252 ret = EndPath(hdcMetafile);
253 ok( ret, "BeginPath error %d\n", GetLastError());
254 ret = ExtTextOutA(hdcMetafile, 0, 60, 0, NULL, text, lstrlenA(text), NULL);
255 ok( ret, "ExtTextOutA error %d\n", GetLastError());
256
257 hFont = SelectObject(hdcMetafile, hFont);
259 ok( ret, "DeleteObject error %d\n", GetLastError());
260
261 hMetafile = CloseEnhMetaFile(hdcMetafile);
262 ok(hMetafile != 0, "CloseEnhMetaFile error %d\n", GetLastError());
263
264 ok(!GetObjectType(hdcMetafile), "CloseEnhMetaFile has to destroy metafile hdc\n");
265
266 ret = PlayEnhMetaFile(hdcDisplay, hMetafile, &rc);
267 ok( ret, "PlayEnhMetaFile error %d\n", GetLastError());
268
270 SetBkColor(hdcDisplay, RGB(0xff, 0, 0));
271 SetTextColor(hdcDisplay, RGB(0, 0xff, 0));
272 SetROP2(hdcDisplay, R2_NOT);
273 SetArcDirection(hdcDisplay, AD_CLOCKWISE);
274 SetPolyFillMode(hdcDisplay, WINDING);
275 SetStretchBltMode(hdcDisplay, HALFTONE);
276
277 if(pSetRelAbs) pSetRelAbs(hdcDisplay, RELATIVE);
278 SetBkMode(hdcDisplay, OPAQUE);
279
280 ret = EnumEnhMetaFile(hdcDisplay, hMetafile, eto_emf_enum_proc, dx, &rc);
281 ok( ret, "EnumEnhMetaFile error %d\n", GetLastError());
282
284 "text align %08x\n", GetTextAlign(hdcDisplay));
285 ok( GetBkColor(hdcDisplay) == RGB(0xff, 0, 0), "bk color %08x\n", GetBkColor(hdcDisplay));
286 ok( GetTextColor(hdcDisplay) == RGB(0, 0xff, 0), "text color %08x\n", GetTextColor(hdcDisplay));
287 ok( GetROP2(hdcDisplay) == R2_NOT, "rop2 %d\n", GetROP2(hdcDisplay));
288 ok( GetArcDirection(hdcDisplay) == AD_CLOCKWISE, "arc dir %d\n", GetArcDirection(hdcDisplay));
289 ok( GetPolyFillMode(hdcDisplay) == WINDING, "poly fill %d\n", GetPolyFillMode(hdcDisplay));
290 ok( GetStretchBltMode(hdcDisplay) == HALFTONE, "stretchblt mode %d\n", GetStretchBltMode(hdcDisplay));
291
292 ok(emr_processed, "EnumEnhMetaFile couldn't find EMR_EXTTEXTOUTA or EMR_EXTTEXTOUTW record\n");
293
294 ok(!EnumEnhMetaFile(hdcDisplay, hMetafile, eto_emf_enum_proc, dx, NULL),
295 "A valid hdc has to require a valid rc\n");
296
298 "A null hdc does not require a valid rc\n");
299
300 ret = DeleteEnhMetaFile(hMetafile);
301 ok( ret, "DeleteEnhMetaFile error %d\n", GetLastError());
302 ret = ReleaseDC(hwnd, hdcDisplay);
303 ok( ret, "ReleaseDC error %d\n", GetLastError());
305}
#define WINDING
Definition: constants.h:279
const WCHAR * text
Definition: package.c:1799
GLenum GLsizei len
Definition: glext.h:6722
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
static int CALLBACK eto_emf_enum_proc(HDC hdc, HANDLETABLE *handle_table, const ENHMETARECORD *emr, int n_objs, LPARAM param)
Definition: metafile.c:81
#define DT_RASDISPLAY
Definition: wingdi.h:708
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
#define TA_UPDATECP
Definition: wingdi.h:936
UINT WINAPI SetTextAlign(_In_ HDC, _In_ UINT)
Definition: text.c:883
int WINAPI SetArcDirection(_In_ HDC, _In_ int)
#define TA_RTLREADING
Definition: wingdi.h:934
#define R2_NOT
Definition: wingdi.h:347
#define TA_BASELINE
Definition: wingdi.h:928
#define HALFTONE
Definition: wingdi.h:955
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
int WINAPI SetROP2(_In_ HDC, _In_ int)
Definition: dc.c:1107
#define TA_CENTER
Definition: wingdi.h:931
#define AD_CLOCKWISE
Definition: wingdi.h:668
int WINAPI SetStretchBltMode(_In_ HDC, _In_ int)
Definition: dc.c:1366
BOOL WINAPI GetCharWidthA(_In_ HDC hdc, _In_ UINT iFirst, _In_ UINT iLast, _Out_writes_(iLast+1 - iFirst) LPINT lpBuffer)
BOOL WINAPI PlayEnhMetaFile(_In_ HDC, _In_ HENHMETAFILE, _In_ LPCRECT)
#define TECHNOLOGY
Definition: wingdi.h:706
int WINAPI SetPolyFillMode(_In_ HDC, _In_ int)
Definition: dc.c:1167

Referenced by START_TEST().

◆ test_ExtTextOutScale()

static void test_ExtTextOutScale ( void  )
static

Definition at line 334 of file metafile.c.

335{
336 const RECT rc = { 0, 0, 100, 100 };
337 const WCHAR str[] = {'a',0 };
339 HDC hdcDisplay, hdcMetafile;
340 HENHMETAFILE hMetafile;
341 HWND hwnd;
342 SIZE wndext, vportext;
343 int horzSize, vertSize, horzRes, vertRes;
344 int ret;
345 int i;
346
347 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP | WS_VISIBLE,
348 0, 0, 200, 200, 0, 0, 0, NULL);
349 ok(hwnd != 0, "CreateWindowExA failed\n");
350
351 hdcDisplay = GetDC(hwnd);
352 ok(hdcDisplay != 0, "GetDC failed\n");
353
354 horzSize = GetDeviceCaps(hdcDisplay, HORZSIZE);
355 horzRes = GetDeviceCaps(hdcDisplay, HORZRES);
356 vertSize = GetDeviceCaps(hdcDisplay, VERTSIZE);
357 vertRes = GetDeviceCaps(hdcDisplay, VERTRES);
358 ok(horzSize && horzRes && vertSize && vertRes, "GetDeviceCaps failed\n");
359
360 for (i = 0; i < 16; i++)
361 {
362 test.graphics_mode = i / 8 + 1;
363 test.map_mode = i % 8 + 1;
364
365 ret = SetGraphicsMode(hdcDisplay, test.graphics_mode);
366 ok(ret, "SetGraphicsMode failed\n");
367 ret = SetMapMode(hdcDisplay, test.map_mode);
368 ok(ret, "SetMapMode failed\n");
369
370 if ((test.map_mode == MM_ISOTROPIC) || (test.map_mode == MM_ANISOTROPIC))
371 {
372 ret = SetWindowExtEx(hdcDisplay, 1, 1, NULL);
373 ok(ret, "SetWindowExtEx failed\n");
374 ret = SetViewportExtEx(hdcDisplay, -20, -10, NULL);
375 ok(ret, "SetViewportExtEx failed\n");
376 }
377
378 ret = GetViewportExtEx(hdcDisplay, &vportext);
379 ok(ret, "GetViewportExtEx failed\n");
380 ret = GetWindowExtEx(hdcDisplay, &wndext);
381 ok(ret, "GetWindowExtEx failed\n");
382
383 trace("gm %d, mm %d, wnd %d,%d, vp %d,%d horz %d,%d vert %d,%d\n",
384 test.graphics_mode, test.map_mode,
385 wndext.cx, wndext.cy, vportext.cx, vportext.cy,
386 horzSize, horzRes, vertSize, vertRes);
387
388 if (test.graphics_mode == GM_COMPATIBLE)
389 {
390 test.ex_scale = 100.0 * ((FLOAT)horzSize / (FLOAT)horzRes) /
391 ((FLOAT)wndext.cx / (FLOAT)vportext.cx);
392 test.ey_scale = 100.0 * ((FLOAT)vertSize / (FLOAT)vertRes) /
393 ((FLOAT)wndext.cy / (FLOAT)vportext.cy);
394 }
395 else
396 {
397 test.ex_scale = 0.0;
398 test.ey_scale = 0.0;
399 }
400
401 hdcMetafile = CreateEnhMetaFileA(hdcDisplay, NULL, NULL, NULL);
402 ok(hdcMetafile != 0, "CreateEnhMetaFileA failed\n");
403
404 ret = SetGraphicsMode(hdcMetafile, test.graphics_mode);
405 ok(ret, "SetGraphicsMode failed\n");
406 ret = SetMapMode(hdcMetafile, test.map_mode);
407 ok(ret, "SetMapMode failed\n");
408
409 if ((test.map_mode == MM_ISOTROPIC) || (test.map_mode == MM_ANISOTROPIC))
410 {
411 ret = SetWindowExtEx(hdcMetafile, 1, 1, NULL);
412 ok(ret, "SetWindowExtEx failed\n");
413 ret = SetViewportExtEx(hdcMetafile, -20, -10, NULL);
414 ok(ret, "SetViewportExtEx failed\n");
415 }
416
417 ret = ExtTextOutW(hdcMetafile, 0, 0, 0, 0, str, 1, NULL);
418 ok(ret, "ExtTextOutW failed\n");
419
420 hMetafile = CloseEnhMetaFile(hdcMetafile);
421 ok(hMetafile != 0, "CloseEnhMetaFile failed\n");
422
423 test.processed = 0;
424 ret = EnumEnhMetaFile(hdcDisplay, hMetafile, eto_scale_enum_proc, &test, &rc);
425 ok(ret, "EnumEnhMetaFile failed\n");
426 ok(test.processed, "EnumEnhMetaFile couldn't find EMR_EXTTEXTOUTW record\n");
427
428 ret = DeleteEnhMetaFile(hMetafile);
429 ok(ret, "DeleteEnhMetaFile failed\n");
430 }
431
432 ret = ReleaseDC(hwnd, hdcDisplay);
433 ok(ret, "ReleaseDC failed\n");
435}
static int CALLBACK eto_scale_enum_proc(HDC hdc, HANDLETABLE *handle_table, const ENHMETARECORD *emr, int n_objs, LPARAM param)
Definition: metafile.c:316
const WCHAR * str
#define GM_COMPATIBLE
Definition: wingdi.h:864
BOOL WINAPI ExtTextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_ UINT options, _In_opt_ const RECT *lprect, _In_reads_opt_(c) LPCWSTR lpString, _In_ UINT c, _In_reads_opt_(c) const INT *lpDx)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_gdiis()

static void test_gdiis ( void  )
static

Definition at line 3580 of file metafile.c.

3581{
3582 RECT rect = {0,0,100,100};
3583 HDC hdc, hemfDC, hmfDC;
3584 HENHMETAFILE hemf;
3586
3587 /* resolve all the functions */
3588 hgdi32 = GetModuleHandleA("gdi32.dll");
3589 pGdiIsMetaPrintDC = (void*) GetProcAddress(hgdi32, "GdiIsMetaPrintDC");
3590 pGdiIsMetaFileDC = (void*) GetProcAddress(hgdi32, "GdiIsMetaFileDC");
3591 pGdiIsPlayMetafileDC = (void*) GetProcAddress(hgdi32, "GdiIsPlayMetafileDC");
3592
3593 if(!pGdiIsMetaPrintDC || !pGdiIsMetaFileDC || !pGdiIsPlayMetafileDC)
3594 {
3595 win_skip("Needed GdiIs* functions are not available\n");
3596 return;
3597 }
3598
3599 /* try with nothing */
3600 ok(!pGdiIsMetaPrintDC(NULL), "ismetaprint with NULL parameter\n");
3601 ok(!pGdiIsMetaFileDC(NULL), "ismetafile with NULL parameter\n");
3602 ok(!pGdiIsPlayMetafileDC(NULL), "isplaymetafile with NULL parameter\n");
3603
3604 /* try with a metafile */
3605 hmfDC = CreateMetaFileA(NULL);
3606 ok(!pGdiIsMetaPrintDC(hmfDC), "ismetaprint on metafile\n");
3607 ok(pGdiIsMetaFileDC(hmfDC), "ismetafile on metafile\n");
3608 ok(!pGdiIsPlayMetafileDC(hmfDC), "isplaymetafile on metafile\n");
3610
3611 /* try with an enhanced metafile */
3612 hdc = GetDC(NULL);
3613 hemfDC = CreateEnhMetaFileW(hdc, NULL, &rect, NULL);
3614 ok(hemfDC != NULL, "failed to create emf\n");
3615
3616 ok(!pGdiIsMetaPrintDC(hemfDC), "ismetaprint on emf\n");
3617 ok(pGdiIsMetaFileDC(hemfDC), "ismetafile on emf\n");
3618 ok(!pGdiIsPlayMetafileDC(hemfDC), "isplaymetafile on emf\n");
3619
3620 hemf = CloseEnhMetaFile(hemfDC);
3621 ok(hemf != NULL, "failed to close EMF\n");
3622 DeleteEnhMetaFile(hemf);
3624}
static HMODULE hgdi32
Definition: font.c:65
HDC WINAPI CreateEnhMetaFileW(_In_opt_ HDC, _In_opt_ LPCWSTR, _In_opt_ LPCRECT, _In_opt_ LPCWSTR)

Referenced by START_TEST().

◆ test_GetWinMetaFileBits()

static void test_GetWinMetaFileBits ( void  )
static

Definition at line 3548 of file metafile.c.

3549{
3550 UINT mode;
3551 RECT frames[] =
3552 {
3553 { 1000, 2000, 3000, 6000},
3554 {-1000, 2000, 3000, 6000},
3555 { 1000, -2000, 3000, 6000},
3556 { 1005, 2005, 3000, 6000},
3557 {-1005, -2005, 3000, 6000},
3558 {-1005, -2010, 3000, 6000},
3559 {-1005, 2010, 3000, 6000},
3560 { 0, 0, 1, 1},
3561 { -1, -1, 1, 1},
3562 { 0, 0, 0, 0}
3563 };
3564
3565 for(mode = MM_MIN; mode <= MM_MAX; mode++)
3566 {
3567 RECT *rc;
3568 for(rc = frames; rc->right - rc->left > 0; rc++)
3569 {
3570 getwinmetafilebits(mode, 1, rc);
3571 getwinmetafilebits(mode, 2, rc);
3572 }
3573 }
3574}
static void getwinmetafilebits(UINT mode, int scale, RECT *rc)
Definition: metafile.c:3370
#define MM_MIN
Definition: wingdi.h:876
#define MM_MAX
Definition: wingdi.h:877

Referenced by START_TEST().

◆ test_mf_Blank()

static void test_mf_Blank ( void  )
static

Definition at line 2068 of file metafile.c.

2069{
2070 HDC hdcMetafile;
2071 HMETAFILE hMetafile;
2072 INT caps;
2073 BOOL ret;
2074 INT type;
2075
2076 hdcMetafile = CreateMetaFileA(NULL);
2077 ok(hdcMetafile != 0, "CreateMetaFileA(NULL) error %d\n", GetLastError());
2078 trace("hdcMetafile %p\n", hdcMetafile);
2079
2080/* Tests on metafile initialization */
2081 caps = GetDeviceCaps (hdcMetafile, TECHNOLOGY);
2082 ok (caps == DT_METAFILE,
2083 "GetDeviceCaps: TECHNOLOGY=%d != DT_METAFILE.\n", caps);
2084
2085 hMetafile = CloseMetaFile(hdcMetafile);
2086 ok(hMetafile != 0, "CloseMetaFile error %d\n", GetLastError());
2087 type = GetObjectType(hMetafile);
2088 ok(type == OBJ_METAFILE, "CloseMetaFile created object with type %d\n", type);
2089 ok(!GetObjectType(hdcMetafile), "CloseMetaFile has to destroy metafile hdc\n");
2090
2091 if (compare_mf_bits (hMetafile, MF_BLANK_BITS, sizeof(MF_BLANK_BITS),
2092 "mf_blank") != 0)
2093 {
2094 dump_mf_bits(hMetafile, "mf_Blank");
2095 EnumMetaFile(0, hMetafile, mf_enum_proc, 0);
2096 }
2097
2098 ret = DeleteMetaFile(hMetafile);
2099 ok( ret, "DeleteMetaFile(%p) error %d\n", hMetafile, GetLastError());
2100}
#define DT_METAFILE
Definition: wingdi.h:712

Referenced by START_TEST().

◆ test_mf_clipping()

static void test_mf_clipping ( void  )
static

Definition at line 2889 of file metafile.c.

2890{
2891 /* left top right bottom */
2892 static RECT rc_clip = { 0x11, 0x22, 0x33, 0x44 };
2893 HWND hwnd;
2894 HDC hdc;
2895 HMETAFILE hmf;
2896 HRGN hrgn;
2897 INT ret;
2898
2899 SetLastError(0xdeadbeef);
2901 ok(hdc != 0, "CreateMetaFileA error %d\n", GetLastError());
2902
2903 hrgn = CreateRectRgn(rc_clip.left, rc_clip.top, rc_clip.right, rc_clip.bottom);
2905 /* Seems like it should be SIMPLEREGION, but windows returns NULLREGION? */
2906 ok(ret == NULLREGION, "expected NULLREGION, got %d\n", ret);
2907
2908 /* Draw a line that starts off left of the clip region and ends inside it */
2909 MoveToEx(hdc, 0x1, 0x30, NULL);
2910 LineTo(hdc, 0x20, 0x30);
2911
2912 SetLastError(0xdeadbeef);
2913 hmf = CloseMetaFile(hdc);
2914 ok(hmf != 0, "CloseMetaFile error %d\n", GetLastError());
2915
2916 if (compare_mf_bits(hmf, MF_CLIP_BITS, sizeof(MF_CLIP_BITS),
2917 "mf_clipping") != 0)
2918 {
2919 dump_mf_bits(hmf, "mf_clipping");
2920 }
2921
2923
2924 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP | WS_VISIBLE,
2925 0, 0, 200, 200, 0, 0, 0, NULL);
2926 ok(hwnd != 0, "CreateWindowExA error %d\n", GetLastError());
2927
2928 hdc = GetDC(hwnd);
2929
2930 ret = EnumMetaFile(hdc, hmf, clip_mf_enum_proc, (LPARAM)&rc_clip);
2931 ok(ret, "EnumMetaFile error %d\n", GetLastError());
2932
2933 /* Oddly, windows doesn't seem to use META_SELECTCLIPREGION */
2935 "expected 0 selectclipregion, saw %d\n", clip_mf_enum_proc_seen_selectclipregion);
2937 "expected 1 selectobject, saw %d\n", clip_mf_enum_proc_seen_selectobject);
2938
2939 DeleteMetaFile(hmf);
2940 ReleaseDC(hwnd, hdc);
2942}
static const unsigned char MF_CLIP_BITS[]
Definition: metafile.c:2826
static int CALLBACK clip_mf_enum_proc(HDC hdc, HANDLETABLE *handle_table, METARECORD *mr, int n_objs, LPARAM param)
Definition: metafile.c:2875
LONG_PTR LPARAM
Definition: windef.h:208
#define NULLREGION
Definition: wingdi.h:361

Referenced by START_TEST().

◆ test_mf_conversions()

static void test_mf_conversions ( void  )
static

Definition at line 3072 of file metafile.c.

3073{
3074 trace("Testing MF->EMF conversion (MM_ANISOTROPIC)\n");
3075 {
3077 HENHMETAFILE hemf;
3078 METAFILEPICT mfp;
3079 RECT rect = { 0, 0, 100, 100 };
3080 mfp.mm = MM_ANISOTROPIC;
3081 mfp.xExt = 100;
3082 mfp.yExt = 100;
3083 mfp.hMF = NULL;
3084 hemf = create_converted_emf(&mfp);
3085
3087 "emf_LineTo MM_ANISOTROPIC", TRUE) != 0)
3088 {
3089 dump_emf_bits(hemf, "emf_LineTo MM_ANISOTROPIC");
3090