https://git.reactos.org/?p=reactos.git;a=commitdiff;h=58d515ea16eaadfc8330a0203786002e1abe3a6d

commit 58d515ea16eaadfc8330a0203786002e1abe3a6d
Author:     winesync <[email protected]>
AuthorDate: Wed Feb 5 22:13:54 2020 +0100
Commit:     Jérôme Gardou <[email protected]>
CommitDate: Wed Feb 26 18:19:18 2020 +0100

    [WINESYNC] d3dx9_36: ID3DXFont_DrawText calc_rect can be null
    
    Signed-off-by: Alistair Leslie-Hughes <[email protected]>
    
    wine-staging patch by Alistair Leslie-Hughes <[email protected]>
---
 dll/directx/wine/d3dx9_36/font.c                   |  8 ++-
 modules/rostests/winetests/d3dx9_36/core.c         | 18 ++++++
 ...__ID3DXFont_DrawText_calc_rect_can_be_null.diff | 66 ++++++++++++++++++++++
 3 files changed, 90 insertions(+), 2 deletions(-)

diff --git a/dll/directx/wine/d3dx9_36/font.c b/dll/directx/wine/d3dx9_36/font.c
index 89005ce467c..05e490fd2a5 100644
--- a/dll/directx/wine/d3dx9_36/font.c
+++ b/dll/directx/wine/d3dx9_36/font.c
@@ -235,7 +235,7 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, 
ID3DXSprite *sprite,
         const WCHAR *string, INT count, RECT *rect, DWORD format, D3DCOLOR 
