Fix -Wwrite-strings warnings.
[wine/wine64.git] / dlls / d3d9 / surface.c
blob0f6fb739e9a0ba4937fa38b903a2676b918e9989
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "config.h"
23 #include "d3d9_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
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 IUnknown_AddRef(iface);
35 *ppobj = This;
36 return D3D_OK;
39 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
40 return E_NOINTERFACE;
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);
49 return ref;
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);
58 if (ref == 0) {
59 IWineD3DSurface_Release(This->wineD3DSurface);
60 HeapFree(GetProcessHeap(), 0, This);
62 return ref;
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 TRACE("(%p) Relay\n", This);
74 return IWineD3DSurface_SetPrivateData(This->wineD3DSurface, refguid, pData, SizeOfData, Flags);
77 HRESULT WINAPI IDirect3DSurface9Impl_GetPrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
78 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
79 TRACE("(%p) Relay\n", This);
80 return IWineD3DSurface_GetPrivateData(This->wineD3DSurface, refguid, pData, pSizeOfData);
83 HRESULT WINAPI IDirect3DSurface9Impl_FreePrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid) {
84 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
85 TRACE("(%p) Relay\n", This);
86 return IWineD3DSurface_FreePrivateData(This->wineD3DSurface, refguid);
89 DWORD WINAPI IDirect3DSurface9Impl_SetPriority(LPDIRECT3DSURFACE9 iface, DWORD PriorityNew) {
90 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
91 TRACE("(%p) Relay\n", This);
92 return IWineD3DSurface_SetPriority(This->wineD3DSurface, PriorityNew);
95 DWORD WINAPI IDirect3DSurface9Impl_GetPriority(LPDIRECT3DSURFACE9 iface) {
96 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
97 TRACE("(%p) Relay\n", This);
98 return IWineD3DSurface_GetPriority(This->wineD3DSurface);
101 void WINAPI IDirect3DSurface9Impl_PreLoad(LPDIRECT3DSURFACE9 iface) {
102 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
103 TRACE("(%p) Relay\n", This);
104 IWineD3DSurface_PreLoad(This->wineD3DSurface);
105 return ;
108 D3DRESOURCETYPE WINAPI IDirect3DSurface9Impl_GetType(LPDIRECT3DSURFACE9 iface) {
109 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
110 TRACE("(%p) Relay\n", This);
111 return IWineD3DSurface_GetType(This->wineD3DSurface);
114 /* IDirect3DSurface9 Interface follow: */
115 HRESULT WINAPI IDirect3DSurface9Impl_GetContainer(LPDIRECT3DSURFACE9 iface, REFIID riid, void** ppContainer) {
116 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
117 HRESULT res;
118 IUnknown *IWineContainer = NULL;
120 TRACE("(%p) Relay\n", This);
122 /* The container returned from IWineD3DSurface_GetContainer is either an IWineD3DDevice,
123 one of the subclasses of IWineD3DBaseTexture or an IWineD3DSwapChain */
124 /* Get the IUnknown container. */
125 res = IWineD3DSurface_GetContainer(This->wineD3DSurface, &IID_IUnknown, (void **)&IWineContainer);
126 if (res == D3D_OK && IWineContainer != NULL) {
128 /* Now find out what kind of container it is (so that we can get its parent)*/
129 IUnknown *IUnknownParent = NULL;
130 IUnknown *myContainer = NULL;
131 if(D3D_OK == IUnknown_QueryInterface(IWineContainer, &IID_IWineD3DDevice, (void **)&myContainer)){
132 IWineD3DDevice_GetParent((IWineD3DDevice *)IWineContainer, &IUnknownParent);
133 IUnknown_Release(myContainer);
134 } else
135 if(D3D_OK == IUnknown_QueryInterface(IWineContainer, &IID_IWineD3DBaseTexture, (void **)&myContainer)){
136 IWineD3DBaseTexture_GetParent((IWineD3DBaseTexture *)IWineContainer, &IUnknownParent);
137 IUnknown_Release(myContainer);
138 } else
139 if(D3D_OK == IUnknown_QueryInterface(IWineContainer, &IID_IWineD3DSwapChain, (void **)&myContainer)){
140 IWineD3DBaseTexture_GetParent((IWineD3DBaseTexture *)IWineContainer, &IUnknownParent);
141 IUnknown_Release(myContainer);
142 }else{
143 FIXME("Container is of unknown interface\n");
145 /* Tidy up.. */
146 IUnknown_Release((IWineD3DDevice *)IWineContainer);
148 /* Now, query the interface of the parent for the riid */
149 if(IUnknownParent != NULL){
150 res = IUnknown_QueryInterface(IUnknownParent, riid, ppContainer);
151 /* Tidy up.. */
152 IUnknown_Release(IUnknownParent);
157 TRACE("(%p) : returning %p\n", This, *ppContainer);
158 return res;
161 HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3DSURFACE_DESC* pDesc) {
162 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
163 WINED3DSURFACE_DESC wined3ddesc;
164 UINT tmpInt = -1;
165 TRACE("(%p) Relay\n", This);
167 /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
168 wined3ddesc.Format = &pDesc->Format;
169 wined3ddesc.Type = &pDesc->Type;
170 wined3ddesc.Usage = &pDesc->Usage;
171 wined3ddesc.Pool = &pDesc->Pool;
172 wined3ddesc.Size = &tmpInt;
173 wined3ddesc.MultiSampleType = &pDesc->MultiSampleType;
174 wined3ddesc.MultiSampleQuality = &pDesc->MultiSampleQuality;
175 wined3ddesc.Width = &pDesc->Width;
176 wined3ddesc.Height = &pDesc->Height;
178 return IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
181 HRESULT WINAPI IDirect3DSurface9Impl_LockRect(LPDIRECT3DSURFACE9 iface, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
182 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
183 TRACE("(%p) Relay\n", This);
184 TRACE("(%p) calling IWineD3DSurface_LockRect %p %p %p %ld\n", This, This->wineD3DSurface, pLockedRect, pRect, Flags);
185 return IWineD3DSurface_LockRect(This->wineD3DSurface, pLockedRect, pRect, Flags);
188 HRESULT WINAPI IDirect3DSurface9Impl_UnlockRect(LPDIRECT3DSURFACE9 iface) {
189 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
190 TRACE("(%p) Relay\n", This);
191 return IWineD3DSurface_UnlockRect(This->wineD3DSurface);
194 HRESULT WINAPI IDirect3DSurface9Impl_GetDC(LPDIRECT3DSURFACE9 iface, HDC* phdc) {
195 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
196 TRACE("(%p) Relay\n", This);
197 return IWineD3DSurface_GetDC(This->wineD3DSurface, phdc);
200 HRESULT WINAPI IDirect3DSurface9Impl_ReleaseDC(LPDIRECT3DSURFACE9 iface, HDC hdc) {
201 IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
202 TRACE("(%p) Relay\n", This);
203 return IWineD3DSurface_ReleaseDC(This->wineD3DSurface, hdc);
207 IDirect3DSurface9Vtbl Direct3DSurface9_Vtbl =
209 IDirect3DSurface9Impl_QueryInterface,
210 IDirect3DSurface9Impl_AddRef,
211 IDirect3DSurface9Impl_Release,
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 IDirect3DSurface9Impl_GetContainer,
221 IDirect3DSurface9Impl_GetDesc,
222 IDirect3DSurface9Impl_LockRect,
223 IDirect3DSurface9Impl_UnlockRect,
224 IDirect3DSurface9Impl_GetDC,
225 IDirect3DSurface9Impl_ReleaseDC