Module: wine Branch: master Commit: 4121b223c85a5d0d491a3d9b5674ea854ba84716 URL: http://source.winehq.org/git/wine.git/?a=commit;h=4121b223c85a5d0d491a3d9b56...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Tue Oct 11 23:40:52 2016 +0300
d2d1: Implement GetDesktopDpi().
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/d2d1/factory.c | 36 +++++++++++++++++++++++++++++++----- dlls/d2d1/tests/d2d1.c | 17 +++++++++++++++++ 2 files changed, 48 insertions(+), 5 deletions(-)
diff --git a/dlls/d2d1/factory.c b/dlls/d2d1/factory.c index 86c1690..b83d221 100644 --- a/dlls/d2d1/factory.c +++ b/dlls/d2d1/factory.c @@ -30,6 +30,9 @@ struct d2d_factory LONG refcount;
ID3D10Device1 *device; + + float dpi_x; + float dpi_y; };
static inline struct d2d_factory *impl_from_ID2D1Factory(ID2D1Factory *iface) @@ -37,6 +40,24 @@ static inline struct d2d_factory *impl_from_ID2D1Factory(ID2D1Factory *iface) return CONTAINING_RECORD(iface, struct d2d_factory, ID2D1Factory_iface); }
+static HRESULT d2d_factory_reload_sysmetrics(struct d2d_factory *factory) +{ + HDC hdc; + + if (!(hdc = GetDC(NULL))) + { + factory->dpi_x = factory->dpi_y = 96.0f; + return E_FAIL; + } + + factory->dpi_x = GetDeviceCaps(hdc, LOGPIXELSX); + factory->dpi_y = GetDeviceCaps(hdc, LOGPIXELSY); + + ReleaseDC(NULL, hdc); + + return S_OK; +} + static HRESULT STDMETHODCALLTYPE d2d_factory_QueryInterface(ID2D1Factory *iface, REFIID iid, void **out) { TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); @@ -84,17 +105,21 @@ static ULONG STDMETHODCALLTYPE d2d_factory_Release(ID2D1Factory *iface)
static HRESULT STDMETHODCALLTYPE d2d_factory_ReloadSystemMetrics(ID2D1Factory *iface) { - FIXME("iface %p stub!\n", iface); + struct d2d_factory *factory = impl_from_ID2D1Factory(iface);
- return E_NOTIMPL; + TRACE("iface %p.\n", iface); + + return d2d_factory_reload_sysmetrics(factory); }
static void STDMETHODCALLTYPE d2d_factory_GetDesktopDpi(ID2D1Factory *iface, float *dpi_x, float *dpi_y) { - FIXME("iface %p, dpi_x %p, dpi_y %p stub!\n", iface, dpi_x, dpi_y); + struct d2d_factory *factory = impl_from_ID2D1Factory(iface); + + TRACE("iface %p, dpi_x %p, dpi_y %p.\n", iface, dpi_x, dpi_y);
- *dpi_x = 96.0f; - *dpi_y = 96.0f; + *dpi_x = factory->dpi_x; + *dpi_y = factory->dpi_y; }
static HRESULT STDMETHODCALLTYPE d2d_factory_CreateRectangleGeometry(ID2D1Factory *iface, @@ -381,6 +406,7 @@ static void d2d_factory_init(struct d2d_factory *factory, D2D1_FACTORY_TYPE fact
factory->ID2D1Factory_iface.lpVtbl = &d2d_factory_vtbl; factory->refcount = 1; + d2d_factory_reload_sysmetrics(factory); }
HRESULT WINAPI D2D1CreateFactory(D2D1_FACTORY_TYPE factory_type, REFIID iid, diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 38012ca..433b1a5 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -3099,6 +3099,22 @@ todo_wine ID2D1Factory_Release(factory); }
+static void test_desktop_dpi(void) +{ + ID2D1Factory *factory; + float dpi_x, dpi_y; + HRESULT hr; + + hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory, NULL, (void **)&factory); + ok(SUCCEEDED(hr), "Failed to create factory, hr %#x.\n", hr); + + dpi_x = dpi_y = 0.0f; + ID2D1Factory_GetDesktopDpi(factory, &dpi_x, &dpi_y); + ok(dpi_x > 0.0f && dpi_y > 0.0f, "Got wrong dpi %f x %f.\n", dpi_x, dpi_y); + + ID2D1Factory_Release(factory); +} + START_TEST(d2d1) { test_clip(); @@ -3116,4 +3132,5 @@ START_TEST(d2d1) test_dc_target(); test_hwnd_target(); test_bitmap_target(); + test_desktop_dpi(); }