ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
February 2021
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
30 participants
434 discussions
Start a n
N
ew thread
[reactos] 179/218: [WINESYNC] d3dx9: Handle DT_CALCRECT in ID3DXFont_DrawText.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=031934775448aee427b9a…
commit 031934775448aee427b9a763ba1cb076d91da847 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Mon Sep 21 23:07:31 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Thu Feb 4 16:37:06 2021 +0100 [WINESYNC] d3dx9: Handle DT_CALCRECT in ID3DXFont_DrawText. Signed-off-by: Sven Baars <sbaars(a)codeweavers.com> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 143a2a30f89dfc79cc2a49cd34af6fd587ce3f69 by Sven Baars <sbaars(a)codeweavers.com> --- dll/directx/wine/d3dx9_36/font.c | 24 +++++++++++++++++++----- modules/rostests/winetests/d3dx9_36/core.c | 18 ++++++++++++++++-- sdk/tools/winesync/d3dx9.cfg | 2 +- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/dll/directx/wine/d3dx9_36/font.c b/dll/directx/wine/d3dx9_36/font.c index 9cec2cdaeb7..b260436e8ef 100644 --- a/dll/directx/wine/d3dx9_36/font.c +++ b/dll/directx/wine/d3dx9_36/font.c @@ -557,12 +557,11 @@ static void word_break(HDC hdc, const WCHAR *str, unsigned int *str_len, } static const WCHAR *read_line(HDC hdc, const WCHAR *str, int *count, - WCHAR *dest, unsigned int *dest_len, int width, DWORD format) + WCHAR *dest, unsigned int *dest_len, int width, DWORD format, SIZE *size) { unsigned int i = 0; int orig_count = *count; int num_fit; - SIZE size; *dest_len = 0; while (*count && (str[i] != '\n' || (format & DT_SINGLELINE))) @@ -574,7 +573,7 @@ static const WCHAR *read_line(HDC hdc, const WCHAR *str, int *count, } num_fit = 0; - GetTextExtentExPointW(hdc, dest, *dest_len, width, &num_fit, NULL, &size); + GetTextExtentExPointW(hdc, dest, *dest_len, width, &num_fit, NULL, size); if (num_fit < *dest_len) { @@ -582,7 +581,7 @@ static const WCHAR *read_line(HDC hdc, const WCHAR *str, int *count, { unsigned int chars_used; - word_break(hdc, dest, dest_len, num_fit, &chars_used, format, &size); + word_break(hdc, dest, dest_len, num_fit, &chars_used, format, size); *count = orig_count - chars_used; i = chars_used; } @@ -612,7 +611,9 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, WCHAR *line; RECT textrect = {0}; int lh, x, y, width; + int max_width = 0; int ret = 0; + SIZE size; TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x.\n", iface, sprite, debugstr_wn(string, count), count, wine_dbgstr_rect(rect), format, color); @@ -664,7 +665,7 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, { unsigned int line_len; - string = read_line(font->hdc, string, &count, line, &line_len, width, format); + string = read_line(font->hdc, string, &count, line, &line_len, width, format, &size); if (!(format & DT_CALCRECT)) { @@ -709,11 +710,24 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, heap_free(results.lpCaretPos); heap_free(results.lpGlyphs); } + else if (size.cx > max_width) + { + max_width = size.cx; + } + y += lh; if (!(DT_NOCLIP & format) && (y > textrect.bottom)) break; } + if (format & DT_CALCRECT) + { + *rect = textrect; + + rect->bottom = y; + rect->right = rect->left + max_width; + } + ret = y - textrect.top; cleanup: diff --git a/modules/rostests/winetests/d3dx9_36/core.c b/modules/rostests/winetests/d3dx9_36/core.c index 2b5a868033f..6fae8bf8d5a 100644 --- a/modules/rostests/winetests/d3dx9_36/core.c +++ b/modules/rostests/winetests/d3dx9_36/core.c @@ -64,6 +64,15 @@ static inline void check_mat(D3DXMATRIX got, D3DXMATRIX exp) U(exp).m[3][0],U(exp).m[3][1],U(exp).m[3][2],U(exp).m[3][3]); } +#define check_rect(rect, left, top, right, bottom) _check_rect(__LINE__, rect, left, top, right, bottom) +static inline void _check_rect(unsigned int line, const RECT *rect, int left, int top, int right, int bottom) +{ + ok_(__FILE__, line)(rect->left == left, "Unexpected rect.left %d\n", rect->left); + ok_(__FILE__, line)(rect->top == top, "Unexpected rect.top %d\n", rect->top); + ok_(__FILE__, line)(rect->right == right, "Unexpected rect.right %d\n", rect->right); + ok_(__FILE__, line)(rect->bottom == bottom, "Unexpected rect.bottom %d\n", rect->bottom); +} + static void test_ID3DXBuffer(void) { ID3DXBuffer *buffer; @@ -667,8 +676,8 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(height == tests[i].font_height, "Test %d: got unexpected height %u.\n", i, height); ok(!rect.left, "Test %d: got unexpected rect left %d.\n", i, rect.left); ok(!rect.top, "Test %d: got unexpected rect top %d.\n", i, rect.top); - todo_wine ok(rect.right, "Test %d: got unexpected rect right %d.\n", i, rect.right); - todo_wine ok(rect.bottom == tests[i].font_height, "Test %d: got unexpected rect bottom %d.\n", i, rect.bottom); + ok(rect.right, "Test %d: got unexpected rect right %d.\n", i, rect.right); + ok(rect.bottom == tests[i].font_height, "Test %d: got unexpected rect bottom %d.\n", i, rect.bottom); hr = ID3DXSprite_End(sprite); ok (hr == D3D_OK, "Test %d: got unexpected hr %#x.\n", i, hr); @@ -839,6 +848,11 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CENTER, 0xff00ff); ok(height == 24, "Got unexpected height %d.\n", height); + SetRect(&rect, 10, 10, 50, 50); + height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CALCRECT, 0xff00ff); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, 10, 30, 34); + ID3DXFont_Release(font); } diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg index eb2b4d90f0a..104b780e0f0 100644 --- a/sdk/tools/winesync/d3dx9.cfg +++ b/sdk/tools/winesync/d3dx9.cfg @@ -15,4 +15,4 @@ files: {include/d3dx9.h: sdk/include/dxsdk/d3dx9.h, include/d3dx9anim.h: sdk/inc include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h, include/d3dx9of.h: sdk/include/dxsdk/d3dx9of.h, include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h, include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h, include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h, include/d3dx9xof.h: sdk/include/dxsdk/d3dx9xof.h} -tags: {wine: 333687f522730befb8c64d297dc52f654e53a744} +tags: {wine: 143a2a30f89dfc79cc2a49cd34af6fd587ce3f69}
3 years, 10 months
1
0
0
0
[reactos] 178/218: [WINESYNC] d3dx9: Handle DT_SINGLELINE in ID3DXFont_DrawText.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1dfbf16fa666926eed5c2…
commit 1dfbf16fa666926eed5c296fd616126f86468cfc Author: winesync <ros-dev(a)reactos.org> AuthorDate: Mon Sep 21 23:07:31 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Thu Feb 4 16:37:06 2021 +0100 [WINESYNC] d3dx9: Handle DT_SINGLELINE in ID3DXFont_DrawText. Signed-off-by: Sven Baars <sbaars(a)codeweavers.com> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 333687f522730befb8c64d297dc52f654e53a744 by Sven Baars <sbaars(a)codeweavers.com> --- dll/directx/wine/d3dx9_36/font.c | 29 ++++++++++++++++++++--------- modules/rostests/winetests/d3dx9_36/core.c | 2 +- sdk/tools/winesync/d3dx9.cfg | 2 +- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/dll/directx/wine/d3dx9_36/font.c b/dll/directx/wine/d3dx9_36/font.c index 28ad573cda9..9cec2cdaeb7 100644 --- a/dll/directx/wine/d3dx9_36/font.c +++ b/dll/directx/wine/d3dx9_36/font.c @@ -516,7 +516,7 @@ static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite, } static void word_break(HDC hdc, const WCHAR *str, unsigned int *str_len, - unsigned int chars_fit, unsigned int *chars_used, SIZE *size) + unsigned int chars_fit, unsigned int *chars_used, DWORD format, SIZE *size) { SCRIPT_LOGATTR *sla; SCRIPT_ANALYSIS sa; @@ -539,7 +539,7 @@ static void word_break(HDC hdc, const WCHAR *str, unsigned int *str_len, --i; /* If the there is no word that fits put in all characters that do fit */ - if (!sla[i].fSoftBreak) + if (!sla[i].fSoftBreak || (format & DT_SINGLELINE)) i = chars_fit; *chars_used = i; @@ -565,10 +565,10 @@ static const WCHAR *read_line(HDC hdc, const WCHAR *str, int *count, SIZE size; *dest_len = 0; - while (*count && str[i] != '\n') + while (*count && (str[i] != '\n' || (format & DT_SINGLELINE))) { --(*count); - if (str[i] != '\r') + if (str[i] != '\r' && str[i] != '\n') dest[(*dest_len)++] = str[i]; ++i; } @@ -576,13 +576,21 @@ static const WCHAR *read_line(HDC hdc, const WCHAR *str, int *count, num_fit = 0; GetTextExtentExPointW(hdc, dest, *dest_len, width, &num_fit, NULL, &size); - if (num_fit < *dest_len && (format & DT_WORDBREAK)) + if (num_fit < *dest_len) { - unsigned int chars_used; + if (format & DT_WORDBREAK) + { + unsigned int chars_used; - word_break(hdc, dest, dest_len, num_fit, &chars_used, &size); - *count = orig_count - chars_used; - i = chars_used; + word_break(hdc, dest, dest_len, num_fit, &chars_used, format, &size); + *count = orig_count - chars_used; + i = chars_used; + } + else if (format & DT_SINGLELINE) + { + *dest_len = num_fit; + *count = 0; + } } if (*count && str[i] == '\n') @@ -621,6 +629,9 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, if (format & DT_CALCRECT) format |= DT_NOCLIP; + if (format & DT_SINGLELINE) + format &= ~DT_WORDBREAK; + if (!rect) { y = ID3DXFont_DrawTextW(iface, NULL, string, count, &textrect, format | DT_CALCRECT, 0); diff --git a/modules/rostests/winetests/d3dx9_36/core.c b/modules/rostests/winetests/d3dx9_36/core.c index 45cde62b3a8..2b5a868033f 100644 --- a/modules/rostests/winetests/d3dx9_36/core.c +++ b/modules/rostests/winetests/d3dx9_36/core.c @@ -771,7 +771,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(height == 12, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"a\na", -1, &rect, DT_SINGLELINE, 0xff00ff); - todo_wine ok(height == 12, "Got unexpected height %d.\n", height); + ok(height == 12, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"a\naaaaa aaaa", -1, &rect, 0, 0xff00ff); ok(height == 24, "Got unexpected height %d.\n", height); diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg index 3d6a83cd72a..eb2b4d90f0a 100644 --- a/sdk/tools/winesync/d3dx9.cfg +++ b/sdk/tools/winesync/d3dx9.cfg @@ -15,4 +15,4 @@ files: {include/d3dx9.h: sdk/include/dxsdk/d3dx9.h, include/d3dx9anim.h: sdk/inc include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h, include/d3dx9of.h: sdk/include/dxsdk/d3dx9of.h, include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h, include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h, include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h, include/d3dx9xof.h: sdk/include/dxsdk/d3dx9xof.h} -tags: {wine: e6a1116c2a3b196dea496f77747209f67982652c} +tags: {wine: 333687f522730befb8c64d297dc52f654e53a744}
3 years, 10 months
1
0
0
0
[reactos] 177/218: [WINESYNC] d3dx9: Handle word breaks in ID3DXFont_DrawText.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=806fe486fb3598e3bdb33…
commit 806fe486fb3598e3bdb336226cd93751fe0719c5 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Mon Sep 21 23:06:33 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Thu Feb 4 16:37:06 2021 +0100 [WINESYNC] d3dx9: Handle word breaks in ID3DXFont_DrawText. Signed-off-by: Sven Baars <sbaars(a)codeweavers.com> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id e6a1116c2a3b196dea496f77747209f67982652c by Sven Baars <sbaars(a)codeweavers.com> --- dll/directx/wine/d3dx9_36/d3dx9.cmake | 2 +- dll/directx/wine/d3dx9_36/font.c | 61 ++++++++++++++++++++++++++++-- dll/directx/wine/d3dx9_36/precomp.h | 1 + modules/rostests/winetests/d3dx9_36/core.c | 22 +++++------ sdk/tools/winesync/d3dx9.cfg | 2 +- 5 files changed, 72 insertions(+), 16 deletions(-) diff --git a/dll/directx/wine/d3dx9_36/d3dx9.cmake b/dll/directx/wine/d3dx9_36/d3dx9.cmake index cb8d937a561..082c03e5201 100644 --- a/dll/directx/wine/d3dx9_36/d3dx9.cmake +++ b/dll/directx/wine/d3dx9_36/d3dx9.cmake @@ -40,7 +40,7 @@ function(add_d3dx9_target __version) set_module_type(${module} win32dll) add_dependencies(${module} d3d_idl_headers) target_link_libraries(${module} dxguid wine) - add_importlibs(${module} d3dcompiler_43 d3dxof user32 ole32 gdi32 msvcrt kernel32 ntdll) + add_importlibs(${module} d3dcompiler_43 d3dxof usp10 user32 ole32 gdi32 msvcrt kernel32 ntdll) add_delay_importlibs(${module} windowscodecs) add_pch(${module} ../d3dx9_36/precomp.h "${PCH_SKIP_SOURCE}") add_cd_file(TARGET ${module} DESTINATION reactos/system32 FOR all) diff --git a/dll/directx/wine/d3dx9_36/font.c b/dll/directx/wine/d3dx9_36/font.c index 8b122abd14f..28ad573cda9 100644 --- a/dll/directx/wine/d3dx9_36/font.c +++ b/dll/directx/wine/d3dx9_36/font.c @@ -22,6 +22,8 @@ #include "d3dx9_private.h" + +#include "usp10.h" #endif /* __REACTOS__ */ WINE_DEFAULT_DEBUG_CHANNEL(d3dx); @@ -513,10 +515,53 @@ static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite, return ret; } +static void word_break(HDC hdc, const WCHAR *str, unsigned int *str_len, + unsigned int chars_fit, unsigned int *chars_used, SIZE *size) +{ + SCRIPT_LOGATTR *sla; + SCRIPT_ANALYSIS sa; + unsigned int i; + + *chars_used = 0; + + sla = heap_alloc(*str_len * sizeof(*sla)); + if (!sla) + return; + + memset(&sa, 0, sizeof(sa)); + sa.eScript = SCRIPT_UNDEFINED; + + ScriptBreak(str, *str_len, &sa, sla); + + /* Work back from the last character that did fit to a place where we can break */ + i = chars_fit; + while (i > 0 && !sla[i].fSoftBreak) /* chars_fit < *str_len so this is valid */ + --i; + + /* If the there is no word that fits put in all characters that do fit */ + if (!sla[i].fSoftBreak) + i = chars_fit; + + *chars_used = i; + if (sla[i].fWhiteSpace) + ++(*chars_used); + + /* Remove extra spaces */ + while (i > 0 && sla[i-1].fWhiteSpace) + --i; + *str_len = i; + + /* Remeasure the string */ + GetTextExtentExPointW(hdc, str, *str_len, 0, NULL, NULL, size); + heap_free(sla); +} + static const WCHAR *read_line(HDC hdc, const WCHAR *str, int *count, - WCHAR *dest, unsigned int *dest_len, int width) + WCHAR *dest, unsigned int *dest_len, int width, DWORD format) { unsigned int i = 0; + int orig_count = *count; + int num_fit; SIZE size; *dest_len = 0; @@ -528,7 +573,17 @@ static const WCHAR *read_line(HDC hdc, const WCHAR *str, int *count, ++i; } - GetTextExtentExPointW(hdc, dest, *dest_len, width, NULL, NULL, &size); + num_fit = 0; + GetTextExtentExPointW(hdc, dest, *dest_len, width, &num_fit, NULL, &size); + + if (num_fit < *dest_len && (format & DT_WORDBREAK)) + { + unsigned int chars_used; + + word_break(hdc, dest, dest_len, num_fit, &chars_used, &size); + *count = orig_count - chars_used; + i = chars_used; + } if (*count && str[i] == '\n') { @@ -598,7 +653,7 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, { unsigned int line_len; - string = read_line(font->hdc, string, &count, line, &line_len, width); + string = read_line(font->hdc, string, &count, line, &line_len, width, format); if (!(format & DT_CALCRECT)) { diff --git a/dll/directx/wine/d3dx9_36/precomp.h b/dll/directx/wine/d3dx9_36/precomp.h index b6a35522a31..4325ad715c5 100644 --- a/dll/directx/wine/d3dx9_36/precomp.h +++ b/dll/directx/wine/d3dx9_36/precomp.h @@ -20,6 +20,7 @@ #include <winbase.h> #include <wingdi.h> #include <winuser.h> +#include <usp10.h> #include <wine/winternl.h> diff --git a/modules/rostests/winetests/d3dx9_36/core.c b/modules/rostests/winetests/d3dx9_36/core.c index c79f5c1f728..45cde62b3a8 100644 --- a/modules/rostests/winetests/d3dx9_36/core.c +++ b/modules/rostests/winetests/d3dx9_36/core.c @@ -722,7 +722,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) todo_wine ok(height == 60, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextA(font, NULL, long_text, -1, &rect, DT_WORDBREAK | DT_NOCLIP, 0xff00ff); - todo_wine ok(height == 96, "Got unexpected height %d.\n", height); + ok(height == 96, "Got unexpected height %d.\n", height); SetRect(&rect, 10, 10, 200, 200); @@ -759,7 +759,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) todo_wine ok(height == 60, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, long_textW, -1, &rect, DT_WORDBREAK | DT_NOCLIP, 0xff00ff); - todo_wine ok(height == 96, "Got unexpected height %d.\n", height); + ok(height == 96, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"a\na", -1, &rect, 0, 0xff00ff); ok(height == 24, "Got unexpected height %d.\n", height); @@ -777,7 +777,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(height == 24, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"a\naaaaa aaaa", -1, &rect, DT_WORDBREAK, 0xff00ff); - todo_wine ok(height == 36, "Got unexpected height %d.\n", height); + ok(height == 36, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"1\n2\n3\n4\n5\n6", -1, &rect, 0, 0xff00ff); ok(height == 48, "Got unexpected height %d.\n", height); @@ -789,16 +789,16 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) todo_wine ok(height == 0, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"\t\t\t\t\t\t\t\t\t\ta", -1, &rect, DT_WORDBREAK, 0xff00ff); - ok(height == 12, "Got unexpected height %d.\n", height); + todo_wine ok(height == 12, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"\taaaaaaaaaa", -1, &rect, DT_WORDBREAK, 0xff00ff); todo_wine ok(height == 24, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"\taaaaaaaaaa", -1, &rect, DT_EXPANDTABS | DT_WORDBREAK, 0xff00ff); - todo_wine ok(height == 36, "Got unexpected height %d.\n", height); + ok(height == 36, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"\taaa\taaa\taaa", -1, &rect, DT_WORDBREAK, 0xff00ff); - todo_wine ok(height == 24, "Got unexpected height %d.\n", height); + ok(height == 24, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"\taaa\taaa\taaa", -1, &rect, DT_EXPANDTABS | DT_WORDBREAK, 0xff00ff); todo_wine ok(height == 48, "Got unexpected height %d.\n", height); @@ -813,19 +813,19 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) todo_wine ok(height == 24, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"aaaaaaaaaaaaaaaaaaaa", -1, &rect, DT_WORDBREAK, 0xff00ff); - todo_wine ok(height == 36, "Got unexpected height %d.\n", height); + ok(height == 36, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"a a", -1, &rect, DT_WORDBREAK, 0xff00ff); - todo_wine ok(height == 36, "Got unexpected height %d.\n", height); + ok(height == 36, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK, 0xff00ff); - todo_wine ok(height == 36, "Got unexpected height %d.\n", height); + ok(height == 36, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK | DT_RIGHT, 0xff00ff); - todo_wine ok(height == 36, "Got unexpected height %d.\n", height); + ok(height == 36, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK | DT_RIGHT, 0xff00ff); - todo_wine ok(height == 36, "Got unexpected height %d.\n", height); + ok(height == 36, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_BOTTOM, 0xff00ff); todo_wine ok(height == 40, "Got unexpected height %d.\n", height); diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg index 135d55d8c2f..3d6a83cd72a 100644 --- a/sdk/tools/winesync/d3dx9.cfg +++ b/sdk/tools/winesync/d3dx9.cfg @@ -15,4 +15,4 @@ files: {include/d3dx9.h: sdk/include/dxsdk/d3dx9.h, include/d3dx9anim.h: sdk/inc include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h, include/d3dx9of.h: sdk/include/dxsdk/d3dx9of.h, include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h, include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h, include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h, include/d3dx9xof.h: sdk/include/dxsdk/d3dx9xof.h} -tags: {wine: 6da3e904a1efc921030fdbe34070b981bf57524c} +tags: {wine: e6a1116c2a3b196dea496f77747209f67982652c}
3 years, 10 months
1
0
0
0
[reactos] 176/218: [WINESYNC] d3dx9: Handle clipping in ID3DXFont_DrawText.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=818c9f88b09d8f936ab48…
commit 818c9f88b09d8f936ab4879983db3e53d48372c2 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Mon Sep 21 23:03:28 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Thu Feb 4 16:37:06 2021 +0100 [WINESYNC] d3dx9: Handle clipping in ID3DXFont_DrawText. Signed-off-by: Sven Baars <sbaars(a)codeweavers.com> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 6da3e904a1efc921030fdbe34070b981bf57524c by Sven Baars <sbaars(a)codeweavers.com> --- dll/directx/wine/d3dx9_36/font.c | 5 +++++ modules/rostests/winetests/d3dx9_36/core.c | 2 +- sdk/tools/winesync/d3dx9.cfg | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dll/directx/wine/d3dx9_36/font.c b/dll/directx/wine/d3dx9_36/font.c index d5907d15d94..8b122abd14f 100644 --- a/dll/directx/wine/d3dx9_36/font.c +++ b/dll/directx/wine/d3dx9_36/font.c @@ -563,6 +563,9 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, if (!count) return 0; + if (format & DT_CALCRECT) + format |= DT_NOCLIP; + if (!rect) { y = ID3DXFont_DrawTextW(iface, NULL, string, count, &textrect, format | DT_CALCRECT, 0); @@ -641,6 +644,8 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, heap_free(results.lpGlyphs); } y += lh; + if (!(DT_NOCLIP & format) && (y > textrect.bottom)) + break; } ret = y - textrect.top; diff --git a/modules/rostests/winetests/d3dx9_36/core.c b/modules/rostests/winetests/d3dx9_36/core.c index c6f5beff433..c79f5c1f728 100644 --- a/modules/rostests/winetests/d3dx9_36/core.c +++ b/modules/rostests/winetests/d3dx9_36/core.c @@ -780,7 +780,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) todo_wine ok(height == 36, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"1\n2\n3\n4\n5\n6", -1, &rect, 0, 0xff00ff); - todo_wine ok(height == 48, "Got unexpected height %d.\n", height); + ok(height == 48, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"1\n2\n3\n4\n5\n6", -1, &rect, DT_NOCLIP, 0xff00ff); ok(height == 72, "Got unexpected height %d.\n", height); diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg index 6a43210e9fe..135d55d8c2f 100644 --- a/sdk/tools/winesync/d3dx9.cfg +++ b/sdk/tools/winesync/d3dx9.cfg @@ -15,4 +15,4 @@ files: {include/d3dx9.h: sdk/include/dxsdk/d3dx9.h, include/d3dx9anim.h: sdk/inc include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h, include/d3dx9of.h: sdk/include/dxsdk/d3dx9of.h, include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h, include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h, include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h, include/d3dx9xof.h: sdk/include/dxsdk/d3dx9xof.h} -tags: {wine: 330c3f9108191feb6eb888384befb5cb54645233} +tags: {wine: 6da3e904a1efc921030fdbe34070b981bf57524c}
3 years, 10 months
1
0
0
0
[reactos] 175/218: [WINESYNC] d3dx9: Handle newlines in ID3DXFont_DrawText.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9363eac228ec6734f15d5…
commit 9363eac228ec6734f15d5434701acf3ee91cc1cc Author: winesync <ros-dev(a)reactos.org> AuthorDate: Mon Sep 21 23:03:28 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Thu Feb 4 16:37:06 2021 +0100 [WINESYNC] d3dx9: Handle newlines in ID3DXFont_DrawText. Signed-off-by: Sven Baars <sbaars(a)codeweavers.com> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 330c3f9108191feb6eb888384befb5cb54645233 by Sven Baars <sbaars(a)codeweavers.com> --- dll/directx/wine/d3dx9_36/font.c | 109 ++++++++++++++++++++--------- modules/rostests/winetests/d3dx9_36/core.c | 14 ++-- sdk/tools/winesync/d3dx9.cfg | 2 +- 3 files changed, 84 insertions(+), 41 deletions(-) diff --git a/dll/directx/wine/d3dx9_36/font.c b/dll/directx/wine/d3dx9_36/font.c index 23e2682c75c..d5907d15d94 100644 --- a/dll/directx/wine/d3dx9_36/font.c +++ b/dll/directx/wine/d3dx9_36/font.c @@ -513,13 +513,42 @@ static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite, return ret; } +static const WCHAR *read_line(HDC hdc, const WCHAR *str, int *count, + WCHAR *dest, unsigned int *dest_len, int width) +{ + unsigned int i = 0; + SIZE size; + + *dest_len = 0; + while (*count && str[i] != '\n') + { + --(*count); + if (str[i] != '\r') + dest[(*dest_len)++] = str[i]; + ++i; + } + + GetTextExtentExPointW(hdc, dest, *dest_len, width, NULL, NULL, &size); + + if (*count && str[i] == '\n') + { + --(*count); + ++i; + } + + if (*count) + return str + i; + return NULL; +} + static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, const WCHAR *string, INT count, RECT *rect, DWORD format, D3DCOLOR color) { struct d3dx_font *font = impl_from_ID3DXFont(iface); ID3DXSprite *target = sprite; + WCHAR *line; RECT textrect = {0}; - int lh, x, y; + int lh, x, y, width; int ret = 0; TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x.\n", @@ -548,59 +577,71 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, x = textrect.left; y = textrect.top; + width = textrect.right - textrect.left; lh = font->metrics.tmHeight; + line = heap_alloc(count * sizeof(*line)); + if (!line) + return 0; + if (!(format & DT_CALCRECT) && !sprite) { D3DXCreateSprite(font->device, &target); ID3DXSprite_Begin(target, 0); } - if (!(format & DT_CALCRECT)) + while (string) { - GCP_RESULTSW results; - D3DXVECTOR3 pos; - int i; - - memset(&results, 0, sizeof(results)); - results.nGlyphs = count; + unsigned int line_len; - results.lpCaretPos = heap_alloc(count * sizeof(*results.lpCaretPos)); - if (!results.lpCaretPos) - goto cleanup; + string = read_line(font->hdc, string, &count, line, &line_len, width); - results.lpGlyphs = heap_alloc(count * sizeof(*results.lpGlyphs)); - if (!results.lpGlyphs) + if (!(format & DT_CALCRECT)) { - heap_free(results.lpCaretPos); - goto cleanup; - } + GCP_RESULTSW results; + D3DXVECTOR3 pos; + unsigned int i; - GetCharacterPlacementW(font->hdc, string, count, 0, &results, 0); + memset(&results, 0, sizeof(results)); + results.nGlyphs = line_len; - for (i = 0; i < results.nGlyphs; ++i) - { - IDirect3DTexture9 *texture; - POINT cell_inc; - RECT black_box; + results.lpCaretPos = heap_alloc(line_len * sizeof(*results.lpCaretPos)); + if (!results.lpCaretPos) + goto cleanup; - ID3DXFont_GetGlyphData(iface, results.lpGlyphs[i], &texture, &black_box, &cell_inc); + results.lpGlyphs = heap_alloc(line_len * sizeof(*results.lpGlyphs)); + if (!results.lpGlyphs) + { + heap_free(results.lpCaretPos); + goto cleanup; + } - if (!texture) - continue; + GetCharacterPlacementW(font->hdc, line, line_len, 0, &results, 0); - pos.x = cell_inc.x + x + results.lpCaretPos[i]; - pos.y = cell_inc.y + y; + for (i = 0; i < results.nGlyphs; ++i) + { + IDirect3DTexture9 *texture; + POINT cell_inc; + RECT black_box; - ID3DXSprite_Draw(target, texture, &black_box, NULL, &pos, color); - IDirect3DTexture9_Release(texture); - } + ID3DXFont_GetGlyphData(iface, results.lpGlyphs[i], &texture, &black_box, &cell_inc); - heap_free(results.lpCaretPos); - heap_free(results.lpGlyphs); + if (!texture) + continue; + + pos.x = cell_inc.x + x + results.lpCaretPos[i]; + pos.y = cell_inc.y + y; + + ID3DXSprite_Draw(target, texture, &black_box, NULL, &pos, color); + IDirect3DTexture9_Release(texture); + } + + heap_free(results.lpCaretPos); + heap_free(results.lpGlyphs); + } + y += lh; } - y += lh; ret = y - textrect.top; @@ -611,6 +652,8 @@ cleanup: ID3DXSprite_Release(target); } + heap_free(line); + return ret; } diff --git a/modules/rostests/winetests/d3dx9_36/core.c b/modules/rostests/winetests/d3dx9_36/core.c index c1e0eac0c8f..c6f5beff433 100644 --- a/modules/rostests/winetests/d3dx9_36/core.c +++ b/modules/rostests/winetests/d3dx9_36/core.c @@ -762,19 +762,19 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) todo_wine ok(height == 96, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"a\na", -1, &rect, 0, 0xff00ff); - todo_wine ok(height == 24, "Got unexpected height %d.\n", height); + ok(height == 24, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"a\r\na", -1, &rect, 0, 0xff00ff); - todo_wine ok(height == 24, "Got unexpected height %d.\n", height); + ok(height == 24, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"a\ra", -1, &rect, 0, 0xff00ff); ok(height == 12, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"a\na", -1, &rect, DT_SINGLELINE, 0xff00ff); - ok(height == 12, "Got unexpected height %d.\n", height); + todo_wine ok(height == 12, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"a\naaaaa aaaa", -1, &rect, 0, 0xff00ff); - todo_wine ok(height == 24, "Got unexpected height %d.\n", height); + ok(height == 24, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"a\naaaaa aaaa", -1, &rect, DT_WORDBREAK, 0xff00ff); todo_wine ok(height == 36, "Got unexpected height %d.\n", height); @@ -783,7 +783,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) todo_wine ok(height == 48, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"1\n2\n3\n4\n5\n6", -1, &rect, DT_NOCLIP, 0xff00ff); - todo_wine ok(height == 72, "Got unexpected height %d.\n", height); + ok(height == 72, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"\t\t\t\t\t\t\t\t\t\t", -1, &rect, DT_WORDBREAK, 0xff00ff); todo_wine ok(height == 0, "Got unexpected height %d.\n", height); @@ -834,10 +834,10 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) todo_wine ok(height == 32, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_RIGHT, 0xff00ff); - todo_wine ok(height == 24, "Got unexpected height %d.\n", height); + ok(height == 24, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CENTER, 0xff00ff); - todo_wine ok(height == 24, "Got unexpected height %d.\n", height); + ok(height == 24, "Got unexpected height %d.\n", height); ID3DXFont_Release(font); } diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg index 4bbd42bf86c..6a43210e9fe 100644 --- a/sdk/tools/winesync/d3dx9.cfg +++ b/sdk/tools/winesync/d3dx9.cfg @@ -15,4 +15,4 @@ files: {include/d3dx9.h: sdk/include/dxsdk/d3dx9.h, include/d3dx9anim.h: sdk/inc include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h, include/d3dx9of.h: sdk/include/dxsdk/d3dx9of.h, include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h, include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h, include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h, include/d3dx9xof.h: sdk/include/dxsdk/d3dx9xof.h} -tags: {wine: 316a8d0ae11ae1a9654bc731d2c9dc23febc7a2d} +tags: {wine: 330c3f9108191feb6eb888384befb5cb54645233}
3 years, 10 months
1
0
0
0
[reactos] 174/218: [WINESYNC] d3dx9: Add a very basic ID3DXFont_DrawText implementation.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=928ed97d6c7be8f79cdd0…
commit 928ed97d6c7be8f79cdd0eba0101469e3e226f56 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Mon Sep 21 23:03:28 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Thu Feb 4 16:37:05 2021 +0100 [WINESYNC] d3dx9: Add a very basic ID3DXFont_DrawText implementation. Based on a patch by Tony Wasserka. Signed-off-by: Sven Baars <sbaars(a)codeweavers.com> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 316a8d0ae11ae1a9654bc731d2c9dc23febc7a2d by Sven Baars <sbaars(a)codeweavers.com> --- dll/directx/wine/d3dx9_36/font.c | 128 +++++++++++++++++++++++++++-- modules/rostests/winetests/d3dx9_36/core.c | 59 ++++++------- sdk/tools/winesync/d3dx9.cfg | 2 +- 3 files changed, 150 insertions(+), 39 deletions(-) diff --git a/dll/directx/wine/d3dx9_36/font.c b/dll/directx/wine/d3dx9_36/font.c index 6a4a6ed32c3..23e2682c75c 100644 --- a/dll/directx/wine/d3dx9_36/font.c +++ b/dll/directx/wine/d3dx9_36/font.c @@ -485,17 +485,133 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadTextW(ID3DXFont *iface, const WCHAR * static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite, const char *string, INT count, RECT *rect, DWORD format, D3DCOLOR color) { - FIXME("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x stub!\n", - iface, sprite, debugstr_a(string), count, wine_dbgstr_rect(rect), format, color); - return 1; + int ret, countW; + WCHAR *wstr; + + TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x.\n", + iface, sprite, debugstr_an(string, count), count, wine_dbgstr_rect(rect), format, color); + + if (!string || !count) + return 0; + + countW = MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, NULL, 0); + + if (!countW) + return 0; + + wstr = heap_alloc_zero(countW * sizeof(*wstr)); + if (!wstr) + return 0; + + MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, wstr, countW); + + ret = ID3DXFont_DrawTextW(iface, sprite, wstr, count < 0 ? countW - 1 : countW, + rect, format, color); + + heap_free(wstr); + + return ret; } static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, const WCHAR *string, INT count, RECT *rect, DWORD format, D3DCOLOR color) { - FIXME("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x stub!\n", - iface, sprite, debugstr_w(string), count, wine_dbgstr_rect(rect), format, color); - return 1; + struct d3dx_font *font = impl_from_ID3DXFont(iface); + ID3DXSprite *target = sprite; + RECT textrect = {0}; + int lh, x, y; + int ret = 0; + + TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x.\n", + iface, sprite, debugstr_wn(string, count), count, wine_dbgstr_rect(rect), format, color); + + if (!string) + return 0; + + if (count < 0) + count = lstrlenW(string); + + if (!count) + return 0; + + if (!rect) + { + y = ID3DXFont_DrawTextW(iface, NULL, string, count, &textrect, format | DT_CALCRECT, 0); + + if (format & DT_CALCRECT) + return y; + } + else + { + textrect = *rect; + } + + x = textrect.left; + y = textrect.top; + + lh = font->metrics.tmHeight; + + if (!(format & DT_CALCRECT) && !sprite) + { + D3DXCreateSprite(font->device, &target); + ID3DXSprite_Begin(target, 0); + } + + if (!(format & DT_CALCRECT)) + { + GCP_RESULTSW results; + D3DXVECTOR3 pos; + int i; + + memset(&results, 0, sizeof(results)); + results.nGlyphs = count; + + results.lpCaretPos = heap_alloc(count * sizeof(*results.lpCaretPos)); + if (!results.lpCaretPos) + goto cleanup; + + results.lpGlyphs = heap_alloc(count * sizeof(*results.lpGlyphs)); + if (!results.lpGlyphs) + { + heap_free(results.lpCaretPos); + goto cleanup; + } + + GetCharacterPlacementW(font->hdc, string, count, 0, &results, 0); + + for (i = 0; i < results.nGlyphs; ++i) + { + IDirect3DTexture9 *texture; + POINT cell_inc; + RECT black_box; + + ID3DXFont_GetGlyphData(iface, results.lpGlyphs[i], &texture, &black_box, &cell_inc); + + if (!texture) + continue; + + pos.x = cell_inc.x + x + results.lpCaretPos[i]; + pos.y = cell_inc.y + y; + + ID3DXSprite_Draw(target, texture, &black_box, NULL, &pos, color); + IDirect3DTexture9_Release(texture); + } + + heap_free(results.lpCaretPos); + heap_free(results.lpGlyphs); + } + y += lh; + + ret = y - textrect.top; + +cleanup: + if (target != sprite) + { + ID3DXSprite_End(target); + ID3DXSprite_Release(target); + } + + return ret; } static HRESULT WINAPI ID3DXFontImpl_OnLostDevice(ID3DXFont *iface) diff --git a/modules/rostests/winetests/d3dx9_36/core.c b/modules/rostests/winetests/d3dx9_36/core.c index 662483b687a..c1e0eac0c8f 100644 --- a/modules/rostests/winetests/d3dx9_36/core.c +++ b/modules/rostests/winetests/d3dx9_36/core.c @@ -652,8 +652,6 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) hr = ID3DXSprite_Begin(sprite, D3DXSPRITE_ALPHABLEND); ok (hr == D3D_OK, "Test %d: got unexpected hr %#x.\n", i, hr); - todo_wine - { height = ID3DXFont_DrawTextW(font, sprite, testW, -1, &rect, DT_TOP, 0xffffffff); ok(height == tests[i].font_height, "Test %d: got unexpected height %u.\n", i, height); height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_TOP, 0xffffffff); @@ -662,12 +660,11 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(height == tests[i].font_height, "Test %d: got unexpected height %u.\n", i, height); height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_LEFT | DT_NOCLIP, 0xffffffff); ok(height == tests[i].font_height, "Test %d: got unexpected height %u.\n", i, height); - } SetRectEmpty(&rect); height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_LEFT | DT_CALCRECT, 0xffffffff); - todo_wine ok(height == tests[i].font_height, "Test %d: got unexpected height %u.\n", i, height); + ok(height == tests[i].font_height, "Test %d: got unexpected height %u.\n", i, height); ok(!rect.left, "Test %d: got unexpected rect left %d.\n", i, rect.left); ok(!rect.top, "Test %d: got unexpected rect top %d.\n", i, rect.top); todo_wine ok(rect.right, "Test %d: got unexpected rect right %d.\n", i, rect.right); @@ -687,7 +684,6 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - todo_wine { SetRect(&rect, 10, 10, 200, 200); height = ID3DXFont_DrawTextA(font, NULL, "test", -2, &rect, 0, 0xFF00FF); @@ -723,10 +719,10 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) SetRect(&rect, 10, 10, 50, 50); height = ID3DXFont_DrawTextA(font, NULL, long_text, -1, &rect, DT_WORDBREAK, 0xff00ff); - ok(height == 60, "Got unexpected height %d.\n", height); + todo_wine ok(height == 60, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextA(font, NULL, long_text, -1, &rect, DT_WORDBREAK | DT_NOCLIP, 0xff00ff); - ok(height == 96, "Got unexpected height %d.\n", height); + todo_wine ok(height == 96, "Got unexpected height %d.\n", height); SetRect(&rect, 10, 10, 200, 200); @@ -760,16 +756,16 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) SetRect(&rect, 10, 10, 50, 50); height = ID3DXFont_DrawTextW(font, NULL, long_textW, -1, &rect, DT_WORDBREAK, 0xff00ff); - ok(height == 60, "Got unexpected height %d.\n", height); + todo_wine ok(height == 60, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, long_textW, -1, &rect, DT_WORDBREAK | DT_NOCLIP, 0xff00ff); - ok(height == 96, "Got unexpected height %d.\n", height); + todo_wine ok(height == 96, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"a\na", -1, &rect, 0, 0xff00ff); - ok(height == 24, "Got unexpected height %d.\n", height); + todo_wine ok(height == 24, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"a\r\na", -1, &rect, 0, 0xff00ff); - ok(height == 24, "Got unexpected height %d.\n", height); + todo_wine ok(height == 24, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"a\ra", -1, &rect, 0, 0xff00ff); ok(height == 12, "Got unexpected height %d.\n", height); @@ -778,71 +774,70 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(height == 12, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"a\naaaaa aaaa", -1, &rect, 0, 0xff00ff); - ok(height == 24, "Got unexpected height %d.\n", height); + todo_wine ok(height == 24, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"a\naaaaa aaaa", -1, &rect, DT_WORDBREAK, 0xff00ff); - ok(height == 36, "Got unexpected height %d.\n", height); + todo_wine ok(height == 36, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"1\n2\n3\n4\n5\n6", -1, &rect, 0, 0xff00ff); - ok(height == 48, "Got unexpected height %d.\n", height); + todo_wine ok(height == 48, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"1\n2\n3\n4\n5\n6", -1, &rect, DT_NOCLIP, 0xff00ff); - ok(height == 72, "Got unexpected height %d.\n", height); + todo_wine ok(height == 72, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"\t\t\t\t\t\t\t\t\t\t", -1, &rect, DT_WORDBREAK, 0xff00ff); - ok(height == 0, "Got unexpected height %d.\n", height); + todo_wine ok(height == 0, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"\t\t\t\t\t\t\t\t\t\ta", -1, &rect, DT_WORDBREAK, 0xff00ff); ok(height == 12, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"\taaaaaaaaaa", -1, &rect, DT_WORDBREAK, 0xff00ff); - ok(height == 24, "Got unexpected height %d.\n", height); + todo_wine ok(height == 24, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"\taaaaaaaaaa", -1, &rect, DT_EXPANDTABS | DT_WORDBREAK, 0xff00ff); - ok(height == 36, "Got unexpected height %d.\n", height); + todo_wine ok(height == 36, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"\taaa\taaa\taaa", -1, &rect, DT_WORDBREAK, 0xff00ff); - ok(height == 24, "Got unexpected height %d.\n", height); + todo_wine ok(height == 24, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"\taaa\taaa\taaa", -1, &rect, DT_EXPANDTABS | DT_WORDBREAK, 0xff00ff); - ok(height == 48, "Got unexpected height %d.\n", height); + todo_wine ok(height == 48, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"\t\t\t\t\t\t\t\t\t\t", -1, &rect, DT_EXPANDTABS | DT_WORDBREAK, 0xff00ff); - ok(height == 60, "Got unexpected height %d.\n", height); + todo_wine ok(height == 60, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"a\ta", -1, &rect, DT_EXPANDTABS | DT_WORDBREAK, 0xff00ff); ok(height == 12, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"a\ta\ta", -1, &rect, DT_EXPANDTABS | DT_WORDBREAK, 0xff00ff); - ok(height == 24, "Got unexpected height %d.\n", height); + todo_wine ok(height == 24, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"aaaaaaaaaaaaaaaaaaaa", -1, &rect, DT_WORDBREAK, 0xff00ff); - ok(height == 36, "Got unexpected height %d.\n", height); + todo_wine ok(height == 36, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"a a", -1, &rect, DT_WORDBREAK, 0xff00ff); - ok(height == 36, "Got unexpected height %d.\n", height); + todo_wine ok(height == 36, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK, 0xff00ff); - ok(height == 36, "Got unexpected height %d.\n", height); + todo_wine ok(height == 36, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK | DT_RIGHT, 0xff00ff); - ok(height == 36, "Got unexpected height %d.\n", height); + todo_wine ok(height == 36, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK | DT_RIGHT, 0xff00ff); - ok(height == 36, "Got unexpected height %d.\n", height); + todo_wine ok(height == 36, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_BOTTOM, 0xff00ff); - ok(height == 40, "Got unexpected height %d.\n", height); + todo_wine ok(height == 40, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_VCENTER, 0xff00ff); - ok(height == 32, "Got unexpected height %d.\n", height); + todo_wine ok(height == 32, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_RIGHT, 0xff00ff); - ok(height == 24, "Got unexpected height %d.\n", height); + todo_wine ok(height == 24, "Got unexpected height %d.\n", height); height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CENTER, 0xff00ff); - ok(height == 24, "Got unexpected height %d.\n", height); - } + todo_wine ok(height == 24, "Got unexpected height %d.\n", height); ID3DXFont_Release(font); } diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg index abf1b70c129..4bbd42bf86c 100644 --- a/sdk/tools/winesync/d3dx9.cfg +++ b/sdk/tools/winesync/d3dx9.cfg @@ -15,4 +15,4 @@ files: {include/d3dx9.h: sdk/include/dxsdk/d3dx9.h, include/d3dx9anim.h: sdk/inc include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h, include/d3dx9of.h: sdk/include/dxsdk/d3dx9of.h, include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h, include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h, include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h, include/d3dx9xof.h: sdk/include/dxsdk/d3dx9xof.h} -tags: {wine: cc03400e322edea97f0e425c04cd9069f77b4c9f} +tags: {wine: 316a8d0ae11ae1a9654bc731d2c9dc23febc7a2d}
3 years, 10 months
1
0
0
0
[reactos] 173/218: [WINESYNC] d3dx9: Implement ID3DXFont_PreloadText.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=aa86f68321460ee81131d…
commit aa86f68321460ee81131d37f1abca2dda08859bc Author: winesync <ros-dev(a)reactos.org> AuthorDate: Mon Sep 21 23:03:28 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Thu Feb 4 16:37:05 2021 +0100 [WINESYNC] d3dx9: Implement ID3DXFont_PreloadText. Based on a patch by Tony Wasserka. Signed-off-by: Sven Baars <sbaars(a)codeweavers.com> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id cc03400e322edea97f0e425c04cd9069f77b4c9f by Sven Baars <sbaars(a)codeweavers.com> --- dll/directx/wine/d3dx9_36/font.c | 56 +++++++++++++++++++++++++++--- modules/rostests/winetests/d3dx9_36/core.c | 2 -- sdk/tools/winesync/d3dx9.cfg | 2 +- 3 files changed, 53 insertions(+), 7 deletions(-) diff --git a/dll/directx/wine/d3dx9_36/font.c b/dll/directx/wine/d3dx9_36/font.c index 11e20ed2bdc..6a4a6ed32c3 100644 --- a/dll/directx/wine/d3dx9_36/font.c +++ b/dll/directx/wine/d3dx9_36/font.c @@ -424,14 +424,62 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first, static HRESULT WINAPI ID3DXFontImpl_PreloadTextA(ID3DXFont *iface, const char *string, INT count) { - FIXME("iface %p, string %s, count %d stub!\n", iface, debugstr_a(string), count); - return E_NOTIMPL; + WCHAR *wstr; + HRESULT hr; + int countW; + + TRACE("iface %p, string %s, count %d.\n", iface, debugstr_an(string, count), count); + + if (!string && !count) + return D3D_OK; + + if (!string) + return D3DERR_INVALIDCALL; + + countW = MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, NULL, 0); + + wstr = heap_alloc(countW * sizeof(*wstr)); + if (!wstr) + return E_OUTOFMEMORY; + + MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, wstr, countW); + + hr = ID3DXFont_PreloadTextW(iface, wstr, count < 0 ? countW - 1 : countW); + + heap_free(wstr); + + return hr; } static HRESULT WINAPI ID3DXFontImpl_PreloadTextW(ID3DXFont *iface, const WCHAR *string, INT count) { - FIXME("iface %p, string %s, count %d stub!\n", iface, debugstr_w(string), count); - return E_NOTIMPL; + struct d3dx_font *font = impl_from_ID3DXFont(iface); + WORD *indices; + int i; + + TRACE("iface %p, string %s, count %d.\n", iface, debugstr_wn(string, count), count); + + if (!string && !count) + return D3D_OK; + + if (!string) + return D3DERR_INVALIDCALL; + + if (count < 0) + count = lstrlenW(string); + + indices = heap_alloc(count * sizeof(*indices)); + if (!indices) + return E_OUTOFMEMORY; + + GetGlyphIndicesW(font->hdc, string, count, indices, 0); + + for (i = 0; i < count; ++i) + ID3DXFont_PreloadGlyphs(iface, indices[i], indices[i]); + + heap_free(indices); + + return D3D_OK; } static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite, diff --git a/modules/rostests/winetests/d3dx9_36/core.c b/modules/rostests/winetests/d3dx9_36/core.c index b8e680d1c55..662483b687a 100644 --- a/modules/rostests/winetests/d3dx9_36/core.c +++ b/modules/rostests/winetests/d3dx9_36/core.c @@ -504,7 +504,6 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - todo_wine { hr = ID3DXFont_PreloadTextA(font, NULL, -1); ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); hr = ID3DXFont_PreloadTextA(font, NULL, 0); @@ -530,7 +529,6 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = ID3DXFont_PreloadTextW(font, L"", -1); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - } check_release((IUnknown*)font, 0); diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg index 0181a5fd9b2..abf1b70c129 100644 --- a/sdk/tools/winesync/d3dx9.cfg +++ b/sdk/tools/winesync/d3dx9.cfg @@ -15,4 +15,4 @@ files: {include/d3dx9.h: sdk/include/dxsdk/d3dx9.h, include/d3dx9anim.h: sdk/inc include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h, include/d3dx9of.h: sdk/include/dxsdk/d3dx9of.h, include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h, include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h, include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h, include/d3dx9xof.h: sdk/include/dxsdk/d3dx9xof.h} -tags: {wine: 21fc1f37e76eaced9228eaf62a45489a2bf8ac11} +tags: {wine: cc03400e322edea97f0e425c04cd9069f77b4c9f}
3 years, 10 months
1
0
0
0
[reactos] 172/218: [WINESYNC] d3dx9: Implement ID3DXFont_PreloadCharacters.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6f6f4d1501ad11caf567d…
commit 6f6f4d1501ad11caf567d66b25390022406ed698 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Mon Sep 21 23:03:28 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Thu Feb 4 16:37:05 2021 +0100 [WINESYNC] d3dx9: Implement ID3DXFont_PreloadCharacters. Based on a patch by Tony Wasserka. Signed-off-by: Sven Baars <sbaars(a)codeweavers.com> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 21fc1f37e76eaced9228eaf62a45489a2bf8ac11 by Sven Baars <sbaars(a)codeweavers.com> --- dll/directx/wine/d3dx9_36/font.c | 46 ++++++++++++++++++++++++++++++++++++++-- sdk/tools/winesync/d3dx9.cfg | 2 +- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/dll/directx/wine/d3dx9_36/font.c b/dll/directx/wine/d3dx9_36/font.c index c2cdde37f8f..11e20ed2bdc 100644 --- a/dll/directx/wine/d3dx9_36/font.c +++ b/dll/directx/wine/d3dx9_36/font.c @@ -224,8 +224,50 @@ static HRESULT WINAPI ID3DXFontImpl_GetGlyphData(ID3DXFont *iface, UINT glyph, static HRESULT WINAPI ID3DXFontImpl_PreloadCharacters(ID3DXFont *iface, UINT first, UINT last) { - FIXME("iface %p, first %u, last %u stub!\n", iface, first, last); - return S_OK; + struct d3dx_font *font = impl_from_ID3DXFont(iface); + unsigned int i, count, start, end; + WORD *indices; + WCHAR *chars; + + TRACE("iface %p, first %u, last %u.\n", iface, first, last); + + if (last < first) + return D3D_OK; + + count = last - first + 1; + indices = heap_alloc(count * sizeof(*indices)); + if (!indices) + return E_OUTOFMEMORY; + + chars = heap_alloc(count * sizeof(*chars)); + if (!chars) + { + heap_free(indices); + return E_OUTOFMEMORY; + } + + for (i = 0; i < count; ++i) + chars[i] = first + i; + + GetGlyphIndicesW(font->hdc, chars, count, indices, 0); + + start = end = indices[0]; + for (i = 1; i < count; ++i) + { + if (indices[i] == end + 1) + { + end = indices[i]; + continue; + } + ID3DXFont_PreloadGlyphs(iface, start, end); + start = end = indices[i]; + } + ID3DXFont_PreloadGlyphs(iface, start, end); + + heap_free(chars); + heap_free(indices); + + return D3D_OK; } static uint32_t morton_decode(uint32_t x) diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg index 3948abeff75..0181a5fd9b2 100644 --- a/sdk/tools/winesync/d3dx9.cfg +++ b/sdk/tools/winesync/d3dx9.cfg @@ -15,4 +15,4 @@ files: {include/d3dx9.h: sdk/include/dxsdk/d3dx9.h, include/d3dx9anim.h: sdk/inc include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h, include/d3dx9of.h: sdk/include/dxsdk/d3dx9of.h, include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h, include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h, include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h, include/d3dx9xof.h: sdk/include/dxsdk/d3dx9xof.h} -tags: {wine: e9ea8a05e54f1c950e5c15979d1393ad013402b1} +tags: {wine: 21fc1f37e76eaced9228eaf62a45489a2bf8ac11}
3 years, 10 months
1
0
0
0
[reactos] 171/218: [WINESYNC] d3dx9: Implement ID3DXFont_GetGlyphData.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ea944e7a9e158b7878ca6…
commit ea944e7a9e158b7878ca6b5d9813e4edaaf6899f Author: winesync <ros-dev(a)reactos.org> AuthorDate: Mon Sep 21 23:03:28 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Thu Feb 4 16:37:05 2021 +0100 [WINESYNC] d3dx9: Implement ID3DXFont_GetGlyphData. Based on a patch by Tony Wasserka. Signed-off-by: Sven Baars <sbaars(a)codeweavers.com> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id e9ea8a05e54f1c950e5c15979d1393ad013402b1 by Sven Baars <sbaars(a)codeweavers.com> --- dll/directx/wine/d3dx9_36/font.c | 35 +++++++++++++++++--- modules/rostests/winetests/d3dx9_36/core.c | 53 ++++++++++++++---------------- sdk/tools/winesync/d3dx9.cfg | 2 +- 3 files changed, 56 insertions(+), 34 deletions(-) diff --git a/dll/directx/wine/d3dx9_36/font.c b/dll/directx/wine/d3dx9_36/font.c index 388f73d7efb..c2cdde37f8f 100644 --- a/dll/directx/wine/d3dx9_36/font.c +++ b/dll/directx/wine/d3dx9_36/font.c @@ -188,11 +188,38 @@ static HDC WINAPI ID3DXFontImpl_GetDC(ID3DXFont *iface) } static HRESULT WINAPI ID3DXFontImpl_GetGlyphData(ID3DXFont *iface, UINT glyph, - IDirect3DTexture9 **texture, RECT *blackbox, POINT *cellinc) + IDirect3DTexture9 **texture, RECT *black_box, POINT *cell_inc) { - FIXME("iface %p, glyph %#x, texture %p, blackbox %p, cellinc %p stub!\n", - iface, glyph, texture, blackbox, cellinc); - return E_NOTIMPL; + struct d3dx_font *font = impl_from_ID3DXFont(iface); + struct wine_rb_entry *entry; + HRESULT hr; + + TRACE("iface %p, glyph %#x, texture %p, black_box %p, cell_inc %p.\n", + iface, glyph, texture, black_box, cell_inc); + + hr = ID3DXFont_PreloadGlyphs(iface, glyph, glyph); + if (FAILED(hr)) + return hr; + + entry = wine_rb_get(&font->glyph_tree, ULongToPtr(glyph)); + if (entry) + { + struct d3dx_glyph *current_glyph = WINE_RB_ENTRY_VALUE(entry, struct d3dx_glyph, entry); + + if (cell_inc) + *cell_inc = current_glyph->cell_inc; + if (black_box) + *black_box = current_glyph->black_box; + if (texture) + { + *texture = current_glyph->texture; + if (*texture) + IDirect3DTexture9_AddRef(current_glyph->texture); + } + return D3D_OK; + } + + return D3DXERR_INVALIDDATA; } static HRESULT WINAPI ID3DXFontImpl_PreloadCharacters(ID3DXFont *iface, UINT first, UINT last) diff --git a/modules/rostests/winetests/d3dx9_36/core.c b/modules/rostests/winetests/d3dx9_36/core.c index 22d265b9fc7..b8e680d1c55 100644 --- a/modules/rostests/winetests/d3dx9_36/core.c +++ b/modules/rostests/winetests/d3dx9_36/core.c @@ -543,16 +543,15 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) hdc = ID3DXFont_GetDC(font); ok(!!hdc, "Got unexpected hdc %p.\n", hdc); - todo_wine { hr = ID3DXFont_GetGlyphData(font, 0, NULL, &blackbox, &cellinc); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = ID3DXFont_GetGlyphData(font, 0, &texture, NULL, &cellinc); - if(SUCCEEDED(hr)) check_release((IUnknown *)texture, 1); + check_release((IUnknown *)texture, 1); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = ID3DXFont_GetGlyphData(font, 0, &texture, &blackbox, NULL); - if(SUCCEEDED(hr)) check_release((IUnknown *)texture, 1); + check_release((IUnknown *)texture, 1); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - } + hr = ID3DXFont_PreloadCharacters(font, 'b', 'a'); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = ID3DXFont_PreloadGlyphs(font, 1, 0); @@ -567,12 +566,10 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(count != GDI_ERROR, "Got unexpected count %u.\n", count); hr = ID3DXFont_GetGlyphData(font, glyph, &texture, &blackbox, &cellinc); - todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - if (FAILED(hr)) - continue; + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); levels = IDirect3DTexture9_GetLevelCount(texture); - ok(levels == 5, "Character %c: got unexpected levels %u.\n", c, levels); + todo_wine ok(levels == 5, "Character %c: got unexpected levels %u.\n", c, levels); hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &surf_desc); ok(hr == D3D_OK, "Character %c: got unexpected hr %#x.\n", c, hr); ok(surf_desc.Format == D3DFMT_A8R8G8B8, "Character %c: got unexpected format %#x.\n", c, surf_desc.Format); @@ -587,9 +584,9 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ret = ID3DXFont_GetTextMetricsW(font, &tm); ok(ret, "Got unexpected ret %#x.\n", ret); - ok(blackbox.right - blackbox.left == glyph_metrics.gmBlackBoxX + 2, "Character %c: got %d, expected %d.\n", + todo_wine ok(blackbox.right - blackbox.left == glyph_metrics.gmBlackBoxX + 2, "Character %c: got %d, expected %d.\n", c, blackbox.right - blackbox.left, glyph_metrics.gmBlackBoxX + 2); - ok(blackbox.bottom - blackbox.top == glyph_metrics.gmBlackBoxY + 2, "Character %c: got %d, expected %d.\n", + todo_wine ok(blackbox.bottom - blackbox.top == glyph_metrics.gmBlackBoxY + 2, "Character %c: got %d, expected %d.\n", c, blackbox.bottom - blackbox.top, glyph_metrics.gmBlackBoxY + 2); ok(cellinc.x == glyph_metrics.gmptGlyphOrigin.x - 1, "Character %c: got %d, expected %d.\n", c, cellinc.x, glyph_metrics.gmptGlyphOrigin.x - 1); @@ -611,8 +608,8 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) { texture = (IDirect3DTexture9 *)0xdeadbeef; hr = ID3DXFont_GetGlyphData(font, glyph, &texture, &blackbox, &cellinc); - todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - todo_wine ok(!texture, "Got unexpected texture %p.\n", texture); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(!texture, "Got unexpected texture %p.\n", texture); } check_release((IUnknown *)font, 0); @@ -631,23 +628,21 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(count != GDI_ERROR, "Test %u: got unexpected count %u.\n", i, count); hr = ID3DXFont_GetGlyphData(font, glyph, &texture, NULL, NULL); - todo_wine ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", i, hr); - if(SUCCEEDED(hr)) { - DWORD levels; - D3DSURFACE_DESC desc; - - levels = IDirect3DTexture9_GetLevelCount(texture); - ok(levels == tests[i].expected_levels, "Test %u: got unexpected levels %u.\n", i, levels); - hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - ok(desc.Format == D3DFMT_A8R8G8B8, "Test %u: got unexpected format %#x.\n", i, desc.Format); - ok(desc.Usage == 0, "Test %u: got unexpected usage %#x.\n", i, desc.Usage); - ok(desc.Width == tests[i].expected_size, "Test %u: got unexpected width %u.\n", i, desc.Width); - ok(desc.Height == tests[i].expected_size, "Test %u: got unexpected height %u.\n", i, desc.Height); - ok(desc.Pool == D3DPOOL_MANAGED, "Test %u: got unexpected pool %u.\n", i, desc.Pool); - - IDirect3DTexture9_Release(texture); - } + ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", i, hr); + + levels = IDirect3DTexture9_GetLevelCount(texture); + todo_wine_if(tests[i].expected_levels < 9) + ok(levels == tests[i].expected_levels, "Test %u: got unexpected levels %u.\n", i, levels); + + hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &surf_desc); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(surf_desc.Format == D3DFMT_A8R8G8B8, "Test %u: got unexpected format %#x.\n", i, surf_desc.Format); + ok(surf_desc.Usage == 0, "Test %u: got unexpected usage %#x.\n", i, surf_desc.Usage); + ok(surf_desc.Width == tests[i].expected_size, "Test %u: got unexpected width %u.\n", i, surf_desc.Width); + ok(surf_desc.Height == tests[i].expected_size, "Test %u: got unexpected height %u.\n", i, surf_desc.Height); + ok(surf_desc.Pool == D3DPOOL_MANAGED, "Test %u: got unexpected pool %u.\n", i, surf_desc.Pool); + + IDirect3DTexture9_Release(texture); /* ID3DXFontImpl_DrawText */ D3DXCreateSprite(device, &sprite); diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg index 94741b46435..3948abeff75 100644 --- a/sdk/tools/winesync/d3dx9.cfg +++ b/sdk/tools/winesync/d3dx9.cfg @@ -15,4 +15,4 @@ files: {include/d3dx9.h: sdk/include/dxsdk/d3dx9.h, include/d3dx9anim.h: sdk/inc include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h, include/d3dx9of.h: sdk/include/dxsdk/d3dx9of.h, include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h, include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h, include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h, include/d3dx9xof.h: sdk/include/dxsdk/d3dx9xof.h} -tags: {wine: ac5687463700b070fc1eecca67c4a46ec15127fa} +tags: {wine: e9ea8a05e54f1c950e5c15979d1393ad013402b1}
3 years, 10 months
1
0
0
0
[reactos] 170/218: [WINESYNC] d3dx9: Implement ID3DXFont_PreloadGlyphs.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=541dbf1b361ed155a3c9a…
commit 541dbf1b361ed155a3c9ae61c2382eaedcdf98a2 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Mon Sep 21 23:03:28 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Thu Feb 4 16:37:05 2021 +0100 [WINESYNC] d3dx9: Implement ID3DXFont_PreloadGlyphs. Based on a patch by Tony Wasserka. Signed-off-by: Sven Baars <sbaars(a)codeweavers.com> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id ac5687463700b070fc1eecca67c4a46ec15127fa by Sven Baars <sbaars(a)codeweavers.com> --- dll/directx/wine/d3dx9_36/font.c | 289 +++++++++++++++++++++++++---- modules/rostests/winetests/d3dx9_36/core.c | 5 +- sdk/tools/winesync/d3dx9.cfg | 2 +- 3 files changed, 255 insertions(+), 41 deletions(-) diff --git a/dll/directx/wine/d3dx9_36/font.c b/dll/directx/wine/d3dx9_36/font.c index 20c409c9026..388f73d7efb 100644 --- a/dll/directx/wine/d3dx9_36/font.c +++ b/dll/directx/wine/d3dx9_36/font.c @@ -26,6 +26,16 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3dx); +struct d3dx_glyph +{ + unsigned int id; + RECT black_box; + POINT cell_inc; + IDirect3DTexture9 *texture; + + struct wine_rb_entry entry; +}; + struct d3dx_font { ID3DXFont ID3DXFont_iface; @@ -33,11 +43,34 @@ struct d3dx_font IDirect3DDevice9 *device; D3DXFONT_DESCW desc; + TEXTMETRICW metrics; HDC hdc; HFONT hfont; + + struct wine_rb_tree glyph_tree; + + IDirect3DTexture9 **textures; + unsigned int texture_count, texture_pos; + + unsigned int texture_size, glyph_size, glyphs_per_texture; }; +static int glyph_rb_compare(const void *key, const struct wine_rb_entry *entry) +{ + struct d3dx_glyph *glyph = WINE_RB_ENTRY_VALUE(entry, struct d3dx_glyph, entry); + unsigned int id = (UINT_PTR)key; + + return id - glyph->id; +} + +static void glyph_rb_free(struct wine_rb_entry *entry, void *context) +{ + struct d3dx_glyph *glyph = WINE_RB_ENTRY_VALUE(entry, struct d3dx_glyph, entry); + + heap_free(glyph); +} + static inline struct d3dx_font *impl_from_ID3DXFont(ID3DXFont *iface) { return CONTAINING_RECORD(iface, struct d3dx_font, ID3DXFont_iface); @@ -63,85 +96,95 @@ static HRESULT WINAPI ID3DXFontImpl_QueryInterface(ID3DXFont *iface, REFIID riid static ULONG WINAPI ID3DXFontImpl_AddRef(ID3DXFont *iface) { - struct d3dx_font *This = impl_from_ID3DXFont(iface); - ULONG ref=InterlockedIncrement(&This->ref); + struct d3dx_font *font = impl_from_ID3DXFont(iface); + ULONG ref = InterlockedIncrement(&font->ref); + TRACE("%p increasing refcount to %u\n", iface, ref); return ref; } static ULONG WINAPI ID3DXFontImpl_Release(ID3DXFont *iface) { - struct d3dx_font *This = impl_from_ID3DXFont(iface); - ULONG ref=InterlockedDecrement(&This->ref); + struct d3dx_font *font = impl_from_ID3DXFont(iface); + ULONG ref = InterlockedDecrement(&font->ref); + unsigned int i; TRACE("%p decreasing refcount to %u\n", iface, ref); - if(ref==0) { - DeleteObject(This->hfont); - DeleteDC(This->hdc); - IDirect3DDevice9_Release(This->device); - HeapFree(GetProcessHeap(), 0, This); + if (!ref) + { + for (i = 0; i < font->texture_count; ++i) + IDirect3DTexture9_Release(font->textures[i]); + + heap_free(font->textures); + + wine_rb_destroy(&font->glyph_tree, glyph_rb_free, NULL); + + DeleteObject(font->hfont); + DeleteDC(font->hdc); + IDirect3DDevice9_Release(font->device); + heap_free(font); } return ref; } static HRESULT WINAPI ID3DXFontImpl_GetDevice(ID3DXFont *iface, IDirect3DDevice9 **device) { - struct d3dx_font *This = impl_from_ID3DXFont(iface); + struct d3dx_font *font = impl_from_ID3DXFont(iface); TRACE("iface %p, device %p\n", iface, device); if( !device ) return D3DERR_INVALIDCALL; - *device = This->device; - IDirect3DDevice9_AddRef(This->device); + *device = font->device; + IDirect3DDevice9_AddRef(font->device); return D3D_OK; } static HRESULT WINAPI ID3DXFontImpl_GetDescA(ID3DXFont *iface, D3DXFONT_DESCA *desc) { - struct d3dx_font *This = impl_from_ID3DXFont(iface); + struct d3dx_font *font = impl_from_ID3DXFont(iface); TRACE("iface %p, desc %p\n", iface, desc); if( !desc ) return D3DERR_INVALIDCALL; - memcpy(desc, &This->desc, FIELD_OFFSET(D3DXFONT_DESCA, FaceName)); - WideCharToMultiByte(CP_ACP, 0, This->desc.FaceName, -1, desc->FaceName, ARRAY_SIZE(desc->FaceName), NULL, NULL); + memcpy(desc, &font->desc, FIELD_OFFSET(D3DXFONT_DESCA, FaceName)); + WideCharToMultiByte(CP_ACP, 0, font->desc.FaceName, -1, desc->FaceName, ARRAY_SIZE(desc->FaceName), NULL, NULL); return D3D_OK; } static HRESULT WINAPI ID3DXFontImpl_GetDescW(ID3DXFont *iface, D3DXFONT_DESCW *desc) { - struct d3dx_font *This = impl_from_ID3DXFont(iface); + struct d3dx_font *font = impl_from_ID3DXFont(iface); TRACE("iface %p, desc %p\n", iface, desc); if( !desc ) return D3DERR_INVALIDCALL; - *desc = This->desc; + *desc = font->desc; return D3D_OK; } static BOOL WINAPI ID3DXFontImpl_GetTextMetricsA(ID3DXFont *iface, TEXTMETRICA *metrics) { - struct d3dx_font *This = impl_from_ID3DXFont(iface); + struct d3dx_font *font = impl_from_ID3DXFont(iface); TRACE("iface %p, metrics %p\n", iface, metrics); - return GetTextMetricsA(This->hdc, metrics); + return GetTextMetricsA(font->hdc, metrics); } static BOOL WINAPI ID3DXFontImpl_GetTextMetricsW(ID3DXFont *iface, TEXTMETRICW *metrics) { - struct d3dx_font *This = impl_from_ID3DXFont(iface); + struct d3dx_font *font = impl_from_ID3DXFont(iface); TRACE("iface %p, metrics %p\n", iface, metrics); - return GetTextMetricsW(This->hdc, metrics); + return GetTextMetricsW(font->hdc, metrics); } static HDC WINAPI ID3DXFontImpl_GetDC(ID3DXFont *iface) { - struct d3dx_font *This = impl_from_ID3DXFont(iface); + struct d3dx_font *font = impl_from_ID3DXFont(iface); TRACE("iface %p\n", iface); - return This->hdc; + return font->hdc; } static HRESULT WINAPI ID3DXFontImpl_GetGlyphData(ID3DXFont *iface, UINT glyph, @@ -158,10 +201,156 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadCharacters(ID3DXFont *iface, UINT fir return S_OK; } +static uint32_t morton_decode(uint32_t x) +{ + x &= 0x55555555; + x = (x ^ (x >> 1)) & 0x33333333; + x = (x ^ (x >> 2)) & 0x0f0f0f0f; + x = (x ^ (x >> 4)) & 0x00ff00ff; + x = (x ^ (x >> 8)) & 0x0000ffff; + return x; +} + +/* The glyphs are stored in a grid. Cell sizes vary between different font + * sizes. + * + * The grid is filled in Morton order: + * 1 2 5 6 17 18 21 22 + * 3 4 7 8 19 20 23 24 + * 9 10 13 14 25 26 29 30 + * 11 12 15 16 27 28 31 32 + * 33 34 ... + * ... + * + * i.e. we try to fill one small square, then three equal-sized squares so + * that we get one big square, etc. + * + * The glyphs are positioned around their baseline, which is located at y + * position glyph_size * i + tmAscent. Concerning the x position, the glyphs + * are centered around glyph_size * (i + 0.5). */ static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first, UINT last) { - FIXME("iface %p, first %u, last %u stub!\n", iface, first, last); - return E_NOTIMPL; + static const MAT2 mat = { {0,1}, {0,0}, {0,0}, {0,1} }; + struct d3dx_font *font = impl_from_ID3DXFont(iface); + IDirect3DTexture9 *current_texture = NULL; + unsigned int size, stride, glyph, x, y; + struct d3dx_glyph *current_glyph; + D3DLOCKED_RECT lockrect; + GLYPHMETRICS metrics; + BOOL mapped = FALSE; + DWORD *pixel_data; + BYTE *buffer; + HRESULT hr; + + TRACE("iface %p, first %u, last %u.\n", iface, first, last); + + if (last < first) + return D3D_OK; + + if (font->texture_count) + current_texture = font->textures[font->texture_count - 1]; + + for (glyph = first; glyph <= last; ++glyph) + { + if (wine_rb_get(&font->glyph_tree, ULongToPtr(glyph))) + continue; + + current_glyph = heap_alloc(sizeof(*current_glyph)); + if (!current_glyph) + { + if (mapped) + IDirect3DTexture9_UnlockRect(current_texture, 0); + return E_OUTOFMEMORY; + } + + current_glyph->id = glyph; + current_glyph->texture = NULL; + wine_rb_put(&font->glyph_tree, ULongToPtr(current_glyph->id), ¤t_glyph->entry); + + size = GetGlyphOutlineW(font->hdc, glyph, GGO_GLYPH_INDEX | GGO_GRAY8_BITMAP, &metrics, 0, NULL, &mat); + if (size == GDI_ERROR) + { + WARN("GetGlyphOutlineW failed.\n"); + continue; + } + if (!size) + continue; + + buffer = heap_alloc(size); + if (!buffer) + { + if (mapped) + IDirect3DTexture9_UnlockRect(current_texture, 0); + return E_OUTOFMEMORY; + } + + GetGlyphOutlineW(font->hdc, glyph, GGO_GLYPH_INDEX | GGO_GRAY8_BITMAP, &metrics, size, buffer, &mat); + + if (font->texture_pos == font->glyphs_per_texture) + { + unsigned int new_texture_count = font->texture_count + 1; + IDirect3DTexture9 **new_textures; + + if (mapped) + IDirect3DTexture9_UnlockRect(current_texture, 0); + mapped = FALSE; + new_textures = heap_realloc(font->textures, new_texture_count * sizeof(*new_textures)); + if (!new_textures) + { + heap_free(buffer); + return E_OUTOFMEMORY; + } + font->textures = new_textures; + + if (FAILED(hr = IDirect3DDevice9_CreateTexture(font->device, font->texture_size, + font->texture_size, 0, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, + &font->textures[font->texture_count], NULL))) + { + heap_free(buffer); + return hr; + } + + current_texture = font->textures[font->texture_count++]; + font->texture_pos = 0; + } + + if (!mapped) + { + if (FAILED(hr = IDirect3DTexture9_LockRect(current_texture, 0, &lockrect, NULL, 0))) + { + heap_free(buffer); + return hr; + } + mapped = TRUE; + } + + x = morton_decode(font->texture_pos) * font->glyph_size; + y = morton_decode(font->texture_pos >> 1) * font->glyph_size; + + current_glyph->black_box.left = x - metrics.gmptGlyphOrigin.x + font->glyph_size / 2 + - metrics.gmBlackBoxX / 2; + current_glyph->black_box.top = y - metrics.gmptGlyphOrigin.y + font->metrics.tmAscent + 1; + current_glyph->black_box.right = current_glyph->black_box.left + metrics.gmBlackBoxX; + current_glyph->black_box.bottom = current_glyph->black_box.top + metrics.gmBlackBoxY; + current_glyph->cell_inc.x = metrics.gmptGlyphOrigin.x - 1; + current_glyph->cell_inc.y = font->metrics.tmAscent - metrics.gmptGlyphOrigin.y - 1; + current_glyph->texture = current_texture; + + pixel_data = lockrect.pBits; + stride = (metrics.gmBlackBoxX + 3) & ~3; + for (y = 0; y < metrics.gmBlackBoxY; ++y) + for (x = 0; x < metrics.gmBlackBoxX; ++x) + pixel_data[(current_glyph->black_box.top + y) * lockrect.Pitch / 4 + + current_glyph->black_box.left + x] = + (buffer[y * stride + x] * 255 / 64 << 24) | 0x00ffffffu; + + heap_free(buffer); + ++font->texture_pos; + } + if (mapped) + IDirect3DTexture9_UnlockRect(current_texture, 0); + + return D3D_OK; } static HRESULT WINAPI ID3DXFontImpl_PreloadTextA(ID3DXFont *iface, const char *string, INT count) @@ -295,8 +484,8 @@ HRESULT WINAPI D3DXCreateFontIndirectA(IDirect3DDevice9 *device, const D3DXFONT_ HRESULT WINAPI D3DXCreateFontIndirectW(IDirect3DDevice9 *device, const D3DXFONT_DESCW *desc, ID3DXFont **font) { D3DDEVICE_CREATION_PARAMETERS cpars; - D3DDISPLAYMODE mode; struct d3dx_font *object; + D3DDISPLAYMODE mode; IDirect3D9 *d3d; HRESULT hr; @@ -309,39 +498,63 @@ HRESULT WINAPI D3DXCreateFontIndirectW(IDirect3DDevice9 *device, const D3DXFONT_ IDirect3DDevice9_GetCreationParameters(device, &cpars); IDirect3DDevice9_GetDisplayMode(device, 0, &mode); hr = IDirect3D9_CheckDeviceFormat(d3d, cpars.AdapterOrdinal, cpars.DeviceType, mode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_A8R8G8B8); - if(FAILED(hr)) { + if (FAILED(hr)) + { IDirect3D9_Release(d3d); return D3DXERR_INVALIDDATA; } IDirect3D9_Release(d3d); - object = HeapAlloc(GetProcessHeap(), 0, sizeof(struct d3dx_font)); - if(object==NULL) { - *font=NULL; + object = heap_alloc_zero(sizeof(*object)); + if (!object) + { + *font = NULL; return E_OUTOFMEMORY; } object->ID3DXFont_iface.lpVtbl = &D3DXFont_Vtbl; - object->ref=1; - object->device=device; - object->desc=*desc; + object->ref = 1; + object->device = device; + object->desc = *desc; object->hdc = CreateCompatibleDC(NULL); - if( !object->hdc ) { - HeapFree(GetProcessHeap(), 0, object); + if (!object->hdc) + { + heap_free(object); return D3DXERR_INVALIDDATA; } object->hfont = CreateFontW(desc->Height, desc->Width, 0, 0, desc->Weight, desc->Italic, FALSE, FALSE, desc->CharSet, desc->OutputPrecision, CLIP_DEFAULT_PRECIS, desc->Quality, desc->PitchAndFamily, desc->FaceName); - if( !object->hfont ) { + if (!object->hfont) + { DeleteDC(object->hdc); - HeapFree(GetProcessHeap(), 0, object); + heap_free(object); return D3DXERR_INVALIDDATA; } SelectObject(object->hdc, object->hfont); + wine_rb_init(&object->glyph_tree, glyph_rb_compare); + + if (!GetTextMetricsW(object->hdc, &object->metrics)) + { + DeleteObject(object->hfont); + DeleteDC(object->hdc); + heap_free(object); + return D3DXERR_INVALIDDATA; + } + + object->glyph_size = make_pow2(object->metrics.tmHeight); + + object->texture_size = object->glyph_size; + if (object->glyph_size < 256) + object->texture_size = min(256, object->texture_size * 16); + + object->glyphs_per_texture = object->texture_size * object->texture_size + / (object->glyph_size * object->glyph_size); + object->texture_pos = object->glyphs_per_texture; + IDirect3DDevice9_AddRef(device); - *font=&object->ID3DXFont_iface; + *font = &object->ID3DXFont_iface; return D3D_OK; } diff --git a/modules/rostests/winetests/d3dx9_36/core.c b/modules/rostests/winetests/d3dx9_36/core.c index c44473396b7..22d265b9fc7 100644 --- a/modules/rostests/winetests/d3dx9_36/core.c +++ b/modules/rostests/winetests/d3dx9_36/core.c @@ -556,7 +556,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) hr = ID3DXFont_PreloadCharacters(font, 'b', 'a'); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = ID3DXFont_PreloadGlyphs(font, 1, 0); - todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = ID3DXFont_PreloadCharacters(font, 'a', 'a'); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); @@ -586,6 +586,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ret = ID3DXFont_GetTextMetricsW(font, &tm); ok(ret, "Got unexpected ret %#x.\n", ret); + ok(blackbox.right - blackbox.left == glyph_metrics.gmBlackBoxX + 2, "Character %c: got %d, expected %d.\n", c, blackbox.right - blackbox.left, glyph_metrics.gmBlackBoxX + 2); ok(blackbox.bottom - blackbox.top == glyph_metrics.gmBlackBoxY + 2, "Character %c: got %d, expected %d.\n", @@ -603,7 +604,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) /* Test multiple textures */ hr = ID3DXFont_PreloadGlyphs(font, 0, 1000); - todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); /* Test glyphs that are not rendered */ for (glyph = 1; glyph < 4; ++glyph) diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg index 86c62751e83..94741b46435 100644 --- a/sdk/tools/winesync/d3dx9.cfg +++ b/sdk/tools/winesync/d3dx9.cfg @@ -15,4 +15,4 @@ files: {include/d3dx9.h: sdk/include/dxsdk/d3dx9.h, include/d3dx9anim.h: sdk/inc include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h, include/d3dx9of.h: sdk/include/dxsdk/d3dx9of.h, include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h, include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h, include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h, include/d3dx9xof.h: sdk/include/dxsdk/d3dx9xof.h} -tags: {wine: 1b0ad92db1c21d5052c45be2291759d60553476c} +tags: {wine: ac5687463700b070fc1eecca67c4a46ec15127fa}
3 years, 10 months
1
0
0
0
← Newer
1
...
10
11
12
13
14
15
16
...
44
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Results per page:
10
25
50
100
200