rpcrt4: Replace inline static with static inline.
[wine] / dlls / d3d8 / texture.c
1 /*
2  * IDirect3DTexture8 implementation
3  *
4  * Copyright 2005 Oliver Stieber
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "config.h"
22 #include "d3d8_private.h"
23
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
25
26 /* IDirect3DTexture8 IUnknown parts follow: */
27 static HRESULT WINAPI IDirect3DTexture8Impl_QueryInterface(LPDIRECT3DTEXTURE8 iface, REFIID riid, LPVOID *ppobj) {
28     IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
29
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);
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 IDirect3DTexture8Impl_AddRef(LPDIRECT3DTEXTURE8 iface) {
45     IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)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 IDirect3DTexture8Impl_Release(LPDIRECT3DTEXTURE8 iface) {
54     IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
55     ULONG ref = InterlockedDecrement(&This->ref);
56
57     TRACE("(%p) : ReleaseRef to %d\n", This, ref);
58
59     if (ref == 0) {
60         IWineD3DTexture_Destroy(This->wineD3DTexture, D3D8CB_DestroySurface);
61         IUnknown_Release(This->parentDevice);
62         HeapFree(GetProcessHeap(), 0, This);
63     }
64     return ref;
65 }
66
67 /* IDirect3DTexture8 IDirect3DResource8 Interface follow: */
68 static HRESULT WINAPI IDirect3DTexture8Impl_GetDevice(LPDIRECT3DTEXTURE8 iface, IDirect3DDevice8 **ppDevice) {
69     IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
70     TRACE("(%p) Relay\n", This);
71     return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
72 }
73
74 static HRESULT WINAPI IDirect3DTexture8Impl_SetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
75     IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
76     TRACE("(%p) Relay\n", This);
77     return IWineD3DTexture_SetPrivateData(This->wineD3DTexture, refguid, pData, SizeOfData, Flags);
78 }
79
80 static HRESULT WINAPI IDirect3DTexture8Impl_GetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, void *pData, DWORD* pSizeOfData) {
81     IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
82     TRACE("(%p) Relay\n", This);
83     return IWineD3DTexture_GetPrivateData(This->wineD3DTexture, refguid, pData, pSizeOfData);
84 }
85
86 static HRESULT WINAPI IDirect3DTexture8Impl_FreePrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid) {
87     IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
88     TRACE("(%p) Relay\n", This);
89     return IWineD3DTexture_FreePrivateData(This->wineD3DTexture, refguid);
90 }
91
92 static DWORD WINAPI IDirect3DTexture8Impl_SetPriority(LPDIRECT3DTEXTURE8 iface, DWORD PriorityNew) {
93     IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
94     TRACE("(%p) Relay\n", This);
95     return IWineD3DTexture_SetPriority(This->wineD3DTexture, PriorityNew);
96 }
97
98 static DWORD WINAPI IDirect3DTexture8Impl_GetPriority(LPDIRECT3DTEXTURE8 iface) {
99     IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
100     TRACE("(%p) Relay\n", This);
101     return IWineD3DTexture_GetPriority(This->wineD3DTexture);
102 }
103
104 static void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) {
105     IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
106     TRACE("(%p) Relay\n", This);
107     return IWineD3DTexture_PreLoad(This->wineD3DTexture);
108 }
109
110 static D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 iface) {
111     IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
112     TRACE("(%p) Relay\n", This);
113     return IWineD3DTexture_GetType(This->wineD3DTexture);
114 }
115
116 /* IDirect3DTexture8 IDirect3DBaseTexture8 Interface follow: */
117 static DWORD WINAPI IDirect3DTexture8Impl_SetLOD(LPDIRECT3DTEXTURE8 iface, DWORD LODNew) {
118     IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
119     TRACE("(%p) Relay\n", This);
120     return IWineD3DTexture_SetLOD(This->wineD3DTexture, LODNew);
121 }
122
123 static DWORD WINAPI IDirect3DTexture8Impl_GetLOD(LPDIRECT3DTEXTURE8 iface) {
124     IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
125     TRACE("(%p) Relay\n", This);
126     return IWineD3DTexture_GetLOD(This->wineD3DTexture);
127 }
128
129 static DWORD WINAPI IDirect3DTexture8Impl_GetLevelCount(LPDIRECT3DTEXTURE8 iface) {
130     IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
131     TRACE("(%p) Relay\n", This);
132     return IWineD3DTexture_GetLevelCount(This->wineD3DTexture);
133 }
134
135 /* IDirect3DTexture8 Interface follow: */
136 static HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DSURFACE_DESC *pDesc) {
137     IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
138
139     WINED3DSURFACE_DESC    wined3ddesc;
140     TRACE("(%p) Relay\n", This);
141
142     /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
143     memset(&wined3ddesc, 0, sizeof(wined3ddesc));
144     wined3ddesc.Format              = (WINED3DFORMAT *)&pDesc->Format;
145     wined3ddesc.Type                = (WINED3DRESOURCETYPE *)&pDesc->Type;
146     wined3ddesc.Usage               = &pDesc->Usage;
147     wined3ddesc.Pool                = (WINED3DPOOL *) &pDesc->Pool;
148     wined3ddesc.Size                = &pDesc->Size;
149     wined3ddesc.MultiSampleType     = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
150     wined3ddesc.Width               = &pDesc->Width;
151     wined3ddesc.Height              = &pDesc->Height;
152
153     return IWineD3DTexture_GetLevelDesc(This->wineD3DTexture, Level, &wined3ddesc);
154 }
155
156 static HRESULT WINAPI IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 iface, UINT Level, IDirect3DSurface8 **ppSurfaceLevel) {
157     IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
158     HRESULT hrc = D3D_OK;
159     IWineD3DSurface *mySurface = NULL;
160
161     TRACE("(%p) Relay\n", This);
162     hrc = IWineD3DTexture_GetSurfaceLevel(This->wineD3DTexture, Level, &mySurface);
163     if (hrc == D3D_OK && NULL != ppSurfaceLevel) {
164        IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppSurfaceLevel);
165        IWineD3DSurface_Release(mySurface);
166     }
167     return hrc;
168 }
169
170 static HRESULT WINAPI IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DLOCKED_RECT *pLockedRect, CONST RECT *pRect, DWORD Flags) {
171     IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
172     TRACE("(%p) Relay\n", This);
173     return IWineD3DTexture_LockRect(This->wineD3DTexture, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
174 }
175
176 static HRESULT WINAPI IDirect3DTexture8Impl_UnlockRect(LPDIRECT3DTEXTURE8 iface, UINT Level) {
177     IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
178     TRACE("(%p) Relay\n", This);
179     return IWineD3DTexture_UnlockRect(This->wineD3DTexture, Level);
180 }
181
182 static HRESULT WINAPI IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 iface, CONST RECT *pDirtyRect) {
183     IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
184     TRACE("(%p) Relay\n", This);
185     return IWineD3DTexture_AddDirtyRect(This->wineD3DTexture, pDirtyRect);
186 }
187
188 const IDirect3DTexture8Vtbl Direct3DTexture8_Vtbl =
189 {
190     /* IUnknown */
191     IDirect3DTexture8Impl_QueryInterface,
192     IDirect3DTexture8Impl_AddRef,
193     IDirect3DTexture8Impl_Release,
194      /* IDirect3DResource8 */
195     IDirect3DTexture8Impl_GetDevice,
196     IDirect3DTexture8Impl_SetPrivateData,
197     IDirect3DTexture8Impl_GetPrivateData,
198     IDirect3DTexture8Impl_FreePrivateData,
199     IDirect3DTexture8Impl_SetPriority,
200     IDirect3DTexture8Impl_GetPriority,
201     IDirect3DTexture8Impl_PreLoad,
202     IDirect3DTexture8Impl_GetType,
203     /* IDirect3dBaseTexture8 */
204     IDirect3DTexture8Impl_SetLOD,
205     IDirect3DTexture8Impl_GetLOD,
206     IDirect3DTexture8Impl_GetLevelCount,
207     /* IDirect3DTexture8 */
208     IDirect3DTexture8Impl_GetLevelDesc,
209     IDirect3DTexture8Impl_GetSurfaceLevel,
210     IDirect3DTexture8Impl_LockRect,
211     IDirect3DTexture8Impl_UnlockRect,
212     IDirect3DTexture8Impl_AddDirtyRect
213 };