d3d9: Windows 7 rejects invalid rectangles.

oldstable
Stefan Dösinger 2010-03-15 14:08:23 +01:00 committed by Alexandre Julliard
parent 25c6dbfc2a
commit f5b5f7176a
1 changed files with 32 additions and 22 deletions

View File

@ -255,6 +255,12 @@ static void test_lockrect_offset(IDirect3DDevice9 *device)
IDirect3D9_Release(d3d);
}
struct rect_test
{
RECT rect;
HRESULT win7_result;
};
static void test_lockrect_invalid(IDirect3DDevice9 *device)
{
IDirect3DSurface9 *surface = 0;
@ -264,20 +270,20 @@ static void test_lockrect_invalid(IDirect3DDevice9 *device)
HRESULT hr;
const RECT test_rect_2 = { 0, 0, 8, 8 };
const RECT test_data[] = {
{60, 60, 68, 68}, /* Valid */
{60, 60, 60, 68}, /* 0 height */
{60, 60, 68, 60}, /* 0 width */
{68, 60, 60, 68}, /* left > right */
{60, 68, 68, 60}, /* top > bottom */
{-8, 60, 0, 68}, /* left < surface */
{60, -8, 68, 0}, /* top < surface */
{-16, 60, -8, 68}, /* right < surface */
{60, -16, 68, -8}, /* bottom < surface */
{60, 60, 136, 68}, /* right > surface */
{60, 60, 68, 136}, /* bottom > surface */
{136, 60, 144, 68}, /* left > surface */
{60, 136, 68, 144}, /* top > surface */
const struct rect_test test_data[] = {
{{60, 60, 68, 68}, D3D_OK}, /* Valid */
{{60, 60, 60, 68}, D3DERR_INVALIDCALL}, /* 0 height */
{{60, 60, 68, 60}, D3DERR_INVALIDCALL}, /* 0 width */
{{68, 60, 60, 68}, D3DERR_INVALIDCALL}, /* left > right */
{{60, 68, 68, 60}, D3DERR_INVALIDCALL}, /* top > bottom */
{{-8, 60, 0, 68}, D3DERR_INVALIDCALL}, /* left < surface */
{{60, -8, 68, 0}, D3DERR_INVALIDCALL}, /* top < surface */
{{-16, 60, -8, 68}, D3DERR_INVALIDCALL}, /* right < surface */
{{60, -16, 68, -8}, D3DERR_INVALIDCALL}, /* bottom < surface */
{{60, 60, 136, 68}, D3DERR_INVALIDCALL}, /* right > surface */
{{60, 60, 68, 136}, D3DERR_INVALIDCALL}, /* bottom > surface */
{{136, 60, 144, 68}, D3DERR_INVALIDCALL}, /* left > surface */
{{60, 136, 68, 144}, D3DERR_INVALIDCALL}, /* top > surface */
};
hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 128, 128, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &surface, 0);
@ -294,14 +300,18 @@ static void test_lockrect_invalid(IDirect3DDevice9 *device)
for (i = 0; i < (sizeof(test_data) / sizeof(*test_data)); ++i)
{
unsigned int offset, expected_offset;
const RECT *rect = &test_data[i];
const RECT *rect = &test_data[i].rect;
locked_rect.pBits = (BYTE *)0xdeadbeef;
locked_rect.Pitch = 0xdeadbeef;
hr = IDirect3DSurface9_LockRect(surface, &locked_rect, rect, 0);
ok(SUCCEEDED(hr), "LockRect failed (0x%08x) for rect [%d, %d]->[%d, %d]\n",
/* Windows XP accepts invalid locking rectangles, windows 7 rejects them.
* Some games(C&C3) depend on the XP behavior, mark the Win7 one broken */
ok(SUCCEEDED(hr) || broken(hr == test_data[i].win7_result),
"LockRect failed (0x%08x) for rect [%d, %d]->[%d, %d]\n",
hr, rect->left, rect->top, rect->right, rect->bottom);
if(FAILED(hr)) continue;
offset = (BYTE *)locked_rect.pBits - base;
expected_offset = rect->top * locked_rect.Pitch + rect->left * 4;
@ -319,14 +329,14 @@ static void test_lockrect_invalid(IDirect3DDevice9 *device)
hr = IDirect3DSurface9_UnlockRect(surface);
ok(SUCCEEDED(hr), "UnlockRect failed (0x%08x)\n", hr);
hr = IDirect3DSurface9_LockRect(surface, &locked_rect, &test_data[0], 0);
hr = IDirect3DSurface9_LockRect(surface, &locked_rect, &test_data[0].rect, 0);
ok(hr == D3D_OK, "LockRect failed (0x%08x) for rect [%d, %d]->[%d, %d]"
", expected D3D_OK (0x%08x)\n", hr, test_data[0].left, test_data[0].top,
test_data[0].right, test_data[0].bottom, D3D_OK);
hr = IDirect3DSurface9_LockRect(surface, &locked_rect, &test_data[0], 0);
", expected D3D_OK (0x%08x)\n", hr, test_data[0].rect.left, test_data[0].rect.top,
test_data[0].rect.right, test_data[0].rect.bottom, D3D_OK);
hr = IDirect3DSurface9_LockRect(surface, &locked_rect, &test_data[0].rect, 0);
ok(hr == D3DERR_INVALIDCALL, "Double LockRect failed (0x%08x) for rect [%d, %d]->[%d, %d]"
", expected D3DERR_INVALIDCALL (0x%08x)\n", hr, test_data[0].left, test_data[0].top,
test_data[0].right, test_data[0].bottom, D3DERR_INVALIDCALL);
", expected D3DERR_INVALIDCALL (0x%08x)\n", hr, test_data[0].rect.left, test_data[0].rect.top,
test_data[0].rect.right, test_data[0].rect.bottom, D3DERR_INVALIDCALL);
hr = IDirect3DSurface9_LockRect(surface, &locked_rect, &test_rect_2, 0);
ok(hr == D3DERR_INVALIDCALL, "Double LockRect failed (0x%08x) for rect [%d, %d]->[%d, %d]"
", expected D3DERR_INVALIDCALL (0x%08x)\n", hr, test_rect_2.left, test_rect_2.top,