Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/d3d8/tests/device.c | 1 - dlls/d3d9/tests/device.c | 1 - dlls/wined3d/device.c | 15 +++++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index f63004054a..f9e34ad525 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -1028,7 +1028,6 @@ static void test_cursor(void) expected_hr = D3D_OK; else expected_hr = D3DERR_INVALIDCALL; - todo_wine_if(expected_hr == D3DERR_INVALIDCALL) ok(hr == expected_hr, "Test %u: Expect SetCursorProperties return %#x, got %#x.\n", test_idx, expected_hr, hr); IDirect3DSurface8_Release(cursor); diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index 5a5183c12f..5f4e7dc7df 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -1840,7 +1840,6 @@ static void test_cursor(void) expected_hr = D3D_OK; else expected_hr = D3DERR_INVALIDCALL; - todo_wine_if(expected_hr == D3DERR_INVALIDCALL) ok(hr == expected_hr, "Test %u: Expect SetCursorProperties return %#x, got %#x.\n", test_idx, expected_hr, hr); IDirect3DSurface9_Release(cursor); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index f8caa0c23c..9d5025518d 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -4934,14 +4934,23 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device return WINED3DERR_INVALIDCALL; }
+ /* Cursor width and height must all be powers of two */ + cursor_width = wined3d_texture_get_level_width(texture, texture_level); + cursor_height = wined3d_texture_get_level_height(texture, texture_level); + /* http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2 */ + if ((cursor_width & (cursor_width - 1)) || (cursor_height & (cursor_height - 1))) + { + WARN("Cursor size %ux%u are not all powers of two.\n", cursor_width, cursor_height); + return WINED3DERR_INVALIDCALL; + } + + /* Cursor size must not exceed display mode */ if (FAILED(hr = wined3d_output_get_display_mode(&device->adapter->outputs[0], &mode, NULL))) { ERR("Failed to get display mode, hr %#x.\n", hr); return WINED3DERR_INVALIDCALL; }
- cursor_width = wined3d_texture_get_level_width(texture, texture_level); - cursor_height = wined3d_texture_get_level_height(texture, texture_level); if (cursor_width > mode.width || cursor_height > mode.height) { WARN("Texture %p, sub-resource %u dimensions are %ux%u, but screen dimensions are %ux%u.\n", @@ -4949,8 +4958,6 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device return WINED3DERR_INVALIDCALL; }
- /* TODO: MSDN: Cursor sizes must be a power of 2 */ - /* Do not store the surface's pointer because the application may * release it after setting the cursor image. Windows doesn't * addref the set surface, so we can't do this either without