windowscodecs: Support uncompressed format in DdsFrameDecode_CopyPixels().

Signed-off-by: Ziqing Hui <zhui@codeweavers.com>
Signed-off-by: Esme Povirk <esme@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Ziqing Hui 2020-08-27 13:37:06 +08:00 committed by Alexandre Julliard
parent fa398d6ec0
commit e7abfd6f30
2 changed files with 18 additions and 13 deletions

View File

@ -687,7 +687,7 @@ static ULONG WINAPI DdsFrameDecode_Release(IWICBitmapFrameDecode *iface)
TRACE("(%p) refcount=%u\n", iface, ref);
if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This->pixel_data);
if (This->pixel_data != This->block_data) HeapFree(GetProcessHeap(), 0, This->pixel_data);
HeapFree(GetProcessHeap(), 0, This->block_data);
HeapFree(GetProcessHeap(), 0, This);
}
@ -746,7 +746,7 @@ static HRESULT WINAPI DdsFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface,
DdsFrameDecode *This = impl_from_IWICBitmapFrameDecode(iface);
UINT bpp, frame_stride, frame_size;
INT x, y, width, height;
HRESULT hr = S_OK;
HRESULT hr;
TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
@ -777,13 +777,17 @@ static HRESULT WINAPI DdsFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface,
EnterCriticalSection(&This->lock);
if (!This->pixel_data) {
This->pixel_data = HeapAlloc(GetProcessHeap(), 0, frame_size);
if (!This->pixel_data) {
hr = E_OUTOFMEMORY;
goto end;
if (is_compressed(This->info.format)) {
This->pixel_data = HeapAlloc(GetProcessHeap(), 0, frame_size);
if (!This->pixel_data) {
hr = E_OUTOFMEMORY;
goto end;
}
decode_block(This->block_data, This->info.width_in_blocks * This->info.height_in_blocks, This->info.format,
This->info.width, This->info.height, (DWORD *)This->pixel_data);
} else {
This->pixel_data = This->block_data;
}
decode_block(This->block_data, This->info.width_in_blocks * This->info.height_in_blocks, This->info.format,
This->info.width, This->info.height, (DWORD *)This->pixel_data);
}
hr = copy_pixels(bpp, This->pixel_data, This->info.width, This->info.height, frame_stride,

View File

@ -1069,11 +1069,6 @@ static void test_dds_decoder_frame_data(IWICBitmapFrameDecode* frame, IWICDdsFra
/* CopyPixels tests */
if (!is_compressed(format_info.DxgiFormat)) {
skip("Skip CopyPixels tests for uncompressed image\n");
return;
}
bpp = test_data[i].pixel_format_bpp;
stride = rect.Width * bpp / 8;
frame_stride = frame_width * bpp / 8;
@ -1082,6 +1077,8 @@ static void test_dds_decoder_frame_data(IWICBitmapFrameDecode* frame, IWICDdsFra
hr = IWICBitmapFrameDecode_CopyPixels(frame, NULL, 0, 0, NULL);
ok(hr == E_INVALIDARG, "Test %u, frame %u: CopyPixels got unexpected hr %#x\n", i, frame_index, hr);
todo_wine_if(IsEqualGUID(test_data[i].expected_pixel_format, &GUID_WICPixelFormat24bppBGR) ||
IsEqualGUID(test_data[i].expected_pixel_format, &GUID_WICPixelFormat96bppRGBFloat)) {
hr = IWICBitmapFrameDecode_CopyPixels(frame, &rect_test_a, stride, sizeof(buffer), buffer);
ok(hr == E_INVALIDARG, "Test %u, frame %u: CopyPixels got unexpected hr %#x\n", i, frame_index, hr);
hr = IWICBitmapFrameDecode_CopyPixels(frame, &rect_test_b, stride, sizeof(buffer), buffer);
@ -1118,6 +1115,7 @@ static void test_dds_decoder_frame_data(IWICBitmapFrameDecode* frame, IWICDdsFra
ok(hr == WINCODEC_ERR_INSUFFICIENTBUFFER, "Test %u, frame %u: CopyPixels got unexpected hr %#x\n", i, frame_index, hr);
hr = IWICBitmapFrameDecode_CopyPixels(frame, &rect, stride, stride * rect.Height, buffer);
ok(hr == S_OK, "Test %u, frame %u: CopyPixels got unexpected hr %#x\n", i, frame_index, hr);
}
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);
@ -1130,6 +1128,8 @@ static void test_dds_decoder_frame_data(IWICBitmapFrameDecode* frame, IWICDdsFra
memcpy(pixels, test_data[i].data + block_offset, frame_size);
}
todo_wine_if(IsEqualGUID(test_data[i].expected_pixel_format, &GUID_WICPixelFormat24bppBGR) ||
IsEqualGUID(test_data[i].expected_pixel_format, &GUID_WICPixelFormat96bppRGBFloat)) {
memset(buffer, 0, sizeof(buffer));
hr = IWICBitmapFrameDecode_CopyPixels(frame, &rect, stride, sizeof(buffer), buffer);
ok(hr == S_OK, "Test %u, frame %u: CopyPixels failed, hr %#x\n", i, frame_index, hr);
@ -1155,6 +1155,7 @@ static void test_dds_decoder_frame_data(IWICBitmapFrameDecode* frame, IWICDdsFra
"Test %u, frame %u: Pixels mismatch\n", i, frame_index);
};
}
}
}
static void test_dds_decoder_frame(IWICBitmapDecoder *decoder, int i)