Commit bc805bbc authored by Ziqing Hui's avatar Ziqing Hui Committed by Alexandre Julliard

windowscodecs/tests: Add tests for cube maps.

parent 6b4566df
...@@ -130,7 +130,7 @@ static BYTE test_dds_dxt1[] = { ...@@ -130,7 +130,7 @@ static BYTE test_dds_dxt1[] = {
0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7 0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7
}; };
/* 4x4 compressed(DXT1) cube map */ /* 4x4 compressed(DXT1) cube map, mipMapCount = 3 */
static BYTE test_dds_cube[] = { static BYTE test_dds_cube[] = {
'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x0A, 0x00, 0x04, 0x00, 0x00, 0x00, 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x0A, 0x00, 0x04, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
...@@ -151,6 +151,29 @@ static BYTE test_dds_cube[] = { ...@@ -151,6 +151,29 @@ static BYTE test_dds_cube[] = {
0x32, 0x96, 0x0B, 0x7B, 0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84, 0x00, 0x00, 0x00, 0x00 0x32, 0x96, 0x0B, 0x7B, 0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84, 0x00, 0x00, 0x00, 0x00
}; };
/* 4x4 compressed(DXT1) cube map with extended header, mipMapCount=3 */
static BYTE test_dds_cube_dx10[] = {
'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x0A, 0x00, 0x04, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 'D', 'X', '1', '0', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x40, 0x00,
0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x47, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7, 0x32, 0x96, 0x0B, 0x7B,
0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84, 0x00, 0x00, 0x00, 0x00, 0xF5, 0xA7, 0x08, 0x69,
0x74, 0xC0, 0xBF, 0xD7, 0x32, 0x96, 0x0B, 0x7B, 0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84,
0x00, 0x00, 0x00, 0x00, 0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7, 0x32, 0x96, 0x0B, 0x7B,
0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84, 0x00, 0x00, 0x00, 0x00, 0xF5, 0xA7, 0x08, 0x69,
0x74, 0xC0, 0xBF, 0xD7, 0x32, 0x96, 0x0B, 0x7B, 0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84,
0x00, 0x00, 0x00, 0x00, 0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7, 0x32, 0x96, 0x0B, 0x7B,
0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84, 0x00, 0x00, 0x00, 0x00, 0xF5, 0xA7, 0x08, 0x69,
0x74, 0xC0, 0xBF, 0xD7, 0x32, 0x96, 0x0B, 0x7B, 0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84,
0x00, 0x00, 0x00, 0x00
};
/* 4x4 compressed(DXT1) DDS image with mip maps, mipMapCount=3 */ /* 4x4 compressed(DXT1) DDS image with mip maps, mipMapCount=3 */
static BYTE test_dds_mipmaps[] = { static BYTE test_dds_mipmaps[] = {
'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x0A, 0x00, 0x04, 0x00, 0x00, 0x00, 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x0A, 0x00, 0x04, 0x00, 0x00, 0x00,
...@@ -266,6 +289,10 @@ static struct test_data { ...@@ -266,6 +289,10 @@ static struct test_data {
{ 1, 1, 1, 1, 1, DXGI_FORMAT_R32G32B32_FLOAT, WICDdsTexture2D, WICDdsAlphaModeUnknown }, TRUE }, { 1, 1, 1, 1, 1, DXGI_FORMAT_R32G32B32_FLOAT, WICDdsTexture2D, WICDdsAlphaModeUnknown }, TRUE },
{ test_dds_128bpp, sizeof(test_dds_128bpp), 1, 16, &GUID_WICPixelFormat32bppBGRA, { test_dds_128bpp, sizeof(test_dds_128bpp), 1, 16, &GUID_WICPixelFormat32bppBGRA,
{ 1, 1, 1, 1, 1, DXGI_FORMAT_R32G32B32A32_FLOAT, WICDdsTexture2D, WICDdsAlphaModeUnknown }, TRUE }, { 1, 1, 1, 1, 1, DXGI_FORMAT_R32G32B32A32_FLOAT, WICDdsTexture2D, WICDdsAlphaModeUnknown }, TRUE },
{ test_dds_cube, sizeof(test_dds_cube), 18, 8, &GUID_WICPixelFormat32bppPBGRA,
{ 4, 4, 1, 3, 1, DXGI_FORMAT_BC1_UNORM, WICDdsTextureCube, WICDdsAlphaModePremultiplied }, TRUE },
{ test_dds_cube_dx10, sizeof(test_dds_cube_dx10), 18, 8, &GUID_WICPixelFormat32bppBGRA,
{ 4, 4, 1, 3, 1, DXGI_FORMAT_BC1_UNORM, WICDdsTextureCube, WICDdsAlphaModeUnknown }, TRUE },
{ test_dds_dxt1, sizeof(test_dds_dxt1), 1, 8, &GUID_WICPixelFormat32bppPBGRA, { test_dds_dxt1, sizeof(test_dds_dxt1), 1, 8, &GUID_WICPixelFormat32bppPBGRA,
{ 4, 4, 1, 1, 1, DXGI_FORMAT_BC1_UNORM, WICDdsTexture2D, WICDdsAlphaModePremultiplied } }, { 4, 4, 1, 1, 1, DXGI_FORMAT_BC1_UNORM, WICDdsTexture2D, WICDdsAlphaModePremultiplied } },
{ test_dds_mipmaps, sizeof(test_dds_mipmaps), 3, 8, &GUID_WICPixelFormat32bppPBGRA, { test_dds_mipmaps, sizeof(test_dds_mipmaps), 3, 8, &GUID_WICPixelFormat32bppPBGRA,
...@@ -388,6 +415,7 @@ static void test_dds_decoder_initialize(void) ...@@ -388,6 +415,7 @@ static void test_dds_decoder_initialize(void)
{ test_dds_96bpp, sizeof(test_dds_96bpp), WINCODEC_ERR_BADHEADER, TRUE }, { test_dds_96bpp, sizeof(test_dds_96bpp), WINCODEC_ERR_BADHEADER, TRUE },
{ test_dds_128bpp, sizeof(test_dds_128bpp), WINCODEC_ERR_BADHEADER, TRUE }, { test_dds_128bpp, sizeof(test_dds_128bpp), WINCODEC_ERR_BADHEADER, TRUE },
{ test_dds_cube, sizeof(test_dds_cube), WINCODEC_ERR_BADHEADER, TRUE }, { test_dds_cube, sizeof(test_dds_cube), WINCODEC_ERR_BADHEADER, TRUE },
{ test_dds_cube_dx10, sizeof(test_dds_cube_dx10), WINCODEC_ERR_BADHEADER, TRUE },
{ test_dds_bad_magic, sizeof(test_dds_bad_magic), WINCODEC_ERR_UNKNOWNIMAGEFORMAT }, { test_dds_bad_magic, sizeof(test_dds_bad_magic), WINCODEC_ERR_UNKNOWNIMAGEFORMAT },
{ test_dds_bad_header, sizeof(test_dds_bad_header), WINCODEC_ERR_BADHEADER }, { test_dds_bad_header, sizeof(test_dds_bad_header), WINCODEC_ERR_BADHEADER },
{ &byte, sizeof(byte), WINCODEC_ERR_STREAMREAD }, { &byte, sizeof(byte), WINCODEC_ERR_STREAMREAD },
...@@ -502,13 +530,18 @@ static void test_dds_decoder_image_parameters(void) ...@@ -502,13 +530,18 @@ static void test_dds_decoder_image_parameters(void)
hr = init_decoder(decoder, stream, S_OK, -1, test_data[i].wine_init); hr = init_decoder(decoder, stream, S_OK, -1, test_data[i].wine_init);
if (hr != S_OK) { if (hr != S_OK) {
win_skip("uncompressed DDS image is not supported\n"); if (test_data[i].expected_parameters.Dimension == WICDdsTextureCube) {
win_skip("Cube map is not supported\n");
} else {
win_skip("Uncompressed DDS image is not supported\n");
}
goto next; goto next;
} }
hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count); hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count);
ok(hr == S_OK, "Test %u: GetFrameCount failed, hr %#x\n", i, hr); ok(hr == S_OK, "Test %u: GetFrameCount failed, hr %#x\n", i, hr);
if (hr == S_OK) { if (hr == S_OK) {
todo_wine_if(test_data[i].expected_parameters.Dimension == WICDdsTextureCube)
ok(frame_count == test_data[i].expected_frame_count, "Test %u: Expected frame count %u, got %u\n", ok(frame_count == test_data[i].expected_frame_count, "Test %u: Expected frame count %u, got %u\n",
i, test_data[i].expected_frame_count, frame_count); i, test_data[i].expected_frame_count, frame_count);
} }
...@@ -761,6 +794,11 @@ static void test_dds_decoder_frame(IWICBitmapDecoder *decoder, int i) ...@@ -761,6 +794,11 @@ static void test_dds_decoder_frame(IWICBitmapDecoder *decoder, int i)
UINT frame_count, j; UINT frame_count, j;
WICDdsParameters params; WICDdsParameters params;
if (test_data[i].expected_parameters.Dimension == WICDdsTextureCube) {
skip("Frame tests for cube maps will crash\n");
return;
}
hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count); hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count);
ok(hr == S_OK, "Test %u: GetFrameCount failed, hr %#x\n", i, hr); ok(hr == S_OK, "Test %u: GetFrameCount failed, hr %#x\n", i, hr);
if (hr != S_OK) return; if (hr != S_OK) return;
...@@ -771,6 +809,8 @@ static void test_dds_decoder_frame(IWICBitmapDecoder *decoder, int i) ...@@ -771,6 +809,8 @@ static void test_dds_decoder_frame(IWICBitmapDecoder *decoder, int i)
ok(hr == S_OK, "Test %u: GetParameters failed, hr %#x\n", i, hr); ok(hr == S_OK, "Test %u: GetParameters failed, hr %#x\n", i, hr);
if (hr != S_OK) goto end; if (hr != S_OK) goto end;
if (test_data[i].expected_parameters.Dimension == WICDdsTextureCube) params.ArraySize *= 6;
for (j = 0; j < frame_count; j++) for (j = 0; j < frame_count; j++)
{ {
IWICBitmapFrameDecode *frame_decode = NULL; IWICBitmapFrameDecode *frame_decode = NULL;
...@@ -814,7 +854,11 @@ static void test_dds_decoder(void) ...@@ -814,7 +854,11 @@ static void test_dds_decoder(void)
if (!decoder) goto next; if (!decoder) goto next;
hr = init_decoder(decoder, stream, S_OK, -1, test_data[i].wine_init); hr = init_decoder(decoder, stream, S_OK, -1, test_data[i].wine_init);
if (hr != S_OK) { if (hr != S_OK) {
win_skip("uncompressed DDS image is not supported\n"); if (test_data[i].expected_parameters.Dimension == WICDdsTextureCube) {
win_skip("Cube map is not supported\n");
} else {
win_skip("Uncompressed DDS image is not supported\n");
}
goto next; goto next;
} }
......
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