Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3dx10_43/font.c | 26 ++++++++++++++++++++++---- dlls/d3dx10_43/tests/d3dx10.c | 6 +----- 2 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/dlls/d3dx10_43/font.c b/dlls/d3dx10_43/font.c index 7b2295cc414..77604895903 100644 --- a/dlls/d3dx10_43/font.c +++ b/dlls/d3dx10_43/font.c @@ -32,6 +32,7 @@ struct d3dx_font ID3DX10Font ID3DX10Font_iface; LONG refcount;
+ D3DX10_FONT_DESCW desc; ID3D10Device *device; };
@@ -97,16 +98,32 @@ static HRESULT WINAPI d3dx_font_GetDevice(ID3DX10Font *iface, ID3D10Device **dev
static HRESULT WINAPI d3dx_font_GetDescA(ID3DX10Font *iface, D3DX10_FONT_DESCA *desc) { - FIXME("iface %p, desc %p stub!\n", iface, desc); + struct d3dx_font *font = impl_from_ID3DX10Font(iface);
- return E_NOTIMPL; + TRACE("iface %p, desc %p.\n", iface, desc); + + if (!desc) + return D3DERR_INVALIDCALL; + + memcpy(desc, &font->desc, FIELD_OFFSET(D3DX10_FONT_DESCA, FaceName)); + WideCharToMultiByte(CP_ACP, 0, font->desc.FaceName, -1, desc->FaceName, + ARRAY_SIZE(desc->FaceName), NULL, NULL); + + return S_OK; }
static HRESULT WINAPI d3dx_font_GetDescW(ID3DX10Font *iface, D3DX10_FONT_DESCW *desc) { - FIXME("iface %p, desc %p stub!\n", iface, desc); + struct d3dx_font *font = impl_from_ID3DX10Font(iface);
- return E_NOTIMPL; + TRACE("iface %p, desc %p.\n", iface, desc); + + if (!desc) + return D3DERR_INVALIDCALL; + + *desc = font->desc; + + return S_OK; }
static BOOL WINAPI d3dx_font_GetTextMetricsA(ID3DX10Font *iface, TEXTMETRICA *metrics) @@ -345,6 +362,7 @@ HRESULT WINAPI D3DX10CreateFontIndirectW(ID3D10Device *device, const D3DX10_FONT object->ID3DX10Font_iface.lpVtbl = &d3dx_font_vtbl; object->refcount = 1; object->device = device; + object->desc = *desc; ID3D10Device_AddRef(device);
*font = &object->ID3DX10Font_iface; diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 1b875e4fc09..eec2bfd3206 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -2176,15 +2176,11 @@ static void test_font(void) ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = ID3DX10Font_GetDescA(font, NULL); -todo_wine ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr);
hr = ID3DX10Font_GetDescA(font, &desc); -todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
-if (SUCCEEDED(hr)) -{ ok(desc.Height == 12, "Unexpected height %d.\n", desc.Height); ok(desc.Width == 8, "Unexpected width %u.\n", desc.Width); ok(desc.Weight == FW_BOLD, "Unexpected weight %u.\n", desc.Weight); @@ -2195,7 +2191,7 @@ if (SUCCEEDED(hr)) ok(desc.Quality == ANTIALIASED_QUALITY, "Unexpected quality %u.\n", desc.Quality); ok(desc.PitchAndFamily == VARIABLE_PITCH, "Unexpected pitch and family %#x.\n", desc.PitchAndFamily); ok(!strcmp(desc.FaceName, "Tahoma"), "Unexpected facename %s.\n", debugstr_a(desc.FaceName)); -} + ID3DX10Font_Release(font);
/* GetDC + GetTextMetrics */
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3dx10_43/Makefile.in | 2 +- dlls/d3dx10_43/font.c | 30 ++++++++++++++++++++++++++---- dlls/d3dx10_43/tests/d3dx10.c | 33 ++++++++++++++++++--------------- 3 files changed, 45 insertions(+), 20 deletions(-)
diff --git a/dlls/d3dx10_43/Makefile.in b/dlls/d3dx10_43/Makefile.in index b6baed2b619..5509bca7e08 100644 --- a/dlls/d3dx10_43/Makefile.in +++ b/dlls/d3dx10_43/Makefile.in @@ -1,6 +1,6 @@ MODULE = d3dx10_43.dll IMPORTLIB = d3dx10 -IMPORTS = d3d10_1 d3dcompiler dxguid uuid +IMPORTS = d3d10_1 d3dcompiler dxguid uuid gdi32 DELAYIMPORTS = windowscodecs
EXTRADLLFLAGS = -mno-cygwin -Wb,--prefer-native diff --git a/dlls/d3dx10_43/font.c b/dlls/d3dx10_43/font.c index 77604895903..d1590c8cc99 100644 --- a/dlls/d3dx10_43/font.c +++ b/dlls/d3dx10_43/font.c @@ -32,6 +32,8 @@ struct d3dx_font ID3DX10Font ID3DX10Font_iface; LONG refcount;
+ HDC hdc; + HFONT hfont; D3DX10_FONT_DESCW desc; ID3D10Device *device; }; @@ -77,6 +79,8 @@ static ULONG WINAPI d3dx_font_Release(ID3DX10Font *iface)
if (!refcount) { + DeleteObject(font->hfont); + DeleteDC(font->hdc); ID3D10Device_Release(font->device); heap_free(font); } @@ -142,9 +146,11 @@ static BOOL WINAPI d3dx_font_GetTextMetricsW(ID3DX10Font *iface, TEXTMETRICW *me
static HDC WINAPI d3dx_font_GetDC(ID3DX10Font *iface) { - FIXME("iface %p stub!\n", iface); + struct d3dx_font *font = impl_from_ID3DX10Font(iface); + + TRACE("iface %p.\n", iface);
- return NULL; + return font->hdc; }
static HRESULT WINAPI d3dx_font_GetGlyphData(ID3DX10Font *iface, UINT glyph, @@ -353,11 +359,27 @@ HRESULT WINAPI D3DX10CreateFontIndirectW(ID3D10Device *device, const D3DX10_FONT if (!device || !desc || !font) return D3DERR_INVALIDCALL;
+ *font = NULL; + if (!(object = heap_alloc_zero(sizeof(*object)))) - { - *font = NULL; return E_OUTOFMEMORY; + + object->hdc = CreateCompatibleDC(NULL); + if (!object->hdc) + { + heap_free(object); + return E_FAIL; + } + + object->hfont = CreateFontW(desc->Height, desc->Width, 0, 0, desc->Weight, desc->Italic, FALSE, FALSE, desc->CharSet, + desc->OutputPrecision, CLIP_DEFAULT_PRECIS, desc->Quality, desc->PitchAndFamily, desc->FaceName); + if (!object->hfont) + { + DeleteDC(object->hdc); + heap_free(object); + return E_FAIL; } + SelectObject(object->hdc, object->hfont);
object->ID3DX10Font_iface.lpVtbl = &d3dx_font_vtbl; object->refcount = 1; diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index eec2bfd3206..499d219924d 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -2200,13 +2200,12 @@ static void test_font(void) ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hdc = ID3DX10Font_GetDC(font); -todo_wine ok(!!hdc, "Unexpected hdc %p.\n", hdc);
- ret = ID3DX10Font_GetTextMetricsA(font, &metrics); -todo_wine - ok(ret, "Unexpected ret %#x.\n", ret); ret = GetTextMetricsA(hdc, &expmetrics); + ok(ret, "Unexpected ret %#x.\n", ret); + + ret = ID3DX10Font_GetTextMetricsA(font, &metrics); todo_wine ok(ret, "Unexpected ret %#x.\n", ret);
@@ -2303,7 +2302,6 @@ todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hdc = ID3DX10Font_GetDC(font); -todo_wine ok(!!hdc, "Unexpected hdc %p.\n", hdc);
hr = ID3DX10Font_GetGlyphData(font, 0, NULL, &blackbox, &cellinc); @@ -2333,15 +2331,20 @@ todo_wine
for (c = 'b'; c <= 'z'; ++c) { - if (!hdc) break; - winetest_push_context("Character %c", c); count = GetGlyphIndicesA(hdc, &c, 1, &glyph, 0); ok(count != GDI_ERROR, "Unexpected count %u.\n", count);
hr = ID3DX10Font_GetGlyphData(font, glyph, &srv, &blackbox, &cellinc); + todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ if (FAILED(hr)) + { + winetest_pop_context(); + break; + } + ID3D10ShaderResourceView_GetResource(srv, &resource); hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture2D, (void **)&texture); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); @@ -2415,22 +2418,22 @@ todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hdc = ID3DX10Font_GetDC(font); - todo_wine ok(!!hdc, "Unexpected hdc %p.\n", hdc);
- if (!hdc) - { - ID3DX10Font_Release(font); - winetest_pop_context(); - break; - } - count = GetGlyphIndicesA(hdc, &c, 1, &glyph, 0); ok(count != GDI_ERROR, "Unexpected count %u.\n", count);
hr = ID3DX10Font_GetGlyphData(font, glyph, &srv, NULL, NULL); + todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ if (FAILED(hr)) + { + ID3DX10Font_Release(font); + winetest_pop_context(); + break; + } + ID3D10ShaderResourceView_GetResource(srv, &resource); hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture2D, (void **)&texture); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3dx10_43/font.c | 12 ++++++++---- dlls/d3dx10_43/tests/d3dx10.c | 5 +---- 2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/dlls/d3dx10_43/font.c b/dlls/d3dx10_43/font.c index d1590c8cc99..2145b1c6f1e 100644 --- a/dlls/d3dx10_43/font.c +++ b/dlls/d3dx10_43/font.c @@ -132,16 +132,20 @@ static HRESULT WINAPI d3dx_font_GetDescW(ID3DX10Font *iface, D3DX10_FONT_DESCW *
static BOOL WINAPI d3dx_font_GetTextMetricsA(ID3DX10Font *iface, TEXTMETRICA *metrics) { - FIXME("iface %p, metrics %p stub!\n", iface, metrics); + struct d3dx_font *font = impl_from_ID3DX10Font(iface); + + TRACE("iface %p, metrics %p.\n", iface, metrics);
- return FALSE; + return GetTextMetricsA(font->hdc, metrics); }
static BOOL WINAPI d3dx_font_GetTextMetricsW(ID3DX10Font *iface, TEXTMETRICW *metrics) { - FIXME("iface %p, metrics %p stub!\n", iface, metrics); + struct d3dx_font *font = impl_from_ID3DX10Font(iface); + + TRACE("iface %p, metrics %p.\n", iface, metrics);
- return FALSE; + return GetTextMetricsW(font->hdc, metrics); }
static HDC WINAPI d3dx_font_GetDC(ID3DX10Font *iface) diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 499d219924d..8c55dd5810b 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -2206,11 +2206,8 @@ static void test_font(void) ok(ret, "Unexpected ret %#x.\n", ret);
ret = ID3DX10Font_GetTextMetricsA(font, &metrics); -todo_wine ok(ret, "Unexpected ret %#x.\n", ret);
-if (ret) -{ ok(metrics.tmHeight == expmetrics.tmHeight, "Unexpected height %d, expected %d.\n", metrics.tmHeight, expmetrics.tmHeight); ok(metrics.tmAscent == expmetrics.tmAscent, "Unexpected ascent %d, expected %d.\n", @@ -2251,7 +2248,7 @@ if (ret) metrics.tmPitchAndFamily, expmetrics.tmPitchAndFamily); ok(metrics.tmCharSet == expmetrics.tmCharSet, "Unexpected charset %u, expected %u.\n", metrics.tmCharSet, expmetrics.tmCharSet); -} + ID3DX10Font_Release(font);
/* PreloadText */
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- I.e. when it's easier to simply implement the function instead of introducing a stub...
Thanks for the patch.