ReactOS  0.4.15-dev-1200-gc3b3fcd
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);
52  ULONG ref = InterlockedIncrement(&swapchain->refcount);
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 }
static struct d3d8_swapchain * impl_from_IDirect3DSwapChain8(IDirect3DSwapChain8 *iface)
Definition: swapchain.c:26
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
IDirect3DDevice8 * parent_device
Definition: d3d8_private.h:168
struct wined3d_swapchain * wined3d_swapchain
Definition: d3d8_private.h:167
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53
#define IDirect3DDevice8_AddRef(p)
Definition: d3d8.h:947
ULONG CDECL wined3d_swapchain_incref(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:104
unsigned int ULONG
Definition: retypes.h:1
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373

◆ 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 }
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:112
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
Definition: devices.h:37
static const WCHAR desc[]
Definition: protectdata.c:36
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
#define D3D_OK
Definition: d3d.h:106
static HRESULT swapchain_init(struct d3d8_swapchain *swapchain, struct d3d8_device *device, struct wined3d_swapchain_desc *desc)
Definition: swapchain.c:169
void * object
Definition: jmemsys.h:48
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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 }
static struct d3d8_swapchain * impl_from_IDirect3DSwapChain8(IDirect3DSwapChain8 *iface)
Definition: swapchain.c:26
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:112
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
#define D3DERR_INVALIDCALL
#define IDirect3DSurface8_AddRef(p)
Definition: d3d8.h:309
IDirect3DSurface8 IDirect3DSurface8_iface
Definition: d3d8_private.h:176
struct wined3d_swapchain * wined3d_swapchain
Definition: d3d8_private.h:167
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
void *CDECL wined3d_texture_get_sub_resource_parent(struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: texture.c:3449
#define D3D_OK
Definition: d3d.h:106
struct wined3d_texture *CDECL wined3d_swapchain_get_back_buffer(const struct wined3d_swapchain *swapchain, UINT back_buffer_idx)
Definition: swapchain.c:215
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373

◆ 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 struct d3d8_swapchain * impl_from_IDirect3DSwapChain8(IDirect3DSwapChain8 *iface)
Definition: swapchain.c:26
HRESULT hr
Definition: shlfolder.c:183
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
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
Definition: devices.h:37
#define FIXME(fmt,...)
Definition: debug.h:111
IDirect3DDevice8 * parent_device
Definition: d3d8_private.h:168
struct wined3d_swapchain * wined3d_swapchain
Definition: d3d8_private.h:167
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
#define D3DERR_DEVICELOST
Definition: d3d8.h:82
const char * wine_dbgstr_rect(const RECT *rect)
static struct d3d8_device * impl_from_IDirect3DDevice8(IDirect3DDevice8 *iface)
Definition: d3d8_private.h:132
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373

◆ 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 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
#define WARN(fmt,...)
Definition: debug.h:112
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
#define IDirect3DSwapChain8_AddRef(p)
Definition: d3d8.h:269
const GUID IID_IUnknown
static FILE * out
Definition: regtests2xml.c:44
#define S_OK
Definition: intsafe.h:51
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112

◆ 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);
71  ULONG ref = InterlockedDecrement(&swapchain->refcount);
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 }
ULONG CDECL wined3d_swapchain_decref(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:113
static struct d3d8_swapchain * impl_from_IDirect3DSwapChain8(IDirect3DSwapChain8 *iface)
Definition: swapchain.c:26
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
IDirect3DDevice8 * parent_device
Definition: d3d8_private.h:168
struct wined3d_swapchain * wined3d_swapchain
Definition: d3d8_private.h:167
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedDecrement
Definition: armddk.h:52
#define IDirect3DDevice8_Release(p)
Definition: d3d8.h:948
unsigned int ULONG
Definition: retypes.h:1
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373

◆ 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 {
161  heap_free(parent);
162 }
r parent
Definition: btrfs.c:2944
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ impl_from_IDirect3DSwapChain8()

static struct d3d8_swapchain* impl_from_IDirect3DSwapChain8 ( IDirect3DSwapChain8 *  iface)
inlinestatic

Definition at line 26 of file swapchain.c.

27 {
29 }
IDirect3DSwapChain8 IDirect3DSwapChain8_iface
Definition: d3d8_private.h:165
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

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;
175  swapchain->IDirect3DSwapChain8_iface.lpVtbl = &d3d8_swapchain_vtbl;
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 }
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:112
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
static const struct wined3d_parent_ops d3d8_swapchain_wined3d_parent_ops
Definition: swapchain.c:164
IDirect3DSwapChain8 IDirect3DSwapChain8_iface
Definition: d3d8_private.h:165
Definition: devices.h:37
static const WCHAR desc[]
Definition: protectdata.c:36
IDirect3DDevice8 * parent_device
Definition: d3d8_private.h:168
struct wined3d_swapchain * wined3d_swapchain
Definition: d3d8_private.h:167
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
static const IDirect3DSwapChain8Vtbl d3d8_swapchain_vtbl
Definition: swapchain.c:150
LONG HRESULT
Definition: typedefs.h:79
#define D3D_OK
Definition: d3d.h:106
#define IDirect3DDevice8_AddRef(p)
Definition: d3d8.h:947
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373

Referenced by d3d8_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_GetBackBuffer(IDirect3DSwapChain8 *iface, UINT backbuffer_idx, D3DBACKBUFFER_TYPE backbuffer_type, IDirect3DSurface8 **backbuffer)
Definition: swapchain.c:114
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 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
static ULONG WINAPI d3d8_swapchain_Release(IDirect3DSwapChain8 *iface)
Definition: swapchain.c:68

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().