gdi32, winex11drv: Add a test for compatible bitmap depths.
[wine] / dlls / d3d9 / basetexture.c
1 /*
2  * IDirect3DBaseTexture9 implementation
3  *
4  * Copyright 2002-2004 Jason Edmeades
5  *                     Raphael Junqueira
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #include "config.h"
23 #include "d3d9_private.h"
24
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
26
27 /* IDirect3DBaseTexture9 IUnknown parts follow: */
28 static HRESULT WINAPI IDirect3DBaseTexture9Impl_QueryInterface(LPDIRECT3DBASETEXTURE9 iface, REFIID riid, LPVOID* ppobj) {
29     IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
30     TRACE("(%p) Relay\n" , This);
31     if (IsEqualGUID(riid, &IID_IUnknown)
32         || IsEqualGUID(riid, &IID_IDirect3DResource9)
33         || IsEqualGUID(riid, &IID_IDirect3DBaseTexture9)) {
34         IUnknown_AddRef(iface);
35         *ppobj = This;
36         return S_OK;
37     }
38
39     WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
40     *ppobj = NULL;
41     return E_NOINTERFACE;
42 }
43
44 static ULONG WINAPI IDirect3DBaseTexture9Impl_AddRef(LPDIRECT3DBASETEXTURE9 iface) {
45     IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
46     ULONG ref = InterlockedIncrement(&This->ref);
47
48     TRACE("(%p) : AddRef from %d\n", This, ref - 1);
49
50     return ref;
51 }
52
53 static ULONG WINAPI IDirect3DBaseTexture9Impl_Release(LPDIRECT3DBASETEXTURE9 iface) {
54     IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
55     ULONG ref = InterlockedDecrement(&This->ref);
56
57     TRACE("(%p) : ReleaseRef to %d\n", This, ref);
58
59     if (ref == 0) {
60         IWineD3DBaseTexture_Release(This->wineD3DBaseTexture);
61         HeapFree(GetProcessHeap(), 0, This);
62     }
63     return ref;
64 }
65
66 /* IDirect3DBaseTexture9 IDirect3DResource9 Interface follow: */
67 static HRESULT WINAPI IDirect3DBaseTexture9Impl_GetDevice(LPDIRECT3DBASETEXTURE9 iface, IDirect3DDevice9** ppDevice) {
68     IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
69     TRACE("(%p) Relay\n" , This);
70     return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
71 }
72
73 static HRESULT WINAPI IDirect3DBaseTexture9Impl_SetPrivateData(LPDIRECT3DBASETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
74     IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
75     TRACE("(%p) Relay\n" , This);
76     return IWineD3DBaseTexture_SetPrivateData(This->wineD3DBaseTexture, refguid, pData, SizeOfData, Flags);
77 }
78
79 static HRESULT WINAPI IDirect3DBaseTexture9Impl_GetPrivateData(LPDIRECT3DBASETEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
80     IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
81     TRACE("(%p) Relay\n" , This);
82     return IWineD3DBaseTexture_GetPrivateData(This->wineD3DBaseTexture, refguid, pData, pSizeOfData);
83 }
84
85 static HRESULT WINAPI IDirect3DBaseTexture9Impl_FreePrivateData(LPDIRECT3DBASETEXTURE9 iface, REFGUID refguid) {
86     IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
87     TRACE("(%p) Relay\n" , This);
88     return IWineD3DBaseTexture_FreePrivateData(This->wineD3DBaseTexture, refguid);
89 }
90
91 static DWORD WINAPI IDirect3DBaseTexture9Impl_SetPriority(LPDIRECT3DBASETEXTURE9 iface, DWORD PriorityNew) {
92     IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
93     TRACE("(%p) Relay\n" , This);
94     return IWineD3DBaseTexture_SetPriority(This->wineD3DBaseTexture, PriorityNew);
95 }
96
97 static DWORD WINAPI IDirect3DBaseTexture9Impl_GetPriority(LPDIRECT3DBASETEXTURE9 iface) {
98     IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
99     TRACE("(%p) Relay\n" , This);
100     return IWineD3DBaseTexture_GetPriority(This->wineD3DBaseTexture);
101 }
102
103 static void WINAPI IDirect3DBaseTexture9Impl_PreLoad(LPDIRECT3DBASETEXTURE9 iface) {
104     IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
105     TRACE("(%p) Relay\n" , This);
106     IWineD3DBaseTexture_PreLoad(This->wineD3DBaseTexture);
107     return ;
108 }
109
110 static D3DRESOURCETYPE WINAPI IDirect3DBaseTexture9Impl_GetType(LPDIRECT3DBASETEXTURE9 iface) {
111     IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
112     TRACE("(%p) Relay\n" , This);
113     return IWineD3DBaseTexture_GetType(This->wineD3DBaseTexture);
114 }
115
116 /* IDirect3DBaseTexture9 Interface follow: */
117 static DWORD  WINAPI IDirect3DBaseTexture9Impl_SetLOD(LPDIRECT3DBASETEXTURE9 iface, DWORD LODNew) {
118     IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
119     TRACE("(%p) Relay\n" , This);
120     return IWineD3DBaseTexture_SetLOD(This->wineD3DBaseTexture, LODNew);
121 }
122
123 DWORD WINAPI IDirect3DBaseTexture9Impl_GetLOD(LPDIRECT3DBASETEXTURE9 iface) {
124     IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
125     TRACE("(%p) Relay\n" , This);
126     return IWineD3DBaseTexture_GetLOD(This->wineD3DBaseTexture);
127 }
128
129 static DWORD WINAPI IDirect3DBaseTexture9Impl_GetLevelCount(LPDIRECT3DBASETEXTURE9 iface) {
130     IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
131     TRACE("(%p) Relay\n" , This);
132     return IWineD3DBaseTexture_GetLevelCount(This->wineD3DBaseTexture);
133 }
134
135 static HRESULT WINAPI IDirect3DBaseTexture9Impl_SetAutoGenFilterType(LPDIRECT3DBASETEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
136     IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
137     TRACE("(%p) Relay\n" , This);
138     return IWineD3DBaseTexture_SetAutoGenFilterType(This->wineD3DBaseTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
139 }
140
141 static D3DTEXTUREFILTERTYPE WINAPI IDirect3DBaseTexture9Impl_GetAutoGenFilterType(LPDIRECT3DBASETEXTURE9 iface) {
142     IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
143     TRACE("(%p) Relay\n" , This);
144     return (D3DTEXTUREFILTERTYPE) IWineD3DBaseTexture_GetAutoGenFilterType(This->wineD3DBaseTexture);
145 }
146
147 static void WINAPI IDirect3DBaseTexture9Impl_GenerateMipSubLevels(LPDIRECT3DBASETEXTURE9 iface) {
148     IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
149     TRACE("(%p) Relay\n" , This);
150     IWineD3DBaseTexture_GenerateMipSubLevels(This->wineD3DBaseTexture);
151 }
152
153 const IDirect3DBaseTexture9Vtbl Direct3DBaseTexture9_Vtbl =
154 {
155     IDirect3DBaseTexture9Impl_QueryInterface,
156     IDirect3DBaseTexture9Impl_AddRef,
157     IDirect3DBaseTexture9Impl_Release,
158     IDirect3DBaseTexture9Impl_GetDevice,
159     IDirect3DBaseTexture9Impl_SetPrivateData,
160     IDirect3DBaseTexture9Impl_GetPrivateData,
161     IDirect3DBaseTexture9Impl_FreePrivateData,
162     IDirect3DBaseTexture9Impl_SetPriority,
163     IDirect3DBaseTexture9Impl_GetPriority,
164     IDirect3DBaseTexture9Impl_PreLoad,
165     IDirect3DBaseTexture9Impl_GetType,
166     IDirect3DBaseTexture9Impl_SetLOD,
167     IDirect3DBaseTexture9Impl_GetLOD,
168     IDirect3DBaseTexture9Impl_GetLevelCount,
169     IDirect3DBaseTexture9Impl_SetAutoGenFilterType,
170     IDirect3DBaseTexture9Impl_GetAutoGenFilterType,
171     IDirect3DBaseTexture9Impl_GenerateMipSubLevels   
172 };