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 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 IUnknown_Release(This->parentDevice);
61 HeapFree(GetProcessHeap(), 0, This);
66 /* IDirect3DTexture8 IDirect3DResource8 Interface follow: */
67 HRESULT WINAPI IDirect3DTexture8Impl_GetDevice(LPDIRECT3DTEXTURE8 iface, IDirect3DDevice8 **ppDevice) {
68 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
69 TRACE("(%p) Relay\n", This);
70 return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
73 HRESULT WINAPI IDirect3DTexture8Impl_SetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
74 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
75 TRACE("(%p) Relay\n", This);
76 return IWineD3DTexture_SetPrivateData(This->wineD3DTexture, refguid, pData, SizeOfData, Flags);
79 HRESULT WINAPI IDirect3DTexture8Impl_GetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, void *pData, DWORD* pSizeOfData) {
80 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
81 TRACE("(%p) Relay\n", This);
82 return IWineD3DTexture_GetPrivateData(This->wineD3DTexture, refguid, pData, pSizeOfData);
85 HRESULT WINAPI IDirect3DTexture8Impl_FreePrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid) {
86 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
87 TRACE("(%p) Relay\n", This);
88 return IWineD3DTexture_FreePrivateData(This->wineD3DTexture, refguid);
91 DWORD WINAPI IDirect3DTexture8Impl_SetPriority(LPDIRECT3DTEXTURE8 iface, DWORD PriorityNew) {
92 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
93 TRACE("(%p) Relay\n", This);
94 return IWineD3DTexture_SetPriority(This->wineD3DTexture, PriorityNew);
97 DWORD WINAPI IDirect3DTexture8Impl_GetPriority(LPDIRECT3DTEXTURE8 iface) {
98 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
99 TRACE("(%p) Relay\n", This);
100 return IWineD3DTexture_GetPriority(This->wineD3DTexture);
103 void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) {
104 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
105 TRACE("(%p) Relay\n", This);
106 return IWineD3DTexture_PreLoad(This->wineD3DTexture);
109 D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 iface) {
110 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
111 TRACE("(%p) Relay\n", This);
112 return IWineD3DTexture_GetType(This->wineD3DTexture);
115 /* IDirect3DTexture8 IDirect3DBaseTexture8 Interface follow: */
116 DWORD WINAPI IDirect3DTexture8Impl_SetLOD(LPDIRECT3DTEXTURE8 iface, DWORD LODNew) {
117 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
118 TRACE("(%p) Relay\n", This);
119 return IWineD3DTexture_SetLOD(This->wineD3DTexture, LODNew);
122 DWORD WINAPI IDirect3DTexture8Impl_GetLOD(LPDIRECT3DTEXTURE8 iface) {
123 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
124 TRACE("(%p) Relay\n", This);
125 return IWineD3DTexture_GetLOD(This->wineD3DTexture);
128 DWORD WINAPI IDirect3DTexture8Impl_GetLevelCount(LPDIRECT3DTEXTURE8 iface) {
129 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
130 TRACE("(%p) Relay\n", This);
131 return IWineD3DTexture_GetLevelCount(This->wineD3DTexture);
134 /* IDirect3DTexture8 Interface follow: */
135 HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DSURFACE_DESC *pDesc) {
136 IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
138 WINED3DSURFACE_DESC wined3ddesc;
139 TRACE("(%p) Relay\n", This);
141 /* As d3d8 and d3d9 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 = &pDesc->Size;
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