From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/tests/d3dx9_test_images.h | 37 +++++++++++++++ dlls/d3dx9_36/tests/surface.c | 62 +++++++++++++++++++++++++ 2 files changed, 99 insertions(+)
diff --git a/dlls/d3dx9_36/tests/d3dx9_test_images.h b/dlls/d3dx9_36/tests/d3dx9_test_images.h index 3ed5373c705..e9ee1623134 100644 --- a/dlls/d3dx9_36/tests/d3dx9_test_images.h +++ b/dlls/d3dx9_36/tests/d3dx9_test_images.h @@ -297,6 +297,43 @@ static const uint8_t png_2_2_64bpp_rgba[] = 0x1c,0xbb,0xb8,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82, };
+static const uint8_t png_2_2_1bpp_indexed[] = +{ + 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52, + 0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x01,0x03,0x00,0x00,0x00,0x48,0x78,0x9f, + 0x67,0x00,0x00,0x00,0x06,0x50,0x4c,0x54,0x45,0x00,0x00,0x00,0xff,0xff,0xff,0xa5, + 0xd9,0x9f,0xdd,0x00,0x00,0x00,0x01,0x74,0x52,0x4e,0x53,0x00,0x40,0xe6,0xd8,0x66, + 0x00,0x00,0x00,0x0c,0x49,0x44,0x41,0x54,0x08,0x99,0x63,0x68,0x60,0x70,0x00,0x00, + 0x01,0xc4,0x00,0xc1,0xcd,0x7b,0x18,0xa0,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44, + 0xae,0x42,0x60,0x82, +}; + +static const uint8_t png_2_2_2bpp_indexed[] = +{ + 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52, + 0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x02,0x03,0x00,0x00,0x00,0x0f,0xd8,0xe5, + 0xb7,0x00,0x00,0x00,0x01,0x73,0x52,0x47,0x42,0x00,0xae,0xce,0x1c,0xe9,0x00,0x00, + 0x00,0x04,0x67,0x41,0x4d,0x41,0x00,0x00,0xb1,0x8f,0x0b,0xfc,0x61,0x05,0x00,0x00, + 0x00,0x0c,0x50,0x4c,0x54,0x45,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0xff, + 0xff,0xff,0xfb,0x00,0x60,0xf6,0x00,0x00,0x00,0x0c,0x49,0x44,0x41,0x54,0x18,0xd3, + 0x63,0x90,0x66,0xd8,0x0d,0x00,0x01,0x10,0x00,0xd7,0xa8,0x4b,0x7a,0x58,0x00,0x00, + 0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82, +}; + +static const uint8_t png_2_2_4bpp_indexed[] = +{ + 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52, + 0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x04,0x03,0x00,0x00,0x00,0x80,0x98,0x10, + 0x17,0x00,0x00,0x00,0x30,0x50,0x4c,0x54,0x45,0x00,0x00,0x00,0x11,0x11,0x11,0x22, + 0x22,0x22,0x33,0x33,0x33,0x44,0x44,0x44,0x55,0x55,0x55,0x66,0x66,0x66,0x77,0x77, + 0x77,0x88,0x88,0x88,0x99,0x99,0x99,0xaa,0xaa,0xaa,0xbb,0xbb,0xbb,0xcc,0xcc,0xcc, + 0xdd,0xdd,0xdd,0xee,0xee,0xee,0xff,0xff,0xff,0x7b,0x10,0x18,0x0a,0x00,0x00,0x00, + 0x10,0x74,0x52,0x4e,0x53,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0, + 0xf0,0xf0,0xf0,0xf0,0xf0,0xb1,0x0f,0x99,0x6f,0x00,0x00,0x00,0x0c,0x49,0x44,0x41, + 0x54,0x08,0x99,0x63,0x60,0x61,0xe8,0x01,0x00,0x00,0x9c,0x00,0x91,0x1c,0x0a,0x18, + 0x41,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82, +}; + static const uint8_t jpg_rgb_2_2[] = { 0xff,0xd8,0xff,0xe0,0x00,0x10,0x4a,0x46,0x49,0x46,0x00,0x01,0x01,0x00,0x00,0x01, diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index 5e72eb7d0a4..22afe167155 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -2519,6 +2519,7 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) -0.1f, -0.2f, -NAN, -INFINITY, -1.0f, -1.1f, -1.2f, -1.3f }; static const uint16_t pixdata_v8u8[] = { 0x3000, 0x7f40, 0x8180, 0xffc0 }; BYTE buffer[4 * 8 * 4]; + D3DXIMAGE_INFO info; uint32_t i;
hr = create_file("testdummy.bmp", noimage, sizeof(noimage)); /* invalid image */ @@ -3757,6 +3758,67 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr); check_release((IUnknown *)surf, 0);
+ hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 2, 2, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &surf, NULL); + ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + + /* Indexed PNG. */ + SetRect(&rect, 0, 0, 2, 2); + hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, png_2_2_1bpp_indexed, sizeof(png_2_2_1bpp_indexed), &rect, + D3DX_FILTER_NONE, 0, &info); + ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + check_image_info(&info, 2, 2, 1, 1, D3DFMT_P8, D3DRTYPE_TEXTURE, D3DXIFF_PNG, FALSE); + + if (!strcmp(winetest_platform, "wine")) + { + skip("Skipping 1bpp indexed PNG readback tests.\n"); + } + else + { + hr = IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY); + ok(hr == D3D_OK, "Failed to lock surface, hr %#lx.\n", hr); + check_pixel_4bpp(&lockrect, 0, 0, 0xffffffff); + check_pixel_4bpp(&lockrect, 1, 0, 0x00000000); + check_pixel_4bpp(&lockrect, 0, 1, 0x00000000); + check_pixel_4bpp(&lockrect, 1, 1, 0xffffffff); + hr = IDirect3DSurface9_UnlockRect(surf); + ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr); + } + + /* 2bpp. */ + hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, png_2_2_2bpp_indexed, sizeof(png_2_2_2bpp_indexed), &rect, + D3DX_FILTER_NONE, 0, &info); + todo_wine ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + check_image_info(&info, 2, 2, 1, 1, D3DFMT_P8, D3DRTYPE_TEXTURE, D3DXIFF_PNG, FALSE); + + hr = IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY); + ok(hr == D3D_OK, "Failed to lock surface, hr %#lx.\n", hr); + check_pixel_4bpp(&lockrect, 0, 0, 0xffff0000); + check_pixel_4bpp(&lockrect, 1, 0, 0xff00ff00); + check_pixel_4bpp(&lockrect, 0, 1, 0xff0000ff); + check_pixel_4bpp(&lockrect, 1, 1, 0xffffffff); + hr = IDirect3DSurface9_UnlockRect(surf); + ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr); + } + + /* 4bpp. */ + hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, png_2_2_4bpp_indexed, sizeof(png_2_2_4bpp_indexed), &rect, + D3DX_FILTER_NONE, 0, &info); + ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + check_image_info(&info, 2, 2, 1, 1, D3DFMT_P8, D3DRTYPE_TEXTURE, D3DXIFF_PNG, FALSE); + + hr = IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY); + ok(hr == D3D_OK, "Failed to lock surface, hr %#lx.\n", hr); + todo_wine check_pixel_4bpp(&lockrect, 0, 0, 0xf0000000); + todo_wine check_pixel_4bpp(&lockrect, 1, 0, 0xf0444444); + todo_wine check_pixel_4bpp(&lockrect, 0, 1, 0xf0888888); + todo_wine check_pixel_4bpp(&lockrect, 1, 1, 0xf0cccccc); + hr = IDirect3DSurface9_UnlockRect(surf); + ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr); + + check_release((IUnknown *)surf, 0); + test_format_conversion(device); test_dxt_premultiplied_alpha(device); test_load_surface_from_tga(device);