From c796f7648391cf94a351c6bb28e3b1d1bf4c8f5c Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Tue, 24 Feb 2009 07:43:02 +0100 Subject: [PATCH] wined3d: Add IWineD3DRendertargetView. --- dlls/wined3d/Makefile.in | 1 + dlls/wined3d/device.c | 24 +++++++ dlls/wined3d/view.c | 110 +++++++++++++++++++++++++++++++++ dlls/wined3d/wined3d_private.h | 12 ++++ include/wine/wined3d.idl | 17 +++++ 5 files changed, 164 insertions(+) create mode 100644 dlls/wined3d/view.c diff --git a/dlls/wined3d/Makefile.in b/dlls/wined3d/Makefile.in index 03826c85b0..5eaa1bfca5 100644 --- a/dlls/wined3d/Makefile.in +++ b/dlls/wined3d/Makefile.in @@ -37,6 +37,7 @@ C_SRCS = \ utils.c \ vertexdeclaration.c \ vertexshader.c \ + view.c \ volume.c \ volumetexture.c \ wined3d_main.c diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 6be674606b..21968942a9 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -793,6 +793,29 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U return hr; } +static HRESULT WINAPI IWineD3DDeviceImpl_CreateRendertargetView(IWineD3DDevice *iface, + IWineD3DResource *resource, IUnknown *parent, IWineD3DRendertargetView **rendertarget_view) +{ + struct wined3d_rendertarget_view *object; + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + if (!object) + { + ERR("Failed to allocate memory\n"); + return E_OUTOFMEMORY; + } + + object->vtbl = &wined3d_rendertarget_view_vtbl; + object->refcount = 1; + IWineD3DResource_AddRef(resource); + object->resource = resource; + object->parent = parent; + + *rendertarget_view = (IWineD3DRendertargetView *)object; + + return WINED3D_OK; +} + static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, UINT Width, UINT Height, UINT Levels, DWORD Usage, WINED3DFORMAT Format, WINED3DPOOL Pool, IWineD3DTexture **ppTexture, HANDLE *pSharedHandle, IUnknown *parent) @@ -7575,6 +7598,7 @@ const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl = IWineD3DDeviceImpl_CreateIndexBuffer, IWineD3DDeviceImpl_CreateStateBlock, IWineD3DDeviceImpl_CreateSurface, + IWineD3DDeviceImpl_CreateRendertargetView, IWineD3DDeviceImpl_CreateTexture, IWineD3DDeviceImpl_CreateVolumeTexture, IWineD3DDeviceImpl_CreateVolume, diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c new file mode 100644 index 0000000000..bbf0f5f65c --- /dev/null +++ b/dlls/wined3d/view.c @@ -0,0 +1,110 @@ +/* + * 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 "wined3d_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3d); + +/* IUnknown methods */ + +static HRESULT STDMETHODCALLTYPE rendertarget_view_QueryInterface(IWineD3DRendertargetView *iface, + REFIID riid, void **object) +{ + TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object); + + if (IsEqualGUID(riid, &IID_IWineD3DRendertargetView) + || IsEqualGUID(riid, &IID_IWineD3DBase) + || IsEqualGUID(riid, &IID_IUnknown)) + { + IUnknown_AddRef(iface); + *object = iface; + return S_OK; + } + + WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid)); + + *object = NULL; + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE rendertarget_view_AddRef(IWineD3DRendertargetView *iface) +{ + struct wined3d_rendertarget_view *This = (struct wined3d_rendertarget_view *)iface; + ULONG refcount = InterlockedIncrement(&This->refcount); + + TRACE("%p increasing refcount to %u\n", This, refcount); + + return refcount; +} + +static ULONG STDMETHODCALLTYPE rendertarget_view_Release(IWineD3DRendertargetView *iface) +{ + struct wined3d_rendertarget_view *This = (struct wined3d_rendertarget_view *)iface; + ULONG refcount = InterlockedDecrement(&This->refcount); + + TRACE("%p decreasing refcount to %u\n", This, refcount); + + if (!refcount) + { + IWineD3DResource_Release(This->resource); + HeapFree(GetProcessHeap(), 0, This); + } + + return refcount; +} + +/* IWineD3DBase methods */ + +static HRESULT STDMETHODCALLTYPE rendertarget_view_GetParent(IWineD3DRendertargetView *iface, IUnknown **parent) +{ + struct wined3d_rendertarget_view *This = (struct wined3d_rendertarget_view *)iface; + + IUnknown_AddRef(This->parent); + *parent = This->parent; + + return WINED3D_OK; +} + +/* IWineD3DRendertargetView methods */ + +static HRESULT STDMETHODCALLTYPE rendertarget_view_GetResource(IWineD3DRendertargetView *iface, + IWineD3DResource **resource) +{ + struct wined3d_rendertarget_view *This = (struct wined3d_rendertarget_view *)iface; + + IWineD3DResource_AddRef(This->resource); + *resource = This->resource; + + return WINED3D_OK; +} + +const struct IWineD3DRendertargetViewVtbl wined3d_rendertarget_view_vtbl = +{ + /* IUnknown methods */ + rendertarget_view_QueryInterface, + rendertarget_view_AddRef, + rendertarget_view_Release, + /* IWineD3DBase methods */ + rendertarget_view_GetParent, + /* IWineD3DRendertargetView methods */ + rendertarget_view_GetResource, +}; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 8a88cf1f2b..4c895b1e41 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1985,6 +1985,18 @@ struct wined3d_buffer extern const IWineD3DBufferVtbl wined3d_buffer_vtbl; +/* IWineD3DRendertargetView */ +struct wined3d_rendertarget_view +{ + const struct IWineD3DRendertargetViewVtbl *vtbl; + LONG refcount; + + IWineD3DResource *resource; + IUnknown *parent; +}; + +extern const IWineD3DRendertargetViewVtbl wined3d_rendertarget_view_vtbl; + /***************************************************************************** * IWineD3DSwapChainImpl implementation structure (extends IUnknown) */ diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl index dc376d06c0..70e73b51e0 100644 --- a/include/wine/wined3d.idl +++ b/include/wine/wined3d.idl @@ -2393,6 +2393,18 @@ interface IWineD3DResource : IWineD3DBase ); } +[ + object, + local, + uuid(f7d8abf4-fb93-43e4-9c96-4618cf9b3cbc) +] +interface IWineD3DRendertargetView : IWineD3DBase +{ + HRESULT GetResource( + [out] IWineD3DResource **resource + ); +} + [ object, local, @@ -3012,6 +3024,11 @@ interface IWineD3DDevice : IWineD3DBase [in] WINED3DSURFTYPE surface_type, [in] IUnknown *parent ); + HRESULT CreateRendertargetView( + [in] IWineD3DResource *resource, + [in] IUnknown *parent, + [out] IWineD3DRendertargetView **rendertarget_view + ); HRESULT CreateTexture( [in] UINT width, [in] UINT height,