From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/d3dx9_private.h | 5 +++-- dlls/d3dx9_36/surface.c | 7 ++++--- dlls/d3dx9_36/tests/surface.c | 27 ++++++++++----------------- 3 files changed, 17 insertions(+), 22 deletions(-)
diff --git a/dlls/d3dx9_36/d3dx9_private.h b/dlls/d3dx9_36/d3dx9_private.h index 503dbfdc924..303489374f8 100644 --- a/dlls/d3dx9_36/d3dx9_private.h +++ b/dlls/d3dx9_36/d3dx9_private.h @@ -153,15 +153,16 @@ struct d3dx_image uint32_t layer_count;
BYTE *pixels; + PALETTEENTRY *palette; uint32_t layer_pitch;
/* - * image_buf and palette are pointers to allocated memory used to store + * image_buf and image_palette are pointers to allocated memory used to store * image data. If they are non-NULL, they need to be freed when no longer * in use. */ void *image_buf; - PALETTEENTRY *palette; + PALETTEENTRY *image_palette;
D3DXIMAGE_FILEFORMAT image_file_format; }; diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index 85a11ef90c1..c75573cd34a 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -643,6 +643,7 @@ static HRESULT d3dx_initialize_image_from_dds(const void *src_data, uint32_t src return D3DXERR_INVALIDDATA; }
+ image->palette = (is_indexed_fmt) ? (PALETTEENTRY *)(((uint8_t *)src_data) + sizeof(*header)) : NULL; image->pixels = ((BYTE *)src_data) + header_size; image->image_file_format = D3DXIFF_DDS; if (starting_mip_level && (image->mip_levels > 1)) @@ -891,13 +892,13 @@ static HRESULT d3dx_image_wic_frame_decode(struct d3dx_image *image, }
image->image_buf = image->pixels = buffer; - image->palette = palette; + image->image_palette = image->palette = palette;
exit: free(colors); if (image->image_buf != buffer) free(buffer); - if (image->palette != palette) + if (image->image_palette != palette) free(palette); if (wic_palette) IWICPalette_Release(wic_palette); @@ -1033,7 +1034,7 @@ HRESULT d3dx_image_init(const void *src_data, uint32_t src_data_size, struct d3d void d3dx_image_cleanup(struct d3dx_image *image) { free(image->image_buf); - free(image->palette); + free(image->image_palette); }
HRESULT d3dx_image_get_pixels(struct d3dx_image *image, uint32_t layer, uint32_t mip_level, diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index 7fc4328d74c..b0d166eb36a 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -1740,23 +1740,16 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device) }
/* Test D3DXLoadSurfaceFromFileInMemory with indexed pixel format DDS files. */ - if (!strcmp(winetest_platform, "windows")) - { - hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, dds_8bit, sizeof(dds_8bit), &rect, D3DX_FILTER_NONE, 0, NULL); - ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); - hr = IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY); - ok(hr == D3D_OK, "Failed to lock surface, hr %#lx.\n", hr); - check_pixel_4bpp(&lockrect, 0, 0, 0xffec2700); - check_pixel_4bpp(&lockrect, 1, 0, 0xffec2700); - check_pixel_4bpp(&lockrect, 0, 1, 0xffec2700); - check_pixel_4bpp(&lockrect, 1, 1, 0xffec2700); - hr = IDirect3DSurface9_UnlockRect(surf); - ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr); - } - else - { - skip("Skipping test on wine to avoid access violation.\n"); - } + hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, dds_8bit, sizeof(dds_8bit), &rect, D3DX_FILTER_NONE, 0, NULL); + ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + hr = IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY); + ok(hr == D3D_OK, "Failed to lock surface, hr %#lx.\n", hr); + check_pixel_4bpp(&lockrect, 0, 0, 0xffec2700); + check_pixel_4bpp(&lockrect, 1, 0, 0xffec2700); + check_pixel_4bpp(&lockrect, 0, 1, 0xffec2700); + check_pixel_4bpp(&lockrect, 1, 1, 0xffec2700); + hr = IDirect3DSurface9_UnlockRect(surf); + ok(hr == D3D_OK, "Failed to unlock surface, hr %#lx.\n", hr);
hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, dds_a8p8, sizeof(dds_a8p8), &rect, D3DX_FILTER_NONE, 0, NULL); todo_wine ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);