advapi32: Implement EnumServicesStatusExA/W.
[wine] / dlls / wined3d / view.c
1 /*
2  * Copyright 2009 Henri Verbeet for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  *
18  */
19
20 #include "config.h"
21 #include "wine/port.h"
22
23 #include "wined3d_private.h"
24
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
26
27 /* IUnknown methods */
28
29 static HRESULT STDMETHODCALLTYPE rendertarget_view_QueryInterface(IWineD3DRendertargetView *iface,
30         REFIID riid, void **object)
31 {
32     TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
33
34     if (IsEqualGUID(riid, &IID_IWineD3DRendertargetView)
35             || IsEqualGUID(riid, &IID_IWineD3DBase)
36             || IsEqualGUID(riid, &IID_IUnknown))
37     {
38         IUnknown_AddRef(iface);
39         *object = iface;
40         return S_OK;
41     }
42
43     WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
44
45     *object = NULL;
46     return E_NOINTERFACE;
47 }
48
49 static ULONG STDMETHODCALLTYPE rendertarget_view_AddRef(IWineD3DRendertargetView *iface)
50 {
51     struct wined3d_rendertarget_view *This = (struct wined3d_rendertarget_view *)iface;
52     ULONG refcount = InterlockedIncrement(&This->refcount);
53
54     TRACE("%p increasing refcount to %u\n", This, refcount);
55
56     return refcount;
57 }
58
59 static ULONG STDMETHODCALLTYPE rendertarget_view_Release(IWineD3DRendertargetView *iface)
60 {
61     struct wined3d_rendertarget_view *This = (struct wined3d_rendertarget_view *)iface;
62     ULONG refcount = InterlockedDecrement(&This->refcount);
63
64     TRACE("%p decreasing refcount to %u\n", This, refcount);
65
66     if (!refcount)
67     {
68         IWineD3DResource_Release(This->resource);
69         HeapFree(GetProcessHeap(), 0, This);
70     }
71
72     return refcount;
73 }
74
75 /* IWineD3DBase methods */
76
77 static void * STDMETHODCALLTYPE rendertarget_view_GetParent(IWineD3DRendertargetView *iface)
78 {
79     TRACE("iface %p.\n", iface);
80
81     return ((struct wined3d_rendertarget_view *)iface)->parent;
82 }
83
84 /* IWineD3DRendertargetView methods */
85
86 static HRESULT STDMETHODCALLTYPE rendertarget_view_GetResource(IWineD3DRendertargetView *iface,
87         IWineD3DResource **resource)
88 {
89     struct wined3d_rendertarget_view *This = (struct wined3d_rendertarget_view *)iface;
90
91     IWineD3DResource_AddRef(This->resource);
92     *resource = This->resource;
93
94     return WINED3D_OK;
95 }
96
97 static const struct IWineD3DRendertargetViewVtbl wined3d_rendertarget_view_vtbl =
98 {
99     /* IUnknown methods */
100     rendertarget_view_QueryInterface,
101     rendertarget_view_AddRef,
102     rendertarget_view_Release,
103     /* IWineD3DBase methods */
104     rendertarget_view_GetParent,
105     /* IWineD3DRendertargetView methods */
106     rendertarget_view_GetResource,
107 };
108
109 void wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *view,
110         IWineD3DResource *resource, void *parent)
111 {
112     view->vtbl = &wined3d_rendertarget_view_vtbl;
113     view->refcount = 1;
114     IWineD3DResource_AddRef(resource);
115     view->resource = resource;
116     view->parent = parent;
117 }