Commit 4121b223 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

d2d1: Implement GetDesktopDpi().

parent 459b7cae
...@@ -30,6 +30,9 @@ struct d2d_factory ...@@ -30,6 +30,9 @@ struct d2d_factory
LONG refcount; LONG refcount;
ID3D10Device1 *device; ID3D10Device1 *device;
float dpi_x;
float dpi_y;
}; };
static inline struct d2d_factory *impl_from_ID2D1Factory(ID2D1Factory *iface) static inline struct d2d_factory *impl_from_ID2D1Factory(ID2D1Factory *iface)
...@@ -37,6 +40,24 @@ 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); 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) 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); 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) ...@@ -84,17 +105,21 @@ static ULONG STDMETHODCALLTYPE d2d_factory_Release(ID2D1Factory *iface)
static HRESULT STDMETHODCALLTYPE d2d_factory_ReloadSystemMetrics(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) 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_x = factory->dpi_x;
*dpi_y = 96.0f; *dpi_y = factory->dpi_y;
} }
static HRESULT STDMETHODCALLTYPE d2d_factory_CreateRectangleGeometry(ID2D1Factory *iface, 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 ...@@ -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->ID2D1Factory_iface.lpVtbl = &d2d_factory_vtbl;
factory->refcount = 1; factory->refcount = 1;
d2d_factory_reload_sysmetrics(factory);
} }
HRESULT WINAPI D2D1CreateFactory(D2D1_FACTORY_TYPE factory_type, REFIID iid, HRESULT WINAPI D2D1CreateFactory(D2D1_FACTORY_TYPE factory_type, REFIID iid,
......
...@@ -3099,6 +3099,22 @@ todo_wine ...@@ -3099,6 +3099,22 @@ todo_wine
ID2D1Factory_Release(factory); 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) START_TEST(d2d1)
{ {
test_clip(); test_clip();
...@@ -3116,4 +3132,5 @@ START_TEST(d2d1) ...@@ -3116,4 +3132,5 @@ START_TEST(d2d1)
test_dc_target(); test_dc_target();
test_hwnd_target(); test_hwnd_target();
test_bitmap_target(); test_bitmap_target();
test_desktop_dpi();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment