Commit e9ea8a05 authored by Sven Baars's avatar Sven Baars Committed by Alexandre Julliard

d3dx9: Implement ID3DXFont_GetGlyphData.

Based on a patch by Tony Wasserka. Signed-off-by: 's avatarSven Baars <sbaars@codeweavers.com> Signed-off-by: 's avatarMatteo Bruni <mbruni@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent ac568746
...@@ -184,11 +184,38 @@ static HDC WINAPI ID3DXFontImpl_GetDC(ID3DXFont *iface) ...@@ -184,11 +184,38 @@ static HDC WINAPI ID3DXFontImpl_GetDC(ID3DXFont *iface)
} }
static HRESULT WINAPI ID3DXFontImpl_GetGlyphData(ID3DXFont *iface, UINT glyph, static HRESULT WINAPI ID3DXFontImpl_GetGlyphData(ID3DXFont *iface, UINT glyph,
IDirect3DTexture9 **texture, RECT *blackbox, POINT *cellinc) IDirect3DTexture9 **texture, RECT *black_box, POINT *cell_inc)
{ {
FIXME("iface %p, glyph %#x, texture %p, blackbox %p, cellinc %p stub!\n", struct d3dx_font *font = impl_from_ID3DXFont(iface);
iface, glyph, texture, blackbox, cellinc); struct wine_rb_entry *entry;
return E_NOTIMPL; HRESULT hr;
TRACE("iface %p, glyph %#x, texture %p, black_box %p, cell_inc %p.\n",
iface, glyph, texture, black_box, cell_inc);
hr = ID3DXFont_PreloadGlyphs(iface, glyph, glyph);
if (FAILED(hr))
return hr;
entry = wine_rb_get(&font->glyph_tree, ULongToPtr(glyph));
if (entry)
{
struct d3dx_glyph *current_glyph = WINE_RB_ENTRY_VALUE(entry, struct d3dx_glyph, entry);
if (cell_inc)
*cell_inc = current_glyph->cell_inc;
if (black_box)
*black_box = current_glyph->black_box;
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) static HRESULT WINAPI ID3DXFontImpl_PreloadCharacters(ID3DXFont *iface, UINT first, UINT last)
......
...@@ -543,16 +543,15 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ...@@ -543,16 +543,15 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
hdc = ID3DXFont_GetDC(font); hdc = ID3DXFont_GetDC(font);
ok(!!hdc, "Got unexpected hdc %p.\n", hdc); ok(!!hdc, "Got unexpected hdc %p.\n", hdc);
todo_wine {
hr = ID3DXFont_GetGlyphData(font, 0, NULL, &blackbox, &cellinc); hr = ID3DXFont_GetGlyphData(font, 0, NULL, &blackbox, &cellinc);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = ID3DXFont_GetGlyphData(font, 0, &texture, NULL, &cellinc); 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); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = ID3DXFont_GetGlyphData(font, 0, &texture, &blackbox, NULL); 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); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
}
hr = ID3DXFont_PreloadCharacters(font, 'b', 'a'); hr = ID3DXFont_PreloadCharacters(font, 'b', 'a');
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = ID3DXFont_PreloadGlyphs(font, 1, 0); hr = ID3DXFont_PreloadGlyphs(font, 1, 0);
...@@ -567,12 +566,10 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ...@@ -567,12 +566,10 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
ok(count != GDI_ERROR, "Got unexpected count %u.\n", count); ok(count != GDI_ERROR, "Got unexpected count %u.\n", count);
hr = ID3DXFont_GetGlyphData(font, glyph, &texture, &blackbox, &cellinc); hr = ID3DXFont_GetGlyphData(font, glyph, &texture, &blackbox, &cellinc);
todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
if (FAILED(hr))
continue;
levels = IDirect3DTexture9_GetLevelCount(texture); 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); hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &surf_desc);
ok(hr == D3D_OK, "Character %c: got unexpected hr %#x.\n", c, hr); 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); 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) ...@@ -587,9 +584,9 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
ret = ID3DXFont_GetTextMetricsW(font, &tm); ret = ID3DXFont_GetTextMetricsW(font, &tm);
ok(ret, "Got unexpected ret %#x.\n", ret); 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); 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); c, blackbox.bottom - blackbox.top, glyph_metrics.gmBlackBoxY + 2);
ok(cellinc.x == glyph_metrics.gmptGlyphOrigin.x - 1, "Character %c: got %d, expected %d.\n", ok(cellinc.x == glyph_metrics.gmptGlyphOrigin.x - 1, "Character %c: got %d, expected %d.\n",
c, cellinc.x, glyph_metrics.gmptGlyphOrigin.x - 1); c, cellinc.x, glyph_metrics.gmptGlyphOrigin.x - 1);
...@@ -611,8 +608,8 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ...@@ -611,8 +608,8 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
{ {
texture = (IDirect3DTexture9 *)0xdeadbeef; texture = (IDirect3DTexture9 *)0xdeadbeef;
hr = ID3DXFont_GetGlyphData(font, glyph, &texture, &blackbox, &cellinc); hr = ID3DXFont_GetGlyphData(font, glyph, &texture, &blackbox, &cellinc);
todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
todo_wine ok(!texture, "Got unexpected texture %p.\n", texture); ok(!texture, "Got unexpected texture %p.\n", texture);
} }
check_release((IUnknown *)font, 0); check_release((IUnknown *)font, 0);
...@@ -631,23 +628,21 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ...@@ -631,23 +628,21 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
ok(count != GDI_ERROR, "Test %u: got unexpected count %u.\n", i, count); ok(count != GDI_ERROR, "Test %u: got unexpected count %u.\n", i, count);
hr = ID3DXFont_GetGlyphData(font, glyph, &texture, NULL, NULL); hr = ID3DXFont_GetGlyphData(font, glyph, &texture, NULL, NULL);
todo_wine ok(hr == D3D_OK, "Test %u: got unexpected hr %#x.\n", i, hr); 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); 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); ok(levels == tests[i].expected_levels, "Test %u: got unexpected levels %u.\n", i, levels);
hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc);
hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &surf_desc);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); 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(surf_desc.Format == D3DFMT_A8R8G8B8, "Test %u: got unexpected format %#x.\n", i, surf_desc.Format);
ok(desc.Usage == 0, "Test %u: got unexpected usage %#x.\n", i, desc.Usage); ok(surf_desc.Usage == 0, "Test %u: got unexpected usage %#x.\n", i, surf_desc.Usage);
ok(desc.Width == tests[i].expected_size, "Test %u: got unexpected width %u.\n", i, desc.Width); ok(surf_desc.Width == tests[i].expected_size, "Test %u: got unexpected width %u.\n", i, surf_desc.Width);
ok(desc.Height == tests[i].expected_size, "Test %u: got unexpected height %u.\n", i, desc.Height); ok(surf_desc.Height == tests[i].expected_size, "Test %u: got unexpected height %u.\n", i, surf_desc.Height);
ok(desc.Pool == D3DPOOL_MANAGED, "Test %u: got unexpected pool %u.\n", i, desc.Pool); ok(surf_desc.Pool == D3DPOOL_MANAGED, "Test %u: got unexpected pool %u.\n", i, surf_desc.Pool);
IDirect3DTexture9_Release(texture); IDirect3DTexture9_Release(texture);
}
/* ID3DXFontImpl_DrawText */ /* ID3DXFontImpl_DrawText */
D3DXCreateSprite(device, &sprite); D3DXCreateSprite(device, &sprite);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment