2 * IDirect3DSurface8 implementation
4 * Copyright 2005 Oliver Stieber
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "d3d8_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d8
);
26 /* IDirect3DSurface8 IUnknown parts follow: */
27 HRESULT WINAPI
IDirect3DSurface8Impl_QueryInterface(LPDIRECT3DSURFACE8 iface
, REFIID riid
, LPVOID
*ppobj
) {
28 IDirect3DSurface8Impl
*This
= (IDirect3DSurface8Impl
*)iface
;
30 if (IsEqualGUID(riid
, &IID_IUnknown
)
31 || IsEqualGUID(riid
, &IID_IDirect3DResource8
)
32 || IsEqualGUID(riid
, &IID_IDirect3DSurface8
)) {
33 IUnknown_AddRef(iface
);
38 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
42 ULONG WINAPI
IDirect3DSurface8Impl_AddRef(LPDIRECT3DSURFACE8 iface
) {
43 IDirect3DSurface8Impl
*This
= (IDirect3DSurface8Impl
*)iface
;
44 ULONG ref
= InterlockedIncrement(&This
->ref
);
46 TRACE("(%p) : AddRef from %ld\n", This
, ref
- 1);
51 ULONG WINAPI
IDirect3DSurface8Impl_Release(LPDIRECT3DSURFACE8 iface
) {
52 IDirect3DSurface8Impl
*This
= (IDirect3DSurface8Impl
*)iface
;
53 ULONG ref
= InterlockedDecrement(&This
->ref
);
55 TRACE("(%p) : ReleaseRef to %ld\n", This
, ref
);
58 IWineD3DSurface_Release(This
->wineD3DSurface
);
59 HeapFree(GetProcessHeap(), 0, This
);
64 /* IDirect3DSurface8 IDirect3DResource8 Interface follow: */
65 HRESULT WINAPI
IDirect3DSurface8Impl_GetDevice(LPDIRECT3DSURFACE8 iface
, IDirect3DDevice8
**ppDevice
) {
66 IDirect3DSurface8Impl
*This
= (IDirect3DSurface8Impl
*)iface
;
67 return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8
) This
, ppDevice
);
70 HRESULT WINAPI
IDirect3DSurface8Impl_SetPrivateData(LPDIRECT3DSURFACE8 iface
, REFGUID refguid
, CONST
void *pData
, DWORD SizeOfData
, DWORD Flags
) {
71 IDirect3DSurface8Impl
*This
= (IDirect3DSurface8Impl
*)iface
;
72 TRACE("(%p) Relay\n", This
);
73 return IWineD3DSurface_SetPrivateData(This
->wineD3DSurface
, refguid
, pData
, SizeOfData
, Flags
);
76 HRESULT WINAPI
IDirect3DSurface8Impl_GetPrivateData(LPDIRECT3DSURFACE8 iface
, REFGUID refguid
, void *pData
, DWORD
*pSizeOfData
) {
77 IDirect3DSurface8Impl
*This
= (IDirect3DSurface8Impl
*)iface
;
78 TRACE("(%p) Relay\n", This
);
79 return IWineD3DSurface_GetPrivateData(This
->wineD3DSurface
, refguid
, pData
, pSizeOfData
);
82 HRESULT WINAPI
IDirect3DSurface8Impl_FreePrivateData(LPDIRECT3DSURFACE8 iface
, REFGUID refguid
) {
83 IDirect3DSurface8Impl
*This
= (IDirect3DSurface8Impl
*)iface
;
84 TRACE("(%p) Relay\n", This
);
85 return IWineD3DSurface_FreePrivateData(This
->wineD3DSurface
, refguid
);
88 /* IDirect3DSurface8 Interface follow: */
89 HRESULT WINAPI
IDirect3DSurface8Impl_GetContainer(LPDIRECT3DSURFACE8 iface
, REFIID riid
, void **ppContainer
) {
90 IDirect3DSurface8Impl
*This
= (IDirect3DSurface8Impl
*)iface
;
92 IUnknown
*IWineContainer
= NULL
;
94 TRACE("(%p) Relay\n", This
);
96 /* The container returned from IWineD3DSurface_GetContainer is either an IWineD3DDevice,
97 one of the subclasses of IWineD3DBaseTexture or an IWineD3DSwapChain */
98 /* Get the IUnknown container. */
99 res
= IWineD3DSurface_GetContainer(This
->wineD3DSurface
, &IID_IUnknown
, (void **)&IWineContainer
);
100 if (res
== D3D_OK
&& IWineContainer
!= NULL
) {
102 /* Now find out what kind of container it is (so that we can get its parent)*/
103 IUnknown
*IUnknownParent
= NULL
;
104 IUnknown
*myContainer
= NULL
;
105 if (D3D_OK
== IUnknown_QueryInterface(IWineContainer
, &IID_IWineD3DDevice
, (void **)&myContainer
)) {
106 IWineD3DDevice_GetParent((IWineD3DDevice
*)IWineContainer
, &IUnknownParent
);
107 IUnknown_Release(myContainer
);
109 if (D3D_OK
== IUnknown_QueryInterface(IWineContainer
, &IID_IWineD3DBaseTexture
, (void **)&myContainer
)) {
110 IWineD3DBaseTexture_GetParent((IWineD3DBaseTexture
*)IWineContainer
, &IUnknownParent
);
111 IUnknown_Release(myContainer
);
113 if (D3D_OK
== IUnknown_QueryInterface(IWineContainer
, &IID_IWineD3DSwapChain
, (void **)&myContainer
)) {
114 IWineD3DSwapChain_GetParent((IWineD3DSwapChain
*)IWineContainer
, &IUnknownParent
);
115 IUnknown_Release(myContainer
);
117 FIXME("Container is of unknown interface\n");
120 IUnknown_Release((IWineD3DDevice
*)IWineContainer
);
122 /* Now, query the interface of the parent for the riid */
123 if (IUnknownParent
!= NULL
) {
124 res
= IUnknown_QueryInterface(IUnknownParent
, riid
, ppContainer
);
126 IUnknown_Release(IUnknownParent
);
130 TRACE("(%p) : returning %p\n", This
, *ppContainer
);
134 HRESULT WINAPI
IDirect3DSurface8Impl_GetDesc(LPDIRECT3DSURFACE8 iface
, D3DSURFACE_DESC
*pDesc
) {
135 IDirect3DSurface8Impl
*This
= (IDirect3DSurface8Impl
*)iface
;
136 WINED3DSURFACE_DESC wined3ddesc
;
138 TRACE("(%p) Relay\n", This
);
140 /* As d3d8 and d3d8 structures differ, pass in ptrs to where data needs to go */
141 memset(&wined3ddesc
, 0, sizeof(wined3ddesc
));
142 wined3ddesc
.Format
= (WINED3DFORMAT
*)&pDesc
->Format
;
143 wined3ddesc
.Type
= &pDesc
->Type
;
144 wined3ddesc
.Usage
= &pDesc
->Usage
;
145 wined3ddesc
.Pool
= &pDesc
->Pool
;
146 wined3ddesc
.Size
= &tmpInt
;
147 wined3ddesc
.MultiSampleType
= &pDesc
->MultiSampleType
;
148 wined3ddesc
.Width
= &pDesc
->Width
;
149 wined3ddesc
.Height
= &pDesc
->Height
;
151 return IWineD3DSurface_GetDesc(This
->wineD3DSurface
, &wined3ddesc
);
154 HRESULT WINAPI
IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface
, D3DLOCKED_RECT
*pLockedRect
, CONST RECT
*pRect
, DWORD Flags
) {
155 IDirect3DSurface8Impl
*This
= (IDirect3DSurface8Impl
*)iface
;
156 TRACE("(%p) Relay\n", This
);
157 TRACE("(%p) calling IWineD3DSurface_LockRect %p %p %p %ld\n", This
, This
->wineD3DSurface
, pLockedRect
, pRect
, Flags
);
158 return IWineD3DSurface_LockRect(This
->wineD3DSurface
, pLockedRect
, pRect
, Flags
);
161 HRESULT WINAPI
IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface
) {
162 IDirect3DSurface8Impl
*This
= (IDirect3DSurface8Impl
*)iface
;
163 TRACE("(%p) Relay\n", This
);
164 return IWineD3DSurface_UnlockRect(This
->wineD3DSurface
);
167 const IDirect3DSurface8Vtbl Direct3DSurface8_Vtbl
=
170 IDirect3DSurface8Impl_QueryInterface
,
171 IDirect3DSurface8Impl_AddRef
,
172 IDirect3DSurface8Impl_Release
,
173 /* IDirect3DResource8 */
174 IDirect3DSurface8Impl_GetDevice
,
175 IDirect3DSurface8Impl_SetPrivateData
,
176 IDirect3DSurface8Impl_GetPrivateData
,
177 IDirect3DSurface8Impl_FreePrivateData
,
178 /* IDirect3DSurface8 */
179 IDirect3DSurface8Impl_GetContainer
,
180 IDirect3DSurface8Impl_GetDesc
,
181 IDirect3DSurface8Impl_LockRect
,
182 IDirect3DSurface8Impl_UnlockRect