push c4c845830c6aff14e1b16bbb8b4a57a7e0d6213f
[wine/hacks.git] / dlls / d3d10core / view.c
blob4643661620389c9a45fe6d16f7149248a519e6ed
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 "d3d10core_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d10core);
27 /* IUnknown methods */
29 static HRESULT STDMETHODCALLTYPE d3d10_rendertarget_view_QueryInterface(ID3D10RenderTargetView *iface,
30 REFIID riid, void **object)
32 TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
34 if (IsEqualGUID(riid, &IID_ID3D10RenderTargetView)
35 || IsEqualGUID(riid, &IID_ID3D10View)
36 || IsEqualGUID(riid, &IID_ID3D10DeviceChild)
37 || IsEqualGUID(riid, &IID_IUnknown))
39 IUnknown_AddRef(iface);
40 *object = iface;
41 return S_OK;
44 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
46 *object = NULL;
47 return E_NOINTERFACE;
50 static ULONG STDMETHODCALLTYPE d3d10_rendertarget_view_AddRef(ID3D10RenderTargetView *iface)
52 struct d3d10_rendertarget_view *This = (struct d3d10_rendertarget_view *)iface;
53 ULONG refcount = InterlockedIncrement(&This->refcount);
55 TRACE("%p increasing refcount to %u\n", This, refcount);
57 return refcount;
60 static ULONG STDMETHODCALLTYPE d3d10_rendertarget_view_Release(ID3D10RenderTargetView *iface)
62 struct d3d10_rendertarget_view *This = (struct d3d10_rendertarget_view *)iface;
63 ULONG refcount = InterlockedDecrement(&This->refcount);
65 TRACE("%p decreasing refcount to %u\n", This, refcount);
67 if (!refcount)
69 IWineD3DRendertargetView_Release(This->wined3d_view);
70 HeapFree(GetProcessHeap(), 0, This);
73 return refcount;
76 /* ID3D10DeviceChild methods */
78 static void STDMETHODCALLTYPE d3d10_rendertarget_view_GetDevice(ID3D10RenderTargetView *iface, ID3D10Device **device)
80 FIXME("iface %p, device %p stub!\n", iface, device);
83 static HRESULT STDMETHODCALLTYPE d3d10_rendertarget_view_GetPrivateData(ID3D10RenderTargetView *iface,
84 REFGUID guid, UINT *data_size, void *data)
86 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
87 iface, debugstr_guid(guid), data_size, data);
89 return E_NOTIMPL;
92 static HRESULT STDMETHODCALLTYPE d3d10_rendertarget_view_SetPrivateData(ID3D10RenderTargetView *iface,
93 REFGUID guid, UINT data_size, const void *data)
95 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
96 iface, debugstr_guid(guid), data_size, data);
98 return E_NOTIMPL;
101 static HRESULT STDMETHODCALLTYPE d3d10_rendertarget_view_SetPrivateDataInterface(ID3D10RenderTargetView *iface,
102 REFGUID guid, const IUnknown *data)
104 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
106 return E_NOTIMPL;
109 /* ID3D10View methods */
111 static void STDMETHODCALLTYPE d3d10_rendertarget_view_GetResource(ID3D10RenderTargetView *iface,
112 ID3D10Resource **resource)
114 struct d3d10_rendertarget_view *This = (struct d3d10_rendertarget_view *)iface;
115 IWineD3DResource *wined3d_resource;
116 IUnknown *parent;
117 HRESULT hr;
119 TRACE("iface %p, resource %p\n", iface, resource);
121 hr = IWineD3DRendertargetView_GetResource(This->wined3d_view, &wined3d_resource);
122 if (FAILED(hr))
124 ERR("Failed to get wined3d resource, hr %#x\n", hr);
125 *resource = NULL;
126 return;
129 hr = IWineD3DResource_GetParent(wined3d_resource, &parent);
130 IWineD3DResource_Release(wined3d_resource);
131 if (FAILED(hr))
133 ERR("Failed to get wined3d resource parent, hr %#x\n", hr);
134 *resource = NULL;
135 return;
138 hr = IUnknown_QueryInterface(parent, &IID_ID3D10Resource, (void **)&resource);
139 IUnknown_Release(parent);
140 if (FAILED(hr))
142 ERR("Resource parent isn't a d3d10 resource, hr %#x\n", hr);
143 *resource = NULL;
144 return;
148 /* ID3D10RenderTargetView methods */
150 static void STDMETHODCALLTYPE d3d10_rendertarget_view_GetDesc(ID3D10RenderTargetView* iface,
151 D3D10_RENDER_TARGET_VIEW_DESC *desc)
153 struct d3d10_rendertarget_view *This = (struct d3d10_rendertarget_view *)iface;
155 TRACE("iface %p, desc %p\n", iface, desc);
157 *desc = This->desc;
160 const struct ID3D10RenderTargetViewVtbl d3d10_rendertarget_view_vtbl =
162 /* IUnknown methods */
163 d3d10_rendertarget_view_QueryInterface,
164 d3d10_rendertarget_view_AddRef,
165 d3d10_rendertarget_view_Release,
166 /* ID3D10DeviceChild methods */
167 d3d10_rendertarget_view_GetDevice,
168 d3d10_rendertarget_view_GetPrivateData,
169 d3d10_rendertarget_view_SetPrivateData,
170 d3d10_rendertarget_view_SetPrivateDataInterface,
171 /* ID3D10View methods */
172 d3d10_rendertarget_view_GetResource,
173 /* ID3D10RenderTargetView methods */
174 d3d10_rendertarget_view_GetDesc,