2009-01-15 09:58:44 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2009 Henri Verbeet for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#include "dxgi_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
|
|
|
|
|
2009-01-19 10:39:06 +01:00
|
|
|
/* Inner IUnknown methods */
|
2009-01-15 09:58:44 +01:00
|
|
|
|
2009-01-19 10:39:06 +01:00
|
|
|
static inline struct dxgi_surface *dxgi_surface_from_inner_unknown(IUnknown *iface)
|
|
|
|
{
|
|
|
|
return (struct dxgi_surface *)((char*)iface - FIELD_OFFSET(struct dxgi_surface, inner_unknown_vtbl));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_surface_inner_QueryInterface(IUnknown *iface, REFIID riid, void **object)
|
2009-01-15 09:58:44 +01:00
|
|
|
{
|
2009-01-19 10:39:06 +01:00
|
|
|
struct dxgi_surface *This = dxgi_surface_from_inner_unknown(iface);
|
|
|
|
|
2009-01-15 09:58:44 +01:00
|
|
|
TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IDXGISurface)
|
|
|
|
|| IsEqualGUID(riid, &IID_IDXGIDeviceSubObject)
|
|
|
|
|| IsEqualGUID(riid, &IID_IDXGIObject)
|
|
|
|
|| IsEqualGUID(riid, &IID_IUnknown))
|
|
|
|
{
|
2011-06-07 10:11:55 +02:00
|
|
|
IDXGISurface_AddRef(&This->IDXGISurface_iface);
|
2009-01-19 10:39:06 +01:00
|
|
|
*object = This;
|
2009-01-15 09:58:44 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
|
|
|
|
|
|
|
|
*object = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2009-01-19 10:39:06 +01:00
|
|
|
static ULONG STDMETHODCALLTYPE dxgi_surface_inner_AddRef(IUnknown *iface)
|
2009-01-15 09:58:44 +01:00
|
|
|
{
|
2009-01-19 10:39:06 +01:00
|
|
|
struct dxgi_surface *This = dxgi_surface_from_inner_unknown(iface);
|
2009-01-15 09:58:44 +01:00
|
|
|
ULONG refcount = InterlockedIncrement(&This->refcount);
|
|
|
|
|
|
|
|
TRACE("%p increasing refcount to %u\n", This, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2009-01-19 10:39:06 +01:00
|
|
|
static ULONG STDMETHODCALLTYPE dxgi_surface_inner_Release(IUnknown *iface)
|
2009-01-15 09:58:44 +01:00
|
|
|
{
|
2009-01-19 10:39:06 +01:00
|
|
|
struct dxgi_surface *This = dxgi_surface_from_inner_unknown(iface);
|
2009-01-15 09:58:44 +01:00
|
|
|
ULONG refcount = InterlockedDecrement(&This->refcount);
|
|
|
|
|
|
|
|
TRACE("%p decreasing refcount to %u\n", This, refcount);
|
|
|
|
|
|
|
|
if (!refcount)
|
|
|
|
{
|
2009-12-07 11:08:39 +01:00
|
|
|
IDXGIDevice_Release(This->device);
|
2009-01-15 09:58:44 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2011-06-07 10:11:55 +02:00
|
|
|
static inline struct dxgi_surface *impl_from_IDXGISurface(IDXGISurface *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct dxgi_surface, IDXGISurface_iface);
|
|
|
|
}
|
|
|
|
|
2009-01-19 10:39:06 +01:00
|
|
|
/* IUnknown methods */
|
|
|
|
|
2011-06-07 10:11:55 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_surface_QueryInterface(IDXGISurface *iface, REFIID riid,
|
|
|
|
void **object)
|
2009-01-19 10:39:06 +01:00
|
|
|
{
|
2011-06-07 10:11:55 +02:00
|
|
|
struct dxgi_surface *This = impl_from_IDXGISurface(iface);
|
2009-01-19 10:39:06 +01:00
|
|
|
TRACE("Forwarding to outer IUnknown\n");
|
|
|
|
return IUnknown_QueryInterface(This->outer_unknown, riid, object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE dxgi_surface_AddRef(IDXGISurface *iface)
|
|
|
|
{
|
2011-06-07 10:11:55 +02:00
|
|
|
struct dxgi_surface *This = impl_from_IDXGISurface(iface);
|
2009-01-19 10:39:06 +01:00
|
|
|
TRACE("Forwarding to outer IUnknown\n");
|
|
|
|
return IUnknown_AddRef(This->outer_unknown);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE dxgi_surface_Release(IDXGISurface *iface)
|
|
|
|
{
|
2011-06-07 10:11:55 +02:00
|
|
|
struct dxgi_surface *This = impl_from_IDXGISurface(iface);
|
2009-01-19 10:39:06 +01:00
|
|
|
TRACE("Forwarding to outer IUnknown\n");
|
|
|
|
return IUnknown_Release(This->outer_unknown);
|
|
|
|
}
|
|
|
|
|
2009-01-15 09:58:44 +01:00
|
|
|
/* IDXGIObject methods */
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_surface_SetPrivateData(IDXGISurface *iface,
|
|
|
|
REFGUID guid, UINT data_size, const void *data)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_surface_SetPrivateDataInterface(IDXGISurface *iface,
|
|
|
|
REFGUID guid, const IUnknown *object)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, guid %s, object %p stub!\n", iface, debugstr_guid(guid), object);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_surface_GetPrivateData(IDXGISurface *iface,
|
|
|
|
REFGUID guid, UINT *data_size, void *data)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, guid %s, data_size %p, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_surface_GetParent(IDXGISurface *iface, REFIID riid, void **parent)
|
|
|
|
{
|
2011-06-07 10:11:55 +02:00
|
|
|
struct dxgi_surface *This = impl_from_IDXGISurface(iface);
|
2009-01-15 09:58:44 +01:00
|
|
|
|
2009-12-07 11:08:40 +01:00
|
|
|
TRACE("iface %p, riid %s, parent %p.\n", iface, debugstr_guid(riid), parent);
|
|
|
|
|
|
|
|
return IDXGIDevice_QueryInterface(This->device, riid, parent);
|
2009-01-15 09:58:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* IDXGIDeviceSubObject methods */
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_surface_GetDevice(IDXGISurface *iface, REFIID riid, void **device)
|
|
|
|
{
|
2011-06-07 10:11:55 +02:00
|
|
|
struct dxgi_surface *This = impl_from_IDXGISurface(iface);
|
2009-01-15 09:58:44 +01:00
|
|
|
|
2009-12-07 11:08:39 +01:00
|
|
|
TRACE("iface %p, riid %s, device %p.\n", iface, debugstr_guid(riid), device);
|
|
|
|
|
|
|
|
return IDXGIDevice_QueryInterface(This->device, riid, device);
|
2009-01-15 09:58:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* IDXGISurface methods */
|
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_surface_GetDesc(IDXGISurface *iface, DXGI_SURFACE_DESC *desc)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, desc %p stub!\n", iface, desc);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_surface_Map(IDXGISurface *iface, DXGI_MAPPED_RECT *mapped_rect, UINT flags)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, mapped_rect %p, flags %#x stub!\n", iface, mapped_rect, flags);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_surface_Unmap(IDXGISurface *iface)
|
|
|
|
{
|
|
|
|
FIXME("iface %p stub!\n", iface);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-12-07 11:08:38 +01:00
|
|
|
static const struct IDXGISurfaceVtbl dxgi_surface_vtbl =
|
2009-01-15 09:58:44 +01:00
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
dxgi_surface_QueryInterface,
|
|
|
|
dxgi_surface_AddRef,
|
|
|
|
dxgi_surface_Release,
|
|
|
|
/* IDXGIObject methods */
|
|
|
|
dxgi_surface_SetPrivateData,
|
|
|
|
dxgi_surface_SetPrivateDataInterface,
|
|
|
|
dxgi_surface_GetPrivateData,
|
|
|
|
dxgi_surface_GetParent,
|
|
|
|
/* IDXGIDeviceSubObject methods */
|
|
|
|
dxgi_surface_GetDevice,
|
|
|
|
/* IDXGISurface methods */
|
|
|
|
dxgi_surface_GetDesc,
|
|
|
|
dxgi_surface_Map,
|
|
|
|
dxgi_surface_Unmap,
|
|
|
|
};
|
2009-01-19 10:39:06 +01:00
|
|
|
|
2009-12-07 11:08:38 +01:00
|
|
|
static const struct IUnknownVtbl dxgi_surface_inner_unknown_vtbl =
|
2009-01-19 10:39:06 +01:00
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
dxgi_surface_inner_QueryInterface,
|
|
|
|
dxgi_surface_inner_AddRef,
|
|
|
|
dxgi_surface_inner_Release,
|
|
|
|
};
|
2009-12-07 11:08:38 +01:00
|
|
|
|
2009-12-07 11:08:39 +01:00
|
|
|
HRESULT dxgi_surface_init(struct dxgi_surface *surface, IDXGIDevice *device, IUnknown *outer)
|
2009-12-07 11:08:38 +01:00
|
|
|
{
|
2011-06-07 10:11:55 +02:00
|
|
|
surface->IDXGISurface_iface.lpVtbl = &dxgi_surface_vtbl;
|
2009-12-07 11:08:38 +01:00
|
|
|
surface->inner_unknown_vtbl = &dxgi_surface_inner_unknown_vtbl;
|
|
|
|
surface->refcount = 1;
|
|
|
|
surface->outer_unknown = outer ? outer : (IUnknown *)&surface->inner_unknown_vtbl;
|
2009-12-07 11:08:39 +01:00
|
|
|
surface->device = device;
|
|
|
|
IDXGIDevice_AddRef(device);
|
2009-12-07 11:08:38 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|