Update the address of the Free Software Foundation.
[wine] / dlls / d3d8 / resource.c
1 /*
2  * IDirect3DResource8 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 /* IDirect3DResource8 IUnknown parts follow: */
27 HRESULT WINAPI IDirect3DResource8Impl_QueryInterface(LPDIRECT3DRESOURCE8 iface, REFIID riid, LPVOID* ppobj) {
28     IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
29
30     if (IsEqualGUID(riid, &IID_IUnknown)
31         || IsEqualGUID(riid, &IID_IDirect3DResource8)) {
32         IUnknown_AddRef(iface);
33         *ppobj = This;
34         return D3D_OK;
35     }
36
37     WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
38     return E_NOINTERFACE;
39 }
40
41 ULONG WINAPI IDirect3DResource8Impl_AddRef(LPDIRECT3DRESOURCE8 iface) {
42     IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
43     ULONG ref = InterlockedIncrement(&This->ref);
44
45     TRACE("(%p) : AddRef from %ld\n", This, ref - 1);
46
47     return ref;
48 }
49
50 ULONG WINAPI IDirect3DResource8Impl_Release(LPDIRECT3DRESOURCE8 iface) {
51     IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
52     ULONG ref = InterlockedDecrement(&This->ref);
53
54     TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
55
56     if (ref == 0) {
57         IWineD3DResource_Release(This->wineD3DResource);
58         HeapFree(GetProcessHeap(), 0, This);
59     }
60     return ref;
61 }
62
63 /* IDirect3DResource8 Interface follow: */
64 HRESULT WINAPI IDirect3DResource8Impl_GetDevice(LPDIRECT3DRESOURCE8 iface, IDirect3DDevice8** ppDevice) {
65     IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
66     IWineD3DDevice *myDevice = NULL;
67
68     TRACE("(%p) Relay\n", This);
69
70     IWineD3DResource_GetDevice(This->wineD3DResource, &myDevice);
71     IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
72     IWineD3DDevice_Release(myDevice);
73     return D3D_OK;
74 }
75
76 HRESULT WINAPI IDirect3DResource8Impl_SetPrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
77     IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
78     TRACE("(%p) Relay\n", This);
79     return IWineD3DResource_SetPrivateData(This->wineD3DResource, refguid, pData, SizeOfData, Flags);
80 }
81
82 HRESULT WINAPI IDirect3DResource8Impl_GetPrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
83     IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
84     TRACE("(%p) Relay\n", This);
85     return IWineD3DResource_GetPrivateData(This->wineD3DResource, refguid, pData, pSizeOfData);
86 }
87
88 HRESULT WINAPI IDirect3DResource8Impl_FreePrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid) {
89     IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
90     TRACE("(%p) Relay\n", This);
91     return IWineD3DResource_FreePrivateData(This->wineD3DResource, refguid);
92 }
93
94 DWORD  WINAPI IDirect3DResource8Impl_SetPriority(LPDIRECT3DRESOURCE8 iface, DWORD PriorityNew) {
95     IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
96     TRACE("(%p) Relay\n", This);
97     return IWineD3DResource_SetPriority(This->wineD3DResource, PriorityNew);
98 }
99
100 DWORD WINAPI IDirect3DResource8Impl_GetPriority(LPDIRECT3DRESOURCE8 iface) {
101     IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
102     TRACE("(%p) Relay\n", This);
103     return IWineD3DResource_GetPriority(This->wineD3DResource);
104 }
105
106 void WINAPI IDirect3DResource8Impl_PreLoad(LPDIRECT3DRESOURCE8 iface) {
107     IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
108     TRACE("(%p) Relay\n", This);
109     IWineD3DResource_PreLoad(This->wineD3DResource);
110     return;
111 }
112
113 D3DRESOURCETYPE WINAPI IDirect3DResource8Impl_GetType(LPDIRECT3DRESOURCE8 iface) {
114     IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
115     TRACE("(%p) Relay\n", This);
116     return IWineD3DResource_GetType(This->wineD3DResource);
117 }
118
119 const IDirect3DResource8Vtbl Direct3DResource8_Vtbl =
120 {
121     IDirect3DResource8Impl_QueryInterface,
122     IDirect3DResource8Impl_AddRef,
123     IDirect3DResource8Impl_Release,
124     IDirect3DResource8Impl_GetDevice,
125     IDirect3DResource8Impl_SetPrivateData,
126     IDirect3DResource8Impl_GetPrivateData,
127     IDirect3DResource8Impl_FreePrivateData,
128     IDirect3DResource8Impl_SetPriority,
129     IDirect3DResource8Impl_GetPriority,
130     IDirect3DResource8Impl_PreLoad,
131     IDirect3DResource8Impl_GetType
132 };