Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/d3dx10_43/tests/d3dx10.c | 7 ++---- dlls/d3dx10_43/texture.c | 46 ++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 9 deletions(-)
diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 50128260b3e..55a4d057fdf 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -2076,8 +2076,6 @@ static void test_create_texture(void)
/* D3DX10CreateTextureFromResource tests */
- todo_wine - { hr = D3DX10CreateTextureFromResourceW(device, NULL, NULL, NULL, NULL, &resource, NULL); ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#x.\n", hr); hr = D3DX10CreateTextureFromResourceW(device, NULL, L"deadbeef", NULL, NULL, &resource, NULL); @@ -2086,7 +2084,6 @@ static void test_create_texture(void) ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#x.\n", hr); hr = D3DX10CreateTextureFromResourceA(device, NULL, "deadbeef", NULL, NULL, &resource, NULL); ok(hr == D3DX10_ERR_INVALID_DATA, "Got unexpected hr %#x.\n", hr); - }
for (i = 0; i < ARRAY_SIZE(test_image); ++i) { @@ -2095,7 +2092,7 @@ static void test_create_texture(void)
hr = D3DX10CreateTextureFromResourceW(device, resource_module, test_resource_name, NULL, NULL, &resource, NULL); - todo_wine + todo_wine_if(test_image[i].expected_info.MiscFlags & D3D10_RESOURCE_MISC_TEXTURECUBE) ok(hr == S_OK || broken(hr == E_FAIL && test_image[i].expected_info.ImageFileFormat == D3DX10_IFF_WMP), "Got unexpected hr %#x.\n", hr); if (hr == S_OK) @@ -2107,7 +2104,7 @@ static void test_create_texture(void)
hr = D3DX10CreateTextureFromResourceA(device, resource_module, get_str_a(test_resource_name), NULL, NULL, &resource, NULL); - todo_wine + todo_wine_if(test_image[i].expected_info.MiscFlags & D3D10_RESOURCE_MISC_TEXTURECUBE) ok(hr == S_OK || broken(hr == E_FAIL && test_image[i].expected_info.ImageFileFormat == D3DX10_IFF_WMP), "Got unexpected hr %#x.\n", hr); if (hr == S_OK) diff --git a/dlls/d3dx10_43/texture.c b/dlls/d3dx10_43/texture.c index 62baed0ca23..3488c80ab29 100644 --- a/dlls/d3dx10_43/texture.c +++ b/dlls/d3dx10_43/texture.c @@ -626,17 +626,55 @@ HRESULT WINAPI D3DX10CreateTextureFromFileW(ID3D10Device *device, const WCHAR *s HRESULT WINAPI D3DX10CreateTextureFromResourceA(ID3D10Device *device, HMODULE module, const char *resource, D3DX10_IMAGE_LOAD_INFO *load_info, ID3DX10ThreadPump *pump, ID3D10Resource **texture, HRESULT *hresult) { - FIXME("device %p, module %p, resource %s, load_info %p, pump %p, texture %p, hresult %p stub!\n", + HRSRC res_info; + void *buffer; + DWORD size; + HRESULT hr; + + TRACE("device %p, module %p, resource %s, load_info %p, pump %p, texture %p, hresult %p.\n", device, module, debugstr_a(resource), load_info, pump, texture, hresult); - return E_NOTIMPL; + + if (!resource || !texture) + return D3DX10_ERR_INVALID_DATA; + + if (!(res_info = FindResourceA(module, resource, (const char *)RT_RCDATA))) + { + /* Try loading the resource as bitmap data */ + if (!(res_info = FindResourceA(module, resource, (const char *)RT_BITMAP))) + return D3DX10_ERR_INVALID_DATA; + } + + if (FAILED(hr = load_resource(module, res_info, &buffer, &size))) + return D3DX10_ERR_INVALID_DATA; + + return D3DX10CreateTextureFromMemory(device, buffer, size, load_info, pump, texture, hresult); }
HRESULT WINAPI D3DX10CreateTextureFromResourceW(ID3D10Device *device, HMODULE module, const WCHAR *resource, D3DX10_IMAGE_LOAD_INFO *load_info, ID3DX10ThreadPump *pump, ID3D10Resource **texture, HRESULT *hresult) { - FIXME("device %p, module %p, resource %s, load_info %p, pump %p, texture %p, hresult %p stub!\n", + HRSRC res_info; + void *buffer; + DWORD size; + HRESULT hr; + + TRACE("device %p, module %p, resource %s, load_info %p, pump %p, texture %p, hresult %p.\n", device, module, debugstr_w(resource), load_info, pump, texture, hresult); - return E_NOTIMPL; + + if (!resource || !texture) + return D3DX10_ERR_INVALID_DATA; + + if (!(res_info = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA))) + { + /* Try loading the resource as bitmap data */ + if (!(res_info = FindResourceW(module, resource, (const WCHAR *)RT_BITMAP))) + return D3DX10_ERR_INVALID_DATA; + } + + if (FAILED(hr = load_resource(module, res_info, &buffer, &size))) + return D3DX10_ERR_INVALID_DATA; + + return D3DX10CreateTextureFromMemory(device, buffer, size, load_info, pump, texture, hresult); }
HRESULT WINAPI D3DX10CreateTextureFromMemory(ID3D10Device *device, const void *src_data, SIZE_T src_data_size,