[PATCH v2 6/8] d3dx9: Implement ID3DXFont_PreloadCharacters.
Sven Baars
sbaars at codeweavers.com
Mon Jan 6 08:34:06 CST 2020
Based on a patch by Tony Wasserka.
Signed-off-by: Sven Baars <sbaars at codeweavers.com>
---
dlls/d3dx9_36/font.c | 52 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 50 insertions(+), 2 deletions(-)
diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c
index e204ca3012..e7e4f33d2c 100644
--- a/dlls/d3dx9_36/font.c
+++ b/dlls/d3dx9_36/font.c
@@ -232,10 +232,58 @@ static HRESULT WINAPI ID3DXFontImpl_GetGlyphData(ID3DXFont *iface, UINT glyph,
return D3DXERR_INVALIDDATA;
}
+/************************************************************
+ * ID3DXFont_PreloadCharacters
+ *
+ * Preloads the specified character series into the internal texture
+ *
+ * PARAMS
+ * first [I] first character to be preloaded
+ * last [I] last character to be preloaded
+ *
+ * RETURNS
+ * Success: D3D_OK
+ * Failure: D3DERR_INVALIDCALL
+ *
+ * NOTES
+ * We just split each character into its glyphs and call PreloadGlyphs here.
+ *
+ */
static HRESULT WINAPI ID3DXFontImpl_PreloadCharacters(ID3DXFont *iface, UINT first, UINT last)
{
- FIXME("iface %p, first %u, last %u stub!\n", iface, first, last);
- return S_OK;
+ struct d3dx_font *This = impl_from_ID3DXFont(iface);
+ UINT i, count;
+ WCHAR *chars;
+ WORD *indices;
+
+ TRACE("iface %p, first %u, last %u\n", iface, first, last);
+
+ if (last < first) return D3D_OK;
+
+ count = last - first + 1;
+ indices = heap_alloc(count * sizeof(WORD));
+ if (!indices)
+ return E_OUTOFMEMORY;
+
+ chars = heap_alloc(count * sizeof(WCHAR));
+ if (!chars)
+ {
+ heap_free(indices);
+ return E_OUTOFMEMORY;
+ }
+
+ for (i = 0; i < count; i++)
+ chars[i] = (WCHAR)(first + i);
+
+ GetGlyphIndicesW(This->hdc, chars, count, indices, 0);
+
+ for (i = 0; i < count; i++)
+ ID3DXFont_PreloadGlyphs(iface, indices[i], indices[i]);
+
+ heap_free(chars);
+ heap_free(indices);
+
+ return D3D_OK;
}
/************************************************************
--
2.24.0
More information about the wine-devel
mailing list