Removed W->A from DEFWND_ImmIsUIMessageW.
[wine] / dlls / d3d9 / surface.c
1 /*
2  * IDirect3DSurface9 implementation
3  *
4  * Copyright 2002-2003 Jason Edmeades
5  *                     Raphael Junqueira
6  *
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.
11  *
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.
16  *
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
20  */
21
22 #include "config.h"
23 #include "d3d9_private.h"
24
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
26
27 /* IDirect3DSurface9 IUnknown parts follow: */
28 HRESULT WINAPI IDirect3DSurface9Impl_QueryInterface(LPDIRECT3DSURFACE9 iface, REFIID riid, LPVOID* ppobj) {
29     IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
30
31     if (IsEqualGUID(riid, &IID_IUnknown)
32         || IsEqualGUID(riid, &IID_IDirect3DResource9)
33         || IsEqualGUID(riid, &IID_IDirect3DSurface9)) {
34         IDirect3DSurface9Impl_AddRef(iface);
35         *ppobj = This;
36         return D3D_OK;
37     }
38
39     WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
40     return E_NOINTERFACE;
41 }
42
43 ULONG WINAPI IDirect3DSurface9Impl_AddRef(LPDIRECT3DSURFACE9 iface) {
44     IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
45     TRACE("(%p) : AddRef from %ld\n", This, This->ref);
46     return ++(This->ref);
47 }
48
49 ULONG WINAPI IDirect3DSurface9Impl_Release(LPDIRECT3DSURFACE9 iface) {
50     IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
51     ULONG ref = --This->ref;
52     TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
53     if (ref == 0) {
54       HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
55       HeapFree(GetProcessHeap(), 0, This);
56     }
57     return ref;
58 }
59
60 /* IDirect3DSurface9 IDirect3DResource9 Interface follow: */
61 HRESULT WINAPI IDirect3DSurface9Impl_GetDevice(LPDIRECT3DSURFACE9 iface, IDirect3DDevice9** ppDevice) {
62     IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
63     return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
64 }
65
66 HRESULT WINAPI IDirect3DSurface9Impl_SetPrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
67     IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
68     FIXME("(%p) : stub\n", This);    
69     return D3D_OK;
70 }
71
72 HRESULT WINAPI IDirect3DSurface9Impl_GetPrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
73     IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
74     FIXME("(%p) : stub\n", This);    
75     return D3D_OK;
76 }
77
78 HRESULT WINAPI IDirect3DSurface9Impl_FreePrivateData(LPDIRECT3DSURFACE9 iface, REFGUID refguid) {
79     IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
80     FIXME("(%p) : stub\n", This);    
81     return D3D_OK;
82 }
83
84 DWORD   WINAPI IDirect3DSurface9Impl_SetPriority(LPDIRECT3DSURFACE9 iface, DWORD PriorityNew) {
85     IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
86     return IDirect3DResource9Impl_SetPriority((LPDIRECT3DRESOURCE9) This, PriorityNew);
87 }
88
89 DWORD   WINAPI IDirect3DSurface9Impl_GetPriority(LPDIRECT3DSURFACE9 iface) {
90     IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
91     return IDirect3DResource9Impl_GetPriority((LPDIRECT3DRESOURCE9) This);
92 }
93
94 void    WINAPI IDirect3DSurface9Impl_PreLoad(LPDIRECT3DSURFACE9 iface) {
95     IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
96     FIXME("(%p) : stub\n", This);    
97     return ;
98 }
99
100 D3DRESOURCETYPE WINAPI IDirect3DSurface9Impl_GetType(LPDIRECT3DSURFACE9 iface) {
101     IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
102     return IDirect3DResource9Impl_GetType((LPDIRECT3DRESOURCE9) This);
103 }
104
105 /* IDirect3DSurface9 Interface follow: */
106 HRESULT WINAPI IDirect3DSurface9Impl_GetContainer(LPDIRECT3DSURFACE9 iface, REFIID riid, void** ppContainer) {
107     IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
108     HRESULT res;
109     res = IUnknown_QueryInterface(This->Container, riid, ppContainer);
110     if (E_NOINTERFACE == res) { 
111       /**
112        * If the surface is created using CreateImageSurface, CreateRenderTarget, 
113        * or CreateDepthStencilSurface, the surface is considered stand alone. In this case, 
114        * GetContainer will return the Direct3D device used to create the surface. 
115        */
116       res = IUnknown_QueryInterface(This->Container, &IID_IDirect3DDevice9, ppContainer);
117     }
118     TRACE("(%p) : returning %p\n", This, *ppContainer);
119     return res;
120 }
121
122 HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3DSURFACE_DESC* pDesc) {
123     IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
124     TRACE("(%p) : copying into %p\n", This, pDesc);
125     memcpy(pDesc, &This->myDesc, sizeof(D3DSURFACE_DESC));
126     return D3D_OK;
127 }
128
129 HRESULT WINAPI IDirect3DSurface9Impl_LockRect(LPDIRECT3DSURFACE9 iface, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
130     IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
131     FIXME("(%p) : stub\n", This);
132     return D3D_OK;
133 }
134
135 HRESULT WINAPI IDirect3DSurface9Impl_UnlockRect(LPDIRECT3DSURFACE9 iface) {
136     IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
137     FIXME("(%p) : stub\n", This);
138     return D3D_OK;
139 }
140
141 HRESULT WINAPI IDirect3DSurface9Impl_GetDC(LPDIRECT3DSURFACE9 iface, HDC* phdc) {
142     IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
143     FIXME("(%p) : stub\n", This);
144     return D3D_OK;
145 }
146
147 HRESULT WINAPI IDirect3DSurface9Impl_ReleaseDC(LPDIRECT3DSURFACE9 iface, HDC hdc) {
148     IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
149     FIXME("(%p) : stub\n", This);
150     return D3D_OK;
151 }
152
153
154 IDirect3DSurface9Vtbl Direct3DSurface9_Vtbl =
155 {
156     IDirect3DSurface9Impl_QueryInterface,
157     IDirect3DSurface9Impl_AddRef,
158     IDirect3DSurface9Impl_Release,
159     IDirect3DSurface9Impl_GetDevice,
160     IDirect3DSurface9Impl_SetPrivateData,
161     IDirect3DSurface9Impl_GetPrivateData,
162     IDirect3DSurface9Impl_FreePrivateData,
163     IDirect3DSurface9Impl_SetPriority,
164     IDirect3DSurface9Impl_GetPriority,
165     IDirect3DSurface9Impl_PreLoad,
166     IDirect3DSurface9Impl_GetType,
167     IDirect3DSurface9Impl_GetContainer,
168     IDirect3DSurface9Impl_GetDesc,
169     IDirect3DSurface9Impl_LockRect,
170     IDirect3DSurface9Impl_UnlockRect,
171     IDirect3DSurface9Impl_GetDC,
172     IDirect3DSurface9Impl_ReleaseDC
173 };