Module: wine Branch: master Commit: e7abfd6f3001b30dd846448c3d36f9a27853540a URL: https://source.winehq.org/git/wine.git/?a=commit;h=e7abfd6f3001b30dd846448c3...
Author: Ziqing Hui zhui@codeweavers.com Date: Thu Aug 27 13:37:06 2020 +0800
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
---
dlls/windowscodecs/ddsformat.c | 20 ++++++++++++-------- dlls/windowscodecs/tests/ddsformat.c | 11 ++++++----- 2 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/dlls/windowscodecs/ddsformat.c b/dlls/windowscodecs/ddsformat.c index 7e3bd44bd8..46e1074f25 100644 --- a/dlls/windowscodecs/ddsformat.c +++ b/dlls/windowscodecs/ddsformat.c @@ -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, diff --git a/dlls/windowscodecs/tests/ddsformat.c b/dlls/windowscodecs/tests/ddsformat.c index 37ed17bd79..139aaee7ed 100644 --- a/dlls/windowscodecs/tests/ddsformat.c +++ b/dlls/windowscodecs/tests/ddsformat.c @@ -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)