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 %d\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 %d\n", This, ref);
61 IWineD3DTexture_Destroy(This->wineD3DTexture, D3D8CB_DestroySurface);
62 wined3d_mutex_unlock();
64 IUnknown_Release(This->parentDevice);
65 HeapFree(GetProcessHeap(), 0, This);
70 /* IDirect3DTexture8 IDirect3DResource8 Interface follow: */
71 static HRESULT WINAPI IDirect3DTexture8Impl_GetDevice(LPDIRECT3DTEXTURE8 iface, IDirect3DDevice8 **ppDevice) {
72 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
73 IWineD3DDevice *wined3d_device;
75 TRACE("(%p) Relay\n", This);
78 hr = IWineD3DTexture_GetDevice(This->wineD3DTexture, &wined3d_device);
81 IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
82 IWineD3DDevice_Release(wined3d_device);
84 wined3d_mutex_unlock();
89 static HRESULT WINAPI IDirect3DTexture8Impl_SetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
90 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
92 TRACE("(%p) Relay\n", This);
95 hr = IWineD3DTexture_SetPrivateData(This->wineD3DTexture, refguid, pData, SizeOfData, Flags);
96 wined3d_mutex_unlock();
101 static HRESULT WINAPI IDirect3DTexture8Impl_GetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, void *pData, DWORD* pSizeOfData) {
102 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
104 TRACE("(%p) Relay\n", This);
106 wined3d_mutex_lock();
107 hr = IWineD3DTexture_GetPrivateData(This->wineD3DTexture, refguid, pData, pSizeOfData);
108 wined3d_mutex_unlock();
113 static HRESULT WINAPI IDirect3DTexture8Impl_FreePrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid) {
114 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
116 TRACE("(%p) Relay\n", This);
118 wined3d_mutex_lock();
119 hr = IWineD3DTexture_FreePrivateData(This->wineD3DTexture, refguid);
120 wined3d_mutex_unlock();
125 static DWORD WINAPI IDirect3DTexture8Impl_SetPriority(LPDIRECT3DTEXTURE8 iface, DWORD PriorityNew) {
126 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
128 TRACE("(%p) Relay\n", This);
130 wined3d_mutex_lock();
131 ret = IWineD3DTexture_SetPriority(This->wineD3DTexture, PriorityNew);
132 wined3d_mutex_unlock();
137 static DWORD WINAPI IDirect3DTexture8Impl_GetPriority(LPDIRECT3DTEXTURE8 iface) {
138 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
140 TRACE("(%p) Relay\n", This);
142 wined3d_mutex_lock();
143 ret = IWineD3DTexture_GetPriority(This->wineD3DTexture);
144 wined3d_mutex_unlock();
149 static void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) {
150 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
151 TRACE("(%p) Relay\n", This);
153 wined3d_mutex_lock();
154 IWineD3DTexture_PreLoad(This->wineD3DTexture);
155 wined3d_mutex_unlock();
158 static D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 iface) {
159 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
160 D3DRESOURCETYPE type;
161 TRACE("(%p) Relay\n", This);
163 wined3d_mutex_lock();
164 type = IWineD3DTexture_GetType(This->wineD3DTexture);
165 wined3d_mutex_unlock();
170 /* IDirect3DTexture8 IDirect3DBaseTexture8 Interface follow: */
171 static DWORD WINAPI IDirect3DTexture8Impl_SetLOD(LPDIRECT3DTEXTURE8 iface, DWORD LODNew) {
172 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
174 TRACE("(%p) Relay\n", This);
176 wined3d_mutex_lock();
177 ret = IWineD3DTexture_SetLOD(This->wineD3DTexture, LODNew);
178 wined3d_mutex_unlock();
183 static DWORD WINAPI IDirect3DTexture8Impl_GetLOD(LPDIRECT3DTEXTURE8 iface) {
184 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
186 TRACE("(%p) Relay\n", This);
188 wined3d_mutex_lock();
189 ret = IWineD3DTexture_GetLOD(This->wineD3DTexture);
190 wined3d_mutex_unlock();
195 static DWORD WINAPI IDirect3DTexture8Impl_GetLevelCount(LPDIRECT3DTEXTURE8 iface) {
196 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
198 TRACE("(%p) Relay\n", This);
200 wined3d_mutex_lock();
201 ret = IWineD3DTexture_GetLevelCount(This->wineD3DTexture);
202 wined3d_mutex_unlock();
207 /* IDirect3DTexture8 Interface follow: */
208 static HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DSURFACE_DESC *pDesc) {
209 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
212 WINED3DSURFACE_DESC wined3ddesc;
213 TRACE("(%p) Relay\n", This);
215 wined3d_mutex_lock();
216 hr = IWineD3DTexture_GetLevelDesc(This->wineD3DTexture, Level, &wined3ddesc);
217 wined3d_mutex_unlock();
221 pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.format);
222 pDesc->Type = wined3ddesc.resource_type;
223 pDesc->Usage = wined3ddesc.usage;
224 pDesc->Pool = wined3ddesc.pool;
225 pDesc->Size = wined3ddesc.size;
226 pDesc->MultiSampleType = wined3ddesc.multisample_type;
227 pDesc->Width = wined3ddesc.width;
228 pDesc->Height = wined3ddesc.height;
234 static HRESULT WINAPI IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 iface, UINT Level, IDirect3DSurface8 **ppSurfaceLevel) {
235 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
236 HRESULT hrc = D3D_OK;
237 IWineD3DSurface *mySurface = NULL;
239 TRACE("(%p) Relay\n", This);
241 wined3d_mutex_lock();
242 hrc = IWineD3DTexture_GetSurfaceLevel(This->wineD3DTexture, Level, &mySurface);
243 if (hrc == D3D_OK && NULL != ppSurfaceLevel) {
244 IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppSurfaceLevel);
245 IWineD3DSurface_Release(mySurface);
247 wined3d_mutex_unlock();
252 static HRESULT WINAPI IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DLOCKED_RECT *pLockedRect, CONST RECT *pRect, DWORD Flags) {
253 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
255 TRACE("(%p) Relay\n", This);
257 wined3d_mutex_lock();
258 hr = IWineD3DTexture_LockRect(This->wineD3DTexture, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
259 wined3d_mutex_unlock();
264 static HRESULT WINAPI IDirect3DTexture8Impl_UnlockRect(LPDIRECT3DTEXTURE8 iface, UINT Level) {
265 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
267 TRACE("(%p) Relay\n", This);
269 wined3d_mutex_lock();
270 hr = IWineD3DTexture_UnlockRect(This->wineD3DTexture, Level);
271 wined3d_mutex_unlock();
276 static HRESULT WINAPI IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 iface, CONST RECT *pDirtyRect) {
277 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
279 TRACE("(%p) Relay\n", This);
281 wined3d_mutex_lock();
282 hr = IWineD3DTexture_AddDirtyRect(This->wineD3DTexture, pDirtyRect);
283 wined3d_mutex_unlock();
288 const IDirect3DTexture8Vtbl Direct3DTexture8_Vtbl =
291 IDirect3DTexture8Impl_QueryInterface,
292 IDirect3DTexture8Impl_AddRef,
293 IDirect3DTexture8Impl_Release,
294 /* IDirect3DResource8 */
295 IDirect3DTexture8Impl_GetDevice,
296 IDirect3DTexture8Impl_SetPrivateData,
297 IDirect3DTexture8Impl_GetPrivateData,
298 IDirect3DTexture8Impl_FreePrivateData,
299 IDirect3DTexture8Impl_SetPriority,
300 IDirect3DTexture8Impl_GetPriority,
301 IDirect3DTexture8Impl_PreLoad,
302 IDirect3DTexture8Impl_GetType,
303 /* IDirect3dBaseTexture8 */
304 IDirect3DTexture8Impl_SetLOD,
305 IDirect3DTexture8Impl_GetLOD,
306 IDirect3DTexture8Impl_GetLevelCount,
307 /* IDirect3DTexture8 */
308 IDirect3DTexture8Impl_GetLevelDesc,
309 IDirect3DTexture8Impl_GetSurfaceLevel,
310 IDirect3DTexture8Impl_LockRect,
311 IDirect3DTexture8Impl_UnlockRect,
312 IDirect3DTexture8Impl_AddDirtyRect