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}