ddraw: Merge the surface thunks into surface.c.
[wine] / dlls / d3d10core / state.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 "d3d10core_private.h"
24
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d10core);
26
27 /* IUnknown methods */
28
29 static HRESULT STDMETHODCALLTYPE d3d10_blend_state_QueryInterface(ID3D10BlendState *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_ID3D10BlendState)
35             || IsEqualGUID(riid, &IID_ID3D10DeviceChild)
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 d3d10_blend_state_AddRef(ID3D10BlendState *iface)
50 {
51     struct d3d10_blend_state *This = (struct d3d10_blend_state *)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 d3d10_blend_state_Release(ID3D10BlendState *iface)
60 {
61     struct d3d10_blend_state *This = (struct d3d10_blend_state *)iface;
62     ULONG refcount = InterlockedDecrement(&This->refcount);
63
64     TRACE("%p decreasing refcount to %u.\n", This, refcount);
65
66     if (!refcount)
67     {
68         HeapFree(GetProcessHeap(), 0, This);
69     }
70
71     return refcount;
72 }
73
74 /* ID3D10DeviceChild methods */
75
76 static void STDMETHODCALLTYPE d3d10_blend_state_GetDevice(ID3D10BlendState *iface, ID3D10Device **device)
77 {
78     FIXME("iface %p, device %p stub!\n", iface, device);
79 }
80
81 static HRESULT STDMETHODCALLTYPE d3d10_blend_state_GetPrivateData(ID3D10BlendState *iface,
82         REFGUID guid, UINT *data_size, void *data)
83 {
84     FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
85             iface, debugstr_guid(guid), data_size, data);
86
87     return E_NOTIMPL;
88 }
89
90 static HRESULT STDMETHODCALLTYPE d3d10_blend_state_SetPrivateData(ID3D10BlendState *iface,
91         REFGUID guid, UINT data_size, const void *data)
92 {
93     FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
94             iface, debugstr_guid(guid), data_size, data);
95
96     return E_NOTIMPL;
97 }
98
99 static HRESULT STDMETHODCALLTYPE d3d10_blend_state_SetPrivateDataInterface(ID3D10BlendState *iface,
100         REFGUID guid, const IUnknown *data)
101 {
102     FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
103
104     return E_NOTIMPL;
105 }
106
107 /* ID3D10BlendState methods */
108
109 static void STDMETHODCALLTYPE d3d10_blend_state_GetDesc(ID3D10BlendState *iface,
110         D3D10_BLEND_DESC *desc)
111 {
112     FIXME("iface %p, desc %p stub!\n", iface, desc);
113 }
114
115 static const struct ID3D10BlendStateVtbl d3d10_blend_state_vtbl =
116 {
117     /* IUnknown methods */
118     d3d10_blend_state_QueryInterface,
119     d3d10_blend_state_AddRef,
120     d3d10_blend_state_Release,
121     /* ID3D10DeviceChild methods */
122     d3d10_blend_state_GetDevice,
123     d3d10_blend_state_GetPrivateData,
124     d3d10_blend_state_SetPrivateData,
125     d3d10_blend_state_SetPrivateDataInterface,
126     /* ID3D10BlendState methods */
127     d3d10_blend_state_GetDesc,
128 };
129
130 HRESULT d3d10_blend_state_init(struct d3d10_blend_state *state)
131 {
132     state->vtbl = &d3d10_blend_state_vtbl;
133     state->refcount = 1;
134
135     return S_OK;
136 }
137
138 /* IUnknown methods */
139
140 static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_state_QueryInterface(ID3D10DepthStencilState *iface,
141         REFIID riid, void **object)
142 {
143     TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
144
145     if (IsEqualGUID(riid, &IID_ID3D10DepthStencilState)
146             || IsEqualGUID(riid, &IID_ID3D10DeviceChild)
147             || IsEqualGUID(riid, &IID_IUnknown))
148     {
149         IUnknown_AddRef(iface);
150         *object = iface;
151         return S_OK;
152     }
153
154     WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
155
156     *object = NULL;
157     return E_NOINTERFACE;
158 }
159
160 static ULONG STDMETHODCALLTYPE d3d10_depthstencil_state_AddRef(ID3D10DepthStencilState *iface)
161 {
162     struct d3d10_depthstencil_state *This = (struct d3d10_depthstencil_state *)iface;
163     ULONG refcount = InterlockedIncrement(&This->refcount);
164
165     TRACE("%p increasing refcount to %u.\n", This, refcount);
166
167     return refcount;
168 }
169
170 static ULONG STDMETHODCALLTYPE d3d10_depthstencil_state_Release(ID3D10DepthStencilState *iface)
171 {
172     struct d3d10_depthstencil_state *This = (struct d3d10_depthstencil_state *)iface;
173     ULONG refcount = InterlockedDecrement(&This->refcount);
174
175     TRACE("%p decreasing refcount to %u.\n", This, refcount);
176
177     if (!refcount)
178     {
179         HeapFree(GetProcessHeap(), 0, This);
180     }
181
182     return refcount;
183 }
184
185 /* ID3D10DeviceChild methods */
186
187 static void STDMETHODCALLTYPE d3d10_depthstencil_state_GetDevice(ID3D10DepthStencilState *iface, ID3D10Device **device)
188 {
189     FIXME("iface %p, device %p stub!\n", iface, device);
190 }
191
192 static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_state_GetPrivateData(ID3D10DepthStencilState *iface,
193         REFGUID guid, UINT *data_size, void *data)
194 {
195     FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
196             iface, debugstr_guid(guid), data_size, data);
197
198     return E_NOTIMPL;
199 }
200
201 static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_state_SetPrivateData(ID3D10DepthStencilState *iface,
202         REFGUID guid, UINT data_size, const void *data)
203 {
204     FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
205             iface, debugstr_guid(guid), data_size, data);
206
207     return E_NOTIMPL;
208 }
209
210 static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_state_SetPrivateDataInterface(ID3D10DepthStencilState *iface,
211         REFGUID guid, const IUnknown *data)
212 {
213     FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
214
215     return E_NOTIMPL;
216 }
217
218 /* ID3D10DepthStencilState methods */
219
220 static void STDMETHODCALLTYPE d3d10_depthstencil_state_GetDesc(ID3D10DepthStencilState *iface,
221         D3D10_DEPTH_STENCIL_DESC *desc)
222 {
223     FIXME("iface %p, desc %p stub!\n", iface, desc);
224 }
225
226 static const struct ID3D10DepthStencilStateVtbl d3d10_depthstencil_state_vtbl =
227 {
228     /* IUnknown methods */
229     d3d10_depthstencil_state_QueryInterface,
230     d3d10_depthstencil_state_AddRef,
231     d3d10_depthstencil_state_Release,
232     /* ID3D10DeviceChild methods */
233     d3d10_depthstencil_state_GetDevice,
234     d3d10_depthstencil_state_GetPrivateData,
235     d3d10_depthstencil_state_SetPrivateData,
236     d3d10_depthstencil_state_SetPrivateDataInterface,
237     /* ID3D10DepthStencilState methods */
238     d3d10_depthstencil_state_GetDesc,
239 };
240
241 HRESULT d3d10_depthstencil_state_init(struct d3d10_depthstencil_state *state)
242 {
243     state->vtbl = &d3d10_depthstencil_state_vtbl;
244     state->refcount = 1;
245
246     return S_OK;
247 }
248
249 /* IUnknown methods */
250
251 static HRESULT STDMETHODCALLTYPE d3d10_rasterizer_state_QueryInterface(ID3D10RasterizerState *iface,
252         REFIID riid, void **object)
253 {
254     TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
255
256     if (IsEqualGUID(riid, &IID_ID3D10RasterizerState)
257             || IsEqualGUID(riid, &IID_ID3D10DeviceChild)
258             || IsEqualGUID(riid, &IID_IUnknown))
259     {
260         IUnknown_AddRef(iface);
261         *object = iface;
262         return S_OK;
263     }
264
265     WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
266
267     *object = NULL;
268     return E_NOINTERFACE;
269 }
270
271 static ULONG STDMETHODCALLTYPE d3d10_rasterizer_state_AddRef(ID3D10RasterizerState *iface)
272 {
273     struct d3d10_rasterizer_state *This = (struct d3d10_rasterizer_state *)iface;
274     ULONG refcount = InterlockedIncrement(&This->refcount);
275
276     TRACE("%p increasing refcount to %u.\n", This, refcount);
277
278     return refcount;
279 }
280
281 static ULONG STDMETHODCALLTYPE d3d10_rasterizer_state_Release(ID3D10RasterizerState *iface)
282 {
283     struct d3d10_rasterizer_state *This = (struct d3d10_rasterizer_state *)iface;
284     ULONG refcount = InterlockedDecrement(&This->refcount);
285
286     TRACE("%p decreasing refcount to %u.\n", This, refcount);
287
288     if (!refcount)
289     {
290         HeapFree(GetProcessHeap(), 0, This);
291     }
292
293     return refcount;
294 }
295
296 /* ID3D10DeviceChild methods */
297
298 static void STDMETHODCALLTYPE d3d10_rasterizer_state_GetDevice(ID3D10RasterizerState *iface, ID3D10Device **device)
299 {
300     FIXME("iface %p, device %p stub!\n", iface, device);
301 }
302
303 static HRESULT STDMETHODCALLTYPE d3d10_rasterizer_state_GetPrivateData(ID3D10RasterizerState *iface,
304         REFGUID guid, UINT *data_size, void *data)
305 {
306     FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
307             iface, debugstr_guid(guid), data_size, data);
308
309     return E_NOTIMPL;
310 }
311
312 static HRESULT STDMETHODCALLTYPE d3d10_rasterizer_state_SetPrivateData(ID3D10RasterizerState *iface,
313         REFGUID guid, UINT data_size, const void *data)
314 {
315     FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
316             iface, debugstr_guid(guid), data_size, data);
317
318     return E_NOTIMPL;
319 }
320
321 static HRESULT STDMETHODCALLTYPE d3d10_rasterizer_state_SetPrivateDataInterface(ID3D10RasterizerState *iface,
322         REFGUID guid, const IUnknown *data)
323 {
324     FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
325
326     return E_NOTIMPL;
327 }
328
329 /* ID3D10RasterizerState methods */
330
331 static void STDMETHODCALLTYPE d3d10_rasterizer_state_GetDesc(ID3D10RasterizerState *iface,
332         D3D10_RASTERIZER_DESC *desc)
333 {
334     FIXME("iface %p, desc %p stub!\n", iface, desc);
335 }
336
337 static const struct ID3D10RasterizerStateVtbl d3d10_rasterizer_state_vtbl =
338 {
339     /* IUnknown methods */
340     d3d10_rasterizer_state_QueryInterface,
341     d3d10_rasterizer_state_AddRef,
342     d3d10_rasterizer_state_Release,
343     /* ID3D10DeviceChild methods */
344     d3d10_rasterizer_state_GetDevice,
345     d3d10_rasterizer_state_GetPrivateData,
346     d3d10_rasterizer_state_SetPrivateData,
347     d3d10_rasterizer_state_SetPrivateDataInterface,
348     /* ID3D10RasterizerState methods */
349     d3d10_rasterizer_state_GetDesc,
350 };
351
352 HRESULT d3d10_rasterizer_state_init(struct d3d10_rasterizer_state *state)
353 {
354     state->vtbl = &d3d10_rasterizer_state_vtbl;
355     state->refcount = 1;
356
357     return S_OK;
358 }
359
360 /* IUnknown methods */
361
362 static HRESULT STDMETHODCALLTYPE d3d10_sampler_state_QueryInterface(ID3D10SamplerState *iface,
363         REFIID riid, void **object)
364 {
365     TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
366
367     if (IsEqualGUID(riid, &IID_ID3D10SamplerState)
368             || IsEqualGUID(riid, &IID_ID3D10DeviceChild)
369             || IsEqualGUID(riid, &IID_IUnknown))
370     {
371         IUnknown_AddRef(iface);
372         *object = iface;
373         return S_OK;
374     }
375
376     WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
377
378     *object = NULL;
379     return E_NOINTERFACE;
380 }
381
382 static ULONG STDMETHODCALLTYPE d3d10_sampler_state_AddRef(ID3D10SamplerState *iface)
383 {
384     struct d3d10_sampler_state *This = (struct d3d10_sampler_state *)iface;
385     ULONG refcount = InterlockedIncrement(&This->refcount);
386
387     TRACE("%p increasing refcount to %u.\n", This, refcount);
388
389     return refcount;
390 }
391
392 static ULONG STDMETHODCALLTYPE d3d10_sampler_state_Release(ID3D10SamplerState *iface)
393 {
394     struct d3d10_sampler_state *This = (struct d3d10_sampler_state *)iface;
395     ULONG refcount = InterlockedDecrement(&This->refcount);
396
397     TRACE("%p decreasing refcount to %u.\n", This, refcount);
398
399     if (!refcount)
400     {
401         HeapFree(GetProcessHeap(), 0, This);
402     }
403
404     return refcount;
405 }
406
407 /* ID3D10DeviceChild methods */
408
409 static void STDMETHODCALLTYPE d3d10_sampler_state_GetDevice(ID3D10SamplerState *iface, ID3D10Device **device)
410 {
411     FIXME("iface %p, device %p stub!\n", iface, device);
412 }
413
414 static HRESULT STDMETHODCALLTYPE d3d10_sampler_state_GetPrivateData(ID3D10SamplerState *iface,
415         REFGUID guid, UINT *data_size, void *data)
416 {
417     FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
418             iface, debugstr_guid(guid), data_size, data);
419
420     return E_NOTIMPL;
421 }
422
423 static HRESULT STDMETHODCALLTYPE d3d10_sampler_state_SetPrivateData(ID3D10SamplerState *iface,
424         REFGUID guid, UINT data_size, const void *data)
425 {
426     FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
427             iface, debugstr_guid(guid), data_size, data);
428
429     return E_NOTIMPL;
430 }
431
432 static HRESULT STDMETHODCALLTYPE d3d10_sampler_state_SetPrivateDataInterface(ID3D10SamplerState *iface,
433         REFGUID guid, const IUnknown *data)
434 {
435     FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
436
437     return E_NOTIMPL;
438 }
439
440 /* ID3D10SamplerState methods */
441
442 static void STDMETHODCALLTYPE d3d10_sampler_state_GetDesc(ID3D10SamplerState *iface,
443         D3D10_SAMPLER_DESC *desc)
444 {
445     FIXME("iface %p, desc %p stub!\n", iface, desc);
446 }
447
448 static const struct ID3D10SamplerStateVtbl d3d10_sampler_state_vtbl =
449 {
450     /* IUnknown methods */
451     d3d10_sampler_state_QueryInterface,
452     d3d10_sampler_state_AddRef,
453     d3d10_sampler_state_Release,
454     /* ID3D10DeviceChild methods */
455     d3d10_sampler_state_GetDevice,
456     d3d10_sampler_state_GetPrivateData,
457     d3d10_sampler_state_SetPrivateData,
458     d3d10_sampler_state_SetPrivateDataInterface,
459     /* ID3D10SamplerState methods */
460     d3d10_sampler_state_GetDesc,
461 };
462
463 HRESULT d3d10_sampler_state_init(struct d3d10_sampler_state *state)
464 {
465     state->vtbl = &d3d10_sampler_state_vtbl;
466     state->refcount = 1;
467
468     return S_OK;
469 }