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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "d3d8_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
26 /* IDirect3DTexture8 IUnknown parts follow: */
27 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);
43 ULONG WINAPI IDirect3DTexture8Impl_AddRef(LPDIRECT3DTEXTURE8 iface) {
44 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
45 ULONG ref = InterlockedIncrement(&This->ref);
47 TRACE("(%p) : AddRef from %ld\n", This, ref - 1);
52 ULONG WINAPI IDirect3DTexture8Impl_Release(LPDIRECT3DTEXTURE8 iface) {
53 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
54 ULONG ref = InterlockedDecrement(&This->ref);
56 TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
59 IWineD3DTexture_Release(This->wineD3DTexture);
60 HeapFree(GetProcessHeap(), 0, This);
65 /* IDirect3DTexture8 IDirect3DResource8 Interface follow: */
66 HRESULT WINAPI IDirect3DTexture8Impl_GetDevice(LPDIRECT3DTEXTURE8 iface, IDirect3DDevice8 **ppDevice) {
67 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
68 TRACE("(%p) Relay\n", This);
69 return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
72 HRESULT WINAPI IDirect3DTexture8Impl_SetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
73 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
74 TRACE("(%p) Relay\n", This);
75 return IWineD3DTexture_SetPrivateData(This->wineD3DTexture, refguid, pData, SizeOfData, Flags);
78 HRESULT WINAPI IDirect3DTexture8Impl_GetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, void *pData, DWORD* pSizeOfData) {
79 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
80 TRACE("(%p) Relay\n", This);
81 return IWineD3DTexture_GetPrivateData(This->wineD3DTexture, refguid, pData, pSizeOfData);
84 HRESULT WINAPI IDirect3DTexture8Impl_FreePrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid) {
85 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
86 TRACE("(%p) Relay\n", This);
87 return IWineD3DTexture_FreePrivateData(This->wineD3DTexture, refguid);
90 DWORD WINAPI IDirect3DTexture8Impl_SetPriority(LPDIRECT3DTEXTURE8 iface, DWORD PriorityNew) {
91 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
92 TRACE("(%p) Relay\n", This);
93 return IWineD3DTexture_SetPriority(This->wineD3DTexture, PriorityNew);
96 DWORD WINAPI IDirect3DTexture8Impl_GetPriority(LPDIRECT3DTEXTURE8 iface) {
97 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
98 TRACE("(%p) Relay\n", This);
99 return IWineD3DTexture_GetPriority(This->wineD3DTexture);
102 void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) {
103 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
104 TRACE("(%p) Relay\n", This);
105 return IWineD3DTexture_PreLoad(This->wineD3DTexture);
108 D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 iface) {
109 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
110 TRACE("(%p) Relay\n", This);
111 return IWineD3DTexture_GetType(This->wineD3DTexture);
114 /* IDirect3DTexture8 IDirect3DBaseTexture8 Interface follow: */
115 DWORD WINAPI IDirect3DTexture8Impl_SetLOD(LPDIRECT3DTEXTURE8 iface, DWORD LODNew) {
116 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
117 TRACE("(%p) Relay\n", This);
118 return IWineD3DTexture_SetLOD(This->wineD3DTexture, LODNew);
121 DWORD WINAPI IDirect3DTexture8Impl_GetLOD(LPDIRECT3DTEXTURE8 iface) {
122 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
123 TRACE("(%p) Relay\n", This);
124 return IWineD3DTexture_GetLOD(This->wineD3DTexture);
127 DWORD WINAPI IDirect3DTexture8Impl_GetLevelCount(LPDIRECT3DTEXTURE8 iface) {
128 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
129 TRACE("(%p) Relay\n", This);
130 return IWineD3DTexture_GetLevelCount(This->wineD3DTexture);
133 /* IDirect3DTexture8 Interface follow: */
134 HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DSURFACE_DESC *pDesc) {
135 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
137 WINED3DSURFACE_DESC wined3ddesc;
139 TRACE("(%p) Relay\n", This);
141 /* As d3d8 and d3d8 structures differ, pass in ptrs to where data needs to go */
142 memset(&wined3ddesc, 0, sizeof(wined3ddesc));
143 wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
144 wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
145 wined3ddesc.Usage = &pDesc->Usage;
146 wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
147 wined3ddesc.Size = &tmpInt; /* required for d3d8 */
148 wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
149 wined3ddesc.Width = &pDesc->Width;
150 wined3ddesc.Height = &pDesc->Height;
152 return IWineD3DTexture_GetLevelDesc(This->wineD3DTexture, Level, &wined3ddesc);
155 HRESULT WINAPI IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 iface, UINT Level, IDirect3DSurface8 **ppSurfaceLevel) {
156 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
157 HRESULT hrc = D3D_OK;
158 IWineD3DSurface *mySurface = NULL;
160 TRACE("(%p) Relay\n", This);
161 hrc = IWineD3DTexture_GetSurfaceLevel(This->wineD3DTexture, Level, &mySurface);
162 if (hrc == D3D_OK && NULL != ppSurfaceLevel) {
163 IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppSurfaceLevel);
164 IWineD3DSurface_Release(mySurface);
169 HRESULT WINAPI IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DLOCKED_RECT *pLockedRect, CONST RECT *pRect, DWORD Flags) {
170 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
171 TRACE("(%p) Relay\n", This);
172 return IWineD3DTexture_LockRect(This->wineD3DTexture, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
175 HRESULT WINAPI IDirect3DTexture8Impl_UnlockRect(LPDIRECT3DTEXTURE8 iface, UINT Level) {
176 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
177 TRACE("(%p) Relay\n", This);
178 return IWineD3DTexture_UnlockRect(This->wineD3DTexture, Level);
181 HRESULT WINAPI IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 iface, CONST RECT *pDirtyRect) {
182 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
183 TRACE("(%p) Relay\n", This);
184 return IWineD3DTexture_AddDirtyRect(This->wineD3DTexture, pDirtyRect);
187 const IDirect3DTexture8Vtbl Direct3DTexture8_Vtbl =
190 IDirect3DTexture8Impl_QueryInterface,
191 IDirect3DTexture8Impl_AddRef,
192 IDirect3DTexture8Impl_Release,
193 /* IDirect3DResource8 */
194 IDirect3DTexture8Impl_GetDevice,
195 IDirect3DTexture8Impl_SetPrivateData,
196 IDirect3DTexture8Impl_GetPrivateData,
197 IDirect3DTexture8Impl_FreePrivateData,
198 IDirect3DTexture8Impl_SetPriority,
199 IDirect3DTexture8Impl_GetPriority,
200 IDirect3DTexture8Impl_PreLoad,
201 IDirect3DTexture8Impl_GetType,
202 /* IDirect3dBaseTexture8 */
203 IDirect3DTexture8Impl_SetLOD,
204 IDirect3DTexture8Impl_GetLOD,
205 IDirect3DTexture8Impl_GetLevelCount,
206 /* IDirect3DTexture8 */
207 IDirect3DTexture8Impl_GetLevelDesc,
208 IDirect3DTexture8Impl_GetSurfaceLevel,
209 IDirect3DTexture8Impl_LockRect,
210 IDirect3DTexture8Impl_UnlockRect,
211 IDirect3DTexture8Impl_AddDirtyRect