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 | /*
|
---|
21 | * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
22 | * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
|
---|
23 | * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
|
---|
24 | * a choice of LGPL license versions is made available with the language indicating
|
---|
25 | * that LGPLv2 or any later version may be used, or where a choice of which version
|
---|
26 | * of the LGPL is applied is otherwise unspecified.
|
---|
27 | */
|
---|
28 |
|
---|
29 | #include "config.h"
|
---|
30 | #include "wine/port.h"
|
---|
31 |
|
---|
32 | #include "wined3d_private.h"
|
---|
33 |
|
---|
34 | WINE_DEFAULT_DEBUG_CHANNEL(d3d);
|
---|
35 |
|
---|
36 | /* IUnknown methods */
|
---|
37 |
|
---|
38 | static HRESULT STDMETHODCALLTYPE rendertarget_view_QueryInterface(IWineD3DRendertargetView *iface,
|
---|
39 | REFIID riid, void **object)
|
---|
40 | {
|
---|
41 | TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
|
---|
42 |
|
---|
43 | if (IsEqualGUID(riid, &IID_IWineD3DRendertargetView)
|
---|
44 | || IsEqualGUID(riid, &IID_IWineD3DBase)
|
---|
45 | || IsEqualGUID(riid, &IID_IUnknown))
|
---|
46 | {
|
---|
47 | IUnknown_AddRef(iface);
|
---|
48 | *object = iface;
|
---|
49 | return S_OK;
|
---|
50 | }
|
---|
51 |
|
---|
52 | WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
|
---|
53 |
|
---|
54 | *object = NULL;
|
---|
55 | return E_NOINTERFACE;
|
---|
56 | }
|
---|
57 |
|
---|
58 | static ULONG STDMETHODCALLTYPE rendertarget_view_AddRef(IWineD3DRendertargetView *iface)
|
---|
59 | {
|
---|
60 | struct wined3d_rendertarget_view *This = (struct wined3d_rendertarget_view *)iface;
|
---|
61 | ULONG refcount = InterlockedIncrement(&This->refcount);
|
---|
62 |
|
---|
63 | TRACE("%p increasing refcount to %u\n", This, refcount);
|
---|
64 |
|
---|
65 | return refcount;
|
---|
66 | }
|
---|
67 |
|
---|
68 | static ULONG STDMETHODCALLTYPE rendertarget_view_Release(IWineD3DRendertargetView *iface)
|
---|
69 | {
|
---|
70 | struct wined3d_rendertarget_view *This = (struct wined3d_rendertarget_view *)iface;
|
---|
71 | ULONG refcount = InterlockedDecrement(&This->refcount);
|
---|
72 |
|
---|
73 | TRACE("%p decreasing refcount to %u\n", This, refcount);
|
---|
74 |
|
---|
75 | if (!refcount)
|
---|
76 | {
|
---|
77 | IWineD3DResource_Release(This->resource);
|
---|
78 | HeapFree(GetProcessHeap(), 0, This);
|
---|
79 | }
|
---|
80 |
|
---|
81 | return refcount;
|
---|
82 | }
|
---|
83 |
|
---|
84 | /* IWineD3DBase methods */
|
---|
85 |
|
---|
86 | static HRESULT STDMETHODCALLTYPE rendertarget_view_GetParent(IWineD3DRendertargetView *iface, IUnknown **parent)
|
---|
87 | {
|
---|
88 | struct wined3d_rendertarget_view *This = (struct wined3d_rendertarget_view *)iface;
|
---|
89 |
|
---|
90 | IUnknown_AddRef(This->parent);
|
---|
91 | *parent = This->parent;
|
---|
92 |
|
---|
93 | return WINED3D_OK;
|
---|
94 | }
|
---|
95 |
|
---|
96 | /* IWineD3DRendertargetView methods */
|
---|
97 |
|
---|
98 | static HRESULT STDMETHODCALLTYPE rendertarget_view_GetResource(IWineD3DRendertargetView *iface,
|
---|
99 | IWineD3DResource **resource)
|
---|
100 | {
|
---|
101 | struct wined3d_rendertarget_view *This = (struct wined3d_rendertarget_view *)iface;
|
---|
102 |
|
---|
103 | IWineD3DResource_AddRef(This->resource);
|
---|
104 | *resource = This->resource;
|
---|
105 |
|
---|
106 | return WINED3D_OK;
|
---|
107 | }
|
---|
108 |
|
---|
109 | static const struct IWineD3DRendertargetViewVtbl wined3d_rendertarget_view_vtbl =
|
---|
110 | {
|
---|
111 | /* IUnknown methods */
|
---|
112 | rendertarget_view_QueryInterface,
|
---|
113 | rendertarget_view_AddRef,
|
---|
114 | rendertarget_view_Release,
|
---|
115 | /* IWineD3DBase methods */
|
---|
116 | rendertarget_view_GetParent,
|
---|
117 | /* IWineD3DRendertargetView methods */
|
---|
118 | rendertarget_view_GetResource,
|
---|
119 | };
|
---|
120 |
|
---|
121 | void wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *view,
|
---|
122 | IWineD3DResource *resource, IUnknown *parent)
|
---|
123 | {
|
---|
124 | view->vtbl = &wined3d_rendertarget_view_vtbl;
|
---|
125 | view->refcount = 1;
|
---|
126 | IWineD3DResource_AddRef(resource);
|
---|
127 | view->resource = resource;
|
---|
128 | view->parent = parent;
|
---|
129 | }
|
---|