From: Piotr Caban piotr@codeweavers.com
Signed-off-by: Piotr Caban piotr@codeweavers.com --- dlls/d3dx10_43/tests/d3dx10.c | 5 +++++ dlls/d3dx10_43/texture.c | 32 +++++++++++++++++++++++++------- 2 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 0c6c4e5c8ce..560bc7a8f17 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -2172,6 +2172,11 @@ static void test_create_texture(void)
/* D3DX10CreateTextureFromMemory tests */
+ resource = (ID3D10Resource *)0xdeadbeef; + hr = D3DX10CreateTextureFromMemory(NULL, test_bmp_1bpp, sizeof(test_bmp_1bpp), NULL, NULL, &resource, NULL); + ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); + ok(resource == (ID3D10Resource *)0xdeadbeef, "Got unexpected resource %p.\n", resource); + resource = (ID3D10Resource *)0xdeadbeef; hr = D3DX10CreateTextureFromMemory(device, NULL, 0, NULL, NULL, &resource, NULL); ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); diff --git a/dlls/d3dx10_43/texture.c b/dlls/d3dx10_43/texture.c index 9c7762bc617..d5066b9793b 100644 --- a/dlls/d3dx10_43/texture.c +++ b/dlls/d3dx10_43/texture.c @@ -581,7 +581,9 @@ HRESULT WINAPI D3DX10CreateTextureFromFileA(ID3D10Device *device, const char *sr TRACE("device %p, src_file %s, load_info %p, pump %p, texture %p, hresult %p.\n", device, debugstr_a(src_file), load_info, pump, texture, hresult);
- if (!src_file || !texture) + if (!device) + return E_INVALIDARG; + if (!src_file) return E_FAIL;
if (!(str_len = MultiByteToWideChar(CP_ACP, 0, src_file, -1, NULL, 0))) @@ -608,11 +610,17 @@ HRESULT WINAPI D3DX10CreateTextureFromFileW(ID3D10Device *device, const WCHAR *s TRACE("device %p, src_file %s, load_info %p, pump %p, texture %p, hresult %p.\n", device, debugstr_w(src_file), load_info, pump, texture, hresult);
- if (!src_file || !texture) + if (!device) + return E_INVALIDARG; + if (!src_file) return E_FAIL;
if (FAILED((hr = load_file(src_file, &buffer, &size)))) + { + if (hresult) + *hresult = hr; return hr; + }
hr = D3DX10CreateTextureFromMemory(device, buffer, size, load_info, pump, texture, hresult);
@@ -631,8 +639,8 @@ HRESULT WINAPI D3DX10CreateTextureFromResourceA(ID3D10Device *device, HMODULE mo 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);
- if (!resource || !texture) - return D3DX10_ERR_INVALID_DATA; + if (!device) + return E_INVALIDARG;
hr = load_resourceA(module, resource, &buffer, &size); if (FAILED(hr)) @@ -651,8 +659,8 @@ HRESULT WINAPI D3DX10CreateTextureFromResourceW(ID3D10Device *device, HMODULE mo 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);
- if (!resource || !texture) - return D3DX10_ERR_INVALID_DATA; + if (!device) + return E_INVALIDARG;
hr = load_resourceW(module, resource, &buffer, &size); if (FAILED(hr)) @@ -684,7 +692,9 @@ HRESULT WINAPI D3DX10CreateTextureFromMemory(ID3D10Device *device, const void *s TRACE("device %p, src_data %p, src_data_size %Iu, load_info %p, pump %p, texture %p, hresult %p.\n", device, src_data, src_data_size, load_info, pump, texture, hresult);
- if (!src_data || !src_data_size || !texture) + if (!device) + return E_INVALIDARG; + if (!src_data) return E_FAIL; if (load_info) FIXME("load_info is ignored.\n"); @@ -692,10 +702,16 @@ HRESULT WINAPI D3DX10CreateTextureFromMemory(ID3D10Device *device, const void *s FIXME("Thread pump is not supported yet.\n");
if (FAILED(D3DX10GetImageInfoFromMemory(src_data, src_data_size, NULL, &img_info, NULL))) + { + if (hresult) + *hresult = E_FAIL; return E_FAIL; + } if (img_info.MiscFlags & D3D10_RESOURCE_MISC_TEXTURECUBE) { FIXME("Cube map is not supported.\n"); + if (hresult) + *hresult = E_FAIL; return E_FAIL; }
@@ -807,5 +823,7 @@ end: if (factory) IWICImagingFactory_Release(factory);
+ if (hresult) + *hresult = hr; return hr; }