2 * Copyright 2011 Henri Verbeet for CodeWeavers
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.
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.
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
21 #include "wine/port.h"
23 #include "d3d10_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d10
);
27 struct d3d10_stateblock
29 ID3D10StateBlock ID3D10StateBlock_iface
;
33 static inline struct d3d10_stateblock
*impl_from_ID3D10StateBlock(ID3D10StateBlock
*iface
)
35 return CONTAINING_RECORD(iface
, struct d3d10_stateblock
, ID3D10StateBlock_iface
);
38 static HRESULT STDMETHODCALLTYPE
d3d10_stateblock_QueryInterface(ID3D10StateBlock
*iface
, REFIID iid
, void **object
)
40 struct d3d10_stateblock
*stateblock
;
42 TRACE("iface %p, iid %s, object %p.\n", iface
, debugstr_guid(iid
), object
);
44 stateblock
= impl_from_ID3D10StateBlock(iface
);
46 if (IsEqualGUID(iid
, &IID_ID3D10StateBlock
)
47 || IsEqualGUID(iid
, &IID_IUnknown
))
49 IUnknown_AddRef(&stateblock
->ID3D10StateBlock_iface
);
50 *object
= &stateblock
->ID3D10StateBlock_iface
;
54 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
60 static ULONG STDMETHODCALLTYPE
d3d10_stateblock_AddRef(ID3D10StateBlock
*iface
)
62 struct d3d10_stateblock
*stateblock
= impl_from_ID3D10StateBlock(iface
);
63 ULONG refcount
= InterlockedIncrement(&stateblock
->refcount
);
65 TRACE("%p increasing refcount to %u.\n", stateblock
, refcount
);
70 static ULONG STDMETHODCALLTYPE
d3d10_stateblock_Release(ID3D10StateBlock
*iface
)
72 struct d3d10_stateblock
*stateblock
= impl_from_ID3D10StateBlock(iface
);
73 ULONG refcount
= InterlockedDecrement(&stateblock
->refcount
);
75 TRACE("%p decreasing refcount to %u.\n", stateblock
, refcount
);
78 HeapFree(GetProcessHeap(), 0, stateblock
);
83 static HRESULT STDMETHODCALLTYPE
d3d10_stateblock_Capture(ID3D10StateBlock
*iface
)
85 FIXME("iface %p stub!\n", iface
);
90 static HRESULT STDMETHODCALLTYPE
d3d10_stateblock_Apply(ID3D10StateBlock
*iface
)
92 FIXME("iface %p stub!\n", iface
);
97 static HRESULT STDMETHODCALLTYPE
d3d10_stateblock_ReleaseAllDeviceObjects(ID3D10StateBlock
*iface
)
99 FIXME("iface %p stub!\n", iface
);
104 static HRESULT STDMETHODCALLTYPE
d3d10_stateblock_GetDevice(ID3D10StateBlock
*iface
, ID3D10Device
**device
)
106 FIXME("iface %p, device %p stub!\n", iface
, device
);
111 static const struct ID3D10StateBlockVtbl d3d10_stateblock_vtbl
=
113 /* IUnknown methods */
114 d3d10_stateblock_QueryInterface
,
115 d3d10_stateblock_AddRef
,
116 d3d10_stateblock_Release
,
117 /* ID3D10StateBlock methods */
118 d3d10_stateblock_Capture
,
119 d3d10_stateblock_Apply
,
120 d3d10_stateblock_ReleaseAllDeviceObjects
,
121 d3d10_stateblock_GetDevice
,
124 HRESULT WINAPI
D3D10CreateStateBlock(ID3D10Device
*device
,
125 D3D10_STATE_BLOCK_MASK
*mask
, ID3D10StateBlock
**stateblock
)
127 struct d3d10_stateblock
*object
;
129 FIXME("device %p, mask %p, stateblock %p stub!\n", device
, mask
, stateblock
);
131 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
134 ERR("Failed to allocate D3D10 stateblock object memory.\n");
135 return E_OUTOFMEMORY
;
138 object
->ID3D10StateBlock_iface
.lpVtbl
= &d3d10_stateblock_vtbl
;
139 object
->refcount
= 1;
141 TRACE("Created stateblock %p.\n", object
);
142 *stateblock
= &object
->ID3D10StateBlock_iface
;