Henri Verbeet : dxgi: Add a separate function for surface initialization.

Alexandre Julliard julliard at winehq.org
Mon Dec 7 10:26:18 CST 2009


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Mon Dec  7 11:08:38 2009 +0100

dxgi: Add a separate function for surface initialization.

---

 dlls/dxgi/device.c       |   19 +++++++------------
 dlls/dxgi/dxgi_private.h |    4 ++--
 dlls/dxgi/surface.c      |   14 ++++++++++++--
 3 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c
index 8562d67..7860d0c 100644
--- a/dlls/dxgi/device.c
+++ b/dlls/dxgi/device.c
@@ -262,6 +262,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_create_surface(IWineDXGIDevice *ifa
         DXGI_USAGE usage, const DXGI_SHARED_RESOURCE *shared_resource, IUnknown *outer, void **surface)
 {
     struct dxgi_surface *object;
+    HRESULT hr;
 
     FIXME("iface %p, desc %p, usage %#x, shared_resource %p, outer %p, surface %p partial stub!\n",
             iface, desc, usage, shared_resource, outer, surface);
@@ -273,22 +274,16 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_create_surface(IWineDXGIDevice *ifa
         return E_OUTOFMEMORY;
     }
 
-    object->vtbl = &dxgi_surface_vtbl;
-    object->inner_unknown_vtbl = &dxgi_surface_inner_unknown_vtbl;
-    object->refcount = 1;
-
-    if (outer)
-    {
-        object->outer_unknown = outer;
-        *surface = &object->inner_unknown_vtbl;
-    }
-    else
+    hr = dxgi_surface_init(object, outer);
+    if (FAILED(hr))
     {
-        object->outer_unknown = (IUnknown *)&object->inner_unknown_vtbl;
-        *surface = object;
+        WARN("Failed to initialize surface, hr %#x.\n", hr);
+        HeapFree(GetProcessHeap(), 0, object);
+        return hr;
     }
 
     TRACE("Created IDXGISurface %p\n", object);
+    *surface = outer ? (void *)&object->inner_unknown_vtbl : object;
 
     return S_OK;
 }
diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h
index 033168b..69c9f6c 100644
--- a/dlls/dxgi/dxgi_private.h
+++ b/dlls/dxgi/dxgi_private.h
@@ -130,8 +130,6 @@ struct dxgi_swapchain
 };
 
 /* IDXGISurface */
-extern const struct IDXGISurfaceVtbl dxgi_surface_vtbl DECLSPEC_HIDDEN;
-extern const struct IUnknownVtbl dxgi_surface_inner_unknown_vtbl DECLSPEC_HIDDEN;
 struct dxgi_surface
 {
     const struct IDXGISurfaceVtbl *vtbl;
@@ -140,4 +138,6 @@ struct dxgi_surface
     LONG refcount;
 };
 
+HRESULT dxgi_surface_init(struct dxgi_surface *surface, IUnknown *outer) DECLSPEC_HIDDEN;
+
 #endif /* __WINE_DXGI_PRIVATE_H */
diff --git a/dlls/dxgi/surface.c b/dlls/dxgi/surface.c
index bdbeaf3..1e5038b 100644
--- a/dlls/dxgi/surface.c
+++ b/dlls/dxgi/surface.c
@@ -165,7 +165,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_surface_Unmap(IDXGISurface *iface)
     return E_NOTIMPL;
 }
 
-const struct IDXGISurfaceVtbl dxgi_surface_vtbl =
+static const struct IDXGISurfaceVtbl dxgi_surface_vtbl =
 {
     /* IUnknown methods */
     dxgi_surface_QueryInterface,
@@ -184,10 +184,20 @@ const struct IDXGISurfaceVtbl dxgi_surface_vtbl =
     dxgi_surface_Unmap,
 };
 
-const struct IUnknownVtbl dxgi_surface_inner_unknown_vtbl =
+static const struct IUnknownVtbl dxgi_surface_inner_unknown_vtbl =
 {
     /* IUnknown methods */
     dxgi_surface_inner_QueryInterface,
     dxgi_surface_inner_AddRef,
     dxgi_surface_inner_Release,
 };
+
+HRESULT dxgi_surface_init(struct dxgi_surface *surface, IUnknown *outer)
+{
+    surface->vtbl = &dxgi_surface_vtbl;
+    surface->inner_unknown_vtbl = &dxgi_surface_inner_unknown_vtbl;
+    surface->refcount = 1;
+    surface->outer_unknown = outer ? outer : (IUnknown *)&surface->inner_unknown_vtbl;
+
+    return S_OK;
+}




More information about the wine-cvs mailing list