gdi32: Stop exporting the 16-bit print job functions.
[wine] / dlls / dxgi / surface.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 "dxgi_private.h"
24
25 WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
26
27 /* Inner IUnknown methods */
28
29 static inline struct dxgi_surface *dxgi_surface_from_inner_unknown(IUnknown *iface)
30 {
31     return (struct dxgi_surface *)((char*)iface - FIELD_OFFSET(struct dxgi_surface, inner_unknown_vtbl));
32 }
33
34 static HRESULT STDMETHODCALLTYPE dxgi_surface_inner_QueryInterface(IUnknown *iface, REFIID riid, void **object)
35 {
36     struct dxgi_surface *This = dxgi_surface_from_inner_unknown(iface);
37
38     TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
39
40     if (IsEqualGUID(riid, &IID_IDXGISurface)
41             || IsEqualGUID(riid, &IID_IDXGIDeviceSubObject)
42             || IsEqualGUID(riid, &IID_IDXGIObject)
43             || IsEqualGUID(riid, &IID_IUnknown))
44     {
45         IUnknown_AddRef((IUnknown *)This);
46         *object = This;
47         return S_OK;
48     }
49
50     WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
51
52     *object = NULL;
53     return E_NOINTERFACE;
54 }
55
56 static ULONG STDMETHODCALLTYPE dxgi_surface_inner_AddRef(IUnknown *iface)
57 {
58     struct dxgi_surface *This = dxgi_surface_from_inner_unknown(iface);
59     ULONG refcount = InterlockedIncrement(&This->refcount);
60
61     TRACE("%p increasing refcount to %u\n", This, refcount);
62
63     return refcount;
64 }
65
66 static ULONG STDMETHODCALLTYPE dxgi_surface_inner_Release(IUnknown *iface)
67 {
68     struct dxgi_surface *This = dxgi_surface_from_inner_unknown(iface);
69     ULONG refcount = InterlockedDecrement(&This->refcount);
70
71     TRACE("%p decreasing refcount to %u\n", This, refcount);
72
73     if (!refcount)
74     {
75         HeapFree(GetProcessHeap(), 0, This);
76     }
77
78     return refcount;
79 }
80
81 /* IUnknown methods */
82
83 static HRESULT STDMETHODCALLTYPE dxgi_surface_QueryInterface(IDXGISurface *iface, REFIID riid, void **object)
84 {
85     struct dxgi_surface *This = (struct dxgi_surface *)iface;
86     TRACE("Forwarding to outer IUnknown\n");
87     return IUnknown_QueryInterface(This->outer_unknown, riid, object);
88 }
89
90 static ULONG STDMETHODCALLTYPE dxgi_surface_AddRef(IDXGISurface *iface)
91 {
92     struct dxgi_surface *This = (struct dxgi_surface *)iface;
93     TRACE("Forwarding to outer IUnknown\n");
94     return IUnknown_AddRef(This->outer_unknown);
95 }
96
97 static ULONG STDMETHODCALLTYPE dxgi_surface_Release(IDXGISurface *iface)
98 {
99     struct dxgi_surface *This = (struct dxgi_surface *)iface;
100     TRACE("Forwarding to outer IUnknown\n");
101     return IUnknown_Release(This->outer_unknown);
102 }
103
104 /* IDXGIObject methods */
105
106 static HRESULT STDMETHODCALLTYPE dxgi_surface_SetPrivateData(IDXGISurface *iface,
107         REFGUID guid, UINT data_size, const void *data)
108 {
109     FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
110
111     return E_NOTIMPL;
112 }
113
114 static HRESULT STDMETHODCALLTYPE dxgi_surface_SetPrivateDataInterface(IDXGISurface *iface,
115         REFGUID guid, const IUnknown *object)
116 {
117     FIXME("iface %p, guid %s, object %p stub!\n", iface, debugstr_guid(guid), object);
118
119     return E_NOTIMPL;
120 }
121
122 static HRESULT STDMETHODCALLTYPE dxgi_surface_GetPrivateData(IDXGISurface *iface,
123         REFGUID guid, UINT *data_size, void *data)
124 {
125     FIXME("iface %p, guid %s, data_size %p, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
126
127     return E_NOTIMPL;
128 }
129
130 static HRESULT STDMETHODCALLTYPE dxgi_surface_GetParent(IDXGISurface *iface, REFIID riid, void **parent)
131 {
132     FIXME("iface %p, riid %s, parent %p stub!\n", iface, debugstr_guid(riid), parent);
133
134     return E_NOTIMPL;
135 }
136
137 /* IDXGIDeviceSubObject methods */
138
139 static HRESULT STDMETHODCALLTYPE dxgi_surface_GetDevice(IDXGISurface *iface, REFIID riid, void **device)
140 {
141     FIXME("iface %p, riid %s, device %p stub!\n", iface, debugstr_guid(riid), device);
142
143     return E_NOTIMPL;
144 }
145
146 /* IDXGISurface methods */
147 static HRESULT STDMETHODCALLTYPE dxgi_surface_GetDesc(IDXGISurface *iface, DXGI_SURFACE_DESC *desc)
148 {
149     FIXME("iface %p, desc %p stub!\n", iface, desc);
150
151     return E_NOTIMPL;
152 }
153
154 static HRESULT STDMETHODCALLTYPE dxgi_surface_Map(IDXGISurface *iface, DXGI_MAPPED_RECT *mapped_rect, UINT flags)
155 {
156     FIXME("iface %p, mapped_rect %p, flags %#x stub!\n", iface, mapped_rect, flags);
157
158     return E_NOTIMPL;
159 }
160
161 static HRESULT STDMETHODCALLTYPE dxgi_surface_Unmap(IDXGISurface *iface)
162 {
163     FIXME("iface %p stub!\n", iface);
164
165     return E_NOTIMPL;
166 }
167
168 const struct IDXGISurfaceVtbl dxgi_surface_vtbl =
169 {
170     /* IUnknown methods */
171     dxgi_surface_QueryInterface,
172     dxgi_surface_AddRef,
173     dxgi_surface_Release,
174     /* IDXGIObject methods */
175     dxgi_surface_SetPrivateData,
176     dxgi_surface_SetPrivateDataInterface,
177     dxgi_surface_GetPrivateData,
178     dxgi_surface_GetParent,
179     /* IDXGIDeviceSubObject methods */
180     dxgi_surface_GetDevice,
181     /* IDXGISurface methods */
182     dxgi_surface_GetDesc,
183     dxgi_surface_Map,
184     dxgi_surface_Unmap,
185 };
186
187 const struct IUnknownVtbl dxgi_surface_inner_unknown_vtbl =
188 {
189     /* IUnknown methods */
190     dxgi_surface_inner_QueryInterface,
191     dxgi_surface_inner_AddRef,
192     dxgi_surface_inner_Release,
193 };