Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3dx10_43/font.c | 28 ++++++++++++++++++++++++++-- dlls/d3dx10_43/tests/d3dx10.c | 9 --------- 2 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/dlls/d3dx10_43/font.c b/dlls/d3dx10_43/font.c index 2145b1c6f1e..51704e2bbbe 100644 --- a/dlls/d3dx10_43/font.c +++ b/dlls/d3dx10_43/font.c @@ -210,9 +210,33 @@ static HRESULT WINAPI d3dx_font_PreloadTextA(ID3DX10Font *iface, const char *str
static HRESULT WINAPI d3dx_font_PreloadTextW(ID3DX10Font *iface, const WCHAR *string, INT count) { - FIXME("iface %p, string %s, count %d stub!\n", iface, debugstr_wn(string, count), count); + struct d3dx_font *font = impl_from_ID3DX10Font(iface); + WORD *indices; + int i;
- return E_NOTIMPL; + TRACE("iface %p, string %s, count %d.\n", iface, debugstr_wn(string, count), count); + + if (!string && !count) + return S_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) + ID3DX10Font_PreloadGlyphs(iface, indices[i], indices[i]); + + heap_free(indices); + + return S_OK; }
static INT WINAPI d3dx_font_DrawTextA(ID3DX10Font *iface, ID3DX10Sprite *sprite, diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 8c55dd5810b..65bccb71521 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -2263,32 +2263,23 @@ static void test_font(void) hr = ID3DX10Font_PreloadTextA(font, NULL, 1); ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); hr = ID3DX10Font_PreloadTextA(font, "test", -1); -todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); hr = ID3DX10Font_PreloadTextA(font, "", 0); -todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); hr = ID3DX10Font_PreloadTextA(font, "", -1); -todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = ID3DX10Font_PreloadTextW(font, NULL, -1); -todo_wine ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); hr = ID3DX10Font_PreloadTextW(font, NULL, 0); -todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); hr = ID3DX10Font_PreloadTextW(font, NULL, 1); -todo_wine ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); hr = ID3DX10Font_PreloadTextW(font, testW, -1); -todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); hr = ID3DX10Font_PreloadTextW(font, L"", 0); -todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); hr = ID3DX10Font_PreloadTextW(font, L"", -1); -todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ID3DX10Font_Release(font);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3dx10_43/font.c | 45 +++++++++++++++++++++++++++++++++-- dlls/d3dx10_43/tests/d3dx10.c | 3 --- 2 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/dlls/d3dx10_43/font.c b/dlls/d3dx10_43/font.c index 51704e2bbbe..1a95dbeca02 100644 --- a/dlls/d3dx10_43/font.c +++ b/dlls/d3dx10_43/font.c @@ -168,9 +168,50 @@ static HRESULT WINAPI d3dx_font_GetGlyphData(ID3DX10Font *iface, UINT glyph,
static HRESULT WINAPI d3dx_font_PreloadCharacters(ID3DX10Font *iface, UINT first, UINT last) { - FIXME("iface %p, first %u, last %u stub!\n", iface, first, last); + struct d3dx_font *font = impl_from_ID3DX10Font(iface); + unsigned int i, count, start, end; + WORD *indices; + WCHAR *chars;
- return E_NOTIMPL; + TRACE("iface %p, first %u, last %u.\n", iface, first, last); + + if (last < first) + return S_OK; + + count = last - first + 1; + indices = heap_alloc(count * sizeof(*indices)); + if (!indices) + return E_OUTOFMEMORY; + + chars = heap_alloc(count * sizeof(*chars)); + if (!chars) + { + heap_free(indices); + return E_OUTOFMEMORY; + } + + for (i = 0; i < count; ++i) + chars[i] = first + i; + + GetGlyphIndicesW(font->hdc, chars, count, indices, 0); + + start = end = indices[0]; + for (i = 1; i < count; ++i) + { + if (indices[i] == end + 1) + { + end = indices[i]; + continue; + } + ID3DX10Font_PreloadGlyphs(iface, start, end); + start = end = indices[i]; + } + ID3DX10Font_PreloadGlyphs(iface, start, end); + + heap_free(chars); + heap_free(indices); + + return S_OK; }
static HRESULT WINAPI d3dx_font_PreloadGlyphs(ID3DX10Font *iface, UINT first, UINT last) diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 65bccb71521..c7aa3eccd24 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -2307,14 +2307,12 @@ todo_wine ID3D10ShaderResourceView_Release(srv);
hr = ID3DX10Font_PreloadCharacters(font, 'b', 'a'); -todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); hr = ID3DX10Font_PreloadGlyphs(font, 1, 0); todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = ID3DX10Font_PreloadCharacters(font, 'a', 'a'); -todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
for (c = 'b'; c <= 'z'; ++c) @@ -2376,7 +2374,6 @@ todo_wine }
hr = ID3DX10Font_PreloadCharacters(font, 'a', 'z'); -todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
/* Test multiple textures */
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- Grumble grumble... duplication... grumble grumble...
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3dx10_43/sprite.c | 27 +++++++++++++++++++++++---- dlls/d3dx10_43/tests/d3dx10.c | 14 ++++++++------ 2 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/dlls/d3dx10_43/sprite.c b/dlls/d3dx10_43/sprite.c index 5fc9b9edaa2..b2045e72a27 100644 --- a/dlls/d3dx10_43/sprite.c +++ b/dlls/d3dx10_43/sprite.c @@ -32,6 +32,7 @@ struct d3dx10_sprite ID3DX10Sprite ID3DX10Sprite_iface; LONG refcount;
+ D3DXMATRIX projection; ID3D10Device *device; };
@@ -139,16 +140,30 @@ static HRESULT WINAPI d3dx10_sprite_SetViewTransform(ID3DX10Sprite *iface, D3DXM static HRESULT WINAPI d3dx10_sprite_GetProjectionTransform(ID3DX10Sprite *iface, D3DXMATRIX *transform) { - FIXME("iface %p, transform %p stub!\n", iface, transform); + struct d3dx10_sprite *sprite = impl_from_ID3DX10Sprite(iface);
- return E_NOTIMPL; + TRACE("iface %p, transform %p.\n", iface, transform); + + if (!transform) + return E_FAIL; + + *transform = sprite->projection; + + return S_OK; }
static HRESULT WINAPI d3dx10_sprite_SetProjectionTransform(ID3DX10Sprite *iface, D3DXMATRIX *transform) { - FIXME("iface %p, transform %p stub!\n", iface, transform); + struct d3dx10_sprite *sprite = impl_from_ID3DX10Sprite(iface);
- return E_NOTIMPL; + TRACE("iface %p, transform %p.\n", iface, transform); + + if (!transform) + return E_FAIL; + + sprite->projection = *transform; + + return S_OK; }
static HRESULT WINAPI d3dx10_sprite_GetDevice(ID3DX10Sprite *iface, ID3D10Device **device) @@ -201,6 +216,10 @@ HRESULT WINAPI D3DX10CreateSprite(ID3D10Device *device, UINT size, ID3DX10Sprite object->refcount = 1; object->device = device; ID3D10Device_AddRef(device); + object->projection._11 = 1.0f; + object->projection._22 = 1.0f; + object->projection._33 = 1.0f; + object->projection._44 = 1.0f;
*sprite = &object->ID3DX10Sprite_iface;
diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index c7aa3eccd24..bc5ca6747f5 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -2968,6 +2968,13 @@ static void test_sprite(void) D3DXMATRIX mat, mat2; ULONG refcount; HRESULT hr; + static const D3DXMATRIX identity = + { + ._11 = 1.0f, + ._22 = 1.0f, + ._33 = 1.0f, + ._44 = 1.0f, + };
if (!(device = create_device())) { @@ -3020,11 +3027,10 @@ static void test_sprite(void)
/* Projection transform */ hr = ID3DX10Sprite_GetProjectionTransform(sprite, NULL); -todo_wine ok(hr == E_FAIL, "Unexpected hr %#x.\n", hr); hr = ID3DX10Sprite_GetProjectionTransform(sprite, &mat); -todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(!memcmp(&mat, &identity, sizeof(mat)), "Unexpected projection transform.\n");
/* Set a transform and test if it gets returned correctly */ mat.m[0][0] = 2.1f; mat.m[0][1] = 6.5f; mat.m[0][2] =-9.6f; mat.m[0][3] = 1.7f; @@ -3033,18 +3039,14 @@ todo_wine mat.m[3][0] = 6.7f; mat.m[3][1] =-5.1f; mat.m[3][2] = 6.1f; mat.m[3][3] = 2.2f;
hr = ID3DX10Sprite_SetProjectionTransform(sprite, NULL); -todo_wine ok(hr == E_FAIL, "Unexpected hr %#x.\n", hr);
hr = ID3DX10Sprite_SetProjectionTransform(sprite, &mat); -todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = ID3DX10Sprite_GetProjectionTransform(sprite, &mat2); -todo_wine { ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!memcmp(&mat, &mat2, sizeof(mat)), "Unexpected matrix.\n"); -}
/* View transform */ hr = ID3DX10Sprite_SetViewTransform(sprite, NULL);
Signed-off-by: Matteo Bruni mbruni@codeweavers.com