2 * IDirect3DTexture8 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "d3d8_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d8
);
26 /* IDirect3DTexture8 IUnknown parts follow: */
27 static HRESULT WINAPI
IDirect3DTexture8Impl_QueryInterface(LPDIRECT3DTEXTURE8 iface
, REFIID riid
, LPVOID
*ppobj
) {
28 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
30 if (IsEqualGUID(riid
, &IID_IUnknown
)
31 || IsEqualGUID(riid
, &IID_IDirect3DResource8
)
32 || IsEqualGUID(riid
, &IID_IDirect3DBaseTexture8
)
33 || IsEqualGUID(riid
, &IID_IDirect3DTexture8
)) {
34 IUnknown_AddRef(iface
);
39 WARN("(%p)->(%s,%p) not found\n", This
, debugstr_guid(riid
), ppobj
);
44 static ULONG WINAPI
IDirect3DTexture8Impl_AddRef(LPDIRECT3DTEXTURE8 iface
) {
45 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
46 ULONG ref
= InterlockedIncrement(&This
->ref
);
48 TRACE("(%p) : AddRef from %ld\n", This
, ref
- 1);
53 static ULONG WINAPI
IDirect3DTexture8Impl_Release(LPDIRECT3DTEXTURE8 iface
) {
54 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
55 ULONG ref
= InterlockedDecrement(&This
->ref
);
57 TRACE("(%p) : ReleaseRef to %ld\n", This
, ref
);
60 IWineD3DTexture_Release(This
->wineD3DTexture
);
61 IUnknown_Release(This
->parentDevice
);
62 HeapFree(GetProcessHeap(), 0, This
);
67 /* IDirect3DTexture8 IDirect3DResource8 Interface follow: */
68 static HRESULT WINAPI
IDirect3DTexture8Impl_GetDevice(LPDIRECT3DTEXTURE8 iface
, IDirect3DDevice8
**ppDevice
) {
69 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
70 TRACE("(%p) Relay\n", This
);
71 return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8
) This
, ppDevice
);
74 static HRESULT WINAPI
IDirect3DTexture8Impl_SetPrivateData(LPDIRECT3DTEXTURE8 iface
, REFGUID refguid
, CONST
void *pData
, DWORD SizeOfData
, DWORD Flags
) {
75 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
76 TRACE("(%p) Relay\n", This
);
77 return IWineD3DTexture_SetPrivateData(This
->wineD3DTexture
, refguid
, pData
, SizeOfData
, Flags
);
80 static HRESULT WINAPI
IDirect3DTexture8Impl_GetPrivateData(LPDIRECT3DTEXTURE8 iface
, REFGUID refguid
, void *pData
, DWORD
* pSizeOfData
) {
81 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
82 TRACE("(%p) Relay\n", This
);
83 return IWineD3DTexture_GetPrivateData(This
->wineD3DTexture
, refguid
, pData
, pSizeOfData
);
86 static HRESULT WINAPI
IDirect3DTexture8Impl_FreePrivateData(LPDIRECT3DTEXTURE8 iface
, REFGUID refguid
) {
87 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
88 TRACE("(%p) Relay\n", This
);
89 return IWineD3DTexture_FreePrivateData(This
->wineD3DTexture
, refguid
);
92 static DWORD WINAPI
IDirect3DTexture8Impl_SetPriority(LPDIRECT3DTEXTURE8 iface
, DWORD PriorityNew
) {
93 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
94 TRACE("(%p) Relay\n", This
);
95 return IWineD3DTexture_SetPriority(This
->wineD3DTexture
, PriorityNew
);
98 static DWORD WINAPI
IDirect3DTexture8Impl_GetPriority(LPDIRECT3DTEXTURE8 iface
) {
99 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
100 TRACE("(%p) Relay\n", This
);
101 return IWineD3DTexture_GetPriority(This
->wineD3DTexture
);
104 static void WINAPI
IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface
) {
105 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
106 TRACE("(%p) Relay\n", This
);
107 return IWineD3DTexture_PreLoad(This
->wineD3DTexture
);
110 static D3DRESOURCETYPE WINAPI
IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 iface
) {
111 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
112 TRACE("(%p) Relay\n", This
);
113 return IWineD3DTexture_GetType(This
->wineD3DTexture
);
116 /* IDirect3DTexture8 IDirect3DBaseTexture8 Interface follow: */
117 static DWORD WINAPI
IDirect3DTexture8Impl_SetLOD(LPDIRECT3DTEXTURE8 iface
, DWORD LODNew
) {
118 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
119 TRACE("(%p) Relay\n", This
);
120 return IWineD3DTexture_SetLOD(This
->wineD3DTexture
, LODNew
);
123 static DWORD WINAPI
IDirect3DTexture8Impl_GetLOD(LPDIRECT3DTEXTURE8 iface
) {
124 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
125 TRACE("(%p) Relay\n", This
);
126 return IWineD3DTexture_GetLOD(This
->wineD3DTexture
);
129 static DWORD WINAPI
IDirect3DTexture8Impl_GetLevelCount(LPDIRECT3DTEXTURE8 iface
) {
130 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
131 TRACE("(%p) Relay\n", This
);
132 return IWineD3DTexture_GetLevelCount(This
->wineD3DTexture
);
135 /* IDirect3DTexture8 Interface follow: */
136 static HRESULT WINAPI
IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 iface
, UINT Level
, D3DSURFACE_DESC
*pDesc
) {
137 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
139 WINED3DSURFACE_DESC wined3ddesc
;
140 TRACE("(%p) Relay\n", This
);
142 /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
143 memset(&wined3ddesc
, 0, sizeof(wined3ddesc
));
144 wined3ddesc
.Format
= (WINED3DFORMAT
*)&pDesc
->Format
;
145 wined3ddesc
.Type
= (WINED3DRESOURCETYPE
*)&pDesc
->Type
;
146 wined3ddesc
.Usage
= &pDesc
->Usage
;
147 wined3ddesc
.Pool
= (WINED3DPOOL
*) &pDesc
->Pool
;
148 wined3ddesc
.Size
= &pDesc
->Size
;
149 wined3ddesc
.MultiSampleType
= (WINED3DMULTISAMPLE_TYPE
*) &pDesc
->MultiSampleType
;
150 wined3ddesc
.Width
= &pDesc
->Width
;
151 wined3ddesc
.Height
= &pDesc
->Height
;
153 return IWineD3DTexture_GetLevelDesc(This
->wineD3DTexture
, Level
, &wined3ddesc
);
156 static HRESULT WINAPI
IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 iface
, UINT Level
, IDirect3DSurface8
**ppSurfaceLevel
) {
157 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
158 HRESULT hrc
= D3D_OK
;
159 IWineD3DSurface
*mySurface
= NULL
;
161 TRACE("(%p) Relay\n", This
);
162 hrc
= IWineD3DTexture_GetSurfaceLevel(This
->wineD3DTexture
, Level
, &mySurface
);
163 if (hrc
== D3D_OK
&& NULL
!= ppSurfaceLevel
) {
164 IWineD3DSurface_GetParent(mySurface
, (IUnknown
**)ppSurfaceLevel
);
165 IWineD3DSurface_Release(mySurface
);
170 static HRESULT WINAPI
IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface
, UINT Level
, D3DLOCKED_RECT
*pLockedRect
, CONST RECT
*pRect
, DWORD Flags
) {
171 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
172 TRACE("(%p) Relay\n", This
);
173 return IWineD3DTexture_LockRect(This
->wineD3DTexture
, Level
, (WINED3DLOCKED_RECT
*) pLockedRect
, pRect
, Flags
);
176 static HRESULT WINAPI
IDirect3DTexture8Impl_UnlockRect(LPDIRECT3DTEXTURE8 iface
, UINT Level
) {
177 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
178 TRACE("(%p) Relay\n", This
);
179 return IWineD3DTexture_UnlockRect(This
->wineD3DTexture
, Level
);
182 static HRESULT WINAPI
IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 iface
, CONST RECT
*pDirtyRect
) {
183 IDirect3DTexture8Impl
*This
= (IDirect3DTexture8Impl
*)iface
;
184 TRACE("(%p) Relay\n", This
);
185 return IWineD3DTexture_AddDirtyRect(This
->wineD3DTexture
, pDirtyRect
);
188 const IDirect3DTexture8Vtbl Direct3DTexture8_Vtbl
=
191 IDirect3DTexture8Impl_QueryInterface
,
192 IDirect3DTexture8Impl_AddRef
,
193 IDirect3DTexture8Impl_Release
,
194 /* IDirect3DResource8 */
195 IDirect3DTexture8Impl_GetDevice
,
196 IDirect3DTexture8Impl_SetPrivateData
,
197 IDirect3DTexture8Impl_GetPrivateData
,
198 IDirect3DTexture8Impl_FreePrivateData
,
199 IDirect3DTexture8Impl_SetPriority
,
200 IDirect3DTexture8Impl_GetPriority
,
201 IDirect3DTexture8Impl_PreLoad
,
202 IDirect3DTexture8Impl_GetType
,
203 /* IDirect3dBaseTexture8 */
204 IDirect3DTexture8Impl_SetLOD
,
205 IDirect3DTexture8Impl_GetLOD
,
206 IDirect3DTexture8Impl_GetLevelCount
,
207 /* IDirect3DTexture8 */
208 IDirect3DTexture8Impl_GetLevelDesc
,
209 IDirect3DTexture8Impl_GetSurfaceLevel
,
210 IDirect3DTexture8Impl_LockRect
,
211 IDirect3DTexture8Impl_UnlockRect
,
212 IDirect3DTexture8Impl_AddDirtyRect