Remove bFirstPain funky optimization, it is causing too much grief.
[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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22 #include "wine/port.h"
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "wingdi.h"
28 #include "wine/debug.h"
29
30 #include "d3d8.h"
31 #include "d3dx8core_private.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
34
35 /* ID3DXBuffer IUnknown parts follow: */
36 HRESULT WINAPI ID3DXBufferImpl_QueryInterface(LPD3DXBUFFER iface, REFIID riid, LPVOID* ppobj) {
37   ICOM_THIS(ID3DXBufferImpl,iface);
38   
39   if (IsEqualGUID(riid, &IID_IUnknown)
40       || IsEqualGUID(riid, &IID_ID3DXBuffer)) {
41     ID3DXBufferImpl_AddRef(iface);
42     *ppobj = This;
43     return D3D_OK;
44   }
45
46   WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
47   return E_NOINTERFACE;
48 }
49
50 ULONG WINAPI ID3DXBufferImpl_AddRef(LPD3DXBUFFER iface) {
51   ICOM_THIS(ID3DXBufferImpl,iface);
52   TRACE("(%p) : AddRef from %ld\n", This, This->ref);
53   return ++(This->ref);
54 }
55
56 ULONG WINAPI ID3DXBufferImpl_Release(LPD3DXBUFFER iface) {
57   ICOM_THIS(ID3DXBufferImpl,iface);
58   ULONG ref = --This->ref;
59   TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
60   if (ref == 0) {
61     if (NULL != This->buffer) HeapFree(GetProcessHeap(), 0, This->buffer);
62     HeapFree(GetProcessHeap(), 0, This);
63   }
64   return ref;
65 }
66
67 /* ID3DXBuffer Interface follow: */
68 LPVOID WINAPI ID3DXBufferImpl_GetBufferPointer(LPD3DXBUFFER iface) {
69   ICOM_THIS(ID3DXBufferImpl,iface);
70   return This->buffer;
71 }
72
73 DWORD WINAPI ID3DXBufferImpl_GetBufferSize(LPD3DXBUFFER iface) {
74   ICOM_THIS(ID3DXBufferImpl,iface);
75   return This->bufferSize;
76 }
77
78 ICOM_VTABLE(ID3DXBuffer) D3DXBuffer_Vtbl =
79 {
80     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
81     ID3DXBufferImpl_QueryInterface,
82     ID3DXBufferImpl_AddRef,
83     ID3DXBufferImpl_Release,
84     ID3DXBufferImpl_GetBufferPointer,
85     ID3DXBufferImpl_GetBufferSize
86 };