wininet: Properly clean up in InternetGetCookieExW if no cookies were found.
[wine.git] / dlls / d3d9 / d3d9_main.c
blob0afdc046b440beb2f19c81a296ce356d6c9911a0
1 /*
2 * Direct3D 9
4 * Copyright 2002-2003 Jason Edmeades
5 * Copyright 2002-2003 Raphael Junqueira
6 * Copyright 2005 Oliver Stieber
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.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "config.h"
25 #include "initguid.h"
26 #include "d3d9_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
30 static int D3DPERF_event_level = 0;
32 void WINAPI DebugSetMute(void) {
33 /* nothing to do */
36 IDirect3D9 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate9(UINT sdk_version)
38 struct d3d9 *object;
40 TRACE("sdk_version %#x.\n", sdk_version);
42 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
43 return NULL;
45 if (!d3d9_init(object, FALSE))
47 WARN("Failed to initialize d3d9.\n");
48 HeapFree(GetProcessHeap(), 0, object);
49 return NULL;
52 TRACE("Created d3d9 object %p.\n", object);
54 return (IDirect3D9 *)&object->IDirect3D9Ex_iface;
57 HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT sdk_version, IDirect3D9Ex **d3d9ex)
59 struct d3d9 *object;
61 TRACE("sdk_version %#x, d3d9ex %p.\n", sdk_version, d3d9ex);
63 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
64 return E_OUTOFMEMORY;
66 if (!d3d9_init(object, TRUE))
68 WARN("Failed to initialize d3d9.\n");
69 HeapFree(GetProcessHeap(), 0, object);
70 return D3DERR_NOTAVAILABLE;
73 TRACE("Created d3d9 object %p.\n", object);
74 *d3d9ex = &object->IDirect3D9Ex_iface;
76 return D3D_OK;
79 /*******************************************************************
80 * Direct3DShaderValidatorCreate9 (D3D9.@)
82 * No documentation available for this function.
83 * SDK only says it is internal and shouldn't be used.
85 void* WINAPI Direct3DShaderValidatorCreate9(void)
87 static int once;
89 if (!once++) FIXME("stub\n");
90 return NULL;
93 /***********************************************************************
94 * D3DPERF_BeginEvent (D3D9.@)
96 int WINAPI D3DPERF_BeginEvent(D3DCOLOR color, const WCHAR *name)
98 TRACE("color 0x%08x, name %s.\n", color, debugstr_w(name));
100 return D3DPERF_event_level++;
103 /***********************************************************************
104 * D3DPERF_EndEvent (D3D9.@)
106 int WINAPI D3DPERF_EndEvent(void) {
107 TRACE("(void) : stub\n");
109 return --D3DPERF_event_level;
112 /***********************************************************************
113 * D3DPERF_GetStatus (D3D9.@)
115 DWORD WINAPI D3DPERF_GetStatus(void) {
116 FIXME("(void) : stub\n");
118 return 0;
121 /***********************************************************************
122 * D3DPERF_SetOptions (D3D9.@)
125 void WINAPI D3DPERF_SetOptions(DWORD options)
127 FIXME("(%#x) : stub\n", options);
130 /***********************************************************************
131 * D3DPERF_QueryRepeatFrame (D3D9.@)
133 BOOL WINAPI D3DPERF_QueryRepeatFrame(void) {
134 FIXME("(void) : stub\n");
136 return FALSE;
139 /***********************************************************************
140 * D3DPERF_SetMarker (D3D9.@)
142 void WINAPI D3DPERF_SetMarker(D3DCOLOR color, const WCHAR *name)
144 FIXME("color 0x%08x, name %s stub!\n", color, debugstr_w(name));
147 /***********************************************************************
148 * D3DPERF_SetRegion (D3D9.@)
150 void WINAPI D3DPERF_SetRegion(D3DCOLOR color, const WCHAR *name)
152 FIXME("color 0x%08x, name %s stub!\n", color, debugstr_w(name));
155 void d3d9_resource_cleanup(struct d3d9_resource *resource)
157 wined3d_private_store_cleanup(&resource->private_store);
160 HRESULT d3d9_resource_free_private_data(struct d3d9_resource *resource, const GUID *guid)
162 struct wined3d_private_data *entry;
164 wined3d_mutex_lock();
165 entry = wined3d_private_store_get_private_data(&resource->private_store, guid);
166 if (!entry)
168 wined3d_mutex_unlock();
169 return D3DERR_NOTFOUND;
172 wined3d_private_store_free_private_data(&resource->private_store, entry);
173 wined3d_mutex_unlock();
175 return D3D_OK;
178 HRESULT d3d9_resource_get_private_data(struct d3d9_resource *resource, const GUID *guid,
179 void *data, DWORD *data_size)
181 const struct wined3d_private_data *stored_data;
182 DWORD size_in;
183 HRESULT hr;
185 wined3d_mutex_lock();
186 stored_data = wined3d_private_store_get_private_data(&resource->private_store, guid);
187 if (!stored_data)
189 hr = D3DERR_NOTFOUND;
190 goto done;
193 size_in = *data_size;
194 *data_size = stored_data->size;
195 if (!data)
197 hr = D3D_OK;
198 goto done;
200 if (size_in < stored_data->size)
202 hr = D3DERR_MOREDATA;
203 goto done;
206 if (stored_data->flags & WINED3DSPD_IUNKNOWN)
207 IUnknown_AddRef(stored_data->content.object);
208 memcpy(data, stored_data->content.data, stored_data->size);
209 hr = D3D_OK;
211 done:
212 wined3d_mutex_unlock();
213 return hr;
216 void d3d9_resource_init(struct d3d9_resource *resource)
218 resource->refcount = 1;
219 wined3d_private_store_init(&resource->private_store);
222 HRESULT d3d9_resource_set_private_data(struct d3d9_resource *resource, const GUID *guid,
223 const void *data, DWORD data_size, DWORD flags)
225 HRESULT hr;
227 wined3d_mutex_lock();
228 hr = wined3d_private_store_set_private_data(&resource->private_store, guid, data, data_size, flags);
229 wined3d_mutex_unlock();
230 return hr;