From af4ac5433d4e40c133e4a4eca2d5d8173a702fe1 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sat, 5 Dec 2015 21:43:45 +0100 Subject: [PATCH] Updated patch for d3dx9_36 DrawText implementation and fixed multiple bugs. --- ...-NULL-terminated-strings-in-ID3DXFon.patch | 117 ++++++++++++++++++ ...XFont_DrawText-calc_rect-can-be-null.patch | 80 ++++++++++++ patches/patchinstall.sh | 6 +- staging/changelog | 1 + 4 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 patches/d3dx9_36-DrawText/0003-d3dx9_36-Support-NULL-terminated-strings-in-ID3DXFon.patch create mode 100644 patches/d3dx9_36-DrawText/0004-d3dx9_36-ID3DXFont_DrawText-calc_rect-can-be-null.patch diff --git a/patches/d3dx9_36-DrawText/0003-d3dx9_36-Support-NULL-terminated-strings-in-ID3DXFon.patch b/patches/d3dx9_36-DrawText/0003-d3dx9_36-Support-NULL-terminated-strings-in-ID3DXFon.patch new file mode 100644 index 00000000..d9b94198 --- /dev/null +++ b/patches/d3dx9_36-DrawText/0003-d3dx9_36-Support-NULL-terminated-strings-in-ID3DXFon.patch @@ -0,0 +1,117 @@ +From f28e6a98185ce7dd1137f2f04861c097e75e72a9 Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +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 +--- + 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 + diff --git a/patches/d3dx9_36-DrawText/0004-d3dx9_36-ID3DXFont_DrawText-calc_rect-can-be-null.patch b/patches/d3dx9_36-DrawText/0004-d3dx9_36-ID3DXFont_DrawText-calc_rect-can-be-null.patch new file mode 100644 index 00000000..b66a8c19 --- /dev/null +++ b/patches/d3dx9_36-DrawText/0004-d3dx9_36-ID3DXFont_DrawText-calc_rect-can-be-null.patch @@ -0,0 +1,80 @@ +From 5b46372b7cc36f07d61bce63d5e3ae8aa766aa5a Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +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 +--- + 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 + diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index d065c150..5639e64d 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -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 diff --git a/staging/changelog b/staging/changelog index 2110c17c..06098b0e 100644 --- a/staging/changelog +++ b/staging/changelog @@ -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).