From: Sven Baars sbaars@codeweavers.com
Signed-off-by: Sven Baars sbaars@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dx9_36/tests/core.c | 78 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+)
diff --git a/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c index f5c539ca85e..c44473396b7 100644 --- a/dlls/d3dx9_36/tests/core.c +++ b/dlls/d3dx9_36/tests/core.c @@ -770,6 +770,84 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
height = ID3DXFont_DrawTextW(font, NULL, long_textW, -1, &rect, DT_WORDBREAK | DT_NOCLIP, 0xff00ff); 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); + + height = ID3DXFont_DrawTextW(font, NULL, L"a\r\na", -1, &rect, 0, 0xff00ff); + 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); + + height = ID3DXFont_DrawTextW(font, NULL, L"a\naaaaa aaaa", -1, &rect, 0, 0xff00ff); + 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); + + 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); + + 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); + + 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); + + 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); + + height = ID3DXFont_DrawTextW(font, NULL, L"\taaaaaaaaaa", -1, &rect, DT_EXPANDTABS | DT_WORDBREAK, 0xff00ff); + 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); + + 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); + + 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); + + 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); + + height = ID3DXFont_DrawTextW(font, NULL, L"aaaaaaaaaaaaaaaaaaaa", -1, &rect, DT_WORDBREAK, 0xff00ff); + 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); + + height = ID3DXFont_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK, 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); + 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); + + height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_BOTTOM, 0xff00ff); + 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); + + height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_RIGHT, 0xff00ff); + 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); }
ID3DXFont_Release(font);
From: Sven Baars sbaars@codeweavers.com
Signed-off-by: Sven Baars sbaars@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v2: Add a version using __builtin_clz(). It returns 1 for 0, I assume that's not an issue but if it is, please holler.
dlls/d3dx9_36/d3dx9_private.h | 19 +++++++++++++++++++ dlls/d3dx9_36/texture.c | 15 --------------- 2 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/dlls/d3dx9_36/d3dx9_private.h b/dlls/d3dx9_36/d3dx9_private.h index 61ec320ba52..d64b9af30c5 100644 --- a/dlls/d3dx9_36/d3dx9_private.h +++ b/dlls/d3dx9_36/d3dx9_private.h @@ -22,6 +22,7 @@ #ifndef __WINE_D3DX9_PRIVATE_H #define __WINE_D3DX9_PRIVATE_H
+#include <stdint.h> #define NONAMELESSUNION #include "wine/debug.h" #include "wine/heap.h" @@ -225,6 +226,24 @@ static inline BOOL is_param_type_sampler(D3DXPARAMETER_TYPE type) || type == D3DXPT_SAMPLER3D || type == D3DXPT_SAMPLERCUBE; }
+/* Returns the smallest power of 2 which is greater than or equal to num */ +static inline uint32_t make_pow2(uint32_t num) +{ +#if defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) + return num == 1 ? 1 : 1u << ((__builtin_clz(num - 1) ^ 0x1f) + 1); +#else + num--; + num |= num >> 1; + num |= num >> 2; + num |= num >> 4; + num |= num >> 8; + num |= num >> 16; + num++; + + return num; +#endif +} + struct d3dx_parameter;
enum pres_reg_tables diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c index d96ade9aeda..6af44589047 100644 --- a/dlls/d3dx9_36/texture.c +++ b/dlls/d3dx9_36/texture.c @@ -30,21 +30,6 @@ static BOOL is_pow2(UINT num) return !(num & (num - 1)); }
-/* Returns the smallest power of 2 which is greater than or equal to num */ -static UINT make_pow2(UINT num) -{ - UINT result = 1; - - /* In the unlikely event somebody passes a large value, make sure we don't enter an infinite loop */ - if (num >= 0x80000000) - return 0x80000000; - - while (result < num) - result <<= 1; - - return result; -} - static HRESULT get_surface(D3DRESOURCETYPE type, struct IDirect3DBaseTexture9 *tex, int face, UINT level, struct IDirect3DSurface9 **surf) {