color)
 {
     struct d3dx_font *This = impl_from_ID3DXFont(iface);
-    RECT calc_rect = *rect;
+    RECT calc_rect;
     INT height;
 
     TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, 
color 0x%08x\n",
@@ -251,11 +251,15 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont 
*iface, ID3DXSprite *sprite,
     while (count > 0 && !string[count-1])
         count--;
 
+    if (rect)
+        calc_rect = *rect;
+
     height = DrawTextW(This->hdc, string, count, &calc_rect, format | 
DT_CALCRECT);
 
     if (format & DT_CALCRECT)
     {
-        *rect = calc_rect;
+        if (rect)
+            *rect = calc_rect;
         return height;
     }
 
diff --git a/modules/rostests/winetests/d3dx9_36/core.c 
b/modules/rostests/winetests/d3dx9_36/core.c
index 841d07e8228..a5abb79f904 100644
--- a/modules/rostests/winetests/d3dx9_36/core.c
+++ b/modules/rostests/winetests/d3dx9_36/core.c
@@ -662,6 +662,15 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
         height = ID3DXFont_DrawTextA(font, NULL, testA, 2, &rect, 0, 0xFF00FF);
         ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
 
+        height = ID3DXFont_DrawTextA(font, NULL, testA, -1, NULL, 0, 0xFF00FF);
+        ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
+
+        height = ID3DXFont_DrawTextA(font, NULL, testA, -1, NULL, DT_CALCRECT, 
0xFF00FF);
+        ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
+
+        height = ID3DXFont_DrawTextA(font, NULL, NULL, -1, NULL, 0, 0xFF00FF);
+        ok(height == 0, "DrawTextA returned %d, expected 0.\n", height);
+
 if (0) { /* Causes a lockup on windows 7. */
         height = ID3DXFont_DrawTextW(font, NULL, testW, -2, &rect, 0, 
0xFF00FF);
         ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
@@ -679,6 +688,15 @@ if (0) { /* Causes a lockup on windows 7. */
         height = ID3DXFont_DrawTextW(font, NULL, testW, 2, &rect, 0, 0xFF00FF);
         ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
 
+        height = ID3DXFont_DrawTextW(font, NULL, testW, -1, NULL, 0, 0xFF00FF);
+        ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
+
+        height = ID3DXFont_DrawTextW(font, NULL, testW, -1, NULL, DT_CALCRECT, 
0xFF00FF);
+        ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
+
+        height = ID3DXFont_DrawTextW(font, NULL, NULL, -1, NULL, 0, 0xFF00FF);
+        ok(height == 0, "DrawTextA returned %d, expected 0.\n", height);
+
         ID3DXFont_Release(font);
     }
 }
diff --git 
a/sdk/tools/winesync/d3dx9_staging/0018-d3dx9_36__ID3DXFont_DrawText_calc_rect_can_be_null.diff
 
b/sdk/tools/winesync/d3dx9_staging/0018-d3dx9_36__ID3DXFont_DrawText_calc_rect_can_be_null.diff
new file mode 100644
index 00000000000..d8bcb5f1107
--- /dev/null
+++ 
b/sdk/tools/winesync/d3dx9_staging/0018-d3dx9_36__ID3DXFont_DrawText_calc_rect_can_be_null.diff
@@ -0,0 +1,66 @@
+diff --git a/dll/directx/wine/d3dx9_36/font.c 
b/dll/directx/wine/d3dx9_36/font.c
+index 89005ce..05e490f 100644
+--- a/dll/directx/wine/d3dx9_36/font.c
++++ b/dll/directx/wine/d3dx9_36/font.c
+@@ -235,7 +235,7 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont 
*iface, ID3DXSprite *sprite,
+         const WCHAR *string, INT count, RECT *rect, DWORD format, D3DCOLOR 
color)
+ {
+     struct d3dx_font *This = impl_from_ID3DXFont(iface);
+-    RECT calc_rect = *rect;
++    RECT calc_rect;
+     INT height;
+ 
+     TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, 
color 0x%08x\n",
+@@ -251,11 +251,15 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont 
*iface, ID3DXSprite *sprite,
+     while (count > 0 && !string[count-1])
+         count--;
+ 
++    if (rect)
++        calc_rect = *rect;
++
+     height = DrawTextW(This->hdc, string, count, &calc_rect, format | 
DT_CALCRECT);
+ 
+     if (format & DT_CALCRECT)
+     {
+-        *rect = calc_rect;
++        if (rect)
++            *rect = calc_rect;
+         return height;
+     }
+ 
+diff --git a/modules/rostests/winetests/d3dx9_36/core.c 
b/modules/rostests/winetests/d3dx9_36/core.c
+index 841d07e..a5abb79 100644
+--- a/modules/rostests/winetests/d3dx9_36/core.c
++++ b/modules/rostests/winetests/d3dx9_36/core.c
+@@ -662,6 +662,15 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
+         height = ID3DXFont_DrawTextA(font, NULL, testA, 2, &rect, 0, 
0xFF00FF);
+         ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
+ 
++        height = ID3DXFont_DrawTextA(font, NULL, testA, -1, NULL, 0, 
0xFF00FF);
++        ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
++
++        height = ID3DXFont_DrawTextA(font, NULL, testA, -1, NULL, 
DT_CALCRECT, 0xFF00FF);
++        ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
++
++        height = ID3DXFont_DrawTextA(font, NULL, NULL, -1, NULL, 0, 0xFF00FF);
++        ok(height == 0, "DrawTextA returned %d, expected 0.\n", height);
++
+ if (0) { /* Causes a lockup on windows 7. */
+         height = ID3DXFont_DrawTextW(font, NULL, testW, -2, &rect, 0, 
0xFF00FF);
+         ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
+@@ -679,6 +688,15 @@ if (0) { /* Causes a lockup on windows 7. */
+         height = ID3DXFont_DrawTextW(font, NULL, testW, 2, &rect, 0, 
0xFF00FF);
+         ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
+ 
++        height = ID3DXFont_DrawTextW(font, NULL, testW, -1, NULL, 0, 
0xFF00FF);
++        ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
++
++        height = ID3DXFont_DrawTextW(font, NULL, testW, -1, NULL, 
DT_CALCRECT, 0xFF00FF);
++        ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
++
++        height = ID3DXFont_DrawTextW(font, NULL, NULL, -1, NULL, 0, 0xFF00FF);
++        ok(height == 0, "DrawTextA returned %d, expected 0.\n", height);
++
+         ID3DXFont_Release(font);
+     }
+ }

Reply via email to