[PATCH 1/5] d3dx9_36: Implement D3DXFileCreate. (try 4)
Christian Costa
titan.costa at gmail.com
Wed Oct 24 15:39:28 CDT 2012
Try 4:
- Remove HEAP_ZERO_MEMORY when allocate DXFile object
- Turn some ERR into WARN
- Fix IDirectXFileData_Release
Try 3:
- use sizeof(*object) instead of sizeof(struct)
- fix style in patch 4
Try 2:
- fix unconsistancy in the patches serie Rico spotted
- replace LP stuff spotted by Jacek
- fix GUID affectation
---
dlls/d3dx9_36/Makefile.in | 3 +
dlls/d3dx9_36/d3dx9_36.spec | 2 -
dlls/d3dx9_36/xfile.c | 148 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 151 insertions(+), 2 deletions(-)
create mode 100644 dlls/d3dx9_36/xfile.c
diff --git a/dlls/d3dx9_36/Makefile.in b/dlls/d3dx9_36/Makefile.in
index 7bd96a9..1875e9a 100644
--- a/dlls/d3dx9_36/Makefile.in
+++ b/dlls/d3dx9_36/Makefile.in
@@ -17,7 +17,8 @@ C_SRCS = \
surface.c \
texture.c \
util.c \
- volume.c
+ volume.c \
+ xfile.c
RC_SRCS = version.rc
diff --git a/dlls/d3dx9_36/d3dx9_36.spec b/dlls/d3dx9_36/d3dx9_36.spec
index ac1d208..a89ab29 100644
--- a/dlls/d3dx9_36/d3dx9_36.spec
+++ b/dlls/d3dx9_36/d3dx9_36.spec
@@ -121,7 +121,7 @@
@ stdcall D3DXDeclaratorFromFVF(long ptr)
@ stub D3DXDisassembleEffect(ptr long ptr)
@ stub D3DXDisassembleShader(ptr long ptr ptr)
-@ stub D3DXFileCreate(ptr)
+@ stdcall D3DXFileCreate(ptr)
@ stdcall D3DXFillCubeTexture(ptr ptr ptr)
@ stub D3DXFillCubeTextureTX(ptr ptr)
@ stdcall D3DXFillTexture(ptr ptr ptr)
diff --git a/dlls/d3dx9_36/xfile.c b/dlls/d3dx9_36/xfile.c
new file mode 100644
index 0000000..a510d03
--- /dev/null
+++ b/dlls/d3dx9_36/xfile.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2012 Christian Costa
+ *
+ * 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 "wine/debug.h"
+
+#include "d3dx9.h"
+#include "d3dx9xof.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
+
+typedef struct {
+ ID3DXFile ID3DXFile_iface;
+ LONG ref;
+} ID3DXFileImpl;
+
+
+static inline ID3DXFileImpl* impl_from_ID3DXFile(ID3DXFile *iface)
+{
+ return CONTAINING_RECORD(iface, ID3DXFileImpl, ID3DXFile_iface);
+}
+
+
+/*** IUnknown methods ***/
+
+static HRESULT WINAPI ID3DXFileImpl_QueryInterface(ID3DXFile *iface, REFIID riid, void **ret_iface)
+{
+ TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ret_iface);
+
+ if (IsEqualGUID(riid, &IID_IUnknown) ||
+ IsEqualGUID(riid, &IID_ID3DXFile))
+ {
+ iface->lpVtbl->AddRef(iface);
+ *ret_iface = iface;
+ return S_OK;
+ }
+
+ WARN("(%p)->(%s, %p), not found\n", iface, debugstr_guid(riid), ret_iface);
+ *ret_iface = NULL;
+ return E_NOINTERFACE;
+}
+
+
+static ULONG WINAPI ID3DXFileImpl_AddRef(ID3DXFile *iface)
+{
+ ID3DXFileImpl *This = impl_from_ID3DXFile(iface);
+ ULONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p)->(): new ref %d\n", iface, ref);
+
+ return ref;
+}
+
+
+static ULONG WINAPI ID3DXFileImpl_Release(ID3DXFile *iface)
+{
+ ID3DXFileImpl *This = impl_from_ID3DXFile(iface);
+ ULONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p)->(): new ref %d\n", iface, ref);
+
+ if (!ref)
+ HeapFree(GetProcessHeap(), 0, This);
+
+ return ref;
+}
+
+
+/*** ID3DXFile methods ***/
+
+static HRESULT WINAPI ID3DXFileImpl_CreateEnumObject(ID3DXFile *iface, const void *source, D3DXF_FILELOADOPTIONS options, ID3DXFileEnumObject **enum_object)
+{
+ FIXME("(%p)->(%p, %x, %p): stub\n", iface, source, options, enum_object);
+
+ return E_NOTIMPL;
+}
+
+
+static HRESULT WINAPI ID3DXFileImpl_CreateSaveObject(ID3DXFile *iface, const void *data, D3DXF_FILESAVEOPTIONS options, D3DXF_FILEFORMAT format, ID3DXFileSaveObject **save_object)
+{
+ FIXME("(%p)->(%p, %x, %u, %p): stub\n", iface, data, options, format, save_object);
+
+ return E_NOTIMPL;
+}
+
+
+static HRESULT WINAPI ID3DXFileImpl_RegisterTemplates(ID3DXFile *iface, const void *data, SIZE_T size)
+{
+ FIXME("(%p)->(%p, %lu): stub\n", iface, data, size);
+
+ return E_NOTIMPL;
+}
+
+
+static HRESULT WINAPI ID3DXFileImpl_RegisterEnumTemplates(ID3DXFile *iface, ID3DXFileEnumObject *enum_object)
+{
+ FIXME("(%p)->(%p): stub\n", iface, enum_object);
+
+ return E_NOTIMPL;
+}
+
+
+static const ID3DXFileVtbl ID3DXFile_Vtbl =
+{
+ ID3DXFileImpl_QueryInterface,
+ ID3DXFileImpl_AddRef,
+ ID3DXFileImpl_Release,
+ ID3DXFileImpl_CreateEnumObject,
+ ID3DXFileImpl_CreateSaveObject,
+ ID3DXFileImpl_RegisterTemplates,
+ ID3DXFileImpl_RegisterEnumTemplates
+};
+
+HRESULT WINAPI D3DXFileCreate(ID3DXFile **dxfile)
+{
+ ID3DXFileImpl *object;
+
+ TRACE("(%p)\n", dxfile);
+
+ object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object));
+ if (!object)
+ {
+ ERR("Out of memory\n");
+ return E_OUTOFMEMORY;
+ }
+
+ object->ID3DXFile_iface.lpVtbl = &ID3DXFile_Vtbl;
+ object->ref = 1;
+
+ *dxfile = &object->ID3DXFile_iface;
+
+ return S_OK;
+}
More information about the wine-patches
mailing list