Ziqing Hui : windowscodecs/tests: Introduce is_compressed().
Alexandre Julliard
julliard at winehq.org
Tue Aug 25 16:16:58 CDT 2020
Module: wine
Branch: master
Commit: adef0fc9718bfae0d0b0a1574d20ba4aae4c0648
URL: https://source.winehq.org/git/wine.git/?a=commit;h=adef0fc9718bfae0d0b0a1574d20ba4aae4c0648
Author: Ziqing Hui <zhui at codeweavers.com>
Date: Tue Aug 25 22:01:08 2020 +0800
windowscodecs/tests: Introduce is_compressed().
Signed-off-by: Ziqing Hui <zhui at codeweavers.com>
Signed-off-by: Esme Povirk <esme at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/windowscodecs/tests/ddsformat.c | 38 ++++++++++++++++++++++++------------
1 file changed, 25 insertions(+), 13 deletions(-)
diff --git a/dlls/windowscodecs/tests/ddsformat.c b/dlls/windowscodecs/tests/ddsformat.c
index 2d78319375..9e8c015a58 100644
--- a/dlls/windowscodecs/tests/ddsformat.c
+++ b/dlls/windowscodecs/tests/ddsformat.c
@@ -445,6 +445,16 @@ static struct test_data {
{ test_qword_b, sizeof(test_qword_b), WINCODEC_ERR_STREAMREAD },
};
+static DXGI_FORMAT compressed_formats[] = {
+ DXGI_FORMAT_BC1_TYPELESS, DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM_SRGB,
+ DXGI_FORMAT_BC2_TYPELESS, DXGI_FORMAT_BC2_UNORM, DXGI_FORMAT_BC2_UNORM_SRGB,
+ DXGI_FORMAT_BC3_TYPELESS, DXGI_FORMAT_BC3_UNORM, DXGI_FORMAT_BC3_UNORM_SRGB,
+ DXGI_FORMAT_BC4_TYPELESS, DXGI_FORMAT_BC4_UNORM, DXGI_FORMAT_BC4_SNORM,
+ DXGI_FORMAT_BC5_TYPELESS, DXGI_FORMAT_BC5_UNORM, DXGI_FORMAT_BC5_SNORM,
+ DXGI_FORMAT_BC6H_TYPELESS, DXGI_FORMAT_BC6H_UF16, DXGI_FORMAT_BC6H_SF16,
+ DXGI_FORMAT_BC7_TYPELESS, DXGI_FORMAT_BC7_UNORM, DXGI_FORMAT_BC7_UNORM_SRGB
+};
+
static IWICImagingFactory *factory = NULL;
static IWICStream *create_stream(const void *image_data, UINT image_size)
@@ -510,6 +520,16 @@ static HRESULT init_decoder(IWICBitmapDecoder *decoder, IWICStream *stream, HRES
return hr;
}
+static BOOL is_compressed(DXGI_FORMAT format)
+{
+ UINT i;
+ for (i = 0; i < ARRAY_SIZE(compressed_formats); i++)
+ {
+ if (format == compressed_formats[i]) return TRUE;
+ }
+ return FALSE;
+}
+
static BOOL has_extended_header(const BYTE *data)
{
return data[84] == 'D' && data[85] == 'X' && data[86] == '1' && data[87] == '0';
@@ -876,18 +896,12 @@ static void test_dds_decoder_frame_properties(IWICBitmapFrameDecode *frame_decod
/* frame format information tests */
- if (test_data[i].expected_parameters.DxgiFormat != DXGI_FORMAT_BC1_UNORM &&
- test_data[i].expected_parameters.DxgiFormat != DXGI_FORMAT_BC2_UNORM &&
- test_data[i].expected_parameters.DxgiFormat != DXGI_FORMAT_BC3_UNORM &&
- test_data[i].expected_parameters.DxgiFormat != DXGI_FORMAT_BC4_UNORM &&
- test_data[i].expected_parameters.DxgiFormat != DXGI_FORMAT_BC4_SNORM &&
- test_data[i].expected_parameters.DxgiFormat != DXGI_FORMAT_BC5_UNORM &&
- test_data[i].expected_parameters.DxgiFormat != DXGI_FORMAT_BC5_SNORM) {
- expected_block_width = 1;
- expected_block_height = 1;
- } else {
+ if (is_compressed(test_data[i].expected_parameters.DxgiFormat)) {
expected_block_width = BLOCK_WIDTH;
expected_block_height = BLOCK_HEIGHT;
+ } else {
+ expected_block_width = 1;
+ expected_block_height = 1;
}
hr = IWICDdsFrameDecode_GetFormatInfo(dds_frame, NULL);
@@ -1108,9 +1122,7 @@ static void test_dds_decoder_frame_data(IWICBitmapFrameDecode* frame, IWICDdsFra
hr = IWICBitmapFrameDecode_CopyPixels(frame, &rect, stride, sizeof(buffer), NULL);
ok(hr == E_INVALIDARG, "Test %u, frame %u: CopyBlocks got unexpected hr %#x\n", i, frame_index, hr);
- if (format_info.DxgiFormat == DXGI_FORMAT_BC1_UNORM ||
- format_info.DxgiFormat == DXGI_FORMAT_BC2_UNORM ||
- format_info.DxgiFormat == DXGI_FORMAT_BC3_UNORM ) {
+ if (is_compressed(format_info.DxgiFormat)) {
decode_block(test_data[i].data + block_offset, width_in_blocks * height_in_blocks,
format_info.DxgiFormat, frame_width, frame_height, pixels);
More information about the wine-cvs
mailing list