ReactOS 0.4.15-dev-8093-g3285f69
swapchain.c File Reference
#include "config.h"
#include "d3d8_private.h"
Include dependency graph for swapchain.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d8)
 
static struct d3d8_swapchainimpl_from_IDirect3DSwapChain8 (IDirect3DSwapChain8 *iface)
 
static HRESULT WINAPI d3d8_swapchain_QueryInterface (IDirect3DSwapChain8 *iface, REFIID riid, void **out)
 
static ULONG WINAPI d3d8_swapchain_AddRef (IDirect3DSwapChain8 *iface)
 
static ULONG WINAPI d3d8_swapchain_Release (IDirect3DSwapChain8 *iface)
 
static HRESULT WINAPI DECLSPEC_HOTPATCH d3d8_swapchain_Present (IDirect3DSwapChain8 *iface, const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, const RGNDATA *dirty_region)
 
static HRESULT WINAPI d3d8_swapchain_GetBackBuffer (IDirect3DSwapChain8 *iface, UINT backbuffer_idx, D3DBACKBUFFER_TYPE backbuffer_type, IDirect3DSurface8 **backbuffer)
 
static void STDMETHODCALLTYPE d3d8_swapchain_wined3d_object_released (void *parent)
 
static HRESULT swapchain_init (struct d3d8_swapchain *swapchain, struct d3d8_device *device, struct wined3d_swapchain_desc *desc)
 
HRESULT d3d8_swapchain_create (struct d3d8_device *device, struct wined3d_swapchain_desc *desc, struct d3d8_swapchain **swapchain)
 

Variables

static const IDirect3DSwapChain8Vtbl d3d8_swapchain_vtbl
 
static const struct wined3d_parent_ops d3d8_swapchain_wined3d_parent_ops
 

Function Documentation

◆ d3d8_swapchain_AddRef()

static ULONG WINAPI d3d8_swapchain_AddRef ( IDirect3DSwapChain8 *  iface)
static

Definition at line 49 of file swapchain.c.

