Nikolay Sivov : d3dx10/font: Add PreloadCharacters().
Alexandre Julliard
julliard at winehq.org
Thu Sep 2 15:45:31 CDT 2021
Module: wine
Branch: master
Commit: c09f114319d6ed7bb260b8677156cfaad0884146
URL: https://source.winehq.org/git/wine.git/?a=commit;h=c09f114319d6ed7bb260b8677156cfaad0884146
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Wed Sep 1 16:09:35 2021 +0300
d3dx10/font: Add PreloadCharacters().
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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 */
More information about the wine-cvs
mailing list