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

windowscodecs: Support uncompressed format in DdsFrameDecode_CopyPixels().

parent fa398d6e
...@@ -687,7 +687,7 @@ static ULONG WINAPI DdsFrameDecode_Release(IWICBitmapFrameDecode *iface) ...@@ -687,7 +687,7 @@ static ULONG WINAPI DdsFrameDecode_Release(IWICBitmapFrameDecode *iface)
TRACE("(%p) refcount=%u\n", iface, ref); TRACE("(%p) refcount=%u\n", iface, ref);
if (ref == 0) { 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->block_data);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
...@@ -746,7 +746,7 @@ static HRESULT WINAPI DdsFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface, ...@@ -746,7 +746,7 @@ static HRESULT WINAPI DdsFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface,
DdsFrameDecode *This = impl_from_IWICBitmapFrameDecode(iface); DdsFrameDecode *This = impl_from_IWICBitmapFrameDecode(iface);
UINT bpp, frame_stride, frame_size; UINT bpp, frame_stride, frame_size;
INT x, y, width, height; 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); 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, ...@@ -777,13 +777,17 @@ static HRESULT WINAPI DdsFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface,
EnterCriticalSection(&This->lock); EnterCriticalSection(&This->lock);
if (!This->pixel_data) { if (!This->pixel_data) {
This->pixel_data = HeapAlloc(GetProcessHeap(), 0, frame_size); if (is_compressed(This->info.format)) {
if (!This->pixel_data) { This->pixel_data = HeapAlloc(GetProcessHeap(), 0, frame_size);
hr = E_OUTOFMEMORY; if (!This->pixel_data) {
goto end; 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, hr = copy_pixels(bpp, This->pixel_data, This->info.width, This->info.height, frame_stride,
......
...@@ -1069,11 +1069,6 @@ static void test_dds_decoder_frame_data(IWICBitmapFrameDecode* frame, IWICDdsFra ...@@ -1069,11 +1069,6 @@ static void test_dds_decoder_frame_data(IWICBitmapFrameDecode* frame, IWICDdsFra
/* CopyPixels tests */ /* CopyPixels tests */
if (!is_compressed(format_info.DxgiFormat)) {
skip("Skip CopyPixels tests for uncompressed image\n");
return;
}
bpp = test_data[i].pixel_format_bpp; bpp = test_data[i].pixel_format_bpp;
stride = rect.Width * bpp / 8; stride = rect.Width * bpp / 8;
frame_stride = frame_width * bpp / 8; frame_stride = frame_width * bpp / 8;
...@@ -1082,6 +1077,8 @@ static void test_dds_decoder_frame_data(IWICBitmapFrameDecode* frame, IWICDdsFra ...@@ -1082,6 +1077,8 @@ static void test_dds_decoder_frame_data(IWICBitmapFrameDecode* frame, IWICDdsFra
hr = IWICBitmapFrameDecode_CopyPixels(frame, NULL, 0, 0, NULL); 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); 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); 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); 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); 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 ...@@ -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); 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); 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); 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); 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); 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 ...@@ -1130,6 +1128,8 @@ static void test_dds_decoder_frame_data(IWICBitmapFrameDecode* frame, IWICDdsFra
memcpy(pixels, test_data[i].data + block_offset, frame_size); 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)); memset(buffer, 0, sizeof(buffer));
hr = IWICBitmapFrameDecode_CopyPixels(frame, &rect, stride, sizeof(buffer), 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); 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 ...@@ -1155,6 +1155,7 @@ static void test_dds_decoder_frame_data(IWICBitmapFrameDecode* frame, IWICDdsFra
"Test %u, frame %u: Pixels mismatch\n", i, frame_index); "Test %u, frame %u: Pixels mismatch\n", i, frame_index);
}; };
} }
}
} }
static void test_dds_decoder_frame(IWICBitmapDecoder *decoder, int i) static void test_dds_decoder_frame(IWICBitmapDecoder *decoder, int i)
......
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