50{
51 struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface);
53
54 TRACE("%p increasing refcount to %u.\n", iface, ref);
55
56 if (ref == 1)
57 {
58 if (swapchain->parent_device)
63 }
64
65 return ref;
66}
#define InterlockedIncrement
Definition: armddk.h:53
static struct d3d8_swapchain * impl_from_IDirect3DSwapChain8(IDirect3DSwapChain8 *iface)
Definition: swapchain.c:26
#define IDirect3DDevice8_AddRef(p)
Definition: d3d8.h:947
#define TRACE(s)
Definition: solgame.cpp:4
struct wined3d_swapchain * wined3d_swapchain
Definition: d3d8_private.h:167
IDirect3DDevice8 * parent_device
Definition: d3d8_private.h:168
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59
ULONG CDECL wined3d_swapchain_incref(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:104
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368

◆ d3d8_swapchain_create()

HRESULT d3d8_swapchain_create ( struct d3d8_device device,
struct wined3d_swapchain_desc desc,
struct d3d8_swapchain **  swapchain 
)

Definition at line 194 of file swapchain.c.

196{
197 struct d3d8_swapchain *object;
198 HRESULT hr;
199
200 if (!(object = heap_alloc_zero(sizeof(*object))))
201 return E_OUTOFMEMORY;
202
203 if (FAILED(hr = swapchain_init(object, device, desc)))
204 {
205 WARN("Failed to initialize swapchain, hr %#x.\n", hr);
206 heap_free(object);
207 return hr;
208 }
209
210 TRACE("Created swapchain %p.\n", object);
211 *swapchain = object;
212
213 return D3D_OK;
214}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define WARN(fmt,...)
Definition: debug.h:115
static HRESULT swapchain_init(struct d3d8_swapchain *swapchain, struct d3d8_device *device, struct wined3d_swapchain_desc *desc)
Definition: swapchain.c:169
#define D3D_OK
Definition: d3d.h:106
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FAILED(hr)
Definition: intsafe.h:51
static const WCHAR desc[]
Definition: protectdata.c:36
HRESULT hr
Definition: shlfolder.c:183
Definition: devices.h:37

Referenced by d3d8_device_CreateAdditionalSwapChain(), and device_parent_create_swapchain().

◆ d3d8_swapchain_GetBackBuffer()

static HRESULT WINAPI d3d8_swapchain_GetBackBuffer ( IDirect3DSwapChain8 *  iface,
UINT  backbuffer_idx,
D3DBACKBUFFER_TYPE  backbuffer_type,
IDirect3DSurface8 **  backbuffer 
)
static

Definition at line 114 of file swapchain.c.

116{
117 struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface);
119 struct d3d8_surface *surface_impl;
120 HRESULT hr = D3D_OK;
121
122 TRACE("iface %p, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
123 iface, backbuffer_idx, backbuffer_type, backbuffer);
124
125 /* backbuffer_type is ignored by native. */
126
127 if (!backbuffer)
128 {
129 WARN("The output pointer is NULL, returning D3DERR_INVALIDCALL.\n");
130 return D3DERR_INVALIDCALL;
131 }
132
134 if ((wined3d_texture = wined3d_swapchain_get_back_buffer(swapchain->wined3d_swapchain, backbuffer_idx)))
135 {
137 *backbuffer = &surface_impl->IDirect3DSurface8_iface;
138 IDirect3DSurface8_AddRef(*backbuffer);
139 }
140 else
141 {
142 /* Do not set *backbuffer = NULL, see tests/device.c, test_swapchain(). */
144 }
146
147 return hr;
148}
#define D3DERR_INVALIDCALL
void *CDECL wined3d_texture_get_sub_resource_parent(struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: texture.c:3449
#define IDirect3DSurface8_AddRef(p)
Definition: d3d8.h:309
IDirect3DSurface8 IDirect3DSurface8_iface
Definition: d3d8_private.h:176
struct wined3d_texture *CDECL wined3d_swapchain_get_back_buffer(const struct wined3d_swapchain *swapchain, UINT back_buffer_idx)
Definition: swapchain.c:215

◆ d3d8_swapchain_Present()

static HRESULT WINAPI DECLSPEC_HOTPATCH d3d8_swapchain_Present ( IDirect3DSwapChain8 *  iface,
const RECT src_rect,
const RECT dst_rect,
HWND  dst_window_override,
const RGNDATA dirty_region 
)
static

Definition at line 89 of file swapchain.c.

92{
93 struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface);
95 HRESULT hr;
96
97 TRACE("iface %p, src_rect %s, dst_rect %s, dst_window_override %p, dirty_region %p.\n",
98 iface, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect), dst_window_override, dirty_region);
99
100 if (device->device_state != D3D8_DEVICE_STATE_OK)
101 return D3DERR_DEVICELOST;
102
103 if (dirty_region)
104 FIXME("Ignoring dirty_region %p.\n", dirty_region);
105
108 src_rect, dst_rect, dst_window_override, 0, 0);
110
111 return hr;
112}
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define FIXME(fmt,...)
Definition: debug.h:114
@ D3D8_DEVICE_STATE_OK
Definition: d3d8_private.h:93
static struct d3d8_device * impl_from_IDirect3DDevice8(IDirect3DDevice8 *iface)
Definition: d3d8_private.h:132
#define D3DERR_DEVICELOST
Definition: d3d8.h:82
HRESULT CDECL wined3d_swapchain_present(struct wined3d_swapchain *swapchain, const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, DWORD swap_interval, DWORD flags)
Definition: swapchain.c:152

◆ d3d8_swapchain_QueryInterface()

static HRESULT WINAPI d3d8_swapchain_QueryInterface ( IDirect3DSwapChain8 *  iface,
REFIID  riid,
void **  out 
)
static

Definition at line 31 of file swapchain.c.

