mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
[WINESYNC] d3dx9_36: ID3DXFont_DrawText calc_rect can be null
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com> wine-staging patch by Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
This commit is contained in:
parent
f9c6d6e396
commit
58d515ea16
3 changed files with 90 additions and 2 deletions
|
@ -235,7 +235,7 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
|
||||||
const WCHAR *string, INT count, RECT *rect, DWORD format, D3DCOLOR color)
|
const WCHAR *string, INT count, RECT *rect, DWORD format, D3DCOLOR color)
|
||||||
{
|
{
|
||||||
struct d3dx_font *This = impl_from_ID3DXFont(iface);
|
struct d3dx_font *This = impl_from_ID3DXFont(iface);
|
||||||
RECT calc_rect = *rect;
|
RECT calc_rect;
|
||||||
INT height;
|
INT height;
|
||||||
|
|
||||||
TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x\n",
|
TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x\n",
|
||||||
|
@ -251,10 +251,14 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
|
||||||
while (count > 0 && !string[count-1])
|
while (count > 0 && !string[count-1])
|
||||||
count--;
|
count--;
|
||||||
|
|
||||||
|
if (rect)
|
||||||
|
calc_rect = *rect;
|
||||||
|
|
||||||
height = DrawTextW(This->hdc, string, count, &calc_rect, format | DT_CALCRECT);
|
height = DrawTextW(This->hdc, string, count, &calc_rect, format | DT_CALCRECT);
|
||||||
|
|
||||||
if (format & DT_CALCRECT)
|
if (format & DT_CALCRECT)
|
||||||
{
|
{
|
||||||
|
if (rect)
|
||||||
*rect = calc_rect;
|
*rect = calc_rect;
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
|
@ -662,6 +662,15 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
|
||||||
height = ID3DXFont_DrawTextA(font, NULL, testA, 2, &rect, 0, 0xFF00FF);
|
height = ID3DXFont_DrawTextA(font, NULL, testA, 2, &rect, 0, 0xFF00FF);
|
||||||
ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
|
ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
|
||||||
|
|
||||||
|
height = ID3DXFont_DrawTextA(font, NULL, testA, -1, NULL, 0, 0xFF00FF);
|
||||||
|
ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
|
||||||
|
|
||||||
|
height = ID3DXFont_DrawTextA(font, NULL, testA, -1, NULL, DT_CALCRECT, 0xFF00FF);
|
||||||
|
ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
|
||||||
|
|
||||||
|
height = ID3DXFont_DrawTextA(font, NULL, NULL, -1, NULL, 0, 0xFF00FF);
|
||||||
|
ok(height == 0, "DrawTextA returned %d, expected 0.\n", height);
|
||||||
|
|
||||||
if (0) { /* Causes a lockup on windows 7. */
|
if (0) { /* Causes a lockup on windows 7. */
|
||||||
height = ID3DXFont_DrawTextW(font, NULL, testW, -2, &rect, 0, 0xFF00FF);
|
height = ID3DXFont_DrawTextW(font, NULL, testW, -2, &rect, 0, 0xFF00FF);
|
||||||
ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
|
ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
|
||||||
|
@ -679,6 +688,15 @@ if (0) { /* Causes a lockup on windows 7. */
|
||||||
height = ID3DXFont_DrawTextW(font, NULL, testW, 2, &rect, 0, 0xFF00FF);
|
height = ID3DXFont_DrawTextW(font, NULL, testW, 2, &rect, 0, 0xFF00FF);
|
||||||
ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
|
ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
|
||||||
|
|
||||||
|
height = ID3DXFont_DrawTextW(font, NULL, testW, -1, NULL, 0, 0xFF00FF);
|
||||||
|
ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
|
||||||
|
|
||||||
|
height = ID3DXFont_DrawTextW(font, NULL, testW, -1, NULL, DT_CALCRECT, 0xFF00FF);
|
||||||
|
ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
|
||||||
|
|
||||||
|
height = ID3DXFont_DrawTextW(font, NULL, NULL, -1, NULL, 0, 0xFF00FF);
|
||||||
|
ok(height == 0, "DrawTextA returned %d, expected 0.\n", height);
|
||||||
|
|
||||||
ID3DXFont_Release(font);
|
ID3DXFont_Release(font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
diff --git a/dll/directx/wine/d3dx9_36/font.c b/dll/directx/wine/d3dx9_36/font.c
|
||||||
|
index 89005ce..05e490f 100644
|
||||||
|
--- a/dll/directx/wine/d3dx9_36/font.c
|
||||||
|
+++ b/dll/directx/wine/d3dx9_36/font.c
|
||||||
|
@@ -235,7 +235,7 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
|
||||||
|
const WCHAR *string, INT count, RECT *rect, DWORD format, D3DCOLOR color)
|
||||||
|
{
|
||||||
|
struct d3dx_font *This = impl_from_ID3DXFont(iface);
|
||||||
|
- RECT calc_rect = *rect;
|
||||||
|
+ RECT calc_rect;
|
||||||
|
INT height;
|
||||||
|
|
||||||
|
TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x\n",
|
||||||
|
@@ -251,11 +251,15 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
|
||||||
|
while (count > 0 && !string[count-1])
|
||||||
|
count--;
|
||||||
|
|
||||||
|
+ if (rect)
|
||||||
|
+ calc_rect = *rect;
|
||||||
|
+
|
||||||
|
height = DrawTextW(This->hdc, string, count, &calc_rect, format | DT_CALCRECT);
|
||||||
|
|
||||||
|
if (format & DT_CALCRECT)
|
||||||
|
{
|
||||||
|
- *rect = calc_rect;
|
||||||
|
+ if (rect)
|
||||||
|
+ *rect = calc_rect;
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/modules/rostests/winetests/d3dx9_36/core.c b/modules/rostests/winetests/d3dx9_36/core.c
|
||||||
|
index 841d07e..a5abb79 100644
|
||||||
|
--- a/modules/rostests/winetests/d3dx9_36/core.c
|
||||||
|
+++ b/modules/rostests/winetests/d3dx9_36/core.c
|
||||||
|
@@ -662,6 +662,15 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
|
||||||
|
height = ID3DXFont_DrawTextA(font, NULL, testA, 2, &rect, 0, 0xFF00FF);
|
||||||
|
ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
|
||||||
|
|
||||||
|
+ height = ID3DXFont_DrawTextA(font, NULL, testA, -1, NULL, 0, 0xFF00FF);
|
||||||
|
+ ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
|
||||||
|
+
|
||||||
|
+ height = ID3DXFont_DrawTextA(font, NULL, testA, -1, NULL, DT_CALCRECT, 0xFF00FF);
|
||||||
|
+ ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
|
||||||
|
+
|
||||||
|
+ height = ID3DXFont_DrawTextA(font, NULL, NULL, -1, NULL, 0, 0xFF00FF);
|
||||||
|
+ ok(height == 0, "DrawTextA returned %d, expected 0.\n", height);
|
||||||
|
+
|
||||||
|
if (0) { /* Causes a lockup on windows 7. */
|
||||||
|
height = ID3DXFont_DrawTextW(font, NULL, testW, -2, &rect, 0, 0xFF00FF);
|
||||||
|
ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
|
||||||
|
@@ -679,6 +688,15 @@ if (0) { /* Causes a lockup on windows 7. */
|
||||||
|
height = ID3DXFont_DrawTextW(font, NULL, testW, 2, &rect, 0, 0xFF00FF);
|
||||||
|
ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
|
||||||
|
|
||||||
|
+ height = ID3DXFont_DrawTextW(font, NULL, testW, -1, NULL, 0, 0xFF00FF);
|
||||||
|
+ ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
|
||||||
|
+
|
||||||
|
+ height = ID3DXFont_DrawTextW(font, NULL, testW, -1, NULL, DT_CALCRECT, 0xFF00FF);
|
||||||
|
+ ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
|
||||||
|
+
|
||||||
|
+ height = ID3DXFont_DrawTextW(font, NULL, NULL, -1, NULL, 0, 0xFF00FF);
|
||||||
|
+ ok(height == 0, "DrawTextA returned %d, expected 0.\n", height);
|
||||||
|
+
|
||||||
|
ID3DXFont_Release(font);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue