comctl32: Fix the computation of the select bounds item rect
[wine] / dlls / d3d8 / vertexbuffer.c
1 /*
2  * IDirect3DVertexBuffer8 implementation
3  *
4  * Copyright 2005 Oliver Stieber
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 "d3d8_private.h"
23
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
25
26 /* IDirect3DVertexBuffer8 IUnknown parts follow: */
27 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_QueryInterface(LPDIRECT3DVERTEXBUFFER8 iface, REFIID riid, LPVOID *ppobj) {
28     IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
29
30     if (IsEqualGUID(riid, &IID_IUnknown)
31         || IsEqualGUID(riid, &IID_IDirect3DResource8)
32         || IsEqualGUID(riid, &IID_IDirect3DVertexBuffer8)) {
33         IUnknown_AddRef(iface);
34         *ppobj = This;
35         return S_OK;
36     }
37
38     WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
39
40     *ppobj = NULL;
41     return E_NOINTERFACE;
42 }
43
44 static ULONG WINAPI IDirect3DVertexBuffer8Impl_AddRef(LPDIRECT3DVERTEXBUFFER8 iface) {
45     IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
46     ULONG ref = InterlockedIncrement(&This->ref);
47
48     TRACE("(%p) : AddRef from %d\n", This, ref - 1);
49
50     return ref;
51 }
52
53 static ULONG WINAPI IDirect3DVertexBuffer8Impl_Release(LPDIRECT3DVERTEXBUFFER8 iface) {
54     IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
55     ULONG ref = InterlockedDecrement(&This->ref);
56
57     TRACE("(%p) : ReleaseRef to %d\n", This, ref);
58
59     if (ref == 0) {
60         IWineD3DVertexBuffer_Release(This->wineD3DVertexBuffer);
61         IUnknown_Release(This->parentDevice);
62         HeapFree(GetProcessHeap(), 0, This);
63     }
64
65     return ref;
66 }
67
68 /* IDirect3DVertexBuffer8 IDirect3DResource8 Interface follow: */
69 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDevice(LPDIRECT3DVERTEXBUFFER8 iface, IDirect3DDevice8 **ppDevice) {
70     IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
71     TRACE("(%p) Relay\n", This);
72
73     return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
74 }
75
76 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
77     IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
78     TRACE("(%p) Relay\n", This);
79
80     return IWineD3DVertexBuffer_SetPrivateData(This->wineD3DVertexBuffer, refguid, pData, SizeOfData, Flags);
81 }
82
83 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
84     IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
85     TRACE("(%p) Relay\n", This);
86
87     return IWineD3DVertexBuffer_GetPrivateData(This->wineD3DVertexBuffer, refguid, pData, pSizeOfData);
88 }
89
90 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_FreePrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid) {
91     IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
92     TRACE("(%p) Relay\n", This);
93
94     return IWineD3DVertexBuffer_FreePrivateData(This->wineD3DVertexBuffer, refguid);
95 }
96
97 static DWORD WINAPI IDirect3DVertexBuffer8Impl_SetPriority(LPDIRECT3DVERTEXBUFFER8 iface, DWORD PriorityNew) {
98     IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
99     TRACE("(%p) Relay\n", This);
100
101     return IWineD3DVertexBuffer_SetPriority(This->wineD3DVertexBuffer, PriorityNew);
102 }
103
104 static DWORD WINAPI IDirect3DVertexBuffer8Impl_GetPriority(LPDIRECT3DVERTEXBUFFER8 iface) {
105     IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
106     TRACE("(%p) Relay\n", This);
107
108     return IWineD3DVertexBuffer_GetPriority(This->wineD3DVertexBuffer);
109 }
110
111 static void WINAPI IDirect3DVertexBuffer8Impl_PreLoad(LPDIRECT3DVERTEXBUFFER8 iface) {
112     IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
113     TRACE("(%p) Relay\n", This);
114     IWineD3DVertexBuffer_PreLoad(This->wineD3DVertexBuffer);
115
116     return;
117 }
118
119 static D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer8Impl_GetType(LPDIRECT3DVERTEXBUFFER8 iface) {
120     IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
121     TRACE("(%p) Relay\n", This);
122
123     return IWineD3DVertexBuffer_GetType(This->wineD3DVertexBuffer);
124 }
125
126 /* IDirect3DVertexBuffer8 Interface follow: */
127 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_Lock(LPDIRECT3DVERTEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE **ppbData, DWORD Flags) {
128     IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
129     TRACE("(%p) Relay\n", This);
130
131     return IWineD3DVertexBuffer_Lock(This->wineD3DVertexBuffer, OffsetToLock, SizeToLock, ppbData, Flags);
132 }
133
134 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_Unlock(LPDIRECT3DVERTEXBUFFER8 iface) {
135     IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
136     TRACE("(%p) Relay\n", This);
137
138     return IWineD3DVertexBuffer_Unlock(This->wineD3DVertexBuffer);
139 }
140
141 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDesc(LPDIRECT3DVERTEXBUFFER8 iface, D3DVERTEXBUFFER_DESC *pDesc) {
142     IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
143     TRACE("(%p) Relay\n", This);
144
145     return IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer, (WINED3DVERTEXBUFFER_DESC *) pDesc);
146 }
147
148 const IDirect3DVertexBuffer8Vtbl Direct3DVertexBuffer8_Vtbl =
149 {
150     /* IUnknown */
151     IDirect3DVertexBuffer8Impl_QueryInterface,
152     IDirect3DVertexBuffer8Impl_AddRef,
153     IDirect3DVertexBuffer8Impl_Release,
154     /* IDirect3DResource8 */
155     IDirect3DVertexBuffer8Impl_GetDevice,
156     IDirect3DVertexBuffer8Impl_SetPrivateData,
157     IDirect3DVertexBuffer8Impl_GetPrivateData,
158     IDirect3DVertexBuffer8Impl_FreePrivateData,
159     IDirect3DVertexBuffer8Impl_SetPriority,
160     IDirect3DVertexBuffer8Impl_GetPriority,
161     IDirect3DVertexBuffer8Impl_PreLoad,
162     IDirect3DVertexBuffer8Impl_GetType,
163     /* IDirect3DVertexBuffer8 */
164     IDirect3DVertexBuffer8Impl_Lock,
165     IDirect3DVertexBuffer8Impl_Unlock,
166     IDirect3DVertexBuffer8Impl_GetDesc
167 };