32{
33 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
34
35 if (IsEqualGUID(riid, &IID_IDirect3DSwapChain8)
37 {
39 *out = iface;
40 return S_OK;
41 }
42
43 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
44
45 *out = NULL;
46 return E_NOINTERFACE;
47}
const GUID IID_IUnknown
#define NULL
Definition: types.h:112
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
static FILE * out
Definition: regtests2xml.c:44
#define IDirect3DSwapChain8_AddRef(p)
Definition: d3d8.h:269
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ d3d8_swapchain_Release()

static ULONG WINAPI d3d8_swapchain_Release ( IDirect3DSwapChain8 *  iface)
static

Definition at line 68 of file swapchain.c.

69{
70 struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface);
72
73 TRACE("%p decreasing refcount to %u.\n", iface, ref);
74
75 if (!ref)
76 {
77 IDirect3DDevice8 *parent_device = swapchain->parent_device;
78
82
83 if (parent_device)
85 }
86 return ref;
87}
#define InterlockedDecrement
Definition: armddk.h:52
#define IDirect3DDevice8_Release(p)
Definition: d3d8.h:948
ULONG CDECL wined3d_swapchain_decref(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:113

◆ d3d8_swapchain_wined3d_object_released()

static void STDMETHODCALLTYPE d3d8_swapchain_wined3d_object_released ( void parent)
static

Definition at line 159 of file swapchain.c.

160{
162}
r parent
Definition: btrfs.c:3010

◆ impl_from_IDirect3DSwapChain8()

static struct d3d8_swapchain * impl_from_IDirect3DSwapChain8 ( IDirect3DSwapChain8 *  iface)
inlinestatic

Definition at line 26 of file swapchain.c.

27{
28 return CONTAINING_RECORD(iface, struct d3d8_swapchain, IDirect3DSwapChain8_iface);
29}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by d3d8_swapchain_AddRef(), d3d8_swapchain_GetBackBuffer(), d3d8_swapchain_Present(), and d3d8_swapchain_Release().

◆ swapchain_init()

static HRESULT swapchain_init ( struct d3d8_swapchain swapchain,
struct d3d8_device device,
struct wined3d_swapchain_desc desc 
)
static

Definition at line 169 of file swapchain.c.

171{
172 HRESULT hr;
173
174 swapchain->refcount = 1;
176
178 hr = wined3d_swapchain_create(device->wined3d_device, desc, swapchain,
181
182 if (FAILED(hr))
183 {
184 WARN("Failed to create wined3d swapchain, hr %#x.\n", hr);
185 return hr;
186 }
187
188 swapchain->parent_device = &device->IDirect3DDevice8_iface;
190
191 return D3D_OK;
192}
static const struct wined3d_parent_ops d3d8_swapchain_wined3d_parent_ops
Definition: swapchain.c:164
static const IDirect3DSwapChain8Vtbl d3d8_swapchain_vtbl
Definition: swapchain.c:150
IDirect3DSwapChain8 IDirect3DSwapChain8_iface
Definition: d3d8_private.h:165
HRESULT CDECL wined3d_swapchain_create(struct wined3d_device *device, struct wined3d_swapchain_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_swapchain **swapchain)
Definition: swapchain.c:1023

Referenced by d3d8_swapchain_create(), d3d9_swapchain_create(), and wined3d_swapchain_create().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3d8  )

Variable Documentation

◆ d3d8_swapchain_vtbl

const IDirect3DSwapChain8Vtbl d3d8_swapchain_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI d3d8_swapchain_QueryInterface(IDirect3DSwapChain8 *iface, REFIID riid, void **out)
Definition: swapchain.c:31
static ULONG WINAPI d3d8_swapchain_AddRef(IDirect3DSwapChain8 *iface)
Definition: swapchain.c:49
static ULONG WINAPI d3d8_swapchain_Release(IDirect3DSwapChain8 *iface)
Definition: swapchain.c:68
static HRESULT WINAPI d3d8_swapchain_GetBackBuffer(IDirect3DSwapChain8 *iface, UINT backbuffer_idx, D3DBACKBUFFER_TYPE backbuffer_type, IDirect3DSurface8 **backbuffer)
Definition: swapchain.c:114
static HRESULT WINAPI DECLSPEC_HOTPATCH d3d8_swapchain_Present(IDirect3DSwapChain8 *iface, const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, const RGNDATA *dirty_region)
Definition: swapchain.c:89

Definition at line 150 of file swapchain.c.

Referenced by swapchain_init().

◆ d3d8_swapchain_wined3d_parent_ops

const struct wined3d_parent_ops d3d8_swapchain_wined3d_parent_ops
static
Initial value:
=
{
}
static void STDMETHODCALLTYPE d3d8_swapchain_wined3d_object_released(void *parent)
Definition: swapchain.c:159

Definition at line 164 of file swapchain.c.

Referenced by swapchain_init().