Make GpGraphics save/restore state id's a bit more like Windows. Fixes a winetest graphics state check failure.

svn path=/trunk/; revision=57299
This commit is contained in:
Mike Nordell 2012-09-14 21:26:45 +00:00
parent 3c636c565e
commit 60b3b058ce
2 changed files with 64 additions and 2 deletions

View file

@ -0,0 +1,45 @@
Index: graphics.c
===================================================================
--- graphics.c (revision 57285)
+++ graphics.c (working copy)
@@ -42,6 +42,23 @@
WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
+/* Mike "tamlin" Nordell 2012-09-14 for ReactOS:
+ * NOTE: Wine uses per-GpGraphics id's ('contid' starting from zero in
+ * every GpGraphics). Windows seems to use process-global id's, or at
+ * least more unique id's.
+ * This have the following implications. It:
+ * 1. fails the current gdiplus test case.
+ * 2. is not what Windows does.
+ *
+ * We therefore "obfuscate" the 'contid' a little to more match Windows'
+ * behaviour. The observable behviour should still remain the same,
+ * except for handing out more "unique" id's.
+ */
+#define GDIP_CONTID_STEP 64
+static volatile LONG g_priv_contid = GDIP_CONTID_STEP;
+#define GDIP_GET_NEW_CONTID_FOR(pGpGraphics) \
+ (UINT)(InterlockedExchangeAdd(&g_priv_contid,GDIP_CONTID_STEP))
+
/* looks-right constants */
#define ANCHOR_WIDTH (2.0)
#define MAX_ITERS (50)
@@ -2203,7 +2220,7 @@
(*graphics)->busy = FALSE;
(*graphics)->textcontrast = 4;
list_init(&(*graphics)->containers);
- (*graphics)->contid = 0;
+ (*graphics)->contid = GDIP_GET_NEW_CONTID_FOR(*graphics);
TRACE("<-- %p\n", *graphics);
@@ -2242,7 +2259,7 @@
(*graphics)->busy = FALSE;
(*graphics)->textcontrast = 4;
list_init(&(*graphics)->containers);
- (*graphics)->contid = 0;
+ (*graphics)->contid = GDIP_GET_NEW_CONTID_FOR(*graphics);
TRACE("<-- %p\n", *graphics);

View file

@ -42,6 +42,23 @@
WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
/* Mike "tamlin" Nordell 2012-09-14 for ReactOS:
* NOTE: Wine uses per-GpGraphics id's ('contid' starting from zero in
* every GpGraphics). Windows seems to use process-global id's, or at
* least more unique id's.
* This have the following implications. It:
* 1. fails the current gdiplus test case.
* 2. is not what Windows does.
*
* We therefore "obfuscate" the 'contid' a little to more match Windows'
* behaviour. The observable behviour should still remain the same,
* except for handing out more "unique" id's.
*/
#define GDIP_CONTID_STEP 64
static volatile LONG g_priv_contid = GDIP_CONTID_STEP;
#define GDIP_GET_NEW_CONTID_FOR(pGpGraphics) \
(UINT)(InterlockedExchangeAdd(&g_priv_contid,GDIP_CONTID_STEP))
/* looks-right constants */
#define ANCHOR_WIDTH (2.0)
#define MAX_ITERS (50)
@ -2203,7 +2220,7 @@ GpStatus WINGDIPAPI GdipCreateFromHDC2(HDC hdc, HANDLE hDevice, GpGraphics **gra
(*graphics)->busy = FALSE;
(*graphics)->textcontrast = 4;
list_init(&(*graphics)->containers);
(*graphics)->contid = 0;
(*graphics)->contid = GDIP_GET_NEW_CONTID_FOR(*graphics);
TRACE("<-- %p\n", *graphics);
@ -2242,7 +2259,7 @@ GpStatus graphics_from_image(GpImage *image, GpGraphics **graphics)
(*graphics)->busy = FALSE;
(*graphics)->textcontrast = 4;
list_init(&(*graphics)->containers);
(*graphics)->contid = 0;
(*graphics)->contid = GDIP_GET_NEW_CONTID_FOR(*graphics);
TRACE("<-- %p\n", *graphics);