Commit 47f3afb9 authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

wined3d: Check cursor sizes are powers of two.

parent 73d0f236
...@@ -1027,7 +1027,6 @@ static void test_cursor(void) ...@@ -1027,7 +1027,6 @@ static void test_cursor(void)
expected_hr = D3D_OK; expected_hr = D3D_OK;
else else
expected_hr = D3DERR_INVALIDCALL; expected_hr = D3DERR_INVALIDCALL;
todo_wine_if(expected_hr == D3DERR_INVALIDCALL)
ok(hr == expected_hr, "Test %u: Expect SetCursorProperties return %#x, got %#x.\n", ok(hr == expected_hr, "Test %u: Expect SetCursorProperties return %#x, got %#x.\n",
test_idx, expected_hr, hr); test_idx, expected_hr, hr);
IDirect3DSurface8_Release(cursor); IDirect3DSurface8_Release(cursor);
......
...@@ -1839,7 +1839,6 @@ static void test_cursor(void) ...@@ -1839,7 +1839,6 @@ static void test_cursor(void)
expected_hr = D3D_OK; expected_hr = D3D_OK;
else else
expected_hr = D3DERR_INVALIDCALL; expected_hr = D3DERR_INVALIDCALL;
todo_wine_if(expected_hr == D3DERR_INVALIDCALL)
ok(hr == expected_hr, "Test %u: Expect SetCursorProperties return %#x, got %#x.\n", ok(hr == expected_hr, "Test %u: Expect SetCursorProperties return %#x, got %#x.\n",
test_idx, expected_hr, hr); test_idx, expected_hr, hr);
IDirect3DSurface9_Release(cursor); IDirect3DSurface9_Release(cursor);
......
...@@ -4934,14 +4934,21 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device ...@@ -4934,14 +4934,21 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device
return WINED3DERR_INVALIDCALL; 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);
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;
}
if (FAILED(hr = wined3d_output_get_display_mode(&device->adapter->outputs[0], &mode, NULL))) if (FAILED(hr = wined3d_output_get_display_mode(&device->adapter->outputs[0], &mode, NULL)))
{ {
ERR("Failed to get display mode, hr %#x.\n", hr); ERR("Failed to get display mode, hr %#x.\n", hr);
return WINED3DERR_INVALIDCALL; 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) 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", WARN("Texture %p, sub-resource %u dimensions are %ux%u, but screen dimensions are %ux%u.\n",
...@@ -4949,8 +4956,6 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device ...@@ -4949,8 +4956,6 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
/* TODO: MSDN: Cursor sizes must be a power of 2 */
/* Do not store the surface's pointer because the application may /* Do not store the surface's pointer because the application may
* release it after setting the cursor image. Windows doesn't * release it after setting the cursor image. Windows doesn't
* addref the set surface, so we can't do this either without * addref the set surface, so we can't do this either without
......
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