From 2ab5b833d7006e001e8f101326df530ba7723952 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Tue, 5 Apr 2011 19:01:32 +0200 Subject: [PATCH] wined3d: Remove COM from the rendertarget view implementation. --- dlls/d3d10core/d3d10core_private.h | 2 +- dlls/d3d10core/device.c | 3 +- dlls/d3d10core/view.c | 8 ++-- dlls/wined3d/device.c | 14 ++---- dlls/wined3d/view.c | 74 ++++++------------------------ dlls/wined3d/wined3d.spec | 5 ++ dlls/wined3d/wined3d_private.h | 2 - include/wine/wined3d.idl | 22 ++++----- 8 files changed, 38 insertions(+), 92 deletions(-) diff --git a/dlls/d3d10core/d3d10core_private.h b/dlls/d3d10core/d3d10core_private.h index 716c3f2d42e..34d0b0f1b95 100644 --- a/dlls/d3d10core/d3d10core_private.h +++ b/dlls/d3d10core/d3d10core_private.h @@ -134,7 +134,7 @@ struct d3d10_rendertarget_view const struct ID3D10RenderTargetViewVtbl *vtbl; LONG refcount; - IWineD3DRendertargetView *wined3d_view; + struct wined3d_rendertarget_view *wined3d_view; D3D10_RENDER_TARGET_VIEW_DESC desc; }; diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c index 8fbd8c668a4..849516b95dd 100644 --- a/dlls/d3d10core/device.c +++ b/dlls/d3d10core/device.c @@ -372,12 +372,13 @@ static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device *i ID3D10RenderTargetView *render_target_view, const FLOAT color_rgba[4]) { struct d3d10_device *This = (struct d3d10_device *)iface; - IWineD3DRendertargetView *wined3d_view = ((struct d3d10_rendertarget_view *)render_target_view)->wined3d_view; + struct wined3d_rendertarget_view *wined3d_view; const WINED3DCOLORVALUE color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]}; TRACE("iface %p, render_target_view %p, color_rgba [%f %f %f %f]\n", iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]); + wined3d_view = ((struct d3d10_rendertarget_view *)render_target_view)->wined3d_view; IWineD3DDevice_ClearRendertargetView(This->wined3d_device, wined3d_view, &color); } diff --git a/dlls/d3d10core/view.c b/dlls/d3d10core/view.c index 1eb22ed9986..547da4e9311 100644 --- a/dlls/d3d10core/view.c +++ b/dlls/d3d10core/view.c @@ -328,7 +328,7 @@ static ULONG STDMETHODCALLTYPE d3d10_rendertarget_view_Release(ID3D10RenderTarge if (!refcount) { - IWineD3DRendertargetView_Release(This->wined3d_view); + wined3d_rendertarget_view_decref(This->wined3d_view); HeapFree(GetProcessHeap(), 0, This); } @@ -380,10 +380,10 @@ static void STDMETHODCALLTYPE d3d10_rendertarget_view_GetResource(ID3D10RenderTa TRACE("iface %p, resource %p\n", iface, resource); - hr = IWineD3DRendertargetView_GetResource(This->wined3d_view, &wined3d_resource); - if (FAILED(hr)) + wined3d_resource = wined3d_rendertarget_view_get_resource(This->wined3d_view); + if (!wined3d_resource) { - ERR("Failed to get wined3d resource, hr %#x\n", hr); + ERR("Failed to get wined3d resource.\n"); *resource = NULL; return; } diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 5e9f04ebf00..e91a0783fab 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1089,7 +1089,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UI } static HRESULT WINAPI IWineD3DDeviceImpl_CreateRendertargetView(IWineD3DDevice *iface, - struct wined3d_resource *resource, void *parent, IWineD3DRendertargetView **rendertarget_view) + struct wined3d_resource *resource, void *parent, struct wined3d_rendertarget_view **rendertarget_view) { struct wined3d_rendertarget_view *object; @@ -1106,7 +1106,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateRendertargetView(IWineD3DDevice * wined3d_rendertarget_view_init(object, resource, parent); TRACE("Created render target view %p.\n", object); - *rendertarget_view = (IWineD3DRendertargetView *)object; + *rendertarget_view = object; return WINED3D_OK; } @@ -5776,18 +5776,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ColorFill(IWineD3DDevice *iface, /* Do not call while under the GL lock. */ static void WINAPI IWineD3DDeviceImpl_ClearRendertargetView(IWineD3DDevice *iface, - IWineD3DRendertargetView *rendertarget_view, const WINED3DCOLORVALUE *color) + struct wined3d_rendertarget_view *rendertarget_view, const WINED3DCOLORVALUE *color) { struct wined3d_resource *resource; HRESULT hr; - hr = IWineD3DRendertargetView_GetResource(rendertarget_view, &resource); - if (FAILED(hr)) - { - ERR("Failed to get resource, hr %#x\n", hr); - return; - } - + resource = rendertarget_view->resource; if (resource->resourceType != WINED3DRTYPE_SURFACE) { FIXME("Only supported on surface resources\n"); diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index ab1c831a71e..1ba930451f0 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -1,5 +1,5 @@ /* - * Copyright 2009 Henri Verbeet for CodeWeavers + * Copyright 2009, 2011 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 @@ -24,90 +24,44 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d); -/* IUnknown methods */ - -static HRESULT STDMETHODCALLTYPE rendertarget_view_QueryInterface(IWineD3DRendertargetView *iface, - REFIID riid, void **object) +ULONG CDECL wined3d_rendertarget_view_incref(struct wined3d_rendertarget_view *view) { - TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object); + ULONG refcount = InterlockedIncrement(&view->refcount); - 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); + TRACE("%p increasing refcount to %u.\n", view, refcount); return refcount; } -static ULONG STDMETHODCALLTYPE rendertarget_view_Release(IWineD3DRendertargetView *iface) +ULONG CDECL wined3d_rendertarget_view_decref(struct wined3d_rendertarget_view *view) { - struct wined3d_rendertarget_view *This = (struct wined3d_rendertarget_view *)iface; - ULONG refcount = InterlockedDecrement(&This->refcount); + ULONG refcount = InterlockedDecrement(&view->refcount); - TRACE("%p decreasing refcount to %u\n", This, refcount); + TRACE("%p decreasing refcount to %u.\n", view, refcount); if (!refcount) - { - HeapFree(GetProcessHeap(), 0, This); - } + HeapFree(GetProcessHeap(), 0, view); return refcount; } -/* IWineD3DBase methods */ - -static void * STDMETHODCALLTYPE rendertarget_view_GetParent(IWineD3DRendertargetView *iface) +void * CDECL wined3d_rendertarget_view_get_parent(const struct wined3d_rendertarget_view *view) { - TRACE("iface %p.\n", iface); + TRACE("view %p.\n", view); - return ((struct wined3d_rendertarget_view *)iface)->parent; + return view->parent; } -/* IWineD3DRendertargetView methods */ - -static HRESULT STDMETHODCALLTYPE rendertarget_view_GetResource(IWineD3DRendertargetView *iface, - struct wined3d_resource **resource) +struct wined3d_resource * CDECL wined3d_rendertarget_view_get_resource(const struct wined3d_rendertarget_view *view) { - struct wined3d_rendertarget_view *This = (struct wined3d_rendertarget_view *)iface; + TRACE("view %p.\n", view); - *resource = This->resource; - - return WINED3D_OK; + return view->resource; } -static 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, -}; - void wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *view, struct wined3d_resource *resource, void *parent) { - view->vtbl = &wined3d_rendertarget_view_vtbl; view->refcount = 1; view->resource = resource; view->parent = parent; diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 28bdf4ea1d4..0a75eda4060 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -61,6 +61,11 @@ @ cdecl wined3d_resource_get_desc(ptr ptr) @ cdecl wined3d_resource_get_parent(ptr) +@ cdecl wined3d_rendertarget_view_decref(ptr) +@ cdecl wined3d_rendertarget_view_get_parent(ptr) +@ cdecl wined3d_rendertarget_view_get_resource(ptr) +@ cdecl wined3d_rendertarget_view_incref(ptr) + @ cdecl wined3d_shader_decref(ptr) @ cdecl wined3d_shader_get_byte_code(ptr ptr ptr) @ cdecl wined3d_shader_get_parent(ptr) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 190e877de1e..f1ce5cfc98a 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2507,10 +2507,8 @@ HRESULT buffer_init(struct wined3d_buffer *buffer, IWineD3DDeviceImpl *device, UINT size, DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool, GLenum bind_hint, const char *data, void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN; -/* IWineD3DRendertargetView */ struct wined3d_rendertarget_view { - const struct IWineD3DRendertargetViewVtbl *vtbl; LONG refcount; struct wined3d_resource *resource; diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl index ad32234d6c6..00e6d0e998f 100644 --- a/include/wine/wined3d.idl +++ b/include/wine/wined3d.idl @@ -2096,6 +2096,7 @@ struct wined3d_clipper; struct wined3d_palette; struct wined3d_query; struct wined3d_resource; +struct wined3d_rendertarget_view; struct wined3d_shader; struct wined3d_stateblock; struct wined3d_texture; @@ -2207,18 +2208,6 @@ interface IWineD3DResource : IWineD3DBase ); } -[ - object, - local, - uuid(f7d8abf4-fb93-43e4-9c96-4618cf9b3cbc) -] -interface IWineD3DRendertargetView : IWineD3DBase -{ - HRESULT GetResource( - [out] struct wined3d_resource **resource - ); -} - [ object, local, @@ -2438,7 +2427,7 @@ interface IWineD3DDevice : IUnknown HRESULT CreateRendertargetView( [in] struct wined3d_resource *resource, [in] void *parent, - [out] IWineD3DRendertargetView **rendertarget_view + [out] struct wined3d_rendertarget_view **rendertarget_view ); HRESULT CreateTexture( [in] UINT width, @@ -2893,7 +2882,7 @@ interface IWineD3DDevice : IUnknown [in] DWORD stencil ); void ClearRendertargetView( - [in] IWineD3DRendertargetView *rendertarget_view, + [in] struct wined3d_rendertarget_view *rendertarget_view, [in] const WINED3DCOLORVALUE *color ); void SetPrimitiveType( @@ -3075,6 +3064,11 @@ void __cdecl wined3d_resource_get_desc(const struct wined3d_resource *resource, struct wined3d_resource_desc *desc); void * __cdecl wined3d_resource_get_parent(const struct wined3d_resource *resource); +ULONG __cdecl wined3d_rendertarget_view_decref(struct wined3d_rendertarget_view *view); +void * __cdecl wined3d_rendertarget_view_get_parent(const struct wined3d_rendertarget_view *view); +struct wined3d_resource * __cdecl wined3d_rendertarget_view_get_resource(const struct wined3d_rendertarget_view *view); +ULONG __cdecl wined3d_rendertarget_view_incref(struct wined3d_rendertarget_view *view); + ULONG __cdecl wined3d_shader_decref(struct wined3d_shader *shader); HRESULT __cdecl wined3d_shader_get_byte_code(const struct wined3d_shader *shader, void *byte_code, UINT *byte_code_size);