Don't require execute permission on the process heap.
[wine] / dlls / wined3d / resource.c
1 /*
2  * IWineD3DResource Implementation
3  *
4  * Copyright 2002-2004 Jason Edmeades
5  * Copyright 2003-2004 Raphael Junqueira
6  * Copyright 2004 Christian Costa
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #include "config.h"
24 #include "wined3d_private.h"
25
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
27 #define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
28
29 /* IDirect3DResource IUnknown parts follow: */
30 HRESULT WINAPI IWineD3DResourceImpl_QueryInterface(IWineD3DResource *iface, REFIID riid, LPVOID *ppobj)
31 {
32     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
33     TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
34     if (IsEqualGUID(riid, &IID_IUnknown)
35         || IsEqualGUID(riid, &IID_IWineD3DResource)) {
36         IUnknown_AddRef(iface);
37         *ppobj = This;
38         return D3D_OK;
39     }
40     return E_NOINTERFACE;
41 }
42
43 ULONG WINAPI IWineD3DResourceImpl_AddRef(IWineD3DResource *iface) {
44     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
45     ULONG ref = InterlockedIncrement(&This->resource.ref);
46     TRACE("(%p) : AddRef increasing from %ld\n", This, ref - 1);
47     return ref; 
48 }
49
50 ULONG WINAPI IWineD3DResourceImpl_Release(IWineD3DResource *iface) {
51     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
52     ULONG ref = InterlockedDecrement(&This->resource.ref);
53     TRACE("(%p) : Releasing from %ld\n", This, ref + 1);
54     if (ref == 0) {
55         IWineD3DResourceImpl_CleanUp(iface);
56         HeapFree(GetProcessHeap(), 0, This);
57     }
58     return ref;
59 }
60
61 /* class static (not in vtable) */
62 void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface){
63     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
64     TRACE("(%p) :", This);
65
66     HeapFree(GetProcessHeap(), 0, This->resource.allocatedMemory);
67     This->resource.allocatedMemory = 0;
68 }
69
70 /* IDirect3DResource Interface follow: */
71 HRESULT WINAPI IWineD3DResourceImpl_GetDevice(IWineD3DResource *iface, IWineD3DDevice** ppDevice) {
72     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
73     TRACE("(%p) : returning %p\n", This, This->resource.wineD3DDevice);
74     *ppDevice = (IWineD3DDevice *) This->resource.wineD3DDevice;
75     IWineD3DDevice_AddRef(*ppDevice);
76     return D3D_OK;
77 }
78
79 /* Private Date is not implemented yet */
80 HRESULT WINAPI IWineD3DResourceImpl_SetPrivateData(IWineD3DResource *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
81     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
82     FIXME("(%p) : stub\n", This);    return D3D_OK;
83 }
84 HRESULT WINAPI IWineD3DResourceImpl_GetPrivateData(IWineD3DResource *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
85     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
86     FIXME("(%p) : stub\n", This);    return D3D_OK;
87 }
88 HRESULT WINAPI IWineD3DResourceImpl_FreePrivateData(IWineD3DResource *iface, REFGUID refguid) {
89     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
90     FIXME("(%p) : stub\n", This);    return D3D_OK;
91 }
92
93 /* Priority support is not implemented yet */
94 DWORD    WINAPI        IWineD3DResourceImpl_SetPriority(IWineD3DResource *iface, DWORD PriorityNew) {
95     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
96     FIXME("(%p) : stub\n", This);
97     return 0;
98 }
99 DWORD    WINAPI        IWineD3DResourceImpl_GetPriority(IWineD3DResource *iface) {
100     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
101     FIXME("(%p) : stub\n", This);
102     return 0;
103 }
104
105 /* Preloading of resources is not supported yet */
106 void     WINAPI        IWineD3DResourceImpl_PreLoad(IWineD3DResource *iface) {
107     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
108     FIXME("(%p) : stub\n", This);
109 }
110
111 D3DRESOURCETYPE WINAPI IWineD3DResourceImpl_GetType(IWineD3DResource *iface) {
112     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
113     TRACE("(%p) : returning %d\n", This, This->resource.resourceType);
114     return This->resource.resourceType;
115 }
116
117 HRESULT WINAPI IWineD3DResourceImpl_GetParent(IWineD3DResource *iface, IUnknown **pParent) {
118     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
119     IUnknown_AddRef(This->resource.parent);
120     *pParent = This->resource.parent;
121     return D3D_OK;
122 }
123
124
125 static const IWineD3DResourceVtbl IWineD3DResource_Vtbl =
126 {
127     IWineD3DResourceImpl_QueryInterface,
128     IWineD3DResourceImpl_AddRef,
129     IWineD3DResourceImpl_Release,
130     IWineD3DResourceImpl_GetParent,
131     IWineD3DResourceImpl_GetDevice,
132     IWineD3DResourceImpl_SetPrivateData,
133     IWineD3DResourceImpl_GetPrivateData,
134     IWineD3DResourceImpl_FreePrivateData,
135     IWineD3DResourceImpl_SetPriority,
136     IWineD3DResourceImpl_GetPriority,
137     IWineD3DResourceImpl_PreLoad,
138     IWineD3DResourceImpl_GetType
139 };