Module: wine Branch: master Commit: 43aa33714ee081a8dcb6b489753a977d32b3fb3f URL: https://source.winehq.org/git/wine.git/?a=commit;h=43aa33714ee081a8dcb6b4897...
Author: Ziqing Hui zhui@codeweavers.com Date: Mon Nov 16 10:05:16 2020 +0800
d3dx10: Implement D3DX10GetImageInfoFromResource{A, W}().
Signed-off-by: Ziqing Hui zhui@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/d3dx10_43/tests/d3dx10.c | 7 ++--- dlls/d3dx10_43/texture.c | 66 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 64 insertions(+), 9 deletions(-)
diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index f9bd40a72cb..5d7ffcfde3f 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -1460,8 +1460,6 @@ static void test_get_image_info(void)
/* D3DX10GetImageInfoFromResource tests */
- todo_wine - { hr = D3DX10GetImageInfoFromResourceW(NULL, NULL, NULL, &image_info, NULL); ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#x.\n", hr); hr = D3DX10GetImageInfoFromResourceW(NULL, L"deadbeaf", NULL, &image_info, NULL); @@ -1470,20 +1468,19 @@ static void test_get_image_info(void) ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#x.\n", hr); hr = D3DX10GetImageInfoFromResourceA(NULL, "deadbeaf", NULL, &image_info, NULL); ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#x.\n", hr); - }
for (i = 0; i < ARRAY_SIZE(test_image); ++i) { resource_module = create_resource_module(test_resource_name, test_image[i].data, test_image[i].size);
hr = D3DX10GetImageInfoFromResourceW(resource_module, test_resource_name, 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__);
hr = D3DX10GetImageInfoFromResourceA(resource_module, get_str_a(test_resource_name), 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 23d7b93e649..ea9b5120c47 100644 --- a/dlls/d3dx10_43/texture.c +++ b/dlls/d3dx10_43/texture.c @@ -148,6 +148,22 @@ done: return hr; }
+static HRESULT load_resource(HMODULE module, HRSRC res_info, void **buffer, DWORD *size) +{ + HGLOBAL resource; + + if (!(*size = SizeofResource(module, res_info))) + return HRESULT_FROM_WIN32(GetLastError()); + + if (!(resource = LoadResource(module, res_info))) + return HRESULT_FROM_WIN32(GetLastError()); + + if (!(*buffer = LockResource(resource))) + return HRESULT_FROM_WIN32(GetLastError()); + + return S_OK; +} + HRESULT WINAPI D3DX10GetImageInfoFromFileA(const char *src_file, ID3DX10ThreadPump *pump, D3DX10_IMAGE_INFO *info, HRESULT *result) { @@ -201,19 +217,61 @@ HRESULT WINAPI D3DX10GetImageInfoFromFileW(const WCHAR *src_file, ID3DX10ThreadP HRESULT WINAPI D3DX10GetImageInfoFromResourceA(HMODULE module, const char *resource, ID3DX10ThreadPump *pump, D3DX10_IMAGE_INFO *info, HRESULT *result) { - FIXME("module %p, resource %s, pump %p, info %p, result %p\n", + HRSRC res_info; + void *buffer; + HRESULT hr; + DWORD size; + + TRACE("module %p, resource %s, pump %p, info %p, result %p.\n", module, debugstr_a(resource), pump, info, result);
- return E_NOTIMPL; + if (!resource || !info) + return D3DX10_ERR_INVALID_DATA; + + res_info = FindResourceA(module, resource, (const char *)RT_RCDATA); + if (!res_info) + { + /* Try loading the resource as bitmap data */ + res_info = FindResourceA(module, resource, (const char *)RT_BITMAP); + if (!res_info) + return D3DX10_ERR_INVALID_DATA; + } + + hr = load_resource(module, res_info, &buffer, &size); + if (FAILED(hr)) + return D3DX10_ERR_INVALID_DATA; + + return D3DX10GetImageInfoFromMemory(buffer, size, pump, info, result); }
HRESULT WINAPI D3DX10GetImageInfoFromResourceW(HMODULE module, const WCHAR *resource, ID3DX10ThreadPump *pump, D3DX10_IMAGE_INFO *info, HRESULT *result) { - FIXME("module %p, resource %s, pump %p, info %p, result %p\n", + unsigned int size; + HRSRC res_info; + void *buffer; + HRESULT hr; + + TRACE("module %p, resource %s, pump %p, info %p, result %p.\n", module, debugstr_w(resource), pump, info, result);
- return E_NOTIMPL; + if (!resource || !info) + return D3DX10_ERR_INVALID_DATA; + + res_info = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA); + if (!res_info) + { + /* Try loading the resource as bitmap data */ + res_info = FindResourceW(module, resource, (const WCHAR *)RT_BITMAP); + if (!res_info) + return D3DX10_ERR_INVALID_DATA; + } + + hr = load_resource(module, res_info, &buffer, &size); + if (FAILED(hr)) + return D3DX10_ERR_INVALID_DATA; + + return D3DX10GetImageInfoFromMemory(buffer, size, pump, info, result); }
HRESULT WINAPI D3DX10GetImageInfoFromMemory(const void *src_data, SIZE_T src_data_size, ID3DX10ThreadPump *pump,