From: Ziqing Hui zhui@codeweavers.com
Signed-off-by: Ziqing Hui zhui@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dx10_43/tests/d3dx10.c | 4 +- dlls/d3dx10_43/texture.c | 70 ++++++++++++++++++++++++++++++++++- 2 files changed, 69 insertions(+), 5 deletions(-)
diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 640e83fcd0fb..e33b8326461d 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -1383,12 +1383,10 @@ static void test_get_image_info(void) check_image_info(&image_info, i, __LINE__); }
- todo_wine { hr = D3DX10GetImageInfoFromFileW(NULL, NULL, &image_info, NULL); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); hr = D3DX10GetImageInfoFromFileW(L"deadbeaf", NULL, &image_info, NULL); ok(hr == D3D10_ERROR_FILE_NOT_FOUND, "Got unexpected hr %#x.\n", hr); - }
for (i = 0; i < ARRAY_SIZE(test_image); ++i) { @@ -1396,7 +1394,7 @@ static void test_get_image_info(void) hr = D3DX10GetImageInfoFromFileW(path, NULL, &image_info, NULL); delete_file(test_filename);
- todo_wine + todo_wine_if(test_image[i].expected.ImageFileFormat == D3DX10_IFF_WMP) ok(hr == S_OK, "Test %u: Got unexpected hr %#x.\n", i, hr); if (hr != S_OK) continue; diff --git a/dlls/d3dx10_43/texture.c b/dlls/d3dx10_43/texture.c index 63e6d71546da..b87134514814 100644 --- a/dlls/d3dx10_43/texture.c +++ b/dlls/d3dx10_43/texture.c @@ -17,6 +17,7 @@ */
#include "wine/debug.h" +#include "wine/heap.h"
#define COBJMACROS
@@ -96,6 +97,57 @@ static DXGI_FORMAT get_d3dx10_dds_format(DXGI_FORMAT format) return format; }
+static HRESULT load_file(const WCHAR *filename, void **buffer, DWORD *size) +{ + HRESULT hr = S_OK; + DWORD bytes_read; + HANDLE file; + BOOL ret; + + file = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); + if (file == INVALID_HANDLE_VALUE) + { + hr = HRESULT_FROM_WIN32(GetLastError()); + goto done; + } + + *size = GetFileSize(file, NULL); + if (*size == INVALID_FILE_SIZE) + { + hr = HRESULT_FROM_WIN32(GetLastError()); + goto done; + } + + *buffer = heap_alloc(*size); + if (!*buffer) + { + hr = E_OUTOFMEMORY; + goto done; + } + + ret = ReadFile(file, *buffer, *size, &bytes_read, NULL); + if (!ret) + { + hr = HRESULT_FROM_WIN32(GetLastError()); + goto done; + } + if (bytes_read != *size) + { + hr = E_FAIL; + goto done; + } + +done: + if (FAILED(hr)) + { + heap_free(*buffer); + *buffer = NULL; + } + if (file != INVALID_HANDLE_VALUE) + CloseHandle(file); + return hr; +} + HRESULT WINAPI D3DX10GetImageInfoFromFileA(const char *src_file, ID3DX10ThreadPump *pump, D3DX10_IMAGE_INFO *info, HRESULT *result) { @@ -107,9 +159,23 @@ HRESULT WINAPI D3DX10GetImageInfoFromFileA(const char *src_file, ID3DX10ThreadPu HRESULT WINAPI D3DX10GetImageInfoFromFileW(const WCHAR *src_file, ID3DX10ThreadPump *pump, D3DX10_IMAGE_INFO *info, HRESULT *result) { - FIXME("src_file %s, pump %p, info %p, result %p\n", debugstr_w(src_file), pump, info, result); + void *buffer = NULL; + DWORD size = 0; + HRESULT hr;
- return E_NOTIMPL; + TRACE("src_file %s, pump %p, info %p, result %p.\n", debugstr_w(src_file), pump, info, result); + + if (!src_file || !info) + return E_FAIL; + + if (FAILED(load_file(src_file, &buffer, &size))) + return D3D10_ERROR_FILE_NOT_FOUND; + + hr = D3DX10GetImageInfoFromMemory(buffer, size, pump, info, result); + + heap_free(buffer); + + return hr; }
HRESULT WINAPI D3DX10GetImageInfoFromResourceA(HMODULE module, const char *resource, ID3DX10ThreadPump *pump,
From: Ziqing Hui zhui@codeweavers.com
Signed-off-by: Ziqing Hui zhui@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dx10_43/tests/d3dx10.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index e33b8326461d..02de73865f5e 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -558,6 +558,14 @@ static BOOL compare_float(float f, float g, unsigned int ulps) return TRUE; }
+static char *get_str_a(const WCHAR *wstr) +{ + static char buffer[MAX_PATH]; + + WideCharToMultiByte(CP_ACP, 0, wstr, -1, buffer, sizeof(buffer), NULL, NULL); + return buffer; +} + static BOOL create_file(const WCHAR *filename, const void *data, unsigned int size, WCHAR *out_path) { WCHAR path[MAX_PATH]; @@ -1387,19 +1395,30 @@ static void test_get_image_info(void) ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); hr = D3DX10GetImageInfoFromFileW(L"deadbeaf", NULL, &image_info, NULL); ok(hr == D3D10_ERROR_FILE_NOT_FOUND, "Got unexpected hr %#x.\n", hr); + todo_wine { + hr = D3DX10GetImageInfoFromFileA(NULL, NULL, &image_info, NULL); + ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); + hr = D3DX10GetImageInfoFromFileA("deadbeaf", NULL, &image_info, NULL); + ok(hr == D3D10_ERROR_FILE_NOT_FOUND, "Got unexpected hr %#x.\n", hr); + }
for (i = 0; i < ARRAY_SIZE(test_image); ++i) { create_file(test_filename, test_image[i].data, test_image[i].size, path); - hr = D3DX10GetImageInfoFromFileW(path, NULL, &image_info, NULL); - delete_file(test_filename);
+ hr = D3DX10GetImageInfoFromFileW(path, NULL, &image_info, NULL); todo_wine_if(test_image[i].expected.ImageFileFormat == D3DX10_IFF_WMP) ok(hr == S_OK, "Test %u: Got unexpected hr %#x.\n", i, hr); - if (hr != S_OK) - continue; + if (hr == S_OK) + check_image_info(&image_info, i, __LINE__);
- check_image_info(&image_info, i, __LINE__); + hr = D3DX10GetImageInfoFromFileA(get_str_a(path), NULL, &image_info, NULL); + todo_wine + ok(hr == S_OK, "Test %u: Got unexpected hr %#x.\n", i, hr); + if (hr == S_OK) + check_image_info(&image_info, i, __LINE__); + + delete_file(test_filename); }
CoUninitialize();
From: Ziqing Hui zhui@codeweavers.com
Signed-off-by: Ziqing Hui zhui@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dx10_43/tests/d3dx10.c | 4 +--- dlls/d3dx10_43/texture.c | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 02de73865f5e..897c54249b39 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -1395,12 +1395,10 @@ static void test_get_image_info(void) ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); hr = D3DX10GetImageInfoFromFileW(L"deadbeaf", NULL, &image_info, NULL); ok(hr == D3D10_ERROR_FILE_NOT_FOUND, "Got unexpected hr %#x.\n", hr); - todo_wine { hr = D3DX10GetImageInfoFromFileA(NULL, NULL, &image_info, NULL); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); hr = D3DX10GetImageInfoFromFileA("deadbeaf", NULL, &image_info, NULL); ok(hr == D3D10_ERROR_FILE_NOT_FOUND, "Got unexpected hr %#x.\n", hr); - }
for (i = 0; i < ARRAY_SIZE(test_image); ++i) { @@ -1413,7 +1411,7 @@ static void test_get_image_info(void) check_image_info(&image_info, i, __LINE__);
hr = D3DX10GetImageInfoFromFileA(get_str_a(path), NULL, &image_info, NULL); - todo_wine + todo_wine_if(test_image[i].expected.ImageFileFormat == D3DX10_IFF_WMP) ok(hr == S_OK, "Test %u: Got unexpected hr %#x.\n", i, hr); if (hr == S_OK) check_image_info(&image_info, i, __LINE__); diff --git a/dlls/d3dx10_43/texture.c b/dlls/d3dx10_43/texture.c index b87134514814..23d7b93e649c 100644 --- a/dlls/d3dx10_43/texture.c +++ b/dlls/d3dx10_43/texture.c @@ -151,9 +151,29 @@ done: HRESULT WINAPI D3DX10GetImageInfoFromFileA(const char *src_file, ID3DX10ThreadPump *pump, D3DX10_IMAGE_INFO *info, HRESULT *result) { - FIXME("src_file %s, pump %p, info %p, result %p\n", debugstr_a(src_file), pump, info, result); + WCHAR *buffer; + int str_len; + HRESULT hr;
- return E_NOTIMPL; + TRACE("src_file %s, pump %p, info %p, result %p.\n", debugstr_a(src_file), pump, info, result); + + if (!src_file || !info) + return E_FAIL; + + str_len = MultiByteToWideChar(CP_ACP, 0, src_file, -1, NULL, 0); + if (!str_len) + return HRESULT_FROM_WIN32(GetLastError()); + + buffer = heap_alloc(str_len * sizeof(*buffer)); + if (!buffer) + return E_OUTOFMEMORY; + + MultiByteToWideChar(CP_ACP, 0, src_file, -1, buffer, str_len); + hr = D3DX10GetImageInfoFromFileW(buffer, pump, info, result); + + heap_free(buffer); + + return hr; }
HRESULT WINAPI D3DX10GetImageInfoFromFileW(const WCHAR *src_file, ID3DX10ThreadPump *pump, D3DX10_IMAGE_INFO *info,