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