[PATCH 1/2] d3drm: Move struct d3drm_texture to header for global access (v2).

Aaryaman Vasishta jem456.vasishta at gmail.com
Mon Mar 21 11:06:45 CDT 2016


Signed-off-by: Aaryaman Vasishta <jem456.vasishta at gmail.com>
---
 dlls/d3drm/d3drm.c         | 91 +++++++++++++++++++++++++++++++++++++++++-----
 dlls/d3drm/d3drm_private.h | 11 +++++-
 dlls/d3drm/meshbuilder.c   |  6 +--
 dlls/d3drm/texture.c       | 19 ++--------
 4 files changed, 99 insertions(+), 28 deletions(-)

diff --git a/dlls/d3drm/d3drm.c b/dlls/d3drm/d3drm.c
index 6d75605..fe33315 100644
--- a/dlls/d3drm/d3drm.c
+++ b/dlls/d3drm/d3drm.c
@@ -3,6 +3,7 @@
  *
  * Copyright 2010, 2012 Christian Costa
  * Copyright 2011 André Hentschel
+ * Copyright 2016 Aaryaman Vasishta
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -192,9 +193,17 @@ static HRESULT WINAPI d3drm1_CreateAnimationSet(IDirect3DRM *iface, IDirect3DRMA
 static HRESULT WINAPI d3drm1_CreateTexture(IDirect3DRM *iface,
         D3DRMIMAGE *image, IDirect3DRMTexture **texture)
 {
+    struct d3drm_texture *object;
+    HRESULT hr;
+
     FIXME("iface %p, image %p, texture %p partial stub.\n", iface, image, texture);
 
-    return Direct3DRMTexture_create(&IID_IDirect3DRMTexture, (IUnknown **)texture);
+    if (FAILED(hr = d3drm_texture_create(&object)))
+        return hr;
+
+    *texture = &object->IDirect3DRMTexture_iface;
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm1_CreateLight(IDirect3DRM *iface,
@@ -402,17 +411,33 @@ static HRESULT WINAPI d3drm1_CreateUserVisual(IDirect3DRM *iface,
 static HRESULT WINAPI d3drm1_LoadTexture(IDirect3DRM *iface,
         const char *filename, IDirect3DRMTexture **texture)
 {
+    struct d3drm_texture *object;
+    HRESULT hr;
+
     FIXME("iface %p, filename %s, texture %p stub!\n", iface, debugstr_a(filename), texture);
 
-    return Direct3DRMTexture_create(&IID_IDirect3DRMTexture, (IUnknown **)texture);
+    if (FAILED(hr = d3drm_texture_create(&object)))
+        return hr;
+
+    *texture = &object->IDirect3DRMTexture_iface;
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm1_LoadTextureFromResource(IDirect3DRM *iface,
         HRSRC resource, IDirect3DRMTexture **texture)
 {
+    struct d3drm_texture *object;
+    HRESULT hr;
+
     FIXME("iface %p, resource %p, texture %p stub!\n", iface, resource, texture);
 
-    return Direct3DRMTexture_create(&IID_IDirect3DRMTexture, (IUnknown **)texture);
+    if (FAILED(hr = d3drm_texture_create(&object)))
+        return hr;
+
+    *texture = &object->IDirect3DRMTexture_iface;
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm1_SetSearchPath(IDirect3DRM *iface, const char *path)
@@ -632,9 +657,17 @@ static HRESULT WINAPI d3drm2_CreateAnimationSet(IDirect3DRM2 *iface, IDirect3DRM
 static HRESULT WINAPI d3drm2_CreateTexture(IDirect3DRM2 *iface,
         D3DRMIMAGE *image, IDirect3DRMTexture2 **texture)
 {
+    struct d3drm_texture *object;
+    HRESULT hr;
+
     FIXME("iface %p, image %p, texture %p partial stub.\n", iface, image, texture);
 
-    return Direct3DRMTexture_create(&IID_IDirect3DRMTexture2, (IUnknown **)texture);
+    if (FAILED(hr = d3drm_texture_create(&object)))
+        return hr;
+
+    *texture = &object->IDirect3DRMTexture2_iface;
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm2_CreateLight(IDirect3DRM2 *iface,
@@ -820,18 +853,34 @@ static HRESULT WINAPI d3drm2_CreateUserVisual(IDirect3DRM2 *iface,
 static HRESULT WINAPI d3drm2_LoadTexture(IDirect3DRM2 *iface,
         const char *filename, IDirect3DRMTexture2 **texture)
 {
+    struct d3drm_texture *object;
+    HRESULT hr;
+
     FIXME("iface %p, filename %s, texture %p stub!\n", iface, debugstr_a(filename), texture);
 
-    return Direct3DRMTexture_create(&IID_IDirect3DRMTexture2, (IUnknown **)texture);
+    if (FAILED(hr = d3drm_texture_create(&object)))
+        return hr;
+
+    *texture = &object->IDirect3DRMTexture2_iface;
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm2_LoadTextureFromResource(IDirect3DRM2 *iface, HMODULE module,
         const char *resource_name, const char *resource_type, IDirect3DRMTexture2 **texture)
 {
+    struct d3drm_texture *object;
+    HRESULT hr;
+
     FIXME("iface %p, resource_name %s, resource_type %s, texture %p stub!\n",
             iface, debugstr_a(resource_name), debugstr_a(resource_type), texture);
 
-    return Direct3DRMTexture_create(&IID_IDirect3DRMTexture2, (IUnknown **)texture);
+    if (FAILED(hr = d3drm_texture_create(&object)))
+        return hr;
+
+    *texture = &object->IDirect3DRMTexture2_iface;
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm2_SetSearchPath(IDirect3DRM2 *iface, const char *path)
@@ -1057,9 +1106,17 @@ static HRESULT WINAPI d3drm3_CreateAnimationSet(IDirect3DRM3 *iface, IDirect3DRM
 static HRESULT WINAPI d3drm3_CreateTexture(IDirect3DRM3 *iface,
         D3DRMIMAGE *image, IDirect3DRMTexture3 **texture)
 {
+    struct d3drm_texture *object;
+    HRESULT hr;
+
     FIXME("iface %p, image %p, texture %p partial stub.\n", iface, image, texture);
 
-    return Direct3DRMTexture_create(&IID_IDirect3DRMTexture3, (IUnknown **)texture);
+    if (FAILED(hr = d3drm_texture_create(&object)))
+        return hr;
+
+    *texture = &object->IDirect3DRMTexture3_iface;
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm3_CreateLight(IDirect3DRM3 *iface,
@@ -1295,18 +1352,34 @@ static HRESULT WINAPI d3drm3_CreateUserVisual(IDirect3DRM3 *iface,
 static HRESULT WINAPI d3drm3_LoadTexture(IDirect3DRM3 *iface,
         const char *filename, IDirect3DRMTexture3 **texture)
 {
+    struct d3drm_texture *object;
+    HRESULT hr;
+
     FIXME("iface %p, filename %s, texture %p stub!\n", iface, debugstr_a(filename), texture);
 
-    return Direct3DRMTexture_create(&IID_IDirect3DRMTexture3, (IUnknown **)texture);
+    if (FAILED(hr = d3drm_texture_create(&object)))
+        return hr;
+
+    *texture = &object->IDirect3DRMTexture3_iface;
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm3_LoadTextureFromResource(IDirect3DRM3 *iface, HMODULE module,
         const char *resource_name, const char *resource_type, IDirect3DRMTexture3 **texture)
 {
+    struct d3drm_texture *object;
+    HRESULT hr;
+
     FIXME("iface %p, module %p, resource_name %s, resource_type %s, texture %p stub!\n",
             iface, module, debugstr_a(resource_name), debugstr_a(resource_type), texture);
 
-    return Direct3DRMTexture_create(&IID_IDirect3DRMTexture3, (IUnknown **)texture);
+    if (FAILED(hr = d3drm_texture_create(&object)))
+        return hr;
+
+    *texture = &object->IDirect3DRMTexture3_iface;
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm3_SetSearchPath(IDirect3DRM3 *iface, const char *path)
diff --git a/dlls/d3drm/d3drm_private.h b/dlls/d3drm/d3drm_private.h
index 34cd913..5452b36 100644
--- a/dlls/d3drm/d3drm_private.h
+++ b/dlls/d3drm/d3drm_private.h
@@ -34,12 +34,22 @@ struct d3drm_object
     struct list destroy_callbacks;
 };
 
+struct d3drm_texture
+{
+    IDirect3DRMTexture IDirect3DRMTexture_iface;
+    IDirect3DRMTexture2 IDirect3DRMTexture2_iface;
+    IDirect3DRMTexture3 IDirect3DRMTexture3_iface;
+    LONG ref;
+    DWORD app_data;
+};
+
 void d3drm_object_init(struct d3drm_object *object) DECLSPEC_HIDDEN;
 HRESULT d3drm_object_add_destroy_callback(struct d3drm_object *object, D3DRMOBJECTCALLBACK cb, void *ctx) DECLSPEC_HIDDEN;
 HRESULT d3drm_object_delete_destroy_callback(struct d3drm_object *object, D3DRMOBJECTCALLBACK cb, void *ctx) DECLSPEC_HIDDEN;
 void d3drm_object_cleanup(IDirect3DRMObject *iface, struct d3drm_object *object) DECLSPEC_HIDDEN;
 
 HRESULT d3drm_device_create(struct d3drm_device **out) DECLSPEC_HIDDEN;
+HRESULT d3drm_texture_create(struct d3drm_texture **texture) DECLSPEC_HIDDEN;
 IDirect3DRMDevice *IDirect3DRMDevice_from_impl(struct d3drm_device *device) DECLSPEC_HIDDEN;
 IDirect3DRMDevice2 *IDirect3DRMDevice2_from_impl(struct d3drm_device *device) DECLSPEC_HIDDEN;
 IDirect3DRMDevice3 *IDirect3DRMDevice3_from_impl(struct d3drm_device *device) DECLSPEC_HIDDEN;
@@ -50,7 +60,6 @@ HRESULT Direct3DRMMesh_create(IDirect3DRMMesh** obj) DECLSPEC_HIDDEN;
 HRESULT Direct3DRMMeshBuilder_create(REFIID riid, IUnknown** ppObj) DECLSPEC_HIDDEN;
 HRESULT Direct3DRMViewport_create(REFIID riid, IUnknown** ppObj) DECLSPEC_HIDDEN;
 HRESULT Direct3DRMMaterial_create(IDirect3DRMMaterial2** ret_iface) DECLSPEC_HIDDEN;
-HRESULT Direct3DRMTexture_create(REFIID riid, IUnknown** ret_iface) DECLSPEC_HIDDEN;
 
 HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *data,
                        D3DRMLOADTEXTURECALLBACK load_texture_proc, void *arg) DECLSPEC_HIDDEN;
diff --git a/dlls/d3drm/meshbuilder.c b/dlls/d3drm/meshbuilder.c
index 6d0b55b..57429a5 100644
--- a/dlls/d3drm/meshbuilder.c
+++ b/dlls/d3drm/meshbuilder.c
@@ -1162,6 +1162,7 @@ HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *pData,
             IDirectXFileObject *child;
             DWORD i = 0;
             float* values;
+            struct d3drm_texture *texture_object;
 
             TRACE("Process MeshMaterialList\n");
 
@@ -1299,13 +1300,12 @@ HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *pData,
                             if (file != INVALID_HANDLE_VALUE)
                             {
                                 CloseHandle(file);
-
-                                hr = Direct3DRMTexture_create(&IID_IDirect3DRMTexture3, (IUnknown**)&This->materials[i].texture);
-                                if (FAILED(hr))
+                                if (FAILED(hr = d3drm_texture_create(&texture_object)))
                                 {
                                     IDirectXFileData_Release(data);
                                     goto end;
                                 }
+                                This->materials[i].texture = &texture_object->IDirect3DRMTexture3_iface;
                             }
                         }
                     }
diff --git a/dlls/d3drm/texture.c b/dlls/d3drm/texture.c
index 080c6f8..1ca7074 100644
--- a/dlls/d3drm/texture.c
+++ b/dlls/d3drm/texture.c
@@ -29,15 +29,6 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
 
-struct d3drm_texture
-{
-    IDirect3DRMTexture IDirect3DRMTexture_iface;
-    IDirect3DRMTexture2 IDirect3DRMTexture2_iface;
-    IDirect3DRMTexture3 IDirect3DRMTexture3_iface;
-    LONG ref;
-    DWORD app_data;
-};
-
 static inline struct d3drm_texture *impl_from_IDirect3DRMTexture(IDirect3DRMTexture *iface)
 {
     return CONTAINING_RECORD(iface, struct d3drm_texture, IDirect3DRMTexture_iface);
@@ -1038,12 +1029,11 @@ static const struct IDirect3DRMTexture3Vtbl d3drm_texture3_vtbl =
     d3drm_texture3_SetValidationCallback,
 };
 
-HRESULT Direct3DRMTexture_create(REFIID riid, IUnknown **out)
+HRESULT d3drm_texture_create(struct d3drm_texture **texture)
 {
     struct d3drm_texture *object;
-    HRESULT hr;
 
-    TRACE("riid %s, out %p.\n", debugstr_guid(riid), out);
+    TRACE("texture %p.\n", texture);
 
     if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
         return E_OUTOFMEMORY;
@@ -1053,8 +1043,7 @@ HRESULT Direct3DRMTexture_create(REFIID riid, IUnknown **out)
     object->IDirect3DRMTexture3_iface.lpVtbl = &d3drm_texture3_vtbl;
     object->ref = 1;
 
-    hr = IDirect3DRMTexture3_QueryInterface(&object->IDirect3DRMTexture3_iface, riid, (void **)out);
-    IDirect3DRMTexture3_Release(&object->IDirect3DRMTexture3_iface);
+    *texture = object;
 
-    return hr;
+    return D3DRM_OK;
 }
-- 
2.3.2 (Apple Git-55)




More information about the wine-patches mailing list