Based on a patch by Tony Wasserka.
Signed-off-by: Sven Baars sbaars@codeweavers.com --- dlls/d3dx9_36/font.c | 33 +++++++++++++++++++++--- dlls/d3dx9_36/tests/core.c | 53 +++++++++++++++++--------------------- 2 files changed, 54 insertions(+), 32 deletions(-)
diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c index 2c910b8b14..ae72f049bd 100644 --- a/dlls/d3dx9_36/font.c +++ b/dlls/d3dx9_36/font.c @@ -186,9 +186,36 @@ static HDC WINAPI ID3DXFontImpl_GetDC(ID3DXFont *iface) static HRESULT WINAPI ID3DXFontImpl_GetGlyphData(ID3DXFont *iface, UINT glyph, IDirect3DTexture9 **texture, RECT *blackbox, POINT *cellinc) { - FIXME("iface %p, glyph %#x, texture %p, blackbox %p, cellinc %p stub!\n", - iface, glyph, texture, blackbox, cellinc); - return E_NOTIMPL; + struct d3dx_font *font = impl_from_ID3DXFont(iface); + struct wine_rb_entry *entry; + HRESULT hr; + + TRACE("iface %p, glyph %#x, texture %p, blackbox %p, cellinc %p\n", + iface, glyph, texture, blackbox, cellinc); + + hr = ID3DXFont_PreloadGlyphs(iface, glyph, glyph); + if (FAILED(hr)) + return hr; + + entry = wine_rb_get(&font->glyph_tree, &glyph); + if (entry) + { + struct d3dx_glyph *current_glyph = WINE_RB_ENTRY_VALUE(entry, struct d3dx_glyph, entry); + + if (cellinc) + *cellinc = current_glyph->cellinc; + if (blackbox) + *blackbox = current_glyph->blackbox; + if (texture) + { + *texture = current_glyph->texture; + if (*texture) + IDirect3DTexture9_AddRef(current_glyph->texture); + } + return D3D_OK; + } + + return D3DXERR_INVALIDDATA; }
static HRESULT WINAPI ID3DXFontImpl_PreloadCharacters(ID3DXFont *iface, UINT first, UINT last) diff --git a/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c index 22d265b9fc..b8e680d1c5 100644 --- a/dlls/d3dx9_36/tests/core.c +++ b/dlls/d3dx9_36/tests/core.c @@ -543,16 +543,15 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) hdc = ID3DXFont_GetDC(font); ok(!!hdc, "Got unexpected hdc %p.\n", hdc);
- todo_wine { hr = ID3DXFont_GetGlyphData(font, 0, NULL, &blackbox, &cellinc); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = ID3DXFont_GetGlyphData(font, 0, &texture, NULL, &cellinc); - if(SUCCEEDED(hr)) check_release((IUnknown *)texture, 1); + check_release((IUnknown *)texture, 1); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = ID3DXFont_GetGlyphData(font, 0, &texture, &blackbox, NULL); - if(SUCCEEDED(hr)) check_release((IUnknown *)texture, 1); + check_release((IUnknown *)texture, 1); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - } + hr = ID3DXFont_PreloadCharacters(font, 'b', 'a'); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = ID3DXFont_PreloadGlyphs(font, 1, 0); @@ -567,12 +566,10 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(count != GDI_ERROR, "Got unexpected count %u.\n", count);
hr = ID3DXFont_GetGlyphData(font, glyph, &texture, &blackbox, &cellinc); - todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - if (FAILED(hr)) - continue; + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
levels = IDirect3DTexture9_GetLevelCount(texture); - ok(levels == 5, "Character %c: got unexpected levels %u.\n", c, levels); + todo_wine ok(levels == 5, "Character %c: got unexpected levels %u.\n", c, levels); hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &surf_desc); ok(hr == D3D_OK, "Character %c: got unexpected hr %#x.\n", c, hr); ok(surf_desc.Format == D3DFMT_A8R8G8B8, "Character %c: got unexpected format %#x.\n", c, surf_desc.Format); @@ -587,9 +584,9 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ret = ID3DXFont_GetTextMetricsW(font, &tm); ok(ret, "Got unexpected ret %#x.\n", ret);
- ok(blackbox.right - blackbox.left == glyph_metrics.gmBlackBoxX + 2, "Character %c: got %d, expected %d.\n", + 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); - ok(blackbox.bottom - blackbox.top == glyph_metrics.gmBlackBoxY + 2, "Character %c: got %d, expected %d.\n", + 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); @@ -611,8 +608,8 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) { texture = (IDirect3DTexture9 *)0xdeadbeef; hr = ID3DXFont_GetGlyphData(font, glyph, &texture, &blackbox, &cellinc); - todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - todo_wine ok(!texture, "Got unexpected texture %p.\n", texture); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(!texture, "Got unexpected texture %p.\n", texture); }
check_release((IUnknown *)font, 0); @@ -631,23 +628,21 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(count != GDI_ERROR, "Test %u: got unexpected count %u.\n", i, count);
hr = ID3DXFont_GetGlyphData(font, glyph, &texture, NULL, NULL); - todo_wine ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", i, hr); - if(SUCCEEDED(hr)) { - DWORD levels; - D3DSURFACE_DESC desc; - - levels = IDirect3DTexture9_GetLevelCount(texture); - ok(levels == tests[i].expected_levels, "Test %u: got unexpected levels %u.\n", i, levels); - hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - ok(desc.Format == D3DFMT_A8R8G8B8, "Test %u: got unexpected format %#x.\n", i, desc.Format); - ok(desc.Usage == 0, "Test %u: got unexpected usage %#x.\n", i, desc.Usage); - ok(desc.Width == tests[i].expected_size, "Test %u: got unexpected width %u.\n", i, desc.Width); - ok(desc.Height == tests[i].expected_size, "Test %u: got unexpected height %u.\n", i, desc.Height); - ok(desc.Pool == D3DPOOL_MANAGED, "Test %u: got unexpected pool %u.\n", i, desc.Pool); - - IDirect3DTexture9_Release(texture); - } + ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", i, hr); + + levels = IDirect3DTexture9_GetLevelCount(texture); + todo_wine_if(tests[i].expected_levels < 9) + ok(levels == tests[i].expected_levels, "Test %u: got unexpected levels %u.\n", i, levels); + + hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &surf_desc); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(surf_desc.Format == D3DFMT_A8R8G8B8, "Test %u: got unexpected format %#x.\n", i, surf_desc.Format); + ok(surf_desc.Usage == 0, "Test %u: got unexpected usage %#x.\n", i, surf_desc.Usage); + ok(surf_desc.Width == tests[i].expected_size, "Test %u: got unexpected width %u.\n", i, surf_desc.Width); + ok(surf_desc.Height == tests[i].expected_size, "Test %u: got unexpected height %u.\n", i, surf_desc.Height); + ok(surf_desc.Pool == D3DPOOL_MANAGED, "Test %u: got unexpected pool %u.\n", i, surf_desc.Pool); + + IDirect3DTexture9_Release(texture);
/* ID3DXFontImpl_DrawText */ D3DXCreateSprite(device, &sprite);