d3dx8: Initialise temp in D3DXQuaternionInverse to avoid a uninitialised variable...
[wine] / dlls / d3dx8 / d3dxbuffer.c
1 /*
2  * ID3DXBuffer implementation
3  *
4  * Copyright 2002 Raphael Junqueira
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include "config.h"
22 #include "wine/port.h"
23
24 #include <stdarg.h>
25
26 #define COBJMACROS
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winuser.h"
30 #include "wingdi.h"
31 #include "wine/debug.h"
32
33 #include "d3d8.h"
34 #include "d3dx8core_private.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
37
38 /* ID3DXBuffer IUnknown parts follow: */
39 static HRESULT WINAPI ID3DXBufferImpl_QueryInterface(LPD3DXBUFFER iface, REFIID riid, LPVOID* ppobj) {
40   ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
41   
42   if (IsEqualGUID(riid, &IID_IUnknown)
43       || IsEqualGUID(riid, &IID_ID3DXBuffer)) {
44     IUnknown_AddRef(iface);
45     *ppobj = This;
46     return D3D_OK;
47   }
48
49   WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
50   return E_NOINTERFACE;
51 }
52
53 static ULONG WINAPI ID3DXBufferImpl_AddRef(LPD3DXBUFFER iface) {
54   ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
55   ULONG ref = InterlockedIncrement(&This->ref);
56
57   TRACE("(%p) : AddRef from %d\n", This, ref - 1);
58
59   return ref;
60 }
61
62 static ULONG WINAPI ID3DXBufferImpl_Release(LPD3DXBUFFER iface) {
63   ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
64   ULONG ref = InterlockedDecrement(&This->ref);
65
66   TRACE("(%p) : ReleaseRef to %d\n", This, ref);
67
68   if (ref == 0) {
69     HeapFree(GetProcessHeap(), 0, This->buffer);
70     HeapFree(GetProcessHeap(), 0, This);
71   }
72   return ref;
73 }
74
75 /* ID3DXBuffer Interface follow: */
76 static LPVOID WINAPI ID3DXBufferImpl_GetBufferPointer(LPD3DXBUFFER iface) {
77   ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
78   return This->buffer;
79 }
80
81 static DWORD WINAPI ID3DXBufferImpl_GetBufferSize(LPD3DXBUFFER iface) {
82   ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
83   return This->bufferSize;
84 }
85
86 const ID3DXBufferVtbl D3DXBuffer_Vtbl =
87 {
88     ID3DXBufferImpl_QueryInterface,
89     ID3DXBufferImpl_AddRef,
90     ID3DXBufferImpl_Release,
91     ID3DXBufferImpl_GetBufferPointer,
92     ID3DXBufferImpl_GetBufferSize
93 };