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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
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);
39 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
44 static ULONG WINAPI IDirect3DSurface9Impl_AddRef(LPDIRECT3DSURFACE9 iface) {
45 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
47 TRACE("(%p)\n", This);
49 if (This->forwardReference) {
50 /* Forward refcounting */
51 TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
52 return IUnknown_AddRef(This->forwardReference);
54 /* No container, handle our own refcounting */
55 ULONG ref = InterlockedIncrement(&This->ref);
56 if(ref == 1 && This->parentDevice) IUnknown_AddRef(This->parentDevice);
57 TRACE("(%p) : AddRef from %d\n", This, ref - 1);
64 static ULONG WINAPI IDirect3DSurface9Impl_Release(LPDIRECT3DSURFACE9 iface) {
65 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
67 TRACE("(%p)\n", This);
69 if (This->forwardReference) {
70 /* Forward to the containerParent */
71 TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
72 return IUnknown_Release(This->forwardReference);
74 /* No container, handle our own refcounting */
75 ULONG ref = InterlockedDecrement(&This->ref);
76 TRACE("(%p) : ReleaseRef to %d\n", This, ref);
79 if (This->parentDevice) IUnknown_Release(This->parentDevice);
80 if (!This->isImplicit) {
81 IWineD3DSurface_Release(This->wineD3DSurface);
82 HeapFree(GetProcessHeap(), 0, This);
90 /* IDirect3DSurface9 IDirect3DResource9 Interface follow: */
91 static HRESULT WINAPI IDirect3DSurface9Impl_GetDevice(LPDIRECT3DSURFACE9 iface, IDirect3DDevice9** ppDevice) {
92 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
93 return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
96 static HRESULT WINAPI IDirect3DSurface9Impl_SetPrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
97 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
98 TRACE("(%p) Relay\n", This);
99 return IWineD3DSurface_SetPrivateData(This->wineD3DSurface, refguid, pData, SizeOfData, Flags);
102 static HRESULT WINAPI IDirect3DSurface9Impl_GetPrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
103 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
104 TRACE("(%p) Relay\n", This);
105 return IWineD3DSurface_GetPrivateData(This->wineD3DSurface, refguid, pData, pSizeOfData);
108 static HRESULT WINAPI IDirect3DSurface9Impl_FreePrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid) {
109 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
110 TRACE("(%p) Relay\n", This);
111 return IWineD3DSurface_FreePrivateData(This->wineD3DSurface, refguid);
114 static DWORD WINAPI IDirect3DSurface9Impl_SetPriority(LPDIRECT3DSURFACE9 iface, DWORD PriorityNew) {
115 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
116 TRACE("(%p) Relay\n", This);
117 return IWineD3DSurface_SetPriority(This->wineD3DSurface, PriorityNew);
120 static DWORD WINAPI IDirect3DSurface9Impl_GetPriority(LPDIRECT3DSURFACE9 iface) {
121 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
122 TRACE("(%p) Relay\n", This);
123 return IWineD3DSurface_GetPriority(This->wineD3DSurface);
126 static void WINAPI IDirect3DSurface9Impl_PreLoad(LPDIRECT3DSURFACE9 iface) {
127 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
128 TRACE("(%p) Relay\n", This);
129 IWineD3DSurface_PreLoad(This->wineD3DSurface);
133 static D3DRESOURCETYPE WINAPI IDirect3DSurface9Impl_GetType(LPDIRECT3DSURFACE9 iface) {
134 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
135 TRACE("(%p) Relay\n", This);
136 return IWineD3DSurface_GetType(This->wineD3DSurface);
139 /* IDirect3DSurface9 Interface follow: */
140 static HRESULT WINAPI IDirect3DSurface9Impl_GetContainer(LPDIRECT3DSURFACE9 iface, REFIID riid, void** ppContainer) {
141 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
144 TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer);
146 if (!This->container) return E_NOINTERFACE;
149 ERR("Called without a valid ppContainer\n");
152 res = IUnknown_QueryInterface(This->container, riid, ppContainer);
154 TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
159 static HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3DSURFACE_DESC* pDesc) {
160 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
161 WINED3DSURFACE_DESC wined3ddesc;
163 TRACE("(%p) Relay\n", This);
165 /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
166 wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
167 wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
168 wined3ddesc.Usage = &pDesc->Usage;
169 wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
170 wined3ddesc.Size = &tmpInt;
171 wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
172 wined3ddesc.MultiSampleQuality = &pDesc->MultiSampleQuality;
173 wined3ddesc.Width = &pDesc->Width;
174 wined3ddesc.Height = &pDesc->Height;
176 return IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
179 static HRESULT WINAPI IDirect3DSurface9Impl_LockRect(LPDIRECT3DSURFACE9 iface, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
180 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
181 TRACE("(%p) Relay\n", This);
182 TRACE("(%p) calling IWineD3DSurface_LockRect %p %p %p %d\n", This, This->wineD3DSurface, pLockedRect, pRect, Flags);
183 return IWineD3DSurface_LockRect(This->wineD3DSurface, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
186 static HRESULT WINAPI IDirect3DSurface9Impl_UnlockRect(LPDIRECT3DSURFACE9 iface) {
187 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
188 TRACE("(%p) Relay\n", This);
189 return IWineD3DSurface_UnlockRect(This->wineD3DSurface);
192 static HRESULT WINAPI IDirect3DSurface9Impl_GetDC(LPDIRECT3DSURFACE9 iface, HDC* phdc) {
193 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
194 TRACE("(%p) Relay\n", This);
195 return IWineD3DSurface_GetDC(This->wineD3DSurface, phdc);
198 static HRESULT WINAPI IDirect3DSurface9Impl_ReleaseDC(LPDIRECT3DSURFACE9 iface, HDC hdc) {
199 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
200 TRACE("(%p) Relay\n", This);
201 return IWineD3DSurface_ReleaseDC(This->wineD3DSurface, hdc);
205 const IDirect3DSurface9Vtbl Direct3DSurface9_Vtbl =
208 IDirect3DSurface9Impl_QueryInterface,
209 IDirect3DSurface9Impl_AddRef,
210 IDirect3DSurface9Impl_Release,
211 /* IDirect3DResource9 */
212 IDirect3DSurface9Impl_GetDevice,
213 IDirect3DSurface9Impl_SetPrivateData,
214 IDirect3DSurface9Impl_GetPrivateData,
215 IDirect3DSurface9Impl_FreePrivateData,
216 IDirect3DSurface9Impl_SetPriority,
217 IDirect3DSurface9Impl_GetPriority,
218 IDirect3DSurface9Impl_PreLoad,
219 IDirect3DSurface9Impl_GetType,
220 /* IDirect3DSurface9 */
221 IDirect3DSurface9Impl_GetContainer,
222 IDirect3DSurface9Impl_GetDesc,
223 IDirect3DSurface9Impl_LockRect,
224 IDirect3DSurface9Impl_UnlockRect,
225 IDirect3DSurface9Impl_GetDC,
226 IDirect3DSurface9Impl_ReleaseDC