winspool: Italian language support.
[wine] / dlls / d3d8 / stateblock.c
1 /*
2  * IDirect3DStateBlock8 implementation
3  *
4  * Copyright 2002-2003 Raphael Junqueira
5  * Copyright 2002-2003 Jason Edmeades
6  * Copyright 2005 Oliver Stieber
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #include "config.h"
24 #include "d3d8_private.h"
25
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
27
28 /* NOTE: DirectX8 doesn't export a IDirect3DStateBlock8, the interface is used internally to keep d3d8 and d3d9 as simila as possible */
29 /* IDirect3DStateBlock8 IUnknown parts follow: */
30 HRESULT WINAPI IDirect3DStateBlock8Impl_QueryInterface(IDirect3DStateBlock8 *iface, REFIID riid, LPVOID *ppobj) {
31     IDirect3DStateBlock8Impl *This = (IDirect3DStateBlock8Impl *)iface;
32
33     if (IsEqualGUID(riid, &IID_IUnknown)
34         || IsEqualGUID(riid, &IID_IDirect3DStateBlock8)) {
35         IUnknown_AddRef(iface);
36         *ppobj = This;
37         return D3D_OK;
38     }
39
40     WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
41     return E_NOINTERFACE;
42 }
43
44 ULONG WINAPI IDirect3DStateBlock8Impl_AddRef(IDirect3DStateBlock8 *iface) {
45     IDirect3DStateBlock8Impl *This = (IDirect3DStateBlock8Impl *)iface;
46     ULONG ref = InterlockedIncrement(&This->ref);
47
48     TRACE("(%p) : AddRef from %ld\n", This, ref - 1);
49
50     return ref;
51 }
52
53 ULONG WINAPI IDirect3DStateBlock8Impl_Release(IDirect3DStateBlock8 *iface) {
54     IDirect3DStateBlock8Impl *This = (IDirect3DStateBlock8Impl *)iface;
55     ULONG ref = InterlockedDecrement(&This->ref);
56
57     TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
58
59     if (ref == 0) {
60         IWineD3DStateBlock_Release(This->wineD3DStateBlock);
61         HeapFree(GetProcessHeap(), 0, This);
62     }
63     return ref;
64 }
65
66 /* IDirect3DStateBlock8 Interface follow: */
67 HRESULT WINAPI IDirect3DStateBlock8Impl_GetDevice(IDirect3DStateBlock8 *iface, IDirect3DDevice8 **ppDevice) {
68     IDirect3DStateBlock8Impl *This = (IDirect3DStateBlock8Impl *)iface;
69     TRACE("(%p) Relay\n", This); 
70     return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
71 }
72
73 HRESULT WINAPI IDirect3DStateBlock8Impl_Capture(IDirect3DStateBlock8 *iface) {
74     IDirect3DStateBlock8Impl *This = (IDirect3DStateBlock8Impl *)iface;
75     TRACE("(%p) Relay\n", This); 
76     return IWineD3DStateBlock_Capture(This->wineD3DStateBlock);
77 }
78
79 HRESULT WINAPI IDirect3DStateBlock8Impl_Apply(IDirect3DStateBlock8 *iface) {
80     IDirect3DStateBlock8Impl *This = (IDirect3DStateBlock8Impl *)iface;
81     TRACE("(%p) Relay\n", This); 
82     return IWineD3DStateBlock_Apply(This->wineD3DStateBlock);
83 }
84
85 const IDirect3DStateBlock8Vtbl Direct3DStateBlock8_Vtbl =
86 {
87     /* IUnknown */
88     IDirect3DStateBlock8Impl_QueryInterface,
89     IDirect3DStateBlock8Impl_AddRef,
90     IDirect3DStateBlock8Impl_Release,
91     /* IDirect3DStateBlock8 */
92     IDirect3DStateBlock8Impl_GetDevice,
93     IDirect3DStateBlock8Impl_Capture,
94     IDirect3DStateBlock8Impl_Apply
95 };