Michael Stefaniuc : d3dx9_36: COM cleanup for the ID3DXMatrixStack iface.

Alexandre Julliard julliard at winehq.org
Thu Jan 27 12:43:19 CST 2011


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

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Thu Jan 27 00:32:20 2011 +0100

d3dx9_36: COM cleanup for the ID3DXMatrixStack iface.

---

 dlls/d3dx9_36/d3dx9_36_private.h |   13 ---------
 dlls/d3dx9_36/math.c             |   56 ++++++++++++++++++++++++-------------
 2 files changed, 36 insertions(+), 33 deletions(-)

diff --git a/dlls/d3dx9_36/d3dx9_36_private.h b/dlls/d3dx9_36/d3dx9_36_private.h
index f19a2fe..5632ae1 100644
--- a/dlls/d3dx9_36/d3dx9_36_private.h
+++ b/dlls/d3dx9_36/d3dx9_36_private.h
@@ -50,19 +50,6 @@ HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, LPVOID *buffer,
 const PixelFormatDesc *get_format_info(D3DFORMAT format);
 const PixelFormatDesc *get_format_info_idx(int idx);
 
-/* ID3DXMatrixStack */
-typedef struct ID3DXMatrixStackImpl
-{
-  /* IUnknown fields */
-  const ID3DXMatrixStackVtbl *lpVtbl;
-  LONG                   ref;
-
-  /* ID3DXMatrixStack fields */
-  unsigned int current;
-  unsigned int stack_size;
-  D3DXMATRIX *stack;
-} ID3DXMatrixStackImpl;
-
 /* ID3DXMesh */
 typedef struct ID3DXMeshImpl
 {
diff --git a/dlls/d3dx9_36/math.c b/dlls/d3dx9_36/math.c
index eb29573..fdb5f92 100644
--- a/dlls/d3dx9_36/math.c
+++ b/dlls/d3dx9_36/math.c
@@ -35,6 +35,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
 
 static const ID3DXMatrixStackVtbl ID3DXMatrixStack_Vtbl;
 
+typedef struct ID3DXMatrixStackImpl
+{
+  ID3DXMatrixStack ID3DXMatrixStack_iface;
+  LONG ref;
+
+  unsigned int current;
+  unsigned int stack_size;
+  D3DXMATRIX *stack;
+} ID3DXMatrixStackImpl;
+
+
 /*_________________D3DXColor____________________*/
 
 D3DXCOLOR* WINAPI D3DXColorAdjustContrast(D3DXCOLOR *pout, CONST D3DXCOLOR *pc, FLOAT s)
@@ -762,7 +773,7 @@ HRESULT WINAPI D3DXCreateMatrixStack(DWORD flags, LPD3DXMATRIXSTACK* ppstack)
      *ppstack = NULL;
      return E_OUTOFMEMORY;
     }
-    object->lpVtbl = &ID3DXMatrixStack_Vtbl;
+    object->ID3DXMatrixStack_iface.lpVtbl = &ID3DXMatrixStack_Vtbl;
     object->ref = 1;
 
     object->stack = HeapAlloc(GetProcessHeap(), 0, INITIAL_STACK_SIZE * sizeof(D3DXMATRIX));
@@ -779,13 +790,18 @@ HRESULT WINAPI D3DXCreateMatrixStack(DWORD flags, LPD3DXMATRIXSTACK* ppstack)
 
     TRACE("Created matrix stack %p\n", object);
 
-    *ppstack = (LPD3DXMATRIXSTACK)object;
+    *ppstack = &object->ID3DXMatrixStack_iface;
     return D3D_OK;
 }
 
+static inline ID3DXMatrixStackImpl *impl_from_ID3DXMatrixStack(ID3DXMatrixStack *iface)
+{
+  return CONTAINING_RECORD(iface, ID3DXMatrixStackImpl, ID3DXMatrixStack_iface);
+}
+
 static HRESULT WINAPI ID3DXMatrixStackImpl_QueryInterface(ID3DXMatrixStack *iface, REFIID riid, void **ppobj)
 {
-    ID3DXMatrixStackImpl *This = (ID3DXMatrixStackImpl *)iface;
+    ID3DXMatrixStackImpl *This = impl_from_ID3DXMatrixStack(iface);
     if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ID3DXMatrixStack))
     {
      ID3DXMatrixStack_AddRef(iface);
@@ -799,7 +815,7 @@ static HRESULT WINAPI ID3DXMatrixStackImpl_QueryInterface(ID3DXMatrixStack *ifac
 
 static ULONG WINAPI ID3DXMatrixStackImpl_AddRef(ID3DXMatrixStack *iface)
 {
-    ID3DXMatrixStackImpl *This = (ID3DXMatrixStackImpl *)iface;
+    ID3DXMatrixStackImpl *This = impl_from_ID3DXMatrixStack(iface);
     ULONG ref = InterlockedIncrement(&This->ref);
     TRACE("(%p) : AddRef from %d\n", This, ref - 1);
     return ref;
@@ -807,7 +823,7 @@ static ULONG WINAPI ID3DXMatrixStackImpl_AddRef(ID3DXMatrixStack *iface)
 
 static ULONG WINAPI ID3DXMatrixStackImpl_Release(ID3DXMatrixStack* iface)
 {
-    ID3DXMatrixStackImpl *This = (ID3DXMatrixStackImpl *)iface;
+    ID3DXMatrixStackImpl *This = impl_from_ID3DXMatrixStack(iface);
     ULONG ref = InterlockedDecrement(&This->ref);
     if (!ref)
     {
@@ -820,7 +836,7 @@ static ULONG WINAPI ID3DXMatrixStackImpl_Release(ID3DXMatrixStack* iface)
 
 static D3DXMATRIX* WINAPI ID3DXMatrixStackImpl_GetTop(ID3DXMatrixStack *iface)
 {
-    ID3DXMatrixStackImpl *This = (ID3DXMatrixStackImpl *)iface;
+    ID3DXMatrixStackImpl *This = impl_from_ID3DXMatrixStack(iface);
 
     TRACE("iface %p\n", iface);
 
@@ -829,7 +845,7 @@ static D3DXMATRIX* WINAPI ID3DXMatrixStackImpl_GetTop(ID3DXMatrixStack *iface)
 
 static HRESULT WINAPI ID3DXMatrixStackImpl_LoadIdentity(ID3DXMatrixStack *iface)
 {
-    ID3DXMatrixStackImpl *This = (ID3DXMatrixStackImpl *)iface;
+    ID3DXMatrixStackImpl *This = impl_from_ID3DXMatrixStack(iface);
 
     TRACE("iface %p\n", iface);
 
@@ -840,7 +856,7 @@ static HRESULT WINAPI ID3DXMatrixStackImpl_LoadIdentity(ID3DXMatrixStack *iface)
 
 static HRESULT WINAPI ID3DXMatrixStackImpl_LoadMatrix(ID3DXMatrixStack *iface, CONST D3DXMATRIX *pm)
 {
-    ID3DXMatrixStackImpl *This = (ID3DXMatrixStackImpl *)iface;
+    ID3DXMatrixStackImpl *This = impl_from_ID3DXMatrixStack(iface);
 
     TRACE("iface %p\n", iface);
 
@@ -851,7 +867,7 @@ static HRESULT WINAPI ID3DXMatrixStackImpl_LoadMatrix(ID3DXMatrixStack *iface, C
 
 static HRESULT WINAPI ID3DXMatrixStackImpl_MultMatrix(ID3DXMatrixStack *iface, CONST D3DXMATRIX *pm)
 {
-    ID3DXMatrixStackImpl *This = (ID3DXMatrixStackImpl *)iface;
+    ID3DXMatrixStackImpl *This = impl_from_ID3DXMatrixStack(iface);
 
     TRACE("iface %p\n", iface);
 
@@ -862,7 +878,7 @@ static HRESULT WINAPI ID3DXMatrixStackImpl_MultMatrix(ID3DXMatrixStack *iface, C
 
 static HRESULT WINAPI ID3DXMatrixStackImpl_MultMatrixLocal(ID3DXMatrixStack *iface, CONST D3DXMATRIX *pm)
 {
-    ID3DXMatrixStackImpl *This = (ID3DXMatrixStackImpl *)iface;
+    ID3DXMatrixStackImpl *This = impl_from_ID3DXMatrixStack(iface);
 
     TRACE("iface %p\n", iface);
 
@@ -873,7 +889,7 @@ static HRESULT WINAPI ID3DXMatrixStackImpl_MultMatrixLocal(ID3DXMatrixStack *ifa
 
 static HRESULT WINAPI ID3DXMatrixStackImpl_Pop(ID3DXMatrixStack *iface)
 {
-    ID3DXMatrixStackImpl *This = (ID3DXMatrixStackImpl *)iface;
+    ID3DXMatrixStackImpl *This = impl_from_ID3DXMatrixStack(iface);
 
     TRACE("iface %p\n", iface);
 
@@ -901,7 +917,7 @@ static HRESULT WINAPI ID3DXMatrixStackImpl_Pop(ID3DXMatrixStack *iface)
 
 static HRESULT WINAPI ID3DXMatrixStackImpl_Push(ID3DXMatrixStack *iface)
 {
-    ID3DXMatrixStackImpl *This = (ID3DXMatrixStackImpl *)iface;
+    ID3DXMatrixStackImpl *This = impl_from_ID3DXMatrixStack(iface);
 
     TRACE("iface %p\n", iface);
 
@@ -929,7 +945,7 @@ static HRESULT WINAPI ID3DXMatrixStackImpl_Push(ID3DXMatrixStack *iface)
 static HRESULT WINAPI ID3DXMatrixStackImpl_RotateAxis(ID3DXMatrixStack *iface, CONST D3DXVECTOR3 *pv, FLOAT angle)
 {
     D3DXMATRIX temp;
-    ID3DXMatrixStackImpl *This = (ID3DXMatrixStackImpl *)iface;
+    ID3DXMatrixStackImpl *This = impl_from_ID3DXMatrixStack(iface);
 
     TRACE("iface %p\n", iface);
 
@@ -942,7 +958,7 @@ static HRESULT WINAPI ID3DXMatrixStackImpl_RotateAxis(ID3DXMatrixStack *iface, C
 static HRESULT WINAPI ID3DXMatrixStackImpl_RotateAxisLocal(ID3DXMatrixStack *iface, CONST D3DXVECTOR3 *pv, FLOAT angle)
 {
     D3DXMATRIX temp;
-    ID3DXMatrixStackImpl *This = (ID3DXMatrixStackImpl *)iface;
+    ID3DXMatrixStackImpl *This = impl_from_ID3DXMatrixStack(iface);
 
     TRACE("iface %p\n", iface);
 
@@ -955,7 +971,7 @@ static HRESULT WINAPI ID3DXMatrixStackImpl_RotateAxisLocal(ID3DXMatrixStack *ifa
 static HRESULT WINAPI ID3DXMatrixStackImpl_RotateYawPitchRoll(ID3DXMatrixStack *iface, FLOAT x, FLOAT y, FLOAT z)
 {
     D3DXMATRIX temp;
-    ID3DXMatrixStackImpl *This = (ID3DXMatrixStackImpl *)iface;
+    ID3DXMatrixStackImpl *This = impl_from_ID3DXMatrixStack(iface);
 
     TRACE("iface %p\n", iface);
 
@@ -968,7 +984,7 @@ static HRESULT WINAPI ID3DXMatrixStackImpl_RotateYawPitchRoll(ID3DXMatrixStack *
 static HRESULT WINAPI ID3DXMatrixStackImpl_RotateYawPitchRollLocal(ID3DXMatrixStack *iface, FLOAT x, FLOAT y, FLOAT z)
 {
     D3DXMATRIX temp;
-    ID3DXMatrixStackImpl *This = (ID3DXMatrixStackImpl *)iface;
+    ID3DXMatrixStackImpl *This = impl_from_ID3DXMatrixStack(iface);
 
     TRACE("iface %p\n", iface);
 
@@ -981,7 +997,7 @@ static HRESULT WINAPI ID3DXMatrixStackImpl_RotateYawPitchRollLocal(ID3DXMatrixSt
 static HRESULT WINAPI ID3DXMatrixStackImpl_Scale(ID3DXMatrixStack *iface, FLOAT x, FLOAT y, FLOAT z)
 {
     D3DXMATRIX temp;
-    ID3DXMatrixStackImpl *This = (ID3DXMatrixStackImpl *)iface;
+    ID3DXMatrixStackImpl *This = impl_from_ID3DXMatrixStack(iface);
 
     TRACE("iface %p\n", iface);
 
@@ -994,7 +1010,7 @@ static HRESULT WINAPI ID3DXMatrixStackImpl_Scale(ID3DXMatrixStack *iface, FLOAT
 static HRESULT WINAPI ID3DXMatrixStackImpl_ScaleLocal(ID3DXMatrixStack *iface, FLOAT x, FLOAT y, FLOAT z)
 {
     D3DXMATRIX temp;
-    ID3DXMatrixStackImpl *This = (ID3DXMatrixStackImpl *)iface;
+    ID3DXMatrixStackImpl *This = impl_from_ID3DXMatrixStack(iface);
 
     TRACE("iface %p\n", iface);
 
@@ -1007,7 +1023,7 @@ static HRESULT WINAPI ID3DXMatrixStackImpl_ScaleLocal(ID3DXMatrixStack *iface, F
 static HRESULT WINAPI ID3DXMatrixStackImpl_Translate(ID3DXMatrixStack *iface, FLOAT x, FLOAT y, FLOAT z)
 {
     D3DXMATRIX temp;
-    ID3DXMatrixStackImpl *This = (ID3DXMatrixStackImpl *)iface;
+    ID3DXMatrixStackImpl *This = impl_from_ID3DXMatrixStack(iface);
 
     TRACE("iface %p\n", iface);
 
@@ -1020,7 +1036,7 @@ static HRESULT WINAPI ID3DXMatrixStackImpl_Translate(ID3DXMatrixStack *iface, FL
 static HRESULT WINAPI ID3DXMatrixStackImpl_TranslateLocal(ID3DXMatrixStack *iface, FLOAT x, FLOAT y, FLOAT z)
 {
     D3DXMATRIX temp;
-    ID3DXMatrixStackImpl *This = (ID3DXMatrixStackImpl *)iface;
+    ID3DXMatrixStackImpl *This = impl_from_ID3DXMatrixStack(iface);
 
     TRACE("iface %p\n", iface);
 




More information about the wine-cvs mailing list