Release 20030408.
[wine/gsoc-2012-control.git] / dlls / d3d8 / texture.c
blob0a44841a87fc89be3416a43c90ee323052053381
1 /*
2 * IDirect3DTexture8 implementation
4 * Copyright 2002 Jason Edmeades
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
21 #include "windef.h"
22 #include "winbase.h"
23 #include "winuser.h"
24 #include "wingdi.h"
25 #include "wine/debug.h"
27 #include "d3d8_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
31 /* IDirect3DTexture8 IUnknown parts follow: */
32 HRESULT WINAPI IDirect3DTexture8Impl_QueryInterface(LPDIRECT3DTEXTURE8 iface,REFIID riid,LPVOID *ppobj)
34 ICOM_THIS(IDirect3DTexture8Impl,iface);
35 TRACE("(%p) : QueryInterface\n", This);
36 if (IsEqualGUID(riid, &IID_IUnknown)
37 || IsEqualGUID(riid, &IID_IDirect3DResource8)
38 || IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)
39 || IsEqualGUID(riid, &IID_IDirect3DTexture8)) {
40 IDirect3DTexture8Impl_AddRef(iface);
41 *ppobj = This;
42 return D3D_OK;
45 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
46 return E_NOINTERFACE;
49 ULONG WINAPI IDirect3DTexture8Impl_AddRef(LPDIRECT3DTEXTURE8 iface) {
50 ICOM_THIS(IDirect3DTexture8Impl,iface);
51 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
52 return ++(This->ref);
55 ULONG WINAPI IDirect3DTexture8Impl_Release(LPDIRECT3DTEXTURE8 iface) {
56 ICOM_THIS(IDirect3DTexture8Impl,iface);
57 ULONG ref = --This->ref;
58 int i;
60 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
61 if (ref == 0) {
62 for (i=0; i<This->levels; i++) {
63 if (This->surfaces[i] != NULL) {
64 TRACE("(%p) : Releasing surface %p\n", This, This->surfaces[i]);
65 IDirect3DSurface8Impl_Release((LPDIRECT3DSURFACE8) This->surfaces[i]);
68 HeapFree(GetProcessHeap(), 0, This);
70 return ref;
73 /* IDirect3DTexture8 IDirect3DResource8 Interface follow: */
74 HRESULT WINAPI IDirect3DTexture8Impl_GetDevice(LPDIRECT3DTEXTURE8 iface, IDirect3DDevice8** ppDevice) {
75 ICOM_THIS(IDirect3DTexture8Impl,iface);
76 TRACE("(%p) : returning %p\n", This, This->Device);
77 *ppDevice = (LPDIRECT3DDEVICE8) This->Device;
78 /**
79 * Note Calling this method will increase the internal reference count
80 * on the IDirect3DDevice8 interface.
82 IDirect3DDevice8Impl_AddRef(*ppDevice);
83 return D3D_OK;
85 HRESULT WINAPI IDirect3DTexture8Impl_SetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
86 ICOM_THIS(IDirect3DTexture8Impl,iface);
87 FIXME("(%p) : stub\n", This); return D3D_OK;
89 HRESULT WINAPI IDirect3DTexture8Impl_GetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
90 ICOM_THIS(IDirect3DTexture8Impl,iface);
91 FIXME("(%p) : stub\n", This); return D3D_OK;
93 HRESULT WINAPI IDirect3DTexture8Impl_FreePrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid) {
94 ICOM_THIS(IDirect3DTexture8Impl,iface);
95 FIXME("(%p) : stub\n", This); return D3D_OK;
97 DWORD WINAPI IDirect3DTexture8Impl_SetPriority(LPDIRECT3DTEXTURE8 iface, DWORD PriorityNew) {
98 ICOM_THIS(IDirect3DTexture8Impl,iface);
99 FIXME("(%p) : stub\n", This); return D3D_OK;
101 DWORD WINAPI IDirect3DTexture8Impl_GetPriority(LPDIRECT3DTEXTURE8 iface) {
102 ICOM_THIS(IDirect3DTexture8Impl,iface);
103 FIXME("(%p) : stub\n", This); return D3D_OK;
105 void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) {
106 ICOM_THIS(IDirect3DTexture8Impl,iface);
107 FIXME("(%p) : stub\n", This);
109 D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 iface) {
110 ICOM_THIS(IDirect3DTexture8Impl,iface);
111 TRACE("(%p) : is %d \n", This, This->ResourceType);
112 return This->ResourceType;
115 /* IDirect3DTexture8 IDirect3DBaseTexture8 Interface follow: */
116 DWORD WINAPI IDirect3DTexture8Impl_SetLOD(LPDIRECT3DTEXTURE8 iface, DWORD LODNew) {
117 ICOM_THIS(IDirect3DTexture8Impl,iface);
118 FIXME("(%p) : stub\n", This); return D3D_OK;
120 DWORD WINAPI IDirect3DTexture8Impl_GetLOD(LPDIRECT3DTEXTURE8 iface) {
121 ICOM_THIS(IDirect3DTexture8Impl,iface);
122 FIXME("(%p) : stub\n", This); return D3D_OK;
124 DWORD WINAPI IDirect3DTexture8Impl_GetLevelCount(LPDIRECT3DTEXTURE8 iface) {
125 ICOM_THIS(IDirect3DTexture8Impl,iface);
126 TRACE("(%p) : returning %d\n", This, This->levels);
127 return This->levels;
130 /* IDirect3DTexture8 */
131 HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 iface, UINT Level,D3DSURFACE_DESC* pDesc) {
132 ICOM_THIS(IDirect3DTexture8Impl,iface);
134 if (Level < This->levels) {
135 TRACE("(%p) Level (%d)\n", This, Level);
136 return IDirect3DSurface8Impl_GetDesc((LPDIRECT3DSURFACE8)This->surfaces[Level], pDesc);
137 } else {
138 FIXME("(%p) Level (%d)\n", This, Level);
140 return D3D_OK;
142 HRESULT WINAPI IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 iface, UINT Level,IDirect3DSurface8** ppSurfaceLevel) {
143 ICOM_THIS(IDirect3DTexture8Impl,iface);
144 *ppSurfaceLevel = (LPDIRECT3DSURFACE8)This->surfaces[Level];
145 IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8)This->surfaces[Level]);
146 TRACE("(%p) : returning %p for level %d\n", This, *ppSurfaceLevel, Level);
147 return D3D_OK;
149 HRESULT WINAPI IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface, UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) {
150 ICOM_THIS(IDirect3DTexture8Impl,iface);
151 TRACE("(%p) Level (%d)\n", This, Level);
152 if (Level < This->levels) {
153 return IDirect3DSurface8Impl_LockRect((LPDIRECT3DSURFACE8)This->surfaces[Level], pLockedRect, pRect, Flags);
154 } else {
155 FIXME("Levels seems too high?!!\n");
157 return D3D_OK;
159 HRESULT WINAPI IDirect3DTexture8Impl_UnlockRect(LPDIRECT3DTEXTURE8 iface, UINT Level) {
160 ICOM_THIS(IDirect3DTexture8Impl,iface);
161 This->Dirty = TRUE;
162 TRACE("(%p) : stub\n", This);
163 return D3D_OK;
165 HRESULT WINAPI IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 iface, CONST RECT* pDirtyRect) {
166 ICOM_THIS(IDirect3DTexture8Impl,iface);
167 This->Dirty = TRUE;
168 FIXME("(%p) : stub\n", This); return D3D_OK;
172 ICOM_VTABLE(IDirect3DTexture8) Direct3DTexture8_Vtbl =
174 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
175 IDirect3DTexture8Impl_QueryInterface,
176 IDirect3DTexture8Impl_AddRef,
177 IDirect3DTexture8Impl_Release,
178 IDirect3DTexture8Impl_GetDevice,
179 IDirect3DTexture8Impl_SetPrivateData,
180 IDirect3DTexture8Impl_GetPrivateData,
181 IDirect3DTexture8Impl_FreePrivateData,
182 IDirect3DTexture8Impl_SetPriority,
183 IDirect3DTexture8Impl_GetPriority,
184 IDirect3DTexture8Impl_PreLoad,
185 IDirect3DTexture8Impl_GetType,
186 IDirect3DTexture8Impl_SetLOD,
187 IDirect3DTexture8Impl_GetLOD,
188 IDirect3DTexture8Impl_GetLevelCount,
189 IDirect3DTexture8Impl_GetLevelDesc,
190 IDirect3DTexture8Impl_GetSurfaceLevel,
191 IDirect3DTexture8Impl_LockRect,
192 IDirect3DTexture8Impl_UnlockRect,
193 IDirect3DTexture8Impl_AddDirtyRect