windowscodecs: Add support for decoding cube maps.
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:
parent
bc805bbcd9
commit
2683be090b
|
@ -14,6 +14,16 @@
|
|||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*
|
||||
* Note:
|
||||
*
|
||||
* Uncompressed image:
|
||||
* For uncompressed formats, a block is equivalent to a pixel.
|
||||
*
|
||||
* Cube map:
|
||||
* A cube map is equivalent to a 2D texture array which has 6 textures.
|
||||
* A cube map array is equivalent to a 2D texture array which has cubeCount*6 textures.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -436,6 +446,7 @@ static void get_dds_info(dds_info* info, DDS_HEADER *header, DDS_HEADER_DXT10 *h
|
|||
}
|
||||
info->frame_count *= info->array_size;
|
||||
}
|
||||
if (info->dimension == WICDdsTextureCube) info->frame_count *= 6;
|
||||
}
|
||||
|
||||
static inline DdsDecoder *impl_from_IWICBitmapDecoder(IWICBitmapDecoder *iface)
|
||||
|
@ -910,7 +921,11 @@ static HRESULT WINAPI DdsDecoder_GetFrame(IWICBitmapDecoder *iface,
|
|||
return WINCODEC_ERR_WRONGSTATE;
|
||||
}
|
||||
|
||||
frame_per_texture = This->info.frame_count / This->info.array_size;
|
||||
if (This->info.dimension == WICDdsTextureCube) {
|
||||
frame_per_texture = This->info.mip_levels;
|
||||
} else {
|
||||
frame_per_texture = This->info.frame_count / This->info.array_size;
|
||||
}
|
||||
array_index = index / frame_per_texture;
|
||||
slice_index = index % frame_per_texture;
|
||||
depth = This->info.depth;
|
||||
|
@ -1021,7 +1036,11 @@ static HRESULT WINAPI DdsDecoder_Dds_GetFrame(IWICDdsDecoder *iface,
|
|||
hr = WINCODEC_ERR_WRONGSTATE;
|
||||
goto end;
|
||||
}
|
||||
if (arrayIndex >= This->info.array_size || mipLevel >= This->info.mip_levels || sliceIndex >= This->info.depth) {
|
||||
|
||||
if ((arrayIndex >= This->info.array_size && This->info.dimension != WICDdsTextureCube) ||
|
||||
(arrayIndex >= This->info.array_size * 6) ||
|
||||
(mipLevel >= This->info.mip_levels) ||
|
||||
(sliceIndex >= This->info.depth)) {
|
||||
hr = E_INVALIDARG;
|
||||
goto end;
|
||||
}
|
||||
|
|
|
@ -541,7 +541,6 @@ static void test_dds_decoder_image_parameters(void)
|
|||
hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count);
|
||||
ok(hr == S_OK, "Test %u: GetFrameCount failed, hr %#x\n", i, hr);
|
||||
if (hr == S_OK) {
|
||||
todo_wine_if(test_data[i].expected_parameters.Dimension == WICDdsTextureCube)
|
||||
ok(frame_count == test_data[i].expected_frame_count, "Test %u: Expected frame count %u, got %u\n",
|
||||
i, test_data[i].expected_frame_count, frame_count);
|
||||
}
|
||||
|
@ -794,11 +793,6 @@ static void test_dds_decoder_frame(IWICBitmapDecoder *decoder, int i)
|
|||
UINT frame_count, j;
|
||||
WICDdsParameters params;
|
||||
|
||||
if (test_data[i].expected_parameters.Dimension == WICDdsTextureCube) {
|
||||
skip("Frame tests for cube maps will crash\n");
|
||||
return;
|
||||
}
|
||||
|
||||
hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count);
|
||||
ok(hr == S_OK, "Test %u: GetFrameCount failed, hr %#x\n", i, hr);
|
||||
if (hr != S_OK) return;
|
||||
|
|
Loading…
Reference in New Issue