Christian Costa : d3dx9_36: Add support for RT_BITMAP resource type since it is in DIB format D3DXIFF_DIB .

Alexandre Julliard julliard at winehq.org
Mon Jan 7 13:42:22 CST 2013


Module: wine
Branch: master
Commit: 4778a5e27d000b906684de76e91d37ddb61f223e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4778a5e27d000b906684de76e91d37ddb61f223e

Author: Christian Costa <titan.costa at gmail.com>
Date:   Mon Jan  7 09:40:08 2013 +0100

d3dx9_36: Add support for RT_BITMAP resource type since it is in DIB format D3DXIFF_DIB.

---

 dlls/d3dx9_36/surface.c       |   50 ++++++++++++++++++-----------------------
 dlls/d3dx9_36/tests/surface.c |    6 ++--
 dlls/d3dx9_36/texture.c       |   26 +++++----------------
 3 files changed, 31 insertions(+), 51 deletions(-)

diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c
index 923f17d..ea77497 100644
--- a/dlls/d3dx9_36/surface.c
+++ b/dlls/d3dx9_36/surface.c
@@ -878,8 +878,12 @@ HRESULT WINAPI D3DXGetImageInfoFromResourceA(HMODULE module, LPCSTR resource, D3
 
     TRACE("(%p, %s, %p)\n", module, debugstr_a(resource), info);
 
-    resinfo = FindResourceA(module, resource, (LPCSTR)RT_RCDATA);
-    if(resinfo) {
+    resinfo = FindResourceA(module, resource, (const char *)RT_RCDATA);
+    if (!resinfo) /* Try loading the resource as bitmap data (which is in DIB format D3DXIFF_DIB) */
+        resinfo = FindResourceA(module, resource, (const char *)RT_BITMAP);
+
+    if (resinfo)
+    {
         LPVOID buffer;
         HRESULT hr;
         DWORD size;
@@ -889,11 +893,6 @@ HRESULT WINAPI D3DXGetImageInfoFromResourceA(HMODULE module, LPCSTR resource, D3
         return D3DXGetImageInfoFromFileInMemory(buffer, size, info);
     }
 
-    resinfo = FindResourceA(module, resource, (LPCSTR)RT_BITMAP);
-    if(resinfo) {
-        FIXME("Implement loading bitmaps from resource type RT_BITMAP\n");
-        return E_NOTIMPL;
-    }
     return D3DXERR_INVALIDDATA;
 }
 
@@ -903,8 +902,12 @@ HRESULT WINAPI D3DXGetImageInfoFromResourceW(HMODULE module, LPCWSTR resource, D
 
     TRACE("(%p, %s, %p)\n", module, debugstr_w(resource), info);
 
-    resinfo = FindResourceW(module, resource, (LPCWSTR)RT_RCDATA);
-    if(resinfo) {
+    resinfo = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA);
+    if (!resinfo) /* Try loading the resource as bitmap data (which is in DIB format D3DXIFF_DIB) */
+        resinfo = FindResourceW(module, resource, (const WCHAR *)RT_BITMAP);
+
+    if (resinfo)
+    {
         LPVOID buffer;
         HRESULT hr;
         DWORD size;
@@ -914,11 +917,6 @@ HRESULT WINAPI D3DXGetImageInfoFromResourceW(HMODULE module, LPCWSTR resource, D
         return D3DXGetImageInfoFromFileInMemory(buffer, size, info);
     }
 
-    resinfo = FindResourceW(module, resource, (LPCWSTR)RT_BITMAP);
-    if(resinfo) {
-        FIXME("Implement loading bitmaps from resource type RT_BITMAP\n");
-        return E_NOTIMPL;
-    }
     return D3DXERR_INVALIDDATA;
 }
 
@@ -1138,7 +1136,11 @@ HRESULT WINAPI D3DXLoadSurfaceFromResourceA(IDirect3DSurface9 *dst_surface,
     if (!dst_surface)
         return D3DERR_INVALIDCALL;
 
-    if ((hResInfo = FindResourceA(src_module, resource, (const char *)RT_RCDATA)))
+    hResInfo = FindResourceA(src_module, resource, (const char *)RT_RCDATA);
+    if (!hResInfo) /* Try loading the resource as bitmap data (which is in DIB format D3DXIFF_DIB) */
+        hResInfo = FindResourceA(src_module, resource, (const char *)RT_BITMAP);
+
+    if (hResInfo)
     {
         UINT data_size;
         void *data;
@@ -1150,12 +1152,6 @@ HRESULT WINAPI D3DXLoadSurfaceFromResourceA(IDirect3DSurface9 *dst_surface,
                 data, data_size, src_rect, filter, color_key, src_info);
     }
 
-    if ((hResInfo = FindResourceA(src_module, resource, (const char *)RT_BITMAP)))
-    {
-        FIXME("Implement loading bitmaps from resource type RT_BITMAP.\n");
-        return E_NOTIMPL;
-    }
-
     return D3DXERR_INVALIDDATA;
 }
 
@@ -1173,7 +1169,11 @@ HRESULT WINAPI D3DXLoadSurfaceFromResourceW(IDirect3DSurface9 *dst_surface,
     if (!dst_surface)
         return D3DERR_INVALIDCALL;
 
-    if ((hResInfo = FindResourceW(src_module, resource, (const WCHAR *)RT_RCDATA)))
+    hResInfo = FindResourceW(src_module, resource, (const WCHAR *)RT_RCDATA);
+    if (!hResInfo) /* Try loading the resource as bitmap data (which is in DIB format D3DXIFF_DIB) */
+        hResInfo = FindResourceW(src_module, resource, (const WCHAR *)RT_BITMAP);
+
+    if (hResInfo)
     {
         UINT data_size;
         void *data;
@@ -1185,12 +1185,6 @@ HRESULT WINAPI D3DXLoadSurfaceFromResourceW(IDirect3DSurface9 *dst_surface,
                 data, data_size, src_rect, filter, color_key, src_info);
     }
 
-    if ((hResInfo = FindResourceW(src_module, resource, (const WCHAR *)RT_BITMAP)))
-    {
-        FIXME("Implement loading bitmaps from resource type RT_BITMAP.\n");
-        return E_NOTIMPL;
-    }
-
     return D3DXERR_INVALIDDATA;
 }
 
diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c
index 7ae7df9..bad9d43 100644
--- a/dlls/d3dx9_36/tests/surface.c
+++ b/dlls/d3dx9_36/tests/surface.c
@@ -380,11 +380,11 @@ static void test_D3DXGetImageInfo(void)
     todo_wine {
         hr = D3DXGetImageInfoFromResourceA(NULL, MAKEINTRESOURCEA(IDB_BITMAP_1x1), &info); /* RT_BITMAP */
         ok(hr == D3D_OK, "D3DXGetImageInfoFromResource returned %#x, expected %#x\n", hr, D3D_OK);
-
-        hr = D3DXGetImageInfoFromResourceA(NULL, MAKEINTRESOURCEA(IDB_BITMAP_1x1), NULL);
-        ok(hr == D3D_OK, "D3DXGetImageInfoFromResource returned %#x, expected %#x\n", hr, D3D_OK);
     }
 
+    hr = D3DXGetImageInfoFromResourceA(NULL, MAKEINTRESOURCEA(IDB_BITMAP_1x1), NULL);
+    ok(hr == D3D_OK, "D3DXGetImageInfoFromResource returned %#x, expected %#x\n", hr, D3D_OK);
+
     hr = D3DXGetImageInfoFromResourceA(NULL, MAKEINTRESOURCEA(IDD_BITMAPDATA_1x1), &info); /* RT_RCDATA */
     ok(hr == D3D_OK, "D3DXGetImageInfoFromResource returned %#x, expected %#x\n", hr, D3D_OK);
 
diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c
index 3809b02..788a572 100644
--- a/dlls/d3dx9_36/texture.c
+++ b/dlls/d3dx9_36/texture.c
@@ -791,7 +791,9 @@ HRESULT WINAPI D3DXCreateTextureFromResourceExA(struct IDirect3DDevice9 *device,
     if (!device || !texture)
         return D3DERR_INVALIDCALL;
 
-    resinfo = FindResourceA(srcmodule, resource, (LPCSTR) RT_RCDATA);
+    resinfo = FindResourceA(srcmodule, resource, (const char *)RT_RCDATA);
+    if (!resinfo) /* Try loading the resource as bitmap data (which is in DIB format D3DXIFF_DIB) */
+        resinfo = FindResourceA(srcmodule, resource, (const char *)RT_BITMAP);
 
     if (resinfo)
     {
@@ -810,15 +812,6 @@ HRESULT WINAPI D3DXCreateTextureFromResourceExA(struct IDirect3DDevice9 *device,
                                                    srcinfo, palette, texture);
     }
 
-    /* Try loading the resource as bitmap data */
-    resinfo = FindResourceA(srcmodule, resource, (LPCSTR) RT_BITMAP);
-
-    if (resinfo)
-    {
-        FIXME("Implement loading bitmaps from resource type RT_BITMAP\n");
-        return E_NOTIMPL;
-    }
-
     return D3DXERR_INVALIDDATA;
 }
 
@@ -834,7 +827,9 @@ HRESULT WINAPI D3DXCreateTextureFromResourceExW(struct IDirect3DDevice9 *device,
     if (!device || !texture)
         return D3DERR_INVALIDCALL;
 
-    resinfo = FindResourceW(srcmodule, resource, (LPCWSTR) RT_RCDATA);
+    resinfo = FindResourceW(srcmodule, resource, (const WCHAR *)RT_RCDATA);
+    if (!resinfo) /* Try loading the resource as bitmap data (which is in DIB format D3DXIFF_DIB) */
+        resinfo = FindResourceW(srcmodule, resource, (const WCHAR *)RT_BITMAP);
 
     if (resinfo)
     {
@@ -853,15 +848,6 @@ HRESULT WINAPI D3DXCreateTextureFromResourceExW(struct IDirect3DDevice9 *device,
                                                    srcinfo, palette, texture);
     }
 
-    /* Try loading the resource as bitmap data */
-    resinfo = FindResourceW(srcmodule, resource, (LPCWSTR) RT_BITMAP);
-
-    if (resinfo)
-    {
-        FIXME("Implement loading bitmaps from resource type RT_BITMAP\n");
-        return E_NOTIMPL;
-    }
-
     return D3DXERR_INVALIDDATA;
 }
 




More information about the wine-cvs mailing list