msi: Correctly parse double quotes in the token value.
[wine/multimedia.git] / dlls / dxgi / surface.c
blob4ce9130586e755b45d79f3cce75cf4621239cf6a
1 /*
2 * Copyright 2009 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "config.h"
21 #include "wine/port.h"
23 #include "dxgi_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
27 /* Inner IUnknown methods */
29 static inline struct dxgi_surface *impl_from_IUnknown(IUnknown *iface)
31 return CONTAINING_RECORD(iface, struct dxgi_surface, IUnknown_iface);
34 static HRESULT STDMETHODCALLTYPE dxgi_surface_inner_QueryInterface(IUnknown *iface, REFIID riid, void **out)
36 struct dxgi_surface *surface = impl_from_IUnknown(iface);
38 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
40 if (IsEqualGUID(riid, &IID_IDXGISurface)
41 || IsEqualGUID(riid, &IID_IDXGIDeviceSubObject)
42 || IsEqualGUID(riid, &IID_IDXGIObject)
43 || IsEqualGUID(riid, &IID_IUnknown))
45 IDXGISurface_AddRef(&surface->IDXGISurface_iface);
46 *out = &surface->IDXGISurface_iface;
47 return S_OK;
50 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
52 *out = NULL;
53 return E_NOINTERFACE;
56 static ULONG STDMETHODCALLTYPE dxgi_surface_inner_AddRef(IUnknown *iface)
58 struct dxgi_surface *surface = impl_from_IUnknown(iface);
59 ULONG refcount = InterlockedIncrement(&surface->refcount);
61 TRACE("%p increasing refcount to %u.\n", surface, refcount);
63 return refcount;
66 static ULONG STDMETHODCALLTYPE dxgi_surface_inner_Release(IUnknown *iface)
68 struct dxgi_surface *surface = impl_from_IUnknown(iface);
69 ULONG refcount = InterlockedDecrement(&surface->refcount);
71 TRACE("%p decreasing refcount to %u.\n", surface, refcount);
73 if (!refcount)
75 wined3d_private_store_cleanup(&surface->private_store);
76 HeapFree(GetProcessHeap(), 0, surface);
79 return refcount;
82 static inline struct dxgi_surface *impl_from_IDXGISurface(IDXGISurface *iface)
84 return CONTAINING_RECORD(iface, struct dxgi_surface, IDXGISurface_iface);
87 /* IUnknown methods */
89 static HRESULT STDMETHODCALLTYPE dxgi_surface_QueryInterface(IDXGISurface *iface, REFIID riid,
90 void **object)
92 struct dxgi_surface *This = impl_from_IDXGISurface(iface);
93 TRACE("Forwarding to outer IUnknown\n");
94 return IUnknown_QueryInterface(This->outer_unknown, riid, object);
97 static ULONG STDMETHODCALLTYPE dxgi_surface_AddRef(IDXGISurface *iface)
99 struct dxgi_surface *This = impl_from_IDXGISurface(iface);
100 TRACE("Forwarding to outer IUnknown\n");
101 return IUnknown_AddRef(This->outer_unknown);
104 static ULONG STDMETHODCALLTYPE dxgi_surface_Release(IDXGISurface *iface)
106 struct dxgi_surface *This = impl_from_IDXGISurface(iface);
107 TRACE("Forwarding to outer IUnknown\n");
108 return IUnknown_Release(This->outer_unknown);
111 /* IDXGIObject methods */
113 static HRESULT STDMETHODCALLTYPE dxgi_surface_SetPrivateData(IDXGISurface *iface,
114 REFGUID guid, UINT data_size, const void *data)
116 struct dxgi_surface *surface = impl_from_IDXGISurface(iface);
118 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
120 return dxgi_set_private_data(&surface->private_store, guid, data_size, data);
123 static HRESULT STDMETHODCALLTYPE dxgi_surface_SetPrivateDataInterface(IDXGISurface *iface,
124 REFGUID guid, const IUnknown *object)
126 struct dxgi_surface *surface = impl_from_IDXGISurface(iface);
128 TRACE("iface %p, guid %s, object %p.\n", iface, debugstr_guid(guid), object);
130 return dxgi_set_private_data_interface(&surface->private_store, guid, object);
133 static HRESULT STDMETHODCALLTYPE dxgi_surface_GetPrivateData(IDXGISurface *iface,
134 REFGUID guid, UINT *data_size, void *data)
136 struct dxgi_surface *surface = impl_from_IDXGISurface(iface);
138 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
140 return dxgi_get_private_data(&surface->private_store, guid, data_size, data);
143 static HRESULT STDMETHODCALLTYPE dxgi_surface_GetParent(IDXGISurface *iface, REFIID riid, void **parent)
145 struct dxgi_surface *This = impl_from_IDXGISurface(iface);
147 TRACE("iface %p, riid %s, parent %p.\n", iface, debugstr_guid(riid), parent);
149 return IDXGIDevice_QueryInterface(This->device, riid, parent);
152 /* IDXGIDeviceSubObject methods */
154 static HRESULT STDMETHODCALLTYPE dxgi_surface_GetDevice(IDXGISurface *iface, REFIID riid, void **device)
156 struct dxgi_surface *This = impl_from_IDXGISurface(iface);
158 TRACE("iface %p, riid %s, device %p.\n", iface, debugstr_guid(riid), device);
160 return IDXGIDevice_QueryInterface(This->device, riid, device);
163 /* IDXGISurface methods */
164 static HRESULT STDMETHODCALLTYPE dxgi_surface_GetDesc(IDXGISurface *iface, DXGI_SURFACE_DESC *desc)
166 struct dxgi_surface *surface = impl_from_IDXGISurface(iface);
167 struct wined3d_resource_desc wined3d_desc;
169 TRACE("iface %p, desc %p.\n", iface, desc);
171 wined3d_mutex_lock();
172 wined3d_resource_get_desc(surface->wined3d_resource, &wined3d_desc);
173 wined3d_mutex_unlock();
174 desc->Width = wined3d_desc.width;
175 desc->Height = wined3d_desc.height;
176 desc->Format = dxgi_format_from_wined3dformat(wined3d_desc.format);
177 dxgi_sample_desc_from_wined3d(&desc->SampleDesc, wined3d_desc.multisample_type, wined3d_desc.multisample_quality);
179 return S_OK;
182 static HRESULT STDMETHODCALLTYPE dxgi_surface_Map(IDXGISurface *iface, DXGI_MAPPED_RECT *mapped_rect, UINT flags)
184 FIXME("iface %p, mapped_rect %p, flags %#x stub!\n", iface, mapped_rect, flags);
186 return E_NOTIMPL;
189 static HRESULT STDMETHODCALLTYPE dxgi_surface_Unmap(IDXGISurface *iface)
191 FIXME("iface %p stub!\n", iface);
193 return E_NOTIMPL;
196 static const struct IDXGISurfaceVtbl dxgi_surface_vtbl =
198 /* IUnknown methods */
199 dxgi_surface_QueryInterface,
200 dxgi_surface_AddRef,
201 dxgi_surface_Release,
202 /* IDXGIObject methods */
203 dxgi_surface_SetPrivateData,
204 dxgi_surface_SetPrivateDataInterface,
205 dxgi_surface_GetPrivateData,
206 dxgi_surface_GetParent,
207 /* IDXGIDeviceSubObject methods */
208 dxgi_surface_GetDevice,
209 /* IDXGISurface methods */
210 dxgi_surface_GetDesc,
211 dxgi_surface_Map,
212 dxgi_surface_Unmap,
215 static const struct IUnknownVtbl dxgi_surface_inner_unknown_vtbl =
217 /* IUnknown methods */
218 dxgi_surface_inner_QueryInterface,
219 dxgi_surface_inner_AddRef,
220 dxgi_surface_inner_Release,
223 HRESULT dxgi_surface_init(struct dxgi_surface *surface, IDXGIDevice *device,
224 IUnknown *outer, struct wined3d_resource *wined3d_resource)
226 surface->IDXGISurface_iface.lpVtbl = &dxgi_surface_vtbl;
227 surface->IUnknown_iface.lpVtbl = &dxgi_surface_inner_unknown_vtbl;
228 surface->refcount = 1;
229 wined3d_private_store_init(&surface->private_store);
230 surface->outer_unknown = outer ? outer : &surface->IUnknown_iface;
231 surface->device = device;
232 surface->wined3d_resource = wined3d_resource;
234 return S_OK;