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

Henri Verbeet hverbeet at codeweavers.com
Fri Mar 6 01:43:49 CST 2009


---
 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;
-- 
1.6.0.6



--------------060701030403030202080406--



More information about the wine-patches mailing list