[PATCH v2 2/5] d3dx9: Implement ID3DXFont_GetGlyphData.

Sven Baars sbaars at codeweavers.com
Wed Feb 26 05:08:58 CST 2020


Based on a patch by Tony Wasserka.

Signed-off-by: Sven Baars <sbaars at codeweavers.com>
---
v2: rename blackbox to black_box, cellinc to cell_inc, use the new rb_tree index

 dlls/d3dx9_36/font.c       | 35 ++++++++++++++++++++++---
 dlls/d3dx9_36/tests/core.c | 53 +++++++++++++++++---------------------
 2 files changed, 55 insertions(+), 33 deletions(-)

diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c
index b5481785a0..03dc7544b3 100644
--- a/dlls/d3dx9_36/font.c
+++ b/dlls/d3dx9_36/font.c
@@ -184,11 +184,38 @@ static HDC WINAPI ID3DXFontImpl_GetDC(ID3DXFont *iface)
 }
 
 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",
-            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, 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)
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);
-- 
2.24.0




More information about the wine-devel mailing list