dxgi: Add a stub IDXGISurface implementation.

Henri Verbeet hverbeet at codeweavers.com
Thu Jan 15 02:58:44 CST 2009


---
 dlls/dxgi/Makefile.in    |    1 +
 dlls/dxgi/device.c       |   33 +++++++++-
 dlls/dxgi/dxgi_private.h |    8 +++
 dlls/dxgi/surface.c      |  155 ++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 195 insertions(+), 2 deletions(-)
 create mode 100644 dlls/dxgi/surface.c

diff --git a/dlls/dxgi/Makefile.in b/dlls/dxgi/Makefile.in
index 2922473..9215e61 100644
--- a/dlls/dxgi/Makefile.in
+++ b/dlls/dxgi/Makefile.in
@@ -12,6 +12,7 @@ C_SRCS = \
 	dxgi_main.c \
 	factory.c \
 	utils.c \
+	surface.c \
 	swapchain.c
 
 RC_SRCS = version.rc
diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c
index 1b82b2a..69ba3e5 100644
--- a/dlls/dxgi/device.c
+++ b/dlls/dxgi/device.c
@@ -141,10 +141,39 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IDXGIDevice *iface,
         const DXGI_SURFACE_DESC *desc, UINT surface_count, DXGI_USAGE usage,
         const DXGI_SHARED_RESOURCE *shared_resource, IDXGISurface **surface)
 {
-    FIXME("iface %p, desc %p, surface_count %u, usage %#x, shared_resource %p, surface %p stub!\n",
+    struct dxgi_surface *object;
+    HRESULT hr;
+    UINT i;
+
+    FIXME("iface %p, desc %p, surface_count %u, usage %#x, shared_resource %p, surface %p partial stub!\n",
             iface, desc, surface_count, usage, shared_resource, surface);
 
-    return E_NOTIMPL;
+    memset(surface, 0, surface_count * sizeof(*surface));
+    for (i = 0; i < surface_count; ++i)
+    {
+        object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+        if (!object)
+        {
+            ERR("Failed to allocate DXGI surface object memory\n");
+            hr = E_OUTOFMEMORY;
+            goto fail;
+        }
+
+        object->vtbl = &dxgi_surface_vtbl;
+        object->refcount = 1;
+        surface[i] = (IDXGISurface *)object;
+
+        TRACE("Created IDXGISurface %p (%u/%u)\n", object, i + 1, surface_count);
+    }
+
+    return S_OK;
+
+fail:
+    for (i = 0; i < surface_count; ++i)
+    {
+        HeapFree(GetProcessHeap(), 0, surface[i]);
+    }
+    return hr;
 }
 
 static HRESULT STDMETHODCALLTYPE dxgi_device_QueryResourceResidency(IDXGIDevice *iface,
diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h
index 1e8ca51..bb2eebe 100644
--- a/dlls/dxgi/dxgi_private.h
+++ b/dlls/dxgi/dxgi_private.h
@@ -79,6 +79,14 @@ struct dxgi_swapchain
     LONG refcount;
 };
 
+/* IDXGISurface */
+extern const struct IDXGISurfaceVtbl dxgi_surface_vtbl;
+struct dxgi_surface
+{
+    const struct IDXGISurfaceVtbl *vtbl;
+    LONG refcount;
+};
+
 /* Layered device */
 enum dxgi_device_layer_id
 {
diff --git a/dlls/dxgi/surface.c b/dlls/dxgi/surface.c
new file mode 100644
index 0000000..82db08b
--- /dev/null
+++ b/dlls/dxgi/surface.c
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2009 Henri Verbeet for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ */
+
+#include "config.h"
+#include "wine/port.h"
+
+#include "dxgi_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
+
+/* IUnknown methods */
+
+static HRESULT STDMETHODCALLTYPE dxgi_surface_QueryInterface(IDXGISurface *iface, REFIID riid, void **object)
+{
+    TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
+
+    if (IsEqualGUID(riid, &IID_IDXGISurface)
+            || IsEqualGUID(riid, &IID_IDXGIDeviceSubObject)
+            || IsEqualGUID(riid, &IID_IDXGIObject)
+            || IsEqualGUID(riid, &IID_IUnknown))
+    {
+        IUnknown_AddRef(iface);
+        *object = iface;
+        return S_OK;
+    }
+
+    WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
+
+    *object = NULL;
+    return E_NOINTERFACE;
+}
+
+static ULONG STDMETHODCALLTYPE dxgi_surface_AddRef(IDXGISurface *iface)
+{
+    struct dxgi_surface *This = (struct dxgi_surface *)iface;
+    ULONG refcount = InterlockedIncrement(&This->refcount);
+
+    TRACE("%p increasing refcount to %u\n", This, refcount);
+
+    return refcount;
+}
+
+static ULONG STDMETHODCALLTYPE dxgi_surface_Release(IDXGISurface *iface)
+{
+    struct dxgi_surface *This = (struct dxgi_surface *)iface;
+    ULONG refcount = InterlockedDecrement(&This->refcount);
+
+    TRACE("%p decreasing refcount to %u\n", This, refcount);
+
+    if (!refcount)
+    {
+        HeapFree(GetProcessHeap(), 0, This);
+    }
+
+    return refcount;
+}
+
+/* IDXGIObject methods */
+
+static HRESULT STDMETHODCALLTYPE dxgi_surface_SetPrivateData(IDXGISurface *iface,
+        REFGUID guid, UINT data_size, const void *data)
+{
+    FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT STDMETHODCALLTYPE dxgi_surface_SetPrivateDataInterface(IDXGISurface *iface,
+        REFGUID guid, const IUnknown *object)
+{
+    FIXME("iface %p, guid %s, object %p stub!\n", iface, debugstr_guid(guid), object);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT STDMETHODCALLTYPE dxgi_surface_GetPrivateData(IDXGISurface *iface,
+        REFGUID guid, UINT *data_size, void *data)
+{
+    FIXME("iface %p, guid %s, data_size %p, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT STDMETHODCALLTYPE dxgi_surface_GetParent(IDXGISurface *iface, REFIID riid, void **parent)
+{
+    FIXME("iface %p, riid %s, parent %p stub!\n", iface, debugstr_guid(riid), parent);
+
+    return E_NOTIMPL;
+}
+
+/* IDXGIDeviceSubObject methods */
+
+static HRESULT STDMETHODCALLTYPE dxgi_surface_GetDevice(IDXGISurface *iface, REFIID riid, void **device)
+{
+    FIXME("iface %p, riid %s, device %p stub!\n", iface, debugstr_guid(riid), device);
+
+    return E_NOTIMPL;
+}
+
+/* IDXGISurface methods */
+static HRESULT STDMETHODCALLTYPE dxgi_surface_GetDesc(IDXGISurface *iface, DXGI_SURFACE_DESC *desc)
+{
+    FIXME("iface %p, desc %p stub!\n", iface, desc);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT STDMETHODCALLTYPE dxgi_surface_Map(IDXGISurface *iface, DXGI_MAPPED_RECT *mapped_rect, UINT flags)
+{
+    FIXME("iface %p, mapped_rect %p, flags %#x stub!\n", iface, mapped_rect, flags);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT STDMETHODCALLTYPE dxgi_surface_Unmap(IDXGISurface *iface)
+{
+    FIXME("iface %p stub!\n", iface);
+
+    return E_NOTIMPL;
+}
+
+const struct IDXGISurfaceVtbl dxgi_surface_vtbl =
+{
+    /* IUnknown methods */
+    dxgi_surface_QueryInterface,
+    dxgi_surface_AddRef,
+    dxgi_surface_Release,
+    /* IDXGIObject methods */
+    dxgi_surface_SetPrivateData,
+    dxgi_surface_SetPrivateDataInterface,
+    dxgi_surface_GetPrivateData,
+    dxgi_surface_GetParent,
+    /* IDXGIDeviceSubObject methods */
+    dxgi_surface_GetDevice,
+    /* IDXGISurface methods */
+    dxgi_surface_GetDesc,
+    dxgi_surface_Map,
+    dxgi_surface_Unmap,
+};
-- 
1.6.0.6



--------------070805070302020503040304--



More information about the wine-patches mailing list