shell32: Fix the file version string of the version resource.
[wine/multimedia.git] / dlls / d3d9 / surface.c
blob6eea19e21b73079cfefff1704b140d1db2a5a1fc
1 /*
2 * IDirect3DSurface9 implementation
4 * Copyright 2002-2005 Jason Edmeades
5 * Raphael Junqueira
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
23 #include "d3d9_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
27 /* IDirect3DSurface9 IUnknown parts follow: */
28 static HRESULT WINAPI IDirect3DSurface9Impl_QueryInterface(LPDIRECT3DSURFACE9 iface, REFIID riid, LPVOID* ppobj) {
29 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
31 if (IsEqualGUID(riid, &IID_IUnknown)
32 || IsEqualGUID(riid, &IID_IDirect3DResource9)
33 || IsEqualGUID(riid, &IID_IDirect3DSurface9)) {
34 IUnknown_AddRef(iface);
35 *ppobj = This;
36 return S_OK;
39 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
40 *ppobj = NULL;
41 return E_NOINTERFACE;
44 static ULONG WINAPI IDirect3DSurface9Impl_AddRef(LPDIRECT3DSURFACE9 iface) {
45 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
46 IUnknown *containerParent = NULL;
48 TRACE("(%p)\n", This);
50 IWineD3DSurface_GetContainerParent(This->wineD3DSurface, &containerParent);
51 if (containerParent) {
52 /* Forward to the containerParent */
53 TRACE("(%p) : Forwarding to %p\n", This, containerParent);
54 return IUnknown_AddRef(containerParent);
55 } else {
56 /* No container, handle our own refcounting */
57 ULONG ref = InterlockedIncrement(&This->ref);
58 TRACE("(%p) : AddRef from %ld\n", This, ref - 1);
60 return ref;
65 static ULONG WINAPI IDirect3DSurface9Impl_Release(LPDIRECT3DSURFACE9 iface) {
66 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
67 IUnknown *containerParent = NULL;
69 TRACE("(%p)\n", This);
71 IWineD3DSurface_GetContainerParent(This->wineD3DSurface, &containerParent);
72 if (containerParent) {
73 /* Forward to the containerParent */
74 TRACE("(%p) : Forwarding to %p\n", This, containerParent);
75 return IUnknown_Release(containerParent);
76 } else {
77 /* No container, handle our own refcounting */
78 ULONG ref = InterlockedDecrement(&This->ref);
79 TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
81 if (ref == 0) {
82 IWineD3DSurface_Release(This->wineD3DSurface);
83 if (This->parentDevice) IUnknown_Release(This->parentDevice);
84 HeapFree(GetProcessHeap(), 0, This);
87 return ref;
91 /* IDirect3DSurface9 IDirect3DResource9 Interface follow: */
92 static HRESULT WINAPI IDirect3DSurface9Impl_GetDevice(LPDIRECT3DSURFACE9 iface, IDirect3DDevice9** ppDevice) {
93 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
94 return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
97 static HRESULT WINAPI IDirect3DSurface9Impl_SetPrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
98 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
99 TRACE("(%p) Relay\n", This);
100 return IWineD3DSurface_SetPrivateData(This->wineD3DSurface, refguid, pData, SizeOfData, Flags);
103 static HRESULT WINAPI IDirect3DSurface9Impl_GetPrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
104 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
105 TRACE("(%p) Relay\n", This);
106 return IWineD3DSurface_GetPrivateData(This->wineD3DSurface, refguid, pData, pSizeOfData);
109 static HRESULT WINAPI IDirect3DSurface9Impl_FreePrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid) {
110 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
111 TRACE("(%p) Relay\n", This);
112 return IWineD3DSurface_FreePrivateData(This->wineD3DSurface, refguid);
115 static DWORD WINAPI IDirect3DSurface9Impl_SetPriority(LPDIRECT3DSURFACE9 iface, DWORD PriorityNew) {
116 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
117 TRACE("(%p) Relay\n", This);
118 return IWineD3DSurface_SetPriority(This->wineD3DSurface, PriorityNew);
121 static DWORD WINAPI IDirect3DSurface9Impl_GetPriority(LPDIRECT3DSURFACE9 iface) {
122 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
123 TRACE("(%p) Relay\n", This);
124 return IWineD3DSurface_GetPriority(This->wineD3DSurface);
127 static void WINAPI IDirect3DSurface9Impl_PreLoad(LPDIRECT3DSURFACE9 iface) {
128 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
129 TRACE("(%p) Relay\n", This);
130 IWineD3DSurface_PreLoad(This->wineD3DSurface);
131 return ;
134 static D3DRESOURCETYPE WINAPI IDirect3DSurface9Impl_GetType(LPDIRECT3DSURFACE9 iface) {
135 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
136 TRACE("(%p) Relay\n", This);
137 return IWineD3DSurface_GetType(This->wineD3DSurface);
140 /* IDirect3DSurface9 Interface follow: */
141 static HRESULT WINAPI IDirect3DSurface9Impl_GetContainer(LPDIRECT3DSURFACE9 iface, REFIID riid, void** ppContainer) {
142 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
143 IWineD3DBase *wineD3DContainer = NULL;
144 IUnknown *wineD3DContainerParent = NULL;
145 HRESULT res;
147 TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer);
149 if (!ppContainer) {
150 ERR("Called without a valid ppContainer\n");
153 /* Get the WineD3D container. */
154 res = IWineD3DSurface_GetContainer(This->wineD3DSurface, &IID_IWineD3DBase, (void **)&wineD3DContainer);
155 if (res != D3D_OK) return res;
157 if (!wineD3DContainer) {
158 ERR("IWineD3DSurface_GetContainer should never return NULL\n");
161 /* Get the parent */
162 IWineD3DBase_GetParent(wineD3DContainer, &wineD3DContainerParent);
163 IUnknown_Release(wineD3DContainer);
165 if (!wineD3DContainerParent) {
166 ERR("IWineD3DBase_GetParent should never return NULL\n");
169 /* Now, query the interface of the parent for the riid */
170 res = IUnknown_QueryInterface(wineD3DContainerParent, riid, ppContainer);
171 IUnknown_Release(wineD3DContainerParent);
173 TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
175 return res;
178 static HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3DSURFACE_DESC* pDesc) {
179 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
180 WINED3DSURFACE_DESC wined3ddesc;
181 UINT tmpInt = -1;
182 TRACE("(%p) Relay\n", This);
184 /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
185 wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
186 wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
187 wined3ddesc.Usage = &pDesc->Usage;
188 wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
189 wined3ddesc.Size = &tmpInt;
190 wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
191 wined3ddesc.MultiSampleQuality = &pDesc->MultiSampleQuality;
192 wined3ddesc.Width = &pDesc->Width;
193 wined3ddesc.Height = &pDesc->Height;
195 return IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
198 static HRESULT WINAPI IDirect3DSurface9Impl_LockRect(LPDIRECT3DSURFACE9 iface, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
199 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
200 TRACE("(%p) Relay\n", This);
201 TRACE("(%p) calling IWineD3DSurface_LockRect %p %p %p %ld\n", This, This->wineD3DSurface, pLockedRect, pRect, Flags);
202 return IWineD3DSurface_LockRect(This->wineD3DSurface, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
205 static HRESULT WINAPI IDirect3DSurface9Impl_UnlockRect(LPDIRECT3DSURFACE9 iface) {
206 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
207 TRACE("(%p) Relay\n", This);
208 return IWineD3DSurface_UnlockRect(This->wineD3DSurface);
211 static HRESULT WINAPI IDirect3DSurface9Impl_GetDC(LPDIRECT3DSURFACE9 iface, HDC* phdc) {
212 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
213 TRACE("(%p) Relay\n", This);
214 return IWineD3DSurface_GetDC(This->wineD3DSurface, phdc);
217 static HRESULT WINAPI IDirect3DSurface9Impl_ReleaseDC(LPDIRECT3DSURFACE9 iface, HDC hdc) {
218 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
219 TRACE("(%p) Relay\n", This);
220 return IWineD3DSurface_ReleaseDC(This->wineD3DSurface, hdc);
224 const IDirect3DSurface9Vtbl Direct3DSurface9_Vtbl =
226 /* IUnknown */
227 IDirect3DSurface9Impl_QueryInterface,
228 IDirect3DSurface9Impl_AddRef,
229 IDirect3DSurface9Impl_Release,
230 /* IDirect3DResource9 */
231 IDirect3DSurface9Impl_GetDevice,
232 IDirect3DSurface9Impl_SetPrivateData,
233 IDirect3DSurface9Impl_GetPrivateData,
234 IDirect3DSurface9Impl_FreePrivateData,
235 IDirect3DSurface9Impl_SetPriority,
236 IDirect3DSurface9Impl_GetPriority,
237 IDirect3DSurface9Impl_PreLoad,
238 IDirect3DSurface9Impl_GetType,
239 /* IDirect3DSurface9 */
240 IDirect3DSurface9Impl_GetContainer,
241 IDirect3DSurface9Impl_GetDesc,
242 IDirect3DSurface9Impl_LockRect,
243 IDirect3DSurface9Impl_UnlockRect,
244 IDirect3DSurface9Impl_GetDC,
245 IDirect3DSurface9Impl_ReleaseDC