Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3dx10_43/Makefile.in | 3 +- dlls/d3dx10_43/d3dx10_43.spec | 2 +- dlls/d3dx10_43/sprite.c | 202 ++++++++++++++++++++++++++++++++++ include/d3dx10core.h | 1 + 4 files changed, 206 insertions(+), 2 deletions(-) create mode 100644 dlls/d3dx10_43/sprite.c
diff --git a/dlls/d3dx10_43/Makefile.in b/dlls/d3dx10_43/Makefile.in index 1fae34191ee..6d74f586841 100644 --- a/dlls/d3dx10_43/Makefile.in +++ b/dlls/d3dx10_43/Makefile.in @@ -1,6 +1,6 @@ MODULE = d3dx10_43.dll IMPORTLIB = d3dx10 -IMPORTS = d3d10_1 d3dcompiler dxguid +IMPORTS = d3d10_1 d3dcompiler dxguid uuid DELAYIMPORTS = windowscodecs
EXTRADLLFLAGS = -mno-cygwin -Wb,--prefer-native @@ -9,6 +9,7 @@ C_SRCS = \ async.c \ compiler.c \ d3dx10_43_main.c \ + sprite.c \ texture.c
RC_SRCS = version.rc diff --git a/dlls/d3dx10_43/d3dx10_43.spec b/dlls/d3dx10_43/d3dx10_43.spec index a00b3402a5a..99b142f34d5 100644 --- a/dlls/d3dx10_43/d3dx10_43.spec +++ b/dlls/d3dx10_43/d3dx10_43.spec @@ -41,7 +41,7 @@ @ stub D3DX10CreateShaderResourceViewFromResourceA(ptr long str ptr ptr ptr ptr) @ stub D3DX10CreateShaderResourceViewFromResourceW(ptr long wstr ptr ptr ptr ptr) @ stub D3DX10CreateSkinInfo(ptr) -@ stub D3DX10CreateSprite(ptr long ptr) +@ stdcall D3DX10CreateSprite(ptr long ptr) @ stub D3DX10CreateTextureFromFileA(ptr str ptr ptr ptr ptr) @ stub D3DX10CreateTextureFromFileW(ptr wstr ptr ptr ptr ptr) @ stdcall D3DX10CreateTextureFromMemory(ptr ptr long ptr ptr ptr ptr) diff --git a/dlls/d3dx10_43/sprite.c b/dlls/d3dx10_43/sprite.c new file mode 100644 index 00000000000..6c1ef732ec0 --- /dev/null +++ b/dlls/d3dx10_43/sprite.c @@ -0,0 +1,202 @@ +/* + * Copyright 2021 Nikolay Sivov for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + * + */ + +#define COBJMACROS +#include "d3dx10.h" + +#include "wine/debug.h" +#include "wine/heap.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); + +#define D3DERR_INVALIDCALL 0x8876086c + +struct d3dx10_sprite +{ + ID3DX10Sprite ID3DX10Sprite_iface; + LONG refcount; + + ID3D10Device *device; +}; + +static inline struct d3dx10_sprite *impl_from_ID3DX10Sprite(ID3DX10Sprite *iface) +{ + return CONTAINING_RECORD(iface, struct d3dx10_sprite, ID3DX10Sprite_iface); +} + +static HRESULT WINAPI d3dx10_sprite_QueryInterface(ID3DX10Sprite *iface, REFIID riid, void **out) +{ + TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out); + + if (IsEqualGUID(riid, &IID_ID3DX10Sprite) + || IsEqualGUID(riid, &IID_IUnknown)) + { + IUnknown_AddRef(iface); + *out = iface; + return S_OK; + } + + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); + + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI d3dx10_sprite_AddRef(ID3DX10Sprite *iface) +{ + struct d3dx10_sprite *sprite = impl_from_ID3DX10Sprite(iface); + ULONG refcount = InterlockedIncrement(&sprite->refcount); + + TRACE("%p increasing refcount to %u.\n", iface, refcount); + + return refcount; +} + +static ULONG WINAPI d3dx10_sprite_Release(ID3DX10Sprite *iface) +{ + struct d3dx10_sprite *sprite = impl_from_ID3DX10Sprite(iface); + ULONG refcount = InterlockedDecrement(&sprite->refcount); + + TRACE("%p decreasing refcount to %u.\n", iface, refcount); + + if (!refcount) + { + ID3D10Device_Release(sprite->device); + heap_free(sprite); + } + + return refcount; +} + +static HRESULT WINAPI d3dx10_sprite_Begin(ID3DX10Sprite *iface, UINT flags) +{ + FIXME("%p, %#x.\n", iface, flags); + + return E_NOTIMPL; +} + +static HRESULT WINAPI d3dx10_sprite_DrawSpritesBuffered(ID3DX10Sprite *iface, D3DX10_SPRITE *sprites, UINT count) +{ + FIXME("%p, %p, %u.\n", iface, sprites, count); + + return E_NOTIMPL; +} + +static HRESULT WINAPI d3dx10_sprite_Flush(ID3DX10Sprite *iface) +{ + FIXME("%p.\n", iface); + + return E_NOTIMPL; +} + +static HRESULT WINAPI d3dx10_sprite_DrawSpritesImmediate(ID3DX10Sprite *iface, D3DX10_SPRITE *sprites, + UINT count, UINT size, UINT flags) +{ + FIXME("%p, %p, %u, %u, %#x.\n", iface, sprites, count, size, flags); + + return E_NOTIMPL; +} + +static HRESULT WINAPI d3dx10_sprite_End(ID3DX10Sprite *iface) +{ + FIXME("%p.\n", iface); + + return E_NOTIMPL; +} + +static HRESULT WINAPI d3dx10_sprite_GetViewTransform(ID3DX10Sprite *iface, D3DXMATRIX *transform) +{ + FIXME("%p, %p.\n", iface, transform); + + return E_NOTIMPL; +} + +static HRESULT WINAPI d3dx10_sprite_SetViewTransform(ID3DX10Sprite *iface, D3DXMATRIX *transform) +{ + FIXME("%p, %p.\n", iface, transform); + + return E_NOTIMPL; +} + +static HRESULT WINAPI d3dx10_sprite_GetProjectionTransform(ID3DX10Sprite *iface, D3DXMATRIX *transform) +{ + FIXME("%p, %p.\n", iface, transform); + + return E_NOTIMPL; +} + +static HRESULT WINAPI d3dx10_sprite_SetProjectionTransform(ID3DX10Sprite *iface, D3DXMATRIX *transform) +{ + FIXME("%p, %p.\n", iface, transform); + + return E_NOTIMPL; +} + +static HRESULT WINAPI d3dx10_sprite_GetDevice(ID3DX10Sprite *iface, ID3D10Device **device) +{ + struct d3dx10_sprite *sprite = impl_from_ID3DX10Sprite(iface); + + TRACE("%p, %p.\n", iface, device); + + *device = sprite->device; + ID3D10Device_AddRef(*device); + + return S_OK; +} + +static const ID3DX10SpriteVtbl d3dx10_sprite_vtbl = +{ + d3dx10_sprite_QueryInterface, + d3dx10_sprite_AddRef, + d3dx10_sprite_Release, + d3dx10_sprite_Begin, + d3dx10_sprite_DrawSpritesBuffered, + d3dx10_sprite_Flush, + d3dx10_sprite_DrawSpritesImmediate, + d3dx10_sprite_End, + d3dx10_sprite_GetViewTransform, + d3dx10_sprite_SetViewTransform, + d3dx10_sprite_GetProjectionTransform, + d3dx10_sprite_SetProjectionTransform, + d3dx10_sprite_GetDevice, +}; + +HRESULT WINAPI D3DX10CreateSprite(ID3D10Device *device, UINT size, ID3DX10Sprite **sprite) +{ + struct d3dx10_sprite *object; + + TRACE("device %p, size %u, sprite %p.\n", device, size, sprite); + + if (!device || !sprite) + return D3DERR_INVALIDCALL; + + *sprite = NULL; + + if (!(object = heap_alloc_zero(sizeof(*object)))) + return E_OUTOFMEMORY; + + object->ID3DX10Sprite_iface.lpVtbl = &d3dx10_sprite_vtbl; + object->refcount = 1; + object->device = device; + ID3D10Device_AddRef(device); + + *sprite = &object->ID3DX10Sprite_iface; + + return S_OK; +} diff --git a/include/d3dx10core.h b/include/d3dx10core.h index d794fa028d7..dbbe4b02e10 100644 --- a/include/d3dx10core.h +++ b/include/d3dx10core.h @@ -289,3 +289,4 @@ HRESULT WINAPI D3DX10CreateDeviceAndSwapChain(IDXGIAdapter *adapter, D3D10_DRIVE ID3D10Device **device); typedef interface ID3D10Device1 ID3D10Device1; HRESULT WINAPI D3DX10GetFeatureLevel1(ID3D10Device *device, ID3D10Device1 **device1); +HRESULT WINAPI D3DX10CreateSprite(ID3D10Device *device, UINT size, ID3DX10Sprite **sprite);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3dx10_43/Makefile.in | 1 + dlls/d3dx10_43/d3dx10_43.spec | 8 +- dlls/d3dx10_43/font.c | 337 ++++++++++++++++++++++++++++++++++ include/d3dx10core.h | 6 + 4 files changed, 348 insertions(+), 4 deletions(-) create mode 100644 dlls/d3dx10_43/font.c
diff --git a/dlls/d3dx10_43/Makefile.in b/dlls/d3dx10_43/Makefile.in index 6d74f586841..a763f588996 100644 --- a/dlls/d3dx10_43/Makefile.in +++ b/dlls/d3dx10_43/Makefile.in @@ -9,6 +9,7 @@ C_SRCS = \ async.c \ compiler.c \ d3dx10_43_main.c \ + font.c \ sprite.c \ texture.c
diff --git a/dlls/d3dx10_43/d3dx10_43.spec b/dlls/d3dx10_43/d3dx10_43.spec index 99b142f34d5..aaa056acdd2 100644 --- a/dlls/d3dx10_43/d3dx10_43.spec +++ b/dlls/d3dx10_43/d3dx10_43.spec @@ -30,10 +30,10 @@ @ stdcall D3DX10CreateEffectPoolFromMemory(ptr long str ptr ptr str long long ptr ptr ptr ptr ptr) @ stub D3DX10CreateEffectPoolFromResourceA(long str str ptr ptr str long long ptr ptr ptr ptr ptr) @ stub D3DX10CreateEffectPoolFromResourceW(long wstr wstr ptr ptr str long long ptr ptr ptr ptr ptr) -@ stub D3DX10CreateFontA(ptr long long long long long long long long long str ptr) -@ stub D3DX10CreateFontIndirectA(ptr ptr ptr) -@ stub D3DX10CreateFontIndirectW(ptr ptr ptr) -@ stub D3DX10CreateFontW(ptr long long long long long long long long long wstr ptr) +@ stdcall D3DX10CreateFontA(ptr long long long long long long long long long str ptr) +@ stdcall D3DX10CreateFontIndirectA(ptr ptr ptr) +@ stdcall D3DX10CreateFontIndirectW(ptr ptr ptr) +@ stdcall D3DX10CreateFontW(ptr long long long long long long long long long wstr ptr) @ stub D3DX10CreateMesh(ptr ptr long str long long long ptr) @ stub D3DX10CreateShaderResourceViewFromFileA(ptr str ptr ptr ptr ptr) @ stub D3DX10CreateShaderResourceViewFromFileW(ptr wstr ptr ptr ptr ptr) diff --git a/dlls/d3dx10_43/font.c b/dlls/d3dx10_43/font.c new file mode 100644 index 00000000000..d1b062b8a84 --- /dev/null +++ b/dlls/d3dx10_43/font.c @@ -0,0 +1,337 @@ +/* + * Copyright (C) 2008 Tony Wasserka + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + * + */ + +#define COBJMACROS +#include "d3dx10.h" + +#include "wine/debug.h" +#include "wine/heap.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); + +#define D3DERR_INVALIDCALL 0x8876086c + +struct d3dx_font +{ + ID3DX10Font ID3DX10Font_iface; + LONG refcount; + + ID3D10Device *device; +}; + +static inline struct d3dx_font *impl_from_ID3DX10Font(ID3DX10Font *iface) +{ + return CONTAINING_RECORD(iface, struct d3dx_font, ID3DX10Font_iface); +} + +static HRESULT WINAPI d3dx_font_QueryInterface(ID3DX10Font *iface, REFIID riid, void **out) +{ + TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out); + + if (IsEqualGUID(riid, &IID_ID3DX10Font) + || IsEqualGUID(riid, &IID_IUnknown)) + { + IUnknown_AddRef(iface); + *out = iface; + return S_OK; + } + + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); + + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI d3dx_font_AddRef(ID3DX10Font *iface) +{ + struct d3dx_font *font = impl_from_ID3DX10Font(iface); + ULONG refcount = InterlockedIncrement(&font->refcount); + + TRACE("%p increasing refcount to %u\n", iface, refcount); + return refcount; +} + +static ULONG WINAPI d3dx_font_Release(ID3DX10Font *iface) +{ + struct d3dx_font *font = impl_from_ID3DX10Font(iface); + ULONG refcount = InterlockedDecrement(&font->refcount); + + TRACE("%p decreasing refcount to %u\n", iface, refcount); + + if (!refcount) + { + ID3D10Device_Release(font->device); + heap_free(font); + } + return refcount; +} + +static HRESULT WINAPI d3dx_font_GetDevice(ID3DX10Font *iface, ID3D10Device **device) +{ + struct d3dx_font *font = impl_from_ID3DX10Font(iface); + + TRACE("iface %p, device %p\n", iface, device); + + if (!device) return D3DERR_INVALIDCALL; + *device = font->device; + ID3D10Device_AddRef(font->device); + + return S_OK; +} + +static HRESULT WINAPI d3dx_font_GetDescA(ID3DX10Font *iface, D3DX10_FONT_DESCA *desc) +{ + FIXME("iface %p, desc %p\n", iface, desc); + + return E_NOTIMPL; +} + +static HRESULT WINAPI d3dx_font_GetDescW(ID3DX10Font *iface, D3DX10_FONT_DESCW *desc) +{ + FIXME("iface %p, desc %p\n", iface, desc); + + return E_NOTIMPL; +} + +static BOOL WINAPI d3dx_font_GetTextMetricsA(ID3DX10Font *iface, TEXTMETRICA *metrics) +{ + FIXME("iface %p, metrics %p\n", iface, metrics); + + return FALSE; +} + +static BOOL WINAPI d3dx_font_GetTextMetricsW(ID3DX10Font *iface, TEXTMETRICW *metrics) +{ + FIXME("iface %p, metrics %p\n", iface, metrics); + + return FALSE; +} + +static HDC WINAPI d3dx_font_GetDC(ID3DX10Font *iface) +{ + FIXME("iface %p\n", iface); + + return NULL; +} + +static HRESULT WINAPI d3dx_font_GetGlyphData(ID3DX10Font *iface, UINT glyph, + ID3D10ShaderResourceView **view, RECT *black_box, POINT *cell_inc) +{ + FIXME("iface %p, glyph %#x, view %p, black_box %p, cell_inc %p.\n", + iface, glyph, view, black_box, cell_inc); + + return E_NOTIMPL; +} + +static HRESULT WINAPI d3dx_font_PreloadCharacters(ID3DX10Font *iface, UINT first, UINT last) +{ + FIXME("iface %p, first %u, last %u.\n", iface, first, last); + + return E_NOTIMPL; +} + +static HRESULT WINAPI d3dx_font_PreloadGlyphs(ID3DX10Font *iface, UINT first, UINT last) +{ + FIXME("iface %p, first %u, last %u.\n", iface, first, last); + + return E_NOTIMPL; +} + +static HRESULT WINAPI d3dx_font_PreloadTextA(ID3DX10Font *iface, const char *string, INT count) +{ + WCHAR *wstr; + HRESULT hr; + int countW; + + TRACE("iface %p, string %s, count %d.\n", iface, debugstr_an(string, count), count); + + if (!string && !count) + return S_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 = ID3DX10Font_PreloadTextW(iface, wstr, count < 0 ? countW - 1 : countW); + + heap_free(wstr); + + return hr; +} + +static HRESULT WINAPI d3dx_font_PreloadTextW(ID3DX10Font *iface, const WCHAR *string, INT count) +{ + FIXME("iface %p, string %s, count %d.\n", iface, debugstr_wn(string, count), count); + + return E_NOTIMPL; +} + +static INT WINAPI d3dx_font_DrawTextA(ID3DX10Font *iface, ID3DX10Sprite *sprite, + const char *string, INT count, RECT *rect, UINT format, D3DXCOLOR color) +{ + int ret, countW; + WCHAR *wstr; + + TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x.\n", + iface, sprite, debugstr_an(string, count), count, wine_dbgstr_rect(rect), format); + + 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 = ID3DX10Font_DrawTextW(iface, sprite, wstr, count < 0 ? countW - 1 : countW, + rect, format, color); + + heap_free(wstr); + + return ret; +} + +static INT WINAPI d3dx_font_DrawTextW(ID3DX10Font *iface, ID3DX10Sprite *sprite, + const WCHAR *string, INT in_count, RECT *rect, DWORD format, D3DXCOLOR color) +{ + FIXME("iface %p, sprite %p, string %s, in_count %d, rect %s, format %#x.\n", + iface, sprite, debugstr_wn(string, in_count), in_count, wine_dbgstr_rect(rect), format); + + return E_NOTIMPL; +} + +static const ID3DX10FontVtbl d3dx_font_vtbl = +{ + /*** IUnknown methods ***/ + d3dx_font_QueryInterface, + d3dx_font_AddRef, + d3dx_font_Release, + /*** ID3DX10Font methods ***/ + d3dx_font_GetDevice, + d3dx_font_GetDescA, + d3dx_font_GetDescW, + d3dx_font_GetTextMetricsA, + d3dx_font_GetTextMetricsW, + d3dx_font_GetDC, + d3dx_font_GetGlyphData, + d3dx_font_PreloadCharacters, + d3dx_font_PreloadGlyphs, + d3dx_font_PreloadTextA, + d3dx_font_PreloadTextW, + d3dx_font_DrawTextA, + d3dx_font_DrawTextW, +}; + +HRESULT WINAPI D3DX10CreateFontA(ID3D10Device *device, INT height, UINT width, + UINT weight, UINT miplevels, BOOL italic, DWORD charset, DWORD precision, DWORD quality, + DWORD pitchandfamily, const char *facename, ID3DX10Font **font) +{ + D3DX10_FONT_DESCA desc; + + if (!device || !font) + return D3DERR_INVALIDCALL; + + desc.Height = height; + desc.Width = width; + desc.Weight = weight; + desc.MipLevels = miplevels; + desc.Italic = italic; + desc.CharSet = charset; + desc.OutputPrecision = precision; + desc.Quality = quality; + desc.PitchAndFamily = pitchandfamily; + if (facename) lstrcpyA(desc.FaceName, facename); + else desc.FaceName[0] = '\0'; + + return D3DX10CreateFontIndirectA(device, &desc, font); +} + +HRESULT WINAPI D3DX10CreateFontW(ID3D10Device *device, INT height, UINT width, UINT weight, UINT miplevels, BOOL italic, DWORD charset, + DWORD precision, DWORD quality, DWORD pitchandfamily, const WCHAR *facename, ID3DX10Font **font) +{ + D3DX10_FONT_DESCW desc; + + if (!device || !font) + return D3DERR_INVALIDCALL; + + desc.Height = height; + desc.Width = width; + desc.Weight = weight; + desc.MipLevels = miplevels; + desc.Italic = italic; + desc.CharSet = charset; + desc.OutputPrecision = precision; + desc.Quality = quality; + desc.PitchAndFamily = pitchandfamily; + if (facename) lstrcpyW(desc.FaceName, facename); + else desc.FaceName[0] = '\0'; + + return D3DX10CreateFontIndirectW(device, &desc, font); +} + +HRESULT WINAPI D3DX10CreateFontIndirectA(ID3D10Device *device, const D3DX10_FONT_DESCA *desc, ID3DX10Font **font) +{ + D3DX10_FONT_DESCW descW; + + if (!device || !desc || !font) + return D3DERR_INVALIDCALL; + + memcpy(&descW, desc, FIELD_OFFSET(D3DX10_FONT_DESCA, FaceName)); + MultiByteToWideChar(CP_ACP, 0, desc->FaceName, -1, descW.FaceName, ARRAY_SIZE(descW.FaceName)); + return D3DX10CreateFontIndirectW(device, &descW, font); +} + +HRESULT WINAPI D3DX10CreateFontIndirectW(ID3D10Device *device, const D3DX10_FONT_DESCW *desc, ID3DX10Font **font) +{ + struct d3dx_font *object; + + TRACE("%p, %p, %p.\n", device, desc, font); + + if (!device || !desc || !font) + return D3DERR_INVALIDCALL; + + object = heap_alloc_zero(sizeof(*object)); + if (!object) + { + *font = NULL; + return E_OUTOFMEMORY; + } + + object->ID3DX10Font_iface.lpVtbl = &d3dx_font_vtbl; + object->refcount = 1; + object->device = device; + ID3D10Device_AddRef(device); + + *font = &object->ID3DX10Font_iface; + + return S_OK; +} diff --git a/include/d3dx10core.h b/include/d3dx10core.h index dbbe4b02e10..63d6e4dae42 100644 --- a/include/d3dx10core.h +++ b/include/d3dx10core.h @@ -289,4 +289,10 @@ HRESULT WINAPI D3DX10CreateDeviceAndSwapChain(IDXGIAdapter *adapter, D3D10_DRIVE ID3D10Device **device); typedef interface ID3D10Device1 ID3D10Device1; HRESULT WINAPI D3DX10GetFeatureLevel1(ID3D10Device *device, ID3D10Device1 **device1); +HRESULT WINAPI D3DX10CreateFontIndirectA(ID3D10Device *device, const D3DX10_FONT_DESCA *desc, ID3DX10Font **font); +HRESULT WINAPI D3DX10CreateFontIndirectW(ID3D10Device *device, const D3DX10_FONT_DESCW *desc, ID3DX10Font **font); +HRESULT WINAPI D3DX10CreateFontA(ID3D10Device *device, INT height, UINT width, UINT weight, UINT miplevels, BOOL italic, DWORD charset, + DWORD precision, DWORD quality, DWORD pitchandfamily, const char *facename, ID3DX10Font **font); +HRESULT WINAPI D3DX10CreateFontW(ID3D10Device *device, INT height, UINT width, UINT weight, UINT miplevels, BOOL italic, DWORD charset, + DWORD precision, DWORD quality, DWORD pitchandfamily, const WCHAR *facename, ID3DX10Font **font); HRESULT WINAPI D3DX10CreateSprite(ID3D10Device *device, UINT size, ID3DX10Sprite **sprite);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- include/d3dx10core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/d3dx10core.h b/include/d3dx10core.h index 63d6e4dae42..28f366f86fb 100644 --- a/include/d3dx10core.h +++ b/include/d3dx10core.h @@ -247,7 +247,7 @@ DECLARE_INTERFACE_(ID3DX10Font, IUnknown) #define ID3DX10Font_AddRef(p) (p)->lpVtbl->AddRef(p) #define ID3DX10Font_Release(p) (p)->lpVtbl->Release(p) /*** ID3DX10Font methods ***/ -#define ID3DX10Font_GetDevice(p,a) (p)->lpVtbl->Begin(p,a) +#define ID3DX10Font_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) #define ID3DX10Font_GetDescA(p,a) (p)->lpVtbl->GetDescA(p,a) #define ID3DX10Font_GetDescW(p,a) (p)->lpVtbl->GetDescW(p,a) #define ID3DX10Font_GetTextMetricsA(p,a) (p)->lpVtbl->GetTextMetricsA(p,a) @@ -266,7 +266,7 @@ DECLARE_INTERFACE_(ID3DX10Font, IUnknown) #define ID3DX10Font_AddRef(p) (p)->AddRef() #define ID3DX10Font_Release(p) (p)->Release() /*** ID3DX10Font methods ***/ -#define ID3DX10Font_GetDevice(p,a) (p)->Begin(a) +#define ID3DX10Font_GetDevice(p,a) (p)->GetDevice(a) #define ID3DX10Font_GetDescA(p,a) (p)->GetDescA(a) #define ID3DX10Font_GetDescW(p,a) (p)->GetDescW(a) #define ID3DX10Font_GetTextMetricsA(p,a) (p)->GetTextMetricsA(a)
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3dx10_43/tests/Makefile.in | 2 +- dlls/d3dx10_43/tests/d3dx10.c | 931 +++++++++++++++++++++++++++++++ 2 files changed, 932 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dx10_43/tests/Makefile.in b/dlls/d3dx10_43/tests/Makefile.in index 095f99771d2..7498e73e4bc 100644 --- a/dlls/d3dx10_43/tests/Makefile.in +++ b/dlls/d3dx10_43/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = d3dx10_43.dll -IMPORTS = d3dx10 ole32 +IMPORTS = d3dx10 ole32 gdi32
C_SRCS = \ d3dx10.c diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 30d766bf244..4805f47507a 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -22,6 +22,8 @@ #include "d3dx10.h" #include "wine/test.h"
+#define D3DERR_INVALIDCALL 0x8876086c + /* 1x1 1bpp bmp image */ static const BYTE test_bmp_1bpp[] = { @@ -820,6 +822,13 @@ static unsigned int get_bpp_from_format(DXGI_FORMAT format) } }
+static ULONG get_refcount(void *iface) +{ + IUnknown *unknown = iface; + IUnknown_AddRef(unknown); + return IUnknown_Release(unknown); +} + static BOOL compare_float(float f, float g, unsigned int ulps) { int x = *(int *)&f; @@ -2016,6 +2025,927 @@ static void test_create_texture(void) ID3D10Device_Release(device); }
+#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_font(void) +{ + static const WCHAR testW[] = L"test"; + static const char long_text[] = "Example text to test clipping and other related things"; + static const WCHAR long_textW[] = L"Example text to test clipping and other related things"; + static const MAT2 mat = { {0,1}, {0,0}, {0,0}, {0,1} }; + static const D3DXCOLOR color = { 1.0f, 0.0f, 1.0f, 0.0f }; + static const D3DXCOLOR white = { 1.0f, 1.0f, 1.0f, 0.0f }; + static const struct + { + int font_height; + unsigned int expected_size; + unsigned int expected_levels; + } + tests[] = + { + { 2, 32, 2 }, + { 6, 128, 4 }, + { 10, 256, 5 }, + { 12, 256, 5 }, + { 72, 256, 8 }, + { 250, 256, 9 }, + { 258, 512, 10 }, + { 512, 512, 10 }, + }; + const unsigned int size = ARRAY_SIZE(testW); + TEXTMETRICA metrics, expmetrics; + D3D10_TEXTURE2D_DESC texture_desc; + ID3D10Device *device, *device2; + ID3D10ShaderResourceView *srv; + GLYPHMETRICS glyph_metrics; + int ref, i, height, count; + ID3D10Texture2D *texture; + ID3D10Resource *resource; + D3DX10_FONT_DESCA desc; + ID3DX10Sprite *sprite; + RECT rect, blackbox; + ID3DX10Font *font; + TEXTMETRICW tm; + POINT cellinc; + HRESULT hr; + WORD glyph; + BOOL ret; + HDC hdc; + char c; + + if (!(device = create_device())) + { + skip("Failed to create device, skipping tests.\n"); + return; + } + + ref = get_refcount(device); + hr = D3DX10CreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); + ok(hr == S_OK, "Failed to create a font, hr %#x.\n", hr); + ok(ref < get_refcount(device), "Unexpected device refcount.\n"); + ID3DX10Font_Release(font); + ok(ref == get_refcount(device), "Unexpected device refcount.\n"); + + /* Zero size */ + hr = D3DX10CreateFontA(device, 0, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); + ok(hr == S_OK, "Failed to create a font, hr %#x.\n", hr); + ID3DX10Font_Release(font); + + /* Unspecified font name */ + hr = D3DX10CreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, NULL, &font); + ok(hr == S_OK, "Failed to create a font, hr %#x.\n", hr); + ID3DX10Font_Release(font); + + /* Empty font name */ + hr = D3DX10CreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "", &font); + ok(hr == S_OK, "Failed to create a font, hr %#x.\n", hr); + ID3DX10Font_Release(font); + + hr = D3DX10CreateFontA(NULL, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); + + hr = D3DX10CreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", NULL); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); + + hr = D3DX10CreateFontA(NULL, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", NULL); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); + + /* D3DX10CreateFontIndirect */ + desc.Height = 12; + desc.Width = 0; + desc.Weight = FW_DONTCARE; + desc.MipLevels = 0; + desc.Italic = FALSE; + desc.CharSet = DEFAULT_CHARSET; + desc.OutputPrecision = OUT_DEFAULT_PRECIS; + desc.Quality = DEFAULT_QUALITY; + desc.PitchAndFamily = DEFAULT_PITCH; + strcpy(desc.FaceName, "Tahoma"); + hr = D3DX10CreateFontIndirectA(device, &desc, &font); + ok(hr == S_OK, "Failed to create a font, hr %#x.\n", hr); + ID3DX10Font_Release(font); + + hr = D3DX10CreateFontIndirectA(NULL, &desc, &font); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); + + hr = D3DX10CreateFontIndirectA(device, NULL, &font); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); + + hr = D3DX10CreateFontIndirectA(device, &desc, NULL); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); + + /* GetDevice */ + hr = D3DX10CreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, + DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = ID3DX10Font_GetDevice(font, NULL); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); + + hr = ID3DX10Font_GetDevice(font, &device2); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ID3D10Device_Release(device2); + + ID3DX10Font_Release(font); + + /* GetDesc */ + hr = D3DX10CreateFontA(device, 12, 8, FW_BOLD, 2, TRUE, ANSI_CHARSET, OUT_RASTER_PRECIS, + ANTIALIASED_QUALITY, VARIABLE_PITCH, "Tahoma", &font); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = ID3DX10Font_GetDescA(font, NULL); +todo_wine + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); + + hr = ID3DX10Font_GetDescA(font, &desc); +todo_wine + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + +if (SUCCEEDED(hr)) +{ + ok(desc.Height == 12, "Got unexpected height %d.\n", desc.Height); + ok(desc.Width == 8, "Got unexpected width %u.\n", desc.Width); + ok(desc.Weight == FW_BOLD, "Got unexpected weight %u.\n", desc.Weight); + ok(desc.MipLevels == 2, "Got unexpected miplevels %u.\n", desc.MipLevels); + ok(desc.Italic == TRUE, "Got unexpected italic %#x.\n", desc.Italic); + ok(desc.CharSet == ANSI_CHARSET, "Got unexpected charset %u.\n", desc.CharSet); + ok(desc.OutputPrecision == OUT_RASTER_PRECIS, "Got unexpected output precision %u.\n", desc.OutputPrecision); + ok(desc.Quality == ANTIALIASED_QUALITY, "Got unexpected quality %u.\n", desc.Quality); + ok(desc.PitchAndFamily == VARIABLE_PITCH, "Got unexpected pitch and family %#x.\n", desc.PitchAndFamily); + ok(!strcmp(desc.FaceName, "Tahoma"), "Got unexpected facename %s.\n", debugstr_a(desc.FaceName)); +} + ID3DX10Font_Release(font); + + /* GetDC + GetTextMetrics */ + hr = D3DX10CreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, + DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hdc = ID3DX10Font_GetDC(font); +todo_wine + ok(!!hdc, "Got unexpected hdc %p.\n", hdc); + + ret = ID3DX10Font_GetTextMetricsA(font, &metrics); +todo_wine + ok(ret, "Got unexpected ret %#x.\n", ret); + ret = GetTextMetricsA(hdc, &expmetrics); +todo_wine + ok(ret, "Got unexpected ret %#x.\n", ret); + +if (ret) +{ + ok(metrics.tmHeight == expmetrics.tmHeight, "Got unexpected height %d, expected %d.\n", + metrics.tmHeight, expmetrics.tmHeight); + ok(metrics.tmAscent == expmetrics.tmAscent, "Got unexpected ascent %d, expected %d.\n", + metrics.tmAscent, expmetrics.tmAscent); + ok(metrics.tmDescent == expmetrics.tmDescent, "Got unexpected descent %d, expected %d.\n", + metrics.tmDescent, expmetrics.tmDescent); + ok(metrics.tmInternalLeading == expmetrics.tmInternalLeading, "Got unexpected internal leading %d, expected %d.\n", + metrics.tmInternalLeading, expmetrics.tmInternalLeading); + ok(metrics.tmExternalLeading == expmetrics.tmExternalLeading, "Got unexpected external leading %d, expected %d.\n", + metrics.tmExternalLeading, expmetrics.tmExternalLeading); + ok(metrics.tmAveCharWidth == expmetrics.tmAveCharWidth, "Got unexpected average char width %d, expected %d.\n", + metrics.tmAveCharWidth, expmetrics.tmAveCharWidth); + ok(metrics.tmMaxCharWidth == expmetrics.tmMaxCharWidth, "Got unexpected maximum char width %d, expected %d.\n", + metrics.tmMaxCharWidth, expmetrics.tmMaxCharWidth); + ok(metrics.tmWeight == expmetrics.tmWeight, "Got unexpected weight %d, expected %d.\n", + metrics.tmWeight, expmetrics.tmWeight); + ok(metrics.tmOverhang == expmetrics.tmOverhang, "Got unexpected overhang %d, expected %d.\n", + metrics.tmOverhang, expmetrics.tmOverhang); + ok(metrics.tmDigitizedAspectX == expmetrics.tmDigitizedAspectX, "Got unexpected digitized x aspect %d, expected %d.\n", + metrics.tmDigitizedAspectX, expmetrics.tmDigitizedAspectX); + ok(metrics.tmDigitizedAspectY == expmetrics.tmDigitizedAspectY, "Got unexpected digitized y aspect %d, expected %d.\n", + metrics.tmDigitizedAspectY, expmetrics.tmDigitizedAspectY); + ok(metrics.tmFirstChar == expmetrics.tmFirstChar, "Got unexpected first char %u, expected %u.\n", + metrics.tmFirstChar, expmetrics.tmFirstChar); + ok(metrics.tmLastChar == expmetrics.tmLastChar, "Got unexpected last char %u, expected %u.\n", + metrics.tmLastChar, expmetrics.tmLastChar); + ok(metrics.tmDefaultChar == expmetrics.tmDefaultChar, "Got unexpected default char %u, expected %u.\n", + metrics.tmDefaultChar, expmetrics.tmDefaultChar); + ok(metrics.tmBreakChar == expmetrics.tmBreakChar, "Got unexpected break char %u, expected %u.\n", + metrics.tmBreakChar, expmetrics.tmBreakChar); + ok(metrics.tmItalic == expmetrics.tmItalic, "Got unexpected italic %u, expected %u.\n", + metrics.tmItalic, expmetrics.tmItalic); + ok(metrics.tmUnderlined == expmetrics.tmUnderlined, "Got unexpected underlined %u, expected %u.\n", + metrics.tmUnderlined, expmetrics.tmUnderlined); + ok(metrics.tmStruckOut == expmetrics.tmStruckOut, "Got unexpected struck out %u, expected %u.\n", + metrics.tmStruckOut, expmetrics.tmStruckOut); + ok(metrics.tmPitchAndFamily == expmetrics.tmPitchAndFamily, "Got unexpected pitch and family %u, expected %u.\n", + metrics.tmPitchAndFamily, expmetrics.tmPitchAndFamily); + ok(metrics.tmCharSet == expmetrics.tmCharSet, "Got unexpected charset %u, expected %u.\n", + metrics.tmCharSet, expmetrics.tmCharSet); +} + ID3DX10Font_Release(font); + + /* PreloadText */ + hr = D3DX10CreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, + DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = ID3DX10Font_PreloadTextA(font, NULL, -1); + ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + hr = ID3DX10Font_PreloadTextA(font, NULL, 0); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = ID3DX10Font_PreloadTextA(font, NULL, 1); + ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + hr = ID3DX10Font_PreloadTextA(font, "test", -1); +todo_wine + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = ID3DX10Font_PreloadTextA(font, "", 0); +todo_wine + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = ID3DX10Font_PreloadTextA(font, "", -1); +todo_wine + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = ID3DX10Font_PreloadTextW(font, NULL, -1); +todo_wine + ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + hr = ID3DX10Font_PreloadTextW(font, NULL, 0); +todo_wine + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = ID3DX10Font_PreloadTextW(font, NULL, 1); +todo_wine + ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + hr = ID3DX10Font_PreloadTextW(font, testW, -1); +todo_wine + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = ID3DX10Font_PreloadTextW(font, L"", 0); +todo_wine + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = ID3DX10Font_PreloadTextW(font, L"", -1); +todo_wine + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + ID3DX10Font_Release(font); + + /* GetGlyphData, PreloadGlyphs, PreloadCharacters */ + hr = D3DX10CreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, + DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hdc = ID3DX10Font_GetDC(font); +todo_wine + ok(!!hdc, "Got unexpected hdc %p.\n", hdc); + + hr = ID3DX10Font_GetGlyphData(font, 0, NULL, &blackbox, &cellinc); +todo_wine + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = ID3DX10Font_GetGlyphData(font, 0, &srv, NULL, &cellinc); +todo_wine + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) + ID3D10ShaderResourceView_Release(srv); + hr = ID3DX10Font_GetGlyphData(font, 0, &srv, &blackbox, NULL); +todo_wine + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) + ID3D10ShaderResourceView_Release(srv); + + hr = ID3DX10Font_PreloadCharacters(font, 'b', 'a'); +todo_wine + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = ID3DX10Font_PreloadGlyphs(font, 1, 0); +todo_wine + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + hr = ID3DX10Font_PreloadCharacters(font, 'a', 'a'); +todo_wine + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + for (c = 'b'; c <= 'z'; ++c) + { + if (!hdc) break; + + count = GetGlyphIndicesA(hdc, &c, 1, &glyph, 0); + ok(count != GDI_ERROR, "Got unexpected count %u.\n", count); + + hr = ID3DX10Font_GetGlyphData(font, glyph, &srv, &blackbox, &cellinc); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + ID3D10ShaderResourceView_GetResource(srv, &resource); + hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture2D, (void **)&texture); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ID3D10Resource_Release(resource); + + ID3D10Texture2D_GetDesc(texture, &texture_desc); + ok(texture_desc.Format == DXGI_FORMAT_R8G8B8A8_UNORM, "Got unexpected format %#x.\n", + texture_desc.Format); + ok(texture_desc.Usage == 0, "Got unexpected usage %#x.\n", texture_desc.Usage); + ok(texture_desc.Width == 256, "Got unexpected width %u.\n", texture_desc.Width); + ok(texture_desc.Height == 256, "Got unexpected height %u.\n", texture_desc.Height); + ok(texture_desc.CPUAccessFlags == 0, "Got unexpected access flags %#x.\n", + texture_desc.CPUAccessFlags); + ok(texture_desc.BindFlags == D3D10_BIND_SHADER_RESOURCE, "Got unexpected bind flags %#x.\n", + texture_desc.BindFlags); + + count = GetGlyphOutlineW(hdc, glyph, GGO_GLYPH_INDEX | GGO_METRICS, &glyph_metrics, 0, NULL, &mat); + ok(count != GDI_ERROR, "Got unexpected count %#x.\n", count); + + ret = ID3DX10Font_GetTextMetricsW(font, &tm); + ok(ret, "Got unexpected ret %#x.\n", ret); + + 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); + 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); + ok(cellinc.y == tm.tmAscent - glyph_metrics.gmptGlyphOrigin.y - 1, "Character %c: got %d, expected %d.\n", + c, cellinc.y, tm.tmAscent - glyph_metrics.gmptGlyphOrigin.y - 1); + + ID3D10Texture2D_Release(texture); + } + + hr = ID3DX10Font_PreloadCharacters(font, 'a', 'z'); +todo_wine + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + /* Test multiple textures */ + hr = ID3DX10Font_PreloadGlyphs(font, 0, 1000); +todo_wine + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + /* Test glyphs that are not rendered */ + for (glyph = 1; glyph < 4; ++glyph) + { + srv = (void *)0xdeadbeef; + hr = ID3DX10Font_GetGlyphData(font, glyph, &srv, &blackbox, &cellinc); + todo_wine { + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!srv, "Got unexpected resource view %p.\n", srv); + } + } + + ID3DX10Font_Release(font); + + c = 'a'; + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = D3DX10CreateFontA(device, tests[i].font_height, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, + OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); + ok(hr == S_OK, "Test %u: got unexpected hr %#x.\n", i, hr); + + hdc = ID3DX10Font_GetDC(font); + todo_wine + ok(!!hdc, "Test %u: got unexpected hdc %p.\n", i, hdc); + + if (!hdc) + { + ID3DX10Font_Release(font); + break; + } + + count = GetGlyphIndicesA(hdc, &c, 1, &glyph, 0); + ok(count != GDI_ERROR, "Test %u: got unexpected count %u.\n", i, count); + + hr = ID3DX10Font_GetGlyphData(font, glyph, &srv, NULL, NULL); + ok(hr == S_OK, "Test %u: got unexpected hr %#x.\n", i, hr); + + ID3D10ShaderResourceView_GetResource(srv, &resource); + hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture2D, (void **)&texture); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ID3D10Resource_Release(resource); + + ID3D10Texture2D_GetDesc(texture, &texture_desc); + + ok(texture_desc.Format == DXGI_FORMAT_R8G8B8A8_UNORM, "Test %u: got unexpected format %#x.\n", + i, texture_desc.Format); + ok(texture_desc.Usage == 0, "Test %u: got unexpected usage %#x.\n", i, texture_desc.Usage); + ok(texture_desc.Width == tests[i].expected_size, "Test %u: got unexpected width %u.\n", i, texture_desc.Width); + ok(texture_desc.Height == tests[i].expected_size, "Test %u: got unexpected height %u.\n", i, texture_desc.Height); + ok(texture_desc.CPUAccessFlags == 0, "Test %u: got unexpected access flags %#x.\n", + i, texture_desc.CPUAccessFlags); + ok(texture_desc.BindFlags == D3D10_BIND_SHADER_RESOURCE, "Test %u: got unexpected bind flags %#x.\n", + i, texture_desc.BindFlags); + + ID3D10Texture2D_Release(texture); + + /* DrawText */ + hr = D3DX10CreateSprite(device, 0, &sprite); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + SetRect(&rect, 0, 0, 640, 480); + + hr = ID3DX10Sprite_Begin(sprite, 0); + ok (hr == S_OK, "Test %d: got unexpected hr %#x.\n", i, hr); + + height = ID3DX10Font_DrawTextW(font, sprite, testW, -1, &rect, DT_TOP, white); + ok(height == tests[i].font_height, "Test %d: got unexpected height %u.\n", i, height); + height = ID3DX10Font_DrawTextW(font, sprite, testW, size, &rect, DT_TOP, white); + ok(height == tests[i].font_height, "Test %d: got unexpected height %u.\n", i, height); + height = ID3DX10Font_DrawTextW(font, sprite, testW, size, &rect, DT_RIGHT, white); + ok(height == tests[i].font_height, "Test %d: got unexpected height %u.\n", i, height); + height = ID3DX10Font_DrawTextW(font, sprite, testW, size, &rect, DT_LEFT | DT_NOCLIP, white); + ok(height == tests[i].font_height, "Test %d: got unexpected height %u.\n", i, height); + + SetRectEmpty(&rect); + height = ID3DX10Font_DrawTextW(font, sprite, testW, size, &rect, + DT_LEFT | DT_CALCRECT, white); + 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); + 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 = ID3DX10Sprite_End(sprite); + ok(hr == S_OK, "Test %d: got unexpected hr %#x.\n", i, hr); + ID3DX10Sprite_Release(sprite); + + ID3DX10Font_Release(font); + } + + if (!strcmp(winetest_platform, "wine")) + return; + + /* DrawText */ + hr = D3DX10CreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, + DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + SetRect(&rect, 10, 10, 200, 200); + + height = ID3DX10Font_DrawTextA(font, NULL, "test", -2, &rect, 0, color); + ok(height == 12, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextA(font, NULL, "test", -1, &rect, 0, color); + ok(height == 12, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextA(font, NULL, "test", 0, &rect, 0, color); + ok(height == 0, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextA(font, NULL, "test", 1, &rect, 0, color); + ok(height == 12, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextA(font, NULL, "test", 2, &rect, 0, color); + ok(height == 12, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextA(font, NULL, "", 0, &rect, 0, color); + ok(height == 0, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextA(font, NULL, "", -1, &rect, 0, color); + ok(height == 0, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextA(font, NULL, "test", -1, NULL, 0, color); + ok(height == 12, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextA(font, NULL, "test", -1, NULL, DT_CALCRECT, color); + ok(height == 12, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextA(font, NULL, NULL, -1, NULL, 0, color); + ok(height == 0, "Got unexpected height %d.\n", height); + + SetRect(&rect, 10, 10, 50, 50); + + height = ID3DX10Font_DrawTextA(font, NULL, long_text, -1, &rect, DT_WORDBREAK, color); + ok(height == 60, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextA(font, NULL, long_text, -1, &rect, DT_WORDBREAK | DT_NOCLIP, color); + ok(height == 96, "Got unexpected height %d.\n", height); + + SetRect(&rect, 10, 10, 200, 200); + + height = ID3DX10Font_DrawTextW(font, NULL, testW, -1, &rect, 0, color); + ok(height == 12, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, testW, 0, &rect, 0, color); + ok(height == 0, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, testW, 1, &rect, 0, color); + ok(height == 12, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, testW, 2, &rect, 0, color); + ok(height == 12, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"", 0, &rect, 0, color); + ok(height == 0, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"", -1, &rect, 0, color); + ok(height == 0, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, testW, -1, NULL, 0, color); + ok(height == 12, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, testW, -1, NULL, DT_CALCRECT, color); + ok(height == 12, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, NULL, -1, NULL, 0, color); + ok(height == 0, "Got unexpected height %d.\n", height); + + SetRect(&rect, 10, 10, 50, 50); + + height = ID3DX10Font_DrawTextW(font, NULL, long_textW, -1, &rect, DT_WORDBREAK, color); + ok(height == 60, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, long_textW, -1, &rect, DT_WORDBREAK | DT_NOCLIP, color); + ok(height == 96, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"a\na", -1, NULL, 0, color); + ok(height == 24, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"a\na", -1, &rect, 0, color); + ok(height == 24, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"a\r\na", -1, &rect, 0, color); + ok(height == 24, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"a\ra", -1, &rect, 0, color); + ok(height == 12, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"a\na", -1, &rect, DT_SINGLELINE, color); + ok(height == 12, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"a\naaaaa aaaa", -1, &rect, DT_SINGLELINE, color); + ok(height == 12, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"a\naaaaa aaaa", -1, &rect, 0, color); + ok(height == 24, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"a\naaaaa aaaa", -1, &rect, DT_WORDBREAK, color); + ok(height == 36, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"a\naaaaa aaaa", -1, &rect, DT_WORDBREAK | DT_SINGLELINE, color); + ok(height == 12, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"1\n2\n3\n4\n5\n6", -1, &rect, 0, color); + ok(height == 48, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"1\n2\n3\n4\n5\n6", -1, &rect, DT_NOCLIP, color); + ok(height == 72, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"\t\t\t\t\t\t\t\t\t\t", -1, &rect, DT_WORDBREAK, color); + ok(height == 0, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"\t\t\t\t\t\t\t\t\t\ta", -1, &rect, DT_WORDBREAK, color); + ok(height == 12, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"\taaaaaaaaaa", -1, &rect, DT_WORDBREAK, color); + ok(height == 24, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"\taaaaaaaaaa", -1, &rect, DT_EXPANDTABS | DT_WORDBREAK, color); + ok(height == 36, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"\taaa\taaa\taaa", -1, &rect, DT_WORDBREAK, color); + ok(height == 24, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"\taaa\taaa\taaa", -1, &rect, DT_EXPANDTABS | DT_WORDBREAK, color); + ok(height == 48, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"\t\t\t\t\t\t\t\t\t\t", -1, &rect, DT_EXPANDTABS | DT_WORDBREAK, color); + ok(height == 60, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"a\ta", -1, &rect, DT_EXPANDTABS | DT_WORDBREAK, color); + ok(height == 12, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"a\ta\ta", -1, &rect, DT_EXPANDTABS | DT_WORDBREAK, color); + ok(height == 24, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaaaaaaaaaaaaaaaaaa", -1, &rect, DT_WORDBREAK, color); + ok(height == 36, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"a a", -1, &rect, DT_WORDBREAK, color); + ok(height == 36, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK, color); + ok(height == 36, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK | DT_RIGHT, color); + ok(height == 36, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK | DT_CENTER, color); + ok(height == 36, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_BOTTOM, color); + ok(height == 40, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_VCENTER, color); + ok(height == 32, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_RIGHT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CENTER, color); + ok(height == 24, "Got unexpected height %d.\n", height); + + SetRect(&rect, 10, 10, 50, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, 10, 30, 34); + + SetRect(&rect, -10, 10, 30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, -10, 10, 10, 34); + + SetRect(&rect, 10, -10, 50, 30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, -10, 30, 14); + + SetRect(&rect, 10, 10, -30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, 10, 30, 34); + + SetRect(&rect, 10, 10, 50, -30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, 10, 30, 34); + + SetRect(&rect, 10, 10, 50, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, 10, 30, 34); + + SetRect(&rect, -10, 10, 30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, -10, 10, 10, 34); + + SetRect(&rect, 10, -10, 50, 30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, -10, 30, 14); + + SetRect(&rect, 10, 10, -30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 12, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, 10, 53, 22); + + SetRect(&rect, 10, 10, 50, -30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, 10, 30, 34); + + SetRect(&rect, 10, 10, 50, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_BOTTOM | DT_CALCRECT, color); + ok(height == 40, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, 26, 30, 50); + + SetRect(&rect, -10, 10, 30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_BOTTOM | DT_CALCRECT, color); + ok(height == 40, "Got unexpected height %d.\n", height); + check_rect(&rect, -10, 26, 10, 50); + + SetRect(&rect, 10, -10, 50, 30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_BOTTOM | DT_CALCRECT, color); + ok(height == 40, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, 6, 30, 30); + + SetRect(&rect, 10, 10, -30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_BOTTOM | DT_CALCRECT, color); + ok(height == 40, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, 26, 30, 50); + + SetRect(&rect, 10, 10, 50, -30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_BOTTOM | DT_CALCRECT, color); + ok(height == -40, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, -54, 30, -30); + + SetRect(&rect, 10, 10, 50, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_BOTTOM | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 40, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, 26, 30, 50); + + SetRect(&rect, -10, 10, 30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_BOTTOM | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 40, "Got unexpected height %d.\n", height); + check_rect(&rect, -10, 26, 10, 50); + + SetRect(&rect, 10, -10, 50, 30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_BOTTOM | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 40, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, 6, 30, 30); + + SetRect(&rect, 10, 10, -30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_BOTTOM | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 40, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, 38, 53, 50); + + SetRect(&rect, 10, 10, 50, -30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_BOTTOM | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == -40, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, -54, 30, -30); + + SetRect(&rect, 10, 10, 50, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_VCENTER | DT_CALCRECT, color); + ok(height == 32, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, 18, 30, 42); + + SetRect(&rect, -10, 10, 30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_VCENTER | DT_CALCRECT, color); + ok(height == 32, "Got unexpected height %d.\n", height); + check_rect(&rect, -10, 18, 10, 42); + + SetRect(&rect, 10, -10, 50, 30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_VCENTER | DT_CALCRECT, color); + ok(height == 32, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, -2, 30, 22); + + SetRect(&rect, 10, 10, -30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_VCENTER | DT_CALCRECT, color); + ok(height == 32, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, 18, 30, 42); + + SetRect(&rect, 10, 10, 50, -30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_VCENTER | DT_CALCRECT, color); + ok(height == -8, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, -22, 30, 2); + + SetRect(&rect, 10, 10, 50, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_VCENTER | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 32, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, 18, 30, 42); + + SetRect(&rect, -10, 10, 30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_VCENTER | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 32, "Got unexpected height %d.\n", height); + check_rect(&rect, -10, 18, 10, 42); + + SetRect(&rect, 10, -10, 50, 30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_VCENTER | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 32, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, -2, 30, 22); + + SetRect(&rect, 10, 10, -30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_VCENTER | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 26, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, 24, 53, 36); + + SetRect(&rect, 10, 10, 50, -30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_VCENTER | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == -8, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, -22, 30, 2); + + SetRect(&rect, 10, 10, 50, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_RIGHT | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 30, 10, 50, 34); + + SetRect(&rect, -10, 10, 30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_RIGHT | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, 10, 30, 34); + + SetRect(&rect, 10, -10, 50, 30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_RIGHT | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 30, -10, 50, 14); + + SetRect(&rect, 10, 10, -30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_RIGHT | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, -50, 10, -30, 34); + + SetRect(&rect, 10, 10, 50, -30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_RIGHT | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 30, 10, 50, 34); + + SetRect(&rect, 10, 10, 50, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_RIGHT | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 30, 10, 50, 34); + + SetRect(&rect, -10, 10, 30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_RIGHT | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 10, 10, 30, 34); + + SetRect(&rect, 10, -10, 50, 30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_RIGHT | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 30, -10, 50, 14); + + SetRect(&rect, 10, 10, -30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_RIGHT | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 12, "Got unexpected height %d.\n", height); + check_rect(&rect, -73, 10, -30, 22); + + SetRect(&rect, 10, 10, 50, -30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_RIGHT | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 30, 10, 50, 34); + + SetRect(&rect, 10, 10, 50, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CENTER | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 20, 10, 40, 34); + + SetRect(&rect, -10, 10, 30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CENTER | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 0, 10, 20, 34); + + SetRect(&rect, 10, -10, 50, 30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CENTER | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 20, -10, 40, 14); + + SetRect(&rect, 10, 10, -30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CENTER | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, -20, 10, 0, 34); + + SetRect(&rect, 10, 10, 50, -30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CENTER | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 20, 10, 40, 34); + + SetRect(&rect, 10, 10, 50, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_CENTER | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 20, 10, 40, 34); + + SetRect(&rect, -10, 10, 30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_CENTER | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 0, 10, 20, 34); + + SetRect(&rect, 10, -10, 50, 30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_CENTER | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 20, -10, 40, 14); + + SetRect(&rect, 10, 10, -30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_CENTER | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 12, "Got unexpected height %d.\n", height); + check_rect(&rect, -31, 10, 12, 22); + + SetRect(&rect, 10, 10, 50, -30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_CENTER | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 20, 10, 40, 34); + + SetRect(&rect, 10, 10, 50, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CENTER | DT_VCENTER | DT_CALCRECT, color); + ok(height == 32, "Got unexpected height %d.\n", height); + check_rect(&rect, 20, 18, 40, 42); + + SetRect(&rect, 10, 10, 50, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CENTER | DT_VCENTER | DT_CALCRECT, color); + ok(height == 32, "Got unexpected height %d.\n", height); + check_rect(&rect, 20, 18, 40, 42); + + SetRect(&rect, -10, 10, 30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CENTER | DT_VCENTER | DT_CALCRECT, color); + ok(height == 32, "Got unexpected height %d.\n", height); + check_rect(&rect, 0, 18, 20, 42); + + SetRect(&rect, 10, -10, 50, 30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CENTER | DT_VCENTER | DT_CALCRECT, color); + ok(height == 32, "Got unexpected height %d.\n", height); + check_rect(&rect, 20, -2, 40, 22); + + SetRect(&rect, 10, 10, -30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CENTER | DT_VCENTER | DT_CALCRECT, color); + ok(height == 32, "Got unexpected height %d.\n", height); + check_rect(&rect, -20, 18, 0, 42); + + SetRect(&rect, 10, 10, 50, -30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CENTER | DT_VCENTER | DT_CALCRECT, color); + ok(height == -8, "Got unexpected height %d.\n", height); + check_rect(&rect, 20, -22, 40, 2); + + SetRect(&rect, 10, 10, 50, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_CENTER | DT_VCENTER | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 32, "Got unexpected height %d.\n", height); + check_rect(&rect, 20, 18, 40, 42); + + SetRect(&rect, 10, 10, 50, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_CENTER | DT_VCENTER | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 32, "Got unexpected height %d.\n", height); + check_rect(&rect, 20, 18, 40, 42); + + SetRect(&rect, -10, 10, 30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_CENTER | DT_VCENTER | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 32, "Got unexpected height %d.\n", height); + check_rect(&rect, 0, 18, 20, 42); + + SetRect(&rect, 10, -10, 50, 30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_CENTER | DT_VCENTER | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 32, "Got unexpected height %d.\n", height); + check_rect(&rect, 20, -2, 40, 22); + + SetRect(&rect, 10, 10, -30, 50); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_CENTER | DT_VCENTER | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == 26, "Got unexpected height %d.\n", height); + check_rect(&rect, -31, 24, 12, 36); + + SetRect(&rect, 10, 10, 50, -30); + height = ID3DX10Font_DrawTextW(font, NULL, L"aaaa aaaa", -1, &rect, DT_CENTER | DT_VCENTER | DT_WORDBREAK | DT_CALCRECT, color); + ok(height == -8, "Got unexpected height %d.\n", height); + check_rect(&rect, 20, -22, 40, 2); + + ID3DX10Font_Release(font); +} + START_TEST(d3dx10) { test_D3DX10UnsetAllDeviceObjects(); @@ -2024,4 +2954,5 @@ START_TEST(d3dx10) test_D3DX10CreateAsyncResourceLoader(); test_get_image_info(); test_create_texture(); + test_font(); }
On Wed, Aug 11, 2021 at 11:12 AM Nikolay Sivov nsivov@codeweavers.com wrote:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
dlls/d3dx10_43/Makefile.in | 3 +- dlls/d3dx10_43/d3dx10_43.spec | 2 +- dlls/d3dx10_43/sprite.c | 202 ++++++++++++++++++++++++++++++++++ include/d3dx10core.h | 1 + 4 files changed, 206 insertions(+), 2 deletions(-) create mode 100644 dlls/d3dx10_43/sprite.c
diff --git a/dlls/d3dx10_43/sprite.c b/dlls/d3dx10_43/sprite.c new file mode 100644 index 00000000000..6c1ef732ec0 --- /dev/null +++ b/dlls/d3dx10_43/sprite.c
+static HRESULT WINAPI d3dx10_sprite_Begin(ID3DX10Sprite *iface, UINT flags) +{
- FIXME("%p, %#x.\n", iface, flags);
The canonical version for d3d* stuff would be
FIXME("iface %p, flags %#x stub!\n");