ReactOS 0.4.15-dev-8100-g1887773
stateblock.c
Go to the documentation of this file.
1/*
2 * IDirect3DStateBlock9 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 */
22
23#include "config.h"
24#include "d3d9_private.h"
25
27
28static inline struct d3d9_stateblock *impl_from_IDirect3DStateBlock9(IDirect3DStateBlock9 *iface)
29{
31}
32
33static HRESULT WINAPI d3d9_stateblock_QueryInterface(IDirect3DStateBlock9 *iface, REFIID riid, void **out)
34{
35 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
36
37 if (IsEqualGUID(riid, &IID_IDirect3DStateBlock9)
39 {
41 *out = iface;
42 return S_OK;
43 }
44
45 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
46
47 *out = NULL;
48 return E_NOINTERFACE;
49}
50
51static ULONG WINAPI d3d9_stateblock_AddRef(IDirect3DStateBlock9 *iface)
52{
53 struct d3d9_stateblock *stateblock = impl_from_IDirect3DStateBlock9(iface);
55
56 TRACE("%p increasing refcount to %u.\n", iface, refcount);
57
58 return refcount;
59}
60
61static ULONG WINAPI d3d9_stateblock_Release(IDirect3DStateBlock9 *iface)
62{
63 struct d3d9_stateblock *stateblock = impl_from_IDirect3DStateBlock9(iface);
65
66 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
67
68 if (!refcount)
69 {
73
75 heap_free(stateblock);
76 }
77
78 return refcount;
79}
80
81static HRESULT WINAPI d3d9_stateblock_GetDevice(IDirect3DStateBlock9 *iface, IDirect3DDevice9 **device)
82{
83 struct d3d9_stateblock *stateblock = impl_from_IDirect3DStateBlock9(iface);
84
85 TRACE("iface %p, device %p.\n", iface, device);
86
87 *device = (IDirect3DDevice9 *)stateblock->parent_device;
89
90 TRACE("Returning device %p.\n", *device);
91
92 return D3D_OK;
93}
94
95static HRESULT WINAPI d3d9_stateblock_Capture(IDirect3DStateBlock9 *iface)
96{
97 struct d3d9_stateblock *stateblock = impl_from_IDirect3DStateBlock9(iface);
98
99 TRACE("iface %p.\n", iface);
100
104
105 return D3D_OK;
106}
107
108static HRESULT WINAPI d3d9_stateblock_Apply(IDirect3DStateBlock9 *iface)
109{
110 struct d3d9_stateblock *stateblock = impl_from_IDirect3DStateBlock9(iface);
111
112 TRACE("iface %p.\n", iface);
113
117
118 return D3D_OK;
119}
120
121
122static const struct IDirect3DStateBlock9Vtbl d3d9_stateblock_vtbl =
123{
124 /* IUnknown */
128 /* IDirect3DStateBlock9 */
132};
133
136{
137 HRESULT hr;
138
140 stateblock->refcount = 1;
141
143 {
145 }
146 else
147 {
149 hr = wined3d_stateblock_create(device->wined3d_device,
152 if (FAILED(hr))
153 {
154 WARN("Failed to create wined3d stateblock, hr %#x.\n", hr);
155 return hr;
156 }
157 }
158
159 stateblock->parent_device = &device->IDirect3DDevice9Ex_iface;
161
162 return D3D_OK;
163}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
const GUID IID_IUnknown
#define WARN(fmt,...)
Definition: debug.h:115
enum _D3DSTATEBLOCKTYPE D3DSTATEBLOCKTYPE
static HRESULT WINAPI d3d9_stateblock_QueryInterface(IDirect3DStateBlock9 *iface, REFIID riid, void **out)
Definition: stateblock.c:33
static HRESULT WINAPI d3d9_stateblock_Apply(IDirect3DStateBlock9 *iface)
Definition: stateblock.c:108
static const struct IDirect3DStateBlock9Vtbl d3d9_stateblock_vtbl
Definition: stateblock.c:122
static HRESULT WINAPI d3d9_stateblock_GetDevice(IDirect3DStateBlock9 *iface, IDirect3DDevice9 **device)
Definition: stateblock.c:81
static ULONG WINAPI d3d9_stateblock_AddRef(IDirect3DStateBlock9 *iface)
Definition: stateblock.c:51
static ULONG WINAPI d3d9_stateblock_Release(IDirect3DStateBlock9 *iface)
Definition: stateblock.c:61
HRESULT stateblock_init(struct d3d9_stateblock *stateblock, struct d3d9_device *device, D3DSTATEBLOCKTYPE type, struct wined3d_stateblock *wined3d_stateblock)
Definition: stateblock.c:134
static HRESULT WINAPI d3d9_stateblock_Capture(IDirect3DStateBlock9 *iface)
Definition: stateblock.c:95
static struct d3d9_stateblock * impl_from_IDirect3DStateBlock9(IDirect3DStateBlock9 *iface)
Definition: stateblock.c:28
#define IDirect3DStateBlock9_AddRef(p)
Definition: d3d9.h:1299
#define IDirect3DDevice9Ex_Release(p)
Definition: d3d9.h:1917
#define IDirect3DDevice9Ex_AddRef(p)
Definition: d3d9.h:1916
#define IDirect3DDevice9_AddRef(p)
Definition: d3d9.h:1507
#define D3D_OK
Definition: d3d.h:106
#define NULL
Definition: types.h:112
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
static FILE * out
Definition: regtests2xml.c:44
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
struct wined3d_stateblock * wined3d_stateblock
Definition: d3d9_private.h:231
IDirect3DDevice9Ex * parent_device
Definition: d3d9_private.h:232
IDirect3DStateBlock9 IDirect3DStateBlock9_iface
Definition: d3d9_private.h:229
Definition: devices.h:37
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define WINAPI
Definition: msvc.h:6
ULONG CDECL wined3d_stateblock_decref(struct wined3d_stateblock *stateblock)
Definition: stateblock.c:552
void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock)
Definition: stateblock.c:684
HRESULT CDECL wined3d_stateblock_create(struct wined3d_device *device, enum wined3d_stateblock_type type, struct wined3d_stateblock **stateblock)
Definition: stateblock.c:1372
void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock)
Definition: stateblock.c:965
wined3d_stateblock_type
Definition: wined3d.h:766
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
#define E_NOINTERFACE
Definition: winerror.h:2364