2 * IDirect3DSurface9 implementation
4 * Copyright 2002-2005 Jason Edmeades
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "d3d9_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
27 /* IDirect3DSurface9 IUnknown parts follow: */
28 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 IDirect3DSurface9Impl_AddRef(iface);
39 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
43 ULONG WINAPI IDirect3DSurface9Impl_AddRef(LPDIRECT3DSURFACE9 iface) {
44 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
45 ULONG ref = InterlockedIncrement(&This->ref);
47 TRACE("(%p) : AddRef from %ld\n", This, ref - 1);
52 ULONG WINAPI IDirect3DSurface9Impl_Release(LPDIRECT3DSURFACE9 iface) {
53 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
54 ULONG ref = InterlockedDecrement(&This->ref);
56 TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
59 IWineD3DSurface_Release(This->wineD3DSurface);
60 HeapFree(GetProcessHeap(), 0, This);
65 /* IDirect3DSurface9 IDirect3DResource9 Interface follow: */
66 HRESULT WINAPI IDirect3DSurface9Impl_GetDevice(LPDIRECT3DSURFACE9 iface, IDirect3DDevice9** ppDevice) {
67 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
68 return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
71 HRESULT WINAPI IDirect3DSurface9Impl_SetPrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
72 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
73 return IWineD3DSurface_SetPrivateData(This->wineD3DSurface, refguid, pData, SizeOfData, Flags);
76 HRESULT WINAPI IDirect3DSurface9Impl_GetPrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
77 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
78 return IWineD3DSurface_GetPrivateData(This->wineD3DSurface, refguid, pData, pSizeOfData);
81 HRESULT WINAPI IDirect3DSurface9Impl_FreePrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid) {
82 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
83 return IWineD3DSurface_FreePrivateData(This->wineD3DSurface, refguid);
86 DWORD WINAPI IDirect3DSurface9Impl_SetPriority(LPDIRECT3DSURFACE9 iface, DWORD PriorityNew) {
87 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
88 return IWineD3DSurface_SetPriority(This->wineD3DSurface, PriorityNew);
91 DWORD WINAPI IDirect3DSurface9Impl_GetPriority(LPDIRECT3DSURFACE9 iface) {
92 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
93 return IWineD3DSurface_GetPriority(This->wineD3DSurface);
96 void WINAPI IDirect3DSurface9Impl_PreLoad(LPDIRECT3DSURFACE9 iface) {
97 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
98 IWineD3DSurface_PreLoad(This->wineD3DSurface);
102 D3DRESOURCETYPE WINAPI IDirect3DSurface9Impl_GetType(LPDIRECT3DSURFACE9 iface) {
103 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
104 return IWineD3DSurface_GetType(This->wineD3DSurface);
107 /* IDirect3DSurface9 Interface follow: */
108 HRESULT WINAPI IDirect3DSurface9Impl_GetContainer(LPDIRECT3DSURFACE9 iface, REFIID riid, void** ppContainer) {
109 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
112 /* The container returned from IWineD3DSurface_GetContainer is either a IWineD3DDevice,
113 one of the subclasses of IWineD3DBaseTexture or a IWineD3DSwapChain */
114 IUnknown *IWineContainer = NULL;
116 TRACE("(%p) Relay\n", This);
118 /* Get the IUnknown container. */
119 res = IWineD3DSurface_GetContainer(This->wineD3DSurface, &IID_IUnknown, (void **)&IWineContainer);
120 if (res == D3D_OK && IWineContainer != NULL) {
122 /* Now find out what kind of container it is (so that we can get its parent)*/
123 IUnknown *IUnknownParent = NULL;
124 IUnknown *myContainer = NULL;
125 if(D3D_OK == IUnknown_QueryInterface(IWineContainer, &IID_IWineD3DDevice, (void **)&myContainer)){
126 IWineD3DDevice_GetParent((IWineD3DDevice *)IWineContainer, &IUnknownParent);
127 IUnknown_Release(myContainer);
129 if(D3D_OK == IUnknown_QueryInterface(IWineContainer, &IID_IWineD3DBaseTexture, (void **)&myContainer)){
130 IWineD3DBaseTexture_GetParent((IWineD3DBaseTexture *)IWineContainer, &IUnknownParent);
131 IUnknown_Release(myContainer);
133 if(D3D_OK == IUnknown_QueryInterface(IWineContainer, &IID_IWineD3DSwapChain, (void **)&myContainer)){
134 IWineD3DBaseTexture_GetParent((IWineD3DBaseTexture *)IWineContainer, &IUnknownParent);
135 IUnknown_Release(myContainer);
137 FIXME("Container is of unknown interface\n");
140 IUnknown_Release((IWineD3DDevice *)IWineContainer);
142 /* Now, query the interface of the parent for the riid */
143 if(IUnknownParent != NULL){
144 res = IUnknown_QueryInterface(IUnknownParent, riid, ppContainer);
146 IUnknown_Release(IUnknownParent);
151 TRACE("(%p) : returning %p\n", This, *ppContainer);
155 HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3DSURFACE_DESC* pDesc) {
156 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
157 WINED3DSURFACE_DESC wined3ddesc;
160 /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
161 wined3ddesc.Format = &pDesc->Format;
162 wined3ddesc.Type = &pDesc->Type;
163 wined3ddesc.Usage = &pDesc->Usage;
164 wined3ddesc.Pool = &pDesc->Pool;
165 wined3ddesc.Size = &tmpInt;
166 wined3ddesc.MultiSampleType = &pDesc->MultiSampleType;
167 wined3ddesc.MultiSampleQuality = &pDesc->MultiSampleQuality;
168 wined3ddesc.Width = &pDesc->Width;
169 wined3ddesc.Height = &pDesc->Height;
171 return IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
174 HRESULT WINAPI IDirect3DSurface9Impl_LockRect(LPDIRECT3DSURFACE9 iface, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
175 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
176 return IWineD3DSurface_LockRect(This->wineD3DSurface, pLockedRect, pRect, Flags);
179 HRESULT WINAPI IDirect3DSurface9Impl_UnlockRect(LPDIRECT3DSURFACE9 iface) {
180 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
181 return IWineD3DSurface_UnlockRect(This->wineD3DSurface);
184 HRESULT WINAPI IDirect3DSurface9Impl_GetDC(LPDIRECT3DSURFACE9 iface, HDC* phdc) {
185 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
186 return IWineD3DSurface_GetDC(This->wineD3DSurface, phdc);
189 HRESULT WINAPI IDirect3DSurface9Impl_ReleaseDC(LPDIRECT3DSURFACE9 iface, HDC hdc) {
190 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
191 return IWineD3DSurface_ReleaseDC(This->wineD3DSurface, hdc);
195 IDirect3DSurface9Vtbl Direct3DSurface9_Vtbl =
197 IDirect3DSurface9Impl_QueryInterface,
198 IDirect3DSurface9Impl_AddRef,
199 IDirect3DSurface9Impl_Release,
200 IDirect3DSurface9Impl_GetDevice,
201 IDirect3DSurface9Impl_SetPrivateData,
202 IDirect3DSurface9Impl_GetPrivateData,
203 IDirect3DSurface9Impl_FreePrivateData,
204 IDirect3DSurface9Impl_SetPriority,
205 IDirect3DSurface9Impl_GetPriority,
206 IDirect3DSurface9Impl_PreLoad,
207 IDirect3DSurface9Impl_GetType,
208 IDirect3DSurface9Impl_GetContainer,
209 IDirect3DSurface9Impl_GetDesc,
210 IDirect3DSurface9Impl_LockRect,
211 IDirect3DSurface9Impl_UnlockRect,
212 IDirect3DSurface9Impl_GetDC,
213 IDirect3DSurface9Impl_ReleaseDC