windowscodecs: Implement DdsFrameDecode_Dds_GetSizeInBlocks().

Signed-off-by: Ziqing Hui <zhui@codeweavers.com>
Signed-off-by: Esme Povirk <vincent@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Ziqing Hui 2020-06-01 12:59:48 +08:00 committed by Alexandre Julliard
parent 81da1f6b5d
commit a31cadae42
2 changed files with 17 additions and 6 deletions

View File

@ -112,6 +112,8 @@ typedef struct dds_frame_info {
UINT bytes_per_block;
UINT block_width;
UINT block_height;
UINT width_in_blocks;
UINT height_in_blocks;
} dds_frame_info;
typedef struct DdsDecoder {
@ -432,9 +434,16 @@ static ULONG WINAPI DdsFrameDecode_Dds_Release(IWICDdsFrameDecode *iface)
static HRESULT WINAPI DdsFrameDecode_Dds_GetSizeInBlocks(IWICDdsFrameDecode *iface,
UINT *widthInBlocks, UINT *heightInBlocks)
{
FIXME("(%p,%p,%p): stub.\n", iface, widthInBlocks, heightInBlocks);
DdsFrameDecode *This = impl_from_IWICDdsFrameDecode(iface);
return E_NOTIMPL;
if (!widthInBlocks || !heightInBlocks) return E_INVALIDARG;
*widthInBlocks = This->info.width_in_blocks;
*heightInBlocks = This->info.height_in_blocks;
TRACE("(%p,%p,%p) -> (%d,%d)\n", iface, widthInBlocks, heightInBlocks, *widthInBlocks, *heightInBlocks);
return S_OK;
}
static HRESULT WINAPI DdsFrameDecode_Dds_GetFormatInfo(IWICDdsFrameDecode *iface,
@ -839,6 +848,8 @@ static HRESULT WINAPI DdsDecoder_Dds_GetFrame(IWICDdsDecoder *iface,
frame_decode->info.bytes_per_block = get_bytes_per_block(This->info.format);
frame_decode->info.block_width = 4;
frame_decode->info.block_height = 4;
frame_decode->info.width_in_blocks = (width + frame_decode->info.block_width - 1) / frame_decode->info.block_width;
frame_decode->info.height_in_blocks = (width + frame_decode->info.block_height - 1) / frame_decode->info.block_height;
*bitmapFrame = &frame_decode->IWICBitmapFrameDecode_iface;
hr = S_OK;

View File

@ -456,13 +456,13 @@ static void test_dds_decoder_frame_properties(IWICBitmapDecoder *decoder, IWICBi
/* size in blocks tests */
hr = IWICDdsFrameDecode_GetSizeInBlocks(dds_frame, NULL, NULL);
todo_wine ok (hr == E_INVALIDARG, "%d: [frame %d] Got unexpected hr %x\n", i, frame_index, hr);
ok (hr == E_INVALIDARG, "%d: [frame %d] Got unexpected hr %x\n", i, frame_index, hr);
hr = IWICDdsFrameDecode_GetSizeInBlocks(dds_frame, NULL, &height_in_blocks);
todo_wine ok (hr == E_INVALIDARG, "%d: [frame %d] Got unexpected hr %x\n", i, frame_index, hr);
ok (hr == E_INVALIDARG, "%d: [frame %d] Got unexpected hr %x\n", i, frame_index, hr);
hr = IWICDdsFrameDecode_GetSizeInBlocks(dds_frame, &width_in_blocks, NULL);
todo_wine ok (hr == E_INVALIDARG, "%d: [frame %d] Got unexpected hr %x\n", i, frame_index, hr);
ok (hr == E_INVALIDARG, "%d: [frame %d] Got unexpected hr %x\n", i, frame_index, hr);
hr = IWICDdsFrameDecode_GetSizeInBlocks(dds_frame, &width_in_blocks, &height_in_blocks);
todo_wine ok (hr == S_OK, "%d: [frame %d] GetSizeInBlocks failed, hr=%x\n", i, frame_index, hr);
ok (hr == S_OK, "%d: [frame %d] GetSizeInBlocks failed, hr=%x\n", i, frame_index, hr);
if (hr != S_OK) goto end;
expected_width_in_blocks = (expected_width + format_info.BlockWidth - 1) / format_info.BlockWidth;