Ziqing Hui : d3dx10: Implement D3DX10CreateTextureFromFile{A,W}.

Alexandre Julliard julliard at winehq.org
Tue Nov 9 15:55:06 CST 2021


Module: wine
Branch: master
Commit: 81bc256685b02f76449b7ae0d382b15b09d6dde9
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=81bc256685b02f76449b7ae0d382b15b09d6dde9

Author: Ziqing Hui <zhui at codeweavers.com>
Date:   Thu Nov  4 19:28:47 2021 +0800

d3dx10: Implement D3DX10CreateTextureFromFile{A,W}.

Signed-off-by: Ziqing Hui <zhui at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/d3dx10_43/tests/d3dx10.c |  7 ++-----
 dlls/d3dx10_43/texture.c      | 42 ++++++++++++++++++++++++++++++++++++++----
 2 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c
index 13f70f34f96..50128260b3e 100644
--- a/dlls/d3dx10_43/tests/d3dx10.c
+++ b/dlls/d3dx10_43/tests/d3dx10.c
@@ -2034,8 +2034,6 @@ static void test_create_texture(void)
 
     /* D3DX10CreateTextureFromFile tests */
 
-    todo_wine
-    {
     hr = D3DX10CreateTextureFromFileW(device, NULL, NULL, NULL, &resource, NULL);
     ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
     hr = D3DX10CreateTextureFromFileW(device, L"deadbeef", NULL, NULL, &resource, NULL);
@@ -2044,7 +2042,6 @@ static void test_create_texture(void)
     ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
     hr = D3DX10CreateTextureFromFileA(device, "deadbeef", NULL, NULL, &resource, NULL);
     ok(hr == D3D10_ERROR_FILE_NOT_FOUND, "Got unexpected hr %#x.\n", hr);
-    }
 
     for (i = 0; i < ARRAY_SIZE(test_image); ++i)
     {
@@ -2052,7 +2049,7 @@ static void test_create_texture(void)
         create_file(test_filename, test_image[i].data, test_image[i].size, path);
 
         hr = D3DX10CreateTextureFromFileW(device, path, 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)
@@ -2063,7 +2060,7 @@ static void test_create_texture(void)
         }
 
         hr = D3DX10CreateTextureFromFileA(device, get_str_a(path), 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 0568bc2316c..62baed0ca23 100644
--- a/dlls/d3dx10_43/texture.c
+++ b/dlls/d3dx10_43/texture.c
@@ -576,17 +576,51 @@ end:
 HRESULT WINAPI D3DX10CreateTextureFromFileA(ID3D10Device *device, const char *src_file,
         D3DX10_IMAGE_LOAD_INFO *load_info, ID3DX10ThreadPump *pump, ID3D10Resource **texture, HRESULT *hresult)
 {
-    FIXME("device %p, src_file %s, load_info %p, pump %p, texture %p, hresult %p stub!\n",
+    WCHAR *buffer;
+    int str_len;
+    HRESULT hr;
+
+    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);
-    return E_NOTIMPL;
+
+    if (!src_file || !texture)
+        return E_FAIL;
+
+    if (!(str_len = MultiByteToWideChar(CP_ACP, 0, src_file, -1, NULL, 0)))
+        return HRESULT_FROM_WIN32(GetLastError());
+
+    if (!(buffer = heap_alloc(str_len * sizeof(*buffer))))
+        return E_OUTOFMEMORY;
+
+    MultiByteToWideChar(CP_ACP, 0, src_file, -1, buffer, str_len);
+    hr = D3DX10CreateTextureFromFileW(device, buffer, load_info, pump, texture, hresult);
+
+    heap_free(buffer);
+
+    return hr;
 }
 
 HRESULT WINAPI D3DX10CreateTextureFromFileW(ID3D10Device *device, const WCHAR *src_file,
         D3DX10_IMAGE_LOAD_INFO *load_info, ID3DX10ThreadPump *pump, ID3D10Resource **texture, HRESULT *hresult)
 {
-    FIXME("device %p, src_file %s, load_info %p, pump %p, texture %p, hresult %p stub!\n",
+    void *buffer = NULL;
+    DWORD size = 0;
+    HRESULT hr;
+
+    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);
-    return E_NOTIMPL;
+
+    if (!src_file || !texture)
+        return E_FAIL;
+
+    if (FAILED(load_file(src_file, &buffer, &size)))
+        return D3D10_ERROR_FILE_NOT_FOUND;
+
+    hr = D3DX10CreateTextureFromMemory(device, buffer, size, load_info, pump, texture, hresult);
+
+    heap_free(buffer);
+
+    return hr;
 }
 
 HRESULT WINAPI D3DX10CreateTextureFromResourceA(ID3D10Device *device, HMODULE module, const char *resource,




More information about the wine-cvs mailing list