https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4ff131d352559da9da3b4…
commit 4ff131d352559da9da3b45dc089ab2e1e4de6f3f
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Mon Sep 21 23:07: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 horizontal alignment 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 d511853d45bc3302b2a4501b1aa0097a4e78b3d9 by Sven Baars
<sbaars(a)codeweavers.com>
---
dll/directx/wine/d3dx9_36/font.c | 23 +++-
modules/rostests/winetests/d3dx9_36/core.c | 162 ++++++++++++++++++++++++++++-
sdk/tools/winesync/d3dx9.cfg | 2 +-
3 files changed, 183 insertions(+), 4 deletions(-)
diff --git a/dll/directx/wine/d3dx9_36/font.c b/dll/directx/wine/d3dx9_36/font.c
index d327d2401e5..2fb924d77ec 100644
--- a/dll/directx/wine/d3dx9_36/font.c
+++ b/dll/directx/wine/d3dx9_36/font.c
@@ -628,7 +628,20 @@ static int compute_rect(struct d3dx_font *font, const WCHAR *string,
unsigned in
break;
}
- rect->right = rect->left + max_width;
+ if (format & DT_CENTER)
+ {
+ rect->left += (rect->right - rect->left - max_width) / 2;
+ rect->right = rect->left + max_width;
+ }
+ else if (format & DT_RIGHT)
+ {
+ rect->left = rect->right - max_width;
+ }
+ else
+ {
+ rect->right = rect->left + max_width;
+ }
+
if (format & DT_VCENTER)
{
rect->top += (rect->bottom - y) / 2;
@@ -703,7 +716,6 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface,
ID3DXSprite *sprite,
top = rect->top;
}
- x = rect->left;
y = rect->top;
lh = font->metrics.tmHeight;
width = rect->right - rect->left;
@@ -722,6 +734,13 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface,
ID3DXSprite *sprite,
string = read_line(font->hdc, string, &count, line, &line_len, width,
format, &size);
+ if (format & DT_CENTER)
+ x = (rect->left + rect->right - size.cx) / 2;
+ else if (format & DT_RIGHT)
+ x = rect->right - size.cx;
+ else
+ x = rect->left;
+
memset(&results, 0, sizeof(results));
results.nGlyphs = line_len;
diff --git a/modules/rostests/winetests/d3dx9_36/core.c
b/modules/rostests/winetests/d3dx9_36/core.c
index 9de91b2b089..020f18e622c 100644
--- a/modules/rostests/winetests/d3dx9_36/core.c
+++ b/modules/rostests/winetests/d3dx9_36/core.c
@@ -842,7 +842,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1,
&rect, DT_WORDBREAK | DT_RIGHT, 0xff00ff);
ok(height == 36, "Got unexpected height %d.\n", height);
- height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1,
&rect, DT_WORDBREAK | DT_RIGHT, 0xff00ff);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1,
&rect, DT_WORDBREAK | DT_CENTER, 0xff00ff);
ok(height == 36, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect,
DT_BOTTOM, 0xff00ff);
@@ -1007,6 +1007,166 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
ok(height == -8, "Got unexpected height %d.\n", height);
check_rect(&rect, 10, -22, 30, 2);
+ SetRect(&rect, 10, 10, 50, 50);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect,
DT_RIGHT | DT_CALCRECT, 0xff00ff);
+ ok(height == 24, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 30, 10, 50, 34);
+
+ SetRect(&rect, -10, 10, 30, 50);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect,
DT_RIGHT | DT_CALCRECT, 0xff00ff);
+ ok(height == 24, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 10, 10, 30, 34);
+
+ SetRect(&rect, 10, -10, 50, 30);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect,
DT_RIGHT | DT_CALCRECT, 0xff00ff);
+ ok(height == 24, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 30, -10, 50, 14);
+
+ SetRect(&rect, 10, 10, -30, 50);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect,
DT_RIGHT | DT_CALCRECT, 0xff00ff);
+ ok(height == 24, "Got unexpected height %d.\n", height);
+ check_rect(&rect, -50, 10, -30, 34);
+
+ SetRect(&rect, 10, 10, 50, -30);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect,
DT_RIGHT | DT_CALCRECT, 0xff00ff);
+ ok(height == 24, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 30, 10, 50, 34);
+
+ SetRect(&rect, 10, 10, 50, 50);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect,
DT_RIGHT | DT_WORDBREAK | DT_CALCRECT, 0xff00ff);
+ ok(height == 24, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 30, 10, 50, 34);
+
+ SetRect(&rect, -10, 10, 30, 50);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect,
DT_RIGHT | DT_WORDBREAK | DT_CALCRECT, 0xff00ff);
+ ok(height == 24, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 10, 10, 30, 34);
+
+ SetRect(&rect, 10, -10, 50, 30);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect,
DT_RIGHT | DT_WORDBREAK | DT_CALCRECT, 0xff00ff);
+ ok(height == 24, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 30, -10, 50, 14);
+
+ SetRect(&rect, 10, 10, -30, 50);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect,
DT_RIGHT | DT_WORDBREAK | DT_CALCRECT, 0xff00ff);
+ ok(height == 12, "Got unexpected height %d.\n", height);
+ check_rect(&rect, -73, 10, -30, 22);
+
+ SetRect(&rect, 10, 10, 50, -30);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect,
DT_RIGHT | DT_WORDBREAK | DT_CALCRECT, 0xff00ff);
+ ok(height == 24, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 30, 10, 50, 34);
+
+ SetRect(&rect, 10, 10, 50, 50);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect,
DT_CENTER | DT_CALCRECT, 0xff00ff);
+ ok(height == 24, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 20, 10, 40, 34);
+
+ SetRect(&rect, -10, 10, 30, 50);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect,
DT_CENTER | DT_CALCRECT, 0xff00ff);
+ ok(height == 24, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 0, 10, 20, 34);
+
+ SetRect(&rect, 10, -10, 50, 30);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect,
DT_CENTER | DT_CALCRECT, 0xff00ff);
+ ok(height == 24, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 20, -10, 40, 14);
+
+ SetRect(&rect, 10, 10, -30, 50);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect,
DT_CENTER | DT_CALCRECT, 0xff00ff);
+ ok(height == 24, "Got unexpected height %d.\n", height);
+ check_rect(&rect, -20, 10, 0, 34);
+
+ SetRect(&rect, 10, 10, 50, -30);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect,
DT_CENTER | DT_CALCRECT, 0xff00ff);
+ ok(height == 24, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 20, 10, 40, 34);
+
+ SetRect(&rect, 10, 10, 50, 50);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect,
DT_CENTER | DT_WORDBREAK | DT_CALCRECT, 0xff00ff);
+ ok(height == 24, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 20, 10, 40, 34);
+
+ SetRect(&rect, -10, 10, 30, 50);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect,
DT_CENTER | DT_WORDBREAK | DT_CALCRECT, 0xff00ff);
+ ok(height == 24, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 0, 10, 20, 34);
+
+ SetRect(&rect, 10, -10, 50, 30);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect,
DT_CENTER | DT_WORDBREAK | DT_CALCRECT, 0xff00ff);
+ ok(height == 24, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 20, -10, 40, 14);
+
+ SetRect(&rect, 10, 10, -30, 50);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect,
DT_CENTER | DT_WORDBREAK | DT_CALCRECT, 0xff00ff);
+ ok(height == 12, "Got unexpected height %d.\n", height);
+ check_rect(&rect, -31, 10, 12, 22);
+
+ SetRect(&rect, 10, 10, 50, -30);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect,
DT_CENTER | DT_WORDBREAK | DT_CALCRECT, 0xff00ff);
+ ok(height == 24, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 20, 10, 40, 34);
+
+ SetRect(&rect, 10, 10, 50, 50);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect,
DT_CENTER | DT_VCENTER | DT_CALCRECT, 0xff00ff);
+ ok(height == 32, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 20, 18, 40, 42);
+
+ SetRect(&rect, 10, 10, 50, 50);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect,
DT_CENTER | DT_VCENTER | DT_CALCRECT, 0xff00ff);
+ ok(height == 32, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 20, 18, 40, 42);
+
+ SetRect(&rect, -10, 10, 30, 50);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect,
DT_CENTER | DT_VCENTER | DT_CALCRECT, 0xff00ff);
+ ok(height == 32, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 0, 18, 20, 42);
+
+ SetRect(&rect, 10, -10, 50, 30);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect,
DT_CENTER | DT_VCENTER | DT_CALCRECT, 0xff00ff);
+ ok(height == 32, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 20, -2, 40, 22);
+
+ SetRect(&rect, 10, 10, -30, 50);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect,
DT_CENTER | DT_VCENTER | DT_CALCRECT, 0xff00ff);
+ ok(height == 32, "Got unexpected height %d.\n", height);
+ check_rect(&rect, -20, 18, 0, 42);
+
+ SetRect(&rect, 10, 10, 50, -30);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect,
DT_CENTER | DT_VCENTER | DT_CALCRECT, 0xff00ff);
+ ok(height == -8, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 20, -22, 40, 2);
+
+ SetRect(&rect, 10, 10, 50, 50);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect,
DT_CENTER | DT_VCENTER | DT_WORDBREAK | DT_CALCRECT, 0xff00ff);
+ ok(height == 32, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 20, 18, 40, 42);
+
+ SetRect(&rect, 10, 10, 50, 50);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect,
DT_CENTER | DT_VCENTER | DT_WORDBREAK | DT_CALCRECT, 0xff00ff);
+ ok(height == 32, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 20, 18, 40, 42);
+
+ SetRect(&rect, -10, 10, 30, 50);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect,
DT_CENTER | DT_VCENTER | DT_WORDBREAK | DT_CALCRECT, 0xff00ff);
+ ok(height == 32, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 0, 18, 20, 42);
+
+ SetRect(&rect, 10, -10, 50, 30);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect,
DT_CENTER | DT_VCENTER | DT_WORDBREAK | DT_CALCRECT, 0xff00ff);
+ ok(height == 32, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 20, -2, 40, 22);
+
+ SetRect(&rect, 10, 10, -30, 50);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect,
DT_CENTER | DT_VCENTER | DT_WORDBREAK | DT_CALCRECT, 0xff00ff);
+ ok(height == 26, "Got unexpected height %d.\n", height);
+ check_rect(&rect, -31, 24, 12, 36);
+
+ SetRect(&rect, 10, 10, 50, -30);
+ height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect,
DT_CENTER | DT_VCENTER | DT_WORDBREAK | DT_CALCRECT, 0xff00ff);
+ ok(height == -8, "Got unexpected height %d.\n", height);
+ check_rect(&rect, 20, -22, 40, 2);
+
ID3DXFont_Release(font);
}
diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg
index 8b6cbbe2589..7dbe3ecf72f 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: fd9808b45af4bf4c6771fe2932e3169cb193bf44}
+tags: {wine: d511853d45bc3302b2a4501b1aa0097a4e78b3d9}