mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[WINESYNC] d3dx9: Implement ID3DXFont_PreloadText.
Based on a patch by Tony Wasserka. Signed-off-by: Sven Baars <sbaars@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org> wine commit id cc03400e322edea97f0e425c04cd9069f77b4c9f by Sven Baars <sbaars@codeweavers.com>
This commit is contained in:
parent
6f6f4d1501
commit
aa86f68321
3 changed files with 53 additions and 7 deletions
|
@ -424,14 +424,62 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first,
|
|||
|
||||
static HRESULT WINAPI ID3DXFontImpl_PreloadTextA(ID3DXFont *iface, const char *string, INT count)
|
||||
{
|
||||
FIXME("iface %p, string %s, count %d stub!\n", iface, debugstr_a(string), count);
|
||||
return E_NOTIMPL;
|
||||
WCHAR *wstr;
|
||||
HRESULT hr;
|
||||
int countW;
|
||||
|
||||
TRACE("iface %p, string %s, count %d.\n", iface, debugstr_an(string, count), count);
|
||||
|
||||
if (!string && !count)
|
||||
return D3D_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 = ID3DXFont_PreloadTextW(iface, wstr, count < 0 ? countW - 1 : countW);
|
||||
|
||||
heap_free(wstr);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ID3DXFontImpl_PreloadTextW(ID3DXFont *iface, const WCHAR *string, INT count)
|
||||
{
|
||||
FIXME("iface %p, string %s, count %d stub!\n", iface, debugstr_w(string), count);
|
||||
return E_NOTIMPL;
|
||||
struct d3dx_font *font = impl_from_ID3DXFont(iface);
|
||||
WORD *indices;
|
||||
int i;
|
||||
|
||||
TRACE("iface %p, string %s, count %d.\n", iface, debugstr_wn(string, count), count);
|
||||
|
||||
if (!string && !count)
|
||||
return D3D_OK;
|
||||
|
||||
if (!string)
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
if (count < 0)
|
||||
count = lstrlenW(string);
|
||||
|
||||
indices = heap_alloc(count * sizeof(*indices));
|
||||
if (!indices)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
GetGlyphIndicesW(font->hdc, string, count, indices, 0);
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
ID3DXFont_PreloadGlyphs(iface, indices[i], indices[i]);
|
||||
|
||||
heap_free(indices);
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite,
|
||||
|
|
|
@ -504,7 +504,6 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
|
|||
DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
todo_wine {
|
||||
hr = ID3DXFont_PreloadTextA(font, NULL, -1);
|
||||
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
|
||||
hr = ID3DXFont_PreloadTextA(font, NULL, 0);
|
||||
|
@ -530,7 +529,6 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
|
|||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = ID3DXFont_PreloadTextW(font, L"", -1);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
}
|
||||
|
||||
check_release((IUnknown*)font, 0);
|
||||
|
||||
|
|
|
@ -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: 21fc1f37e76eaced9228eaf62a45489a2bf8ac11}
|
||||
tags: {wine: cc03400e322edea97f0e425c04cd9069f77b4c9f}
|
||||
|
|
Loading…
Reference in a new issue