Henri Verbeet : d3d9: Improve IDirect3DDevice9::SetFVF() code flow.

Alexandre Julliard julliard at winehq.org
Fri Mar 6 09:49:42 CST 2009


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Fri Mar  6 08:43:49 2009 +0100

d3d9: Improve IDirect3DDevice9::SetFVF() code flow.

---

 dlls/d3d9/device.c |   35 ++++++++++++++++++++---------------
 1 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 57d3e15..8a3325f 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -1507,26 +1507,31 @@ static IDirect3DVertexDeclaration9 *getConvertedDecl(IDirect3DDevice9Impl *This,
 
 static HRESULT WINAPI IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9EX iface, DWORD FVF) {
     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
-    HRESULT hr = S_OK;
+    IDirect3DVertexDeclaration9 *decl;
+    HRESULT hr;
+
     TRACE("(%p) Relay\n" , This);
 
-    EnterCriticalSection(&d3d9_cs);
-    if (0 != FVF) {
-         IDirect3DVertexDeclaration9* pDecl = getConvertedDecl(This, FVF);
+    if (!FVF)
+    {
+        WARN("%#x is not a valid FVF\n", FVF);
+        return D3D_OK;
+    }
 
-         if(!pDecl) {
-             /* Any situation when this should happen, except out of memory? */
-             ERR("Failed to create a converted vertex declaration\n");
-             LeaveCriticalSection(&d3d9_cs);
-             return D3DERR_DRIVERINTERNALERROR;
-         }
+    EnterCriticalSection(&d3d9_cs);
 
-         hr = IDirect3DDevice9Impl_SetVertexDeclaration(iface, pDecl);
-         if (hr != S_OK) {
-             LeaveCriticalSection(&d3d9_cs);
-             return hr;
-         }
+    decl = getConvertedDecl(This, FVF);
+    if (!decl)
+    {
+         /* Any situation when this should happen, except out of memory? */
+         ERR("Failed to create a converted vertex declaration\n");
+         LeaveCriticalSection(&d3d9_cs);
+         return D3DERR_DRIVERINTERNALERROR;
     }
+
+    hr = IDirect3DDevice9Impl_SetVertexDeclaration(iface, decl);
+    if (FAILED(hr)) ERR("Failed to set vertex declaration\n");
+
     LeaveCriticalSection(&d3d9_cs);
 
     return hr;




More information about the wine-cvs mailing list