Updated patch for d3dx9_36 DrawText implementation and fixed multiple bugs.

This commit is contained in:
Sebastian Lackner 2015-12-05 21:43:45 +01:00
parent ce6a5b015d
commit af4ac5433d
4 changed files with 203 additions and 1 deletions

View File

@ -0,0 +1,117 @@
From f28e6a98185ce7dd1137f2f04861c097e75e72a9 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Fri, 4 Dec 2015 09:22:35 +1100
Subject: d3dx9_36: Support NULL terminated strings in ID3DXFont_DrawText
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
---
dlls/d3dx9_36/font.c | 10 ++++++++--
dlls/d3dx9_36/tests/core.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 53 insertions(+), 3 deletions(-)
diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c
index d6dcd6c..63aa828 100644
--- a/dlls/d3dx9_36/font.c
+++ b/dlls/d3dx9_36/font.c
@@ -214,9 +214,12 @@ static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite,
TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x\n",
iface, sprite, debugstr_a(string), count, wine_dbgstr_rect(rect), format, color);
- if (!string || count <= 0)
+ if (!string || count == 0)
return 0;
+ if (count < 0)
+ count = -1;
+
countW = MultiByteToWideChar(CP_ACP, 0, string, count, NULL, 0);
stringW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR));
if (stringW)
@@ -239,9 +242,12 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x\n",
iface, sprite, debugstr_w(string), count, wine_dbgstr_rect(rect), format, color);
- if (!string || count <= 0)
+ if (!string || count == 0)
return 0;
+ if (count < 0)
+ count = lstrlenW(string);
+
/* Strip terminating NULL characters */
while (count > 0 && !string[count-1])
count--;
diff --git a/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c
index 1c379fb..c931260 100644
--- a/dlls/d3dx9_36/tests/core.c
+++ b/dlls/d3dx9_36/tests/core.c
@@ -321,6 +321,8 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
{ 12, 256, 5 },
{ 72, 256, 8 }
};
+ static const WCHAR testW[] = {'t','e','s','t',0};
+ static const char testA[] = "test";
/* D3DXCreateFont */
@@ -463,7 +465,6 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
/* ID3DXFont_PreloadText */
hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font);
if(SUCCEEDED(hr)) {
- const WCHAR testW[] = {'t','e','s','t',0};
todo_wine {
hr = ID3DXFont_PreloadTextA(font, NULL, -1);
@@ -591,6 +592,49 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
}
ID3DXFont_Release(font);
}
+
+ /* ID3DXFont_DrawTextA, ID3DXFont_DrawTextW */
+ hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font);
+ if (SUCCEEDED(hr)) {
+ RECT rect;
+ int height;
+
+ SetRect(&rect, 10, 10, 200, 200);
+
+ 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, &rect, 0, 0xFF00FF);
+ ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
+
+ height = ID3DXFont_DrawTextA(font, NULL, testA, 0, &rect, 0, 0xFF00FF);
+ ok(height == 0, "DrawTextA returned %d, expected 0.\n", height);
+
+ height = ID3DXFont_DrawTextA(font, NULL, testA, 1, &rect, 0, 0xFF00FF);
+ ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
+
+ height = ID3DXFont_DrawTextA(font, NULL, testA, 2, &rect, 0, 0xFF00FF);
+ ok(height == 12, "DrawTextA returned %d, expected 12.\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);
+}
+
+ height = ID3DXFont_DrawTextW(font, NULL, testW, -1, &rect, 0, 0xFF00FF);
+ ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
+
+ height = ID3DXFont_DrawTextW(font, NULL, testW, 0, &rect, 0, 0xFF00FF);
+ ok(height == 0, "DrawTextW returned %d, expected 0.\n", height);
+
+ height = ID3DXFont_DrawTextW(font, NULL, testW, 1, &rect, 0, 0xFF00FF);
+ ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
+
+ height = ID3DXFont_DrawTextW(font, NULL, testW, 2, &rect, 0, 0xFF00FF);
+ ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
+
+ ID3DXFont_Release(font);
+ }
}
static void test_D3DXCreateRenderToSurface(IDirect3DDevice9 *device)
--
2.6.2

View File

@ -0,0 +1,80 @@
From 5b46372b7cc36f07d61bce63d5e3ae8aa766aa5a Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Sat, 5 Dec 2015 15:31:06 +1100
Subject: d3dx9_36: ID3DXFont_DrawText calc_rect can be null
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
---
dlls/d3dx9_36/font.c | 8 ++++++--
dlls/d3dx9_36/tests/core.c | 18 ++++++++++++++++++
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c
index 63aa828..2262db9 100644
--- a/dlls/d3dx9_36/font.c
+++ b/dlls/d3dx9_36/font.c
@@ -236,7 +236,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",
@@ -252,11 +252,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/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c
index c931260..1cf0db6 100644
--- a/dlls/d3dx9_36/tests/core.c
+++ b/dlls/d3dx9_36/tests/core.c
@@ -616,6 +616,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);
@@ -633,6 +642,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);
}
}
--
2.6.2

View File

@ -2701,14 +2701,18 @@ fi
# | * [#24754] Support for ID3DXFont::DrawTextA/W
# |
# | Modified files:
# | * dlls/d3dx9_36/font.c
# | * dlls/d3dx9_36/font.c, dlls/d3dx9_36/tests/core.c
# |
if test "$enable_d3dx9_36_DrawText" -eq 1; then
patch_apply d3dx9_36-DrawText/0001-d3dx9_36-Implement-ID3DXFontImpl_DrawText.patch
patch_apply d3dx9_36-DrawText/0002-d3dx9_36-Fix-horizontal-centering-in-ID3DXFont_DrawT.patch
patch_apply d3dx9_36-DrawText/0003-d3dx9_36-Support-NULL-terminated-strings-in-ID3DXFon.patch
patch_apply d3dx9_36-DrawText/0004-d3dx9_36-ID3DXFont_DrawText-calc_rect-can-be-null.patch
(
echo '+ { "Christian Costa", "d3dx9_36: Implement ID3DXFontImpl_DrawText.", 1 },';
echo '+ { "Christian Costa", "d3dx9_36: Fix horizontal centering in ID3DXFont_DrawText.", 1 },';
echo '+ { "Alistair Leslie-Hughes", "d3dx9_36: Support NULL terminated strings in ID3DXFont_DrawText.", 1 },';
echo '+ { "Alistair Leslie-Hughes", "d3dx9_36: ID3DXFont_DrawText calc_rect can be null.", 1 },';
) >> "$patchlist"
fi

View File

@ -1,4 +1,5 @@
wine-staging (1.8~rc3) UNRELEASED; urgency=low
* Updated patch for d3dx9_36 DrawText implementation and fixed multiple bugs.
* Removed patch for delayed end of DST in Europe/Istanbul (accepted upstream).
* Removed patch to add partial implementation of ITfThreadMgrEx_ActivateEx
(accepted upstream).