ReactOS  0.4.15-dev-1070-ge1a01de
surface.c File Reference
#include "config.h"
#include "d3d9_private.h"
Include dependency graph for surface.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d9)
 
static struct d3d9_surfaceimpl_from_IDirect3DSurface9 (IDirect3DSurface9 *iface)
 
static HRESULT WINAPI d3d9_surface_QueryInterface (IDirect3DSurface9 *iface, REFIID riid, void **out)
 
static ULONG WINAPI d3d9_surface_AddRef (IDirect3DSurface9 *iface)
 
static ULONG WINAPI d3d9_surface_Release (IDirect3DSurface9 *iface)
 
static HRESULT WINAPI d3d9_surface_GetDevice (IDirect3DSurface9 *iface, IDirect3DDevice9 **device)
 
static HRESULT WINAPI d3d9_surface_SetPrivateData (IDirect3DSurface9 *iface, REFGUID guid, const void *data, DWORD data_size, DWORD flags)
 
static HRESULT WINAPI d3d9_surface_GetPrivateData (IDirect3DSurface9 *iface, REFGUID guid, void *data, DWORD *data_size)
 
static HRESULT WINAPI d3d9_surface_FreePrivateData (IDirect3DSurface9 *iface, REFGUID guid)
 
static DWORD WINAPI d3d9_surface_SetPriority (IDirect3DSurface9 *iface, DWORD priority)
 
static DWORD WINAPI d3d9_surface_GetPriority (IDirect3DSurface9 *iface)
 
static void WINAPI d3d9_surface_PreLoad (IDirect3DSurface9 *iface)
 
static D3DRESOURCETYPE WINAPI d3d9_surface_GetType (IDirect3DSurface9 *iface)
 
static HRESULT WINAPI d3d9_surface_GetContainer (IDirect3DSurface9 *iface, REFIID riid, void **container)
 
static HRESULT WINAPI d3d9_surface_GetDesc (IDirect3DSurface9 *iface, D3DSURFACE_DESC *desc)
 
static HRESULT WINAPI d3d9_surface_LockRect (IDirect3DSurface9 *iface, D3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags)
 
static HRESULT WINAPI d3d9_surface_UnlockRect (IDirect3DSurface9 *iface)
 
static HRESULT WINAPI d3d9_surface_GetDC (IDirect3DSurface9 *iface, HDC *dc)
 
static HRESULT WINAPI d3d9_surface_ReleaseDC (IDirect3DSurface9 *iface, HDC dc)
 
static void STDMETHODCALLTYPE surface_wined3d_object_destroyed (void *parent)
 
void surface_init (struct d3d9_surface *surface, struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, const struct wined3d_parent_ops **parent_ops)
 
static void STDMETHODCALLTYPE view_wined3d_object_destroyed (void *parent)
 
struct d3d9_deviced3d9_surface_get_device (const struct d3d9_surface *surface)
 
struct wined3d_rendertarget_viewd3d9_surface_acquire_rendertarget_view (struct d3d9_surface *surface)
 
void d3d9_surface_release_rendertarget_view (struct d3d9_surface *surface, struct wined3d_rendertarget_view *rtv)
 
struct d3d9_surfaceunsafe_impl_from_IDirect3DSurface9 (IDirect3DSurface9 *iface)
 

Variables

static const struct IDirect3DSurface9Vtbl d3d9_surface_vtbl
 
static const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops
 
static const struct wined3d_parent_ops d3d9_view_wined3d_parent_ops
 

Function Documentation

◆ d3d9_surface_acquire_rendertarget_view()

struct wined3d_rendertarget_view* d3d9_surface_acquire_rendertarget_view ( struct d3d9_surface surface)

Definition at line 407 of file surface.c.

408 {
409  HRESULT hr;
410 
411  /* The surface reference count can be equal to 0 when this function is
412  * called. In order to properly manage the render target view reference
413  * count, we temporarily increment the surface reference count. */
415 
416  if (surface->wined3d_rtv)
417  return surface->wined3d_rtv;
418 
420  surface->sub_resource_idx, surface, &d3d9_view_wined3d_parent_ops, &surface->wined3d_rtv)))
421  {
422  ERR("Failed to create rendertarget view, hr %#x.\n", hr);
424  return NULL;
425  }
426 
427  if (surface->texture)
428  list_add_head(&surface->texture->rtv_list, &surface->rtv_entry);
429 
430  return surface->wined3d_rtv;
431 }
HRESULT hr
Definition: shlfolder.c:183
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
static const struct wined3d_parent_ops d3d9_view_wined3d_parent_ops
Definition: surface.c:395
struct wined3d_rendertarget_view * wined3d_rtv
Definition: d3d9_private.h:164
struct wined3d_texture * wined3d_texture
Definition: d3d9_private.h:161
smooth NULL
Definition: ftsmooth.c:416
HRESULT CDECL wined3d_rendertarget_view_create_from_sub_resource(struct wined3d_texture *texture, unsigned int sub_resource_idx, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_rendertarget_view **view)
Definition: view.c:624
struct list rtv_entry
Definition: d3d9_private.h:163
LONG HRESULT
Definition: typedefs.h:79
static ULONG WINAPI d3d9_surface_Release(IDirect3DSurface9 *iface)
Definition: surface.c:81
struct d3d9_texture * texture
Definition: d3d9_private.h:167
#define ERR(fmt,...)
Definition: debug.h:110
unsigned int sub_resource_idx
Definition: d3d9_private.h:162
static ULONG WINAPI d3d9_surface_AddRef(IDirect3DSurface9 *iface)
Definition: surface.c:51
IDirect3DSurface9 IDirect3DSurface9_iface
Definition: d3d9_private.h:159

Referenced by d3d9_device_ColorFill(), d3d9_device_SetDepthStencilSurface(), and d3d9_device_SetRenderTarget().

◆ d3d9_surface_AddRef()

static ULONG WINAPI d3d9_surface_AddRef ( IDirect3DSurface9 *  iface)
static

Definition at line 51 of file surface.c.

52 {
53  struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
54  ULONG refcount;
55 
56  TRACE("iface %p.\n", iface);
57 
58  if (surface->texture)
59  {
60  TRACE("Forwarding to %p.\n", surface->texture);
61  return IDirect3DBaseTexture9_AddRef(&surface->texture->IDirect3DBaseTexture9_iface);
62  }
63 
64  refcount = InterlockedIncrement(&surface->resource.refcount);
65  TRACE("%p increasing refcount to %u.\n", iface, refcount);
66 
67  if (refcount == 1)
68  {
69  if (surface->parent_device)
72  if (surface->wined3d_rtv)
76  }
77 
78  return refcount;
79 }
#define IDirect3DBaseTexture9_AddRef(p)
Definition: d3d9.h:834
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
struct wined3d_rendertarget_view * wined3d_rtv
Definition: d3d9_private.h:164
struct wined3d_texture * wined3d_texture
Definition: d3d9_private.h:161
static struct d3d9_surface * impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)
Definition: surface.c:27
#define IDirect3DDevice9Ex_AddRef(p)
Definition: d3d9.h:1916
ULONG CDECL wined3d_texture_incref(struct wined3d_texture *texture)
Definition: texture.c:994
#define TRACE(s)
Definition: solgame.cpp:4
struct d3d9_texture * texture
Definition: d3d9_private.h:167
#define InterlockedIncrement
Definition: armddk.h:53
IDirect3DDevice9Ex * parent_device
Definition: d3d9_private.h:165
struct d3d9_resource resource
Definition: d3d9_private.h:160
ULONG CDECL wined3d_rendertarget_view_incref(struct wined3d_rendertarget_view *view)
Definition: view.c:318
unsigned int ULONG
Definition: retypes.h:1
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373

Referenced by d3d9_surface_acquire_rendertarget_view().

◆ d3d9_surface_FreePrivateData()

static HRESULT WINAPI d3d9_surface_FreePrivateData ( IDirect3DSurface9 *  iface,
REFGUID  guid 
)
static

Definition at line 158 of file surface.c.

159 {
160  struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
161  TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
162 
163  return d3d9_resource_free_private_data(&surface->resource, guid);
164 }
const GUID * guid
static struct d3d9_surface * impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)
Definition: surface.c:27
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
struct d3d9_resource resource
Definition: d3d9_private.h:160
HRESULT d3d9_resource_free_private_data(struct d3d9_resource *resource, const GUID *guid)
Definition: d3d9_main.c:160

◆ d3d9_surface_get_device()

struct d3d9_device* d3d9_surface_get_device ( const struct d3d9_surface surface)

Definition at line 400 of file surface.c.

401 {
402  IDirect3DDevice9Ex *device;
403  device = surface->texture ? surface->texture->parent_device : surface->parent_device;
405 }
Definition: devices.h:37
static struct d3d9_device * impl_from_IDirect3DDevice9Ex(IDirect3DDevice9Ex *iface)
Definition: d3d9_private.h:289
struct d3d9_texture * texture
Definition: d3d9_private.h:167
IDirect3DDevice9Ex * parent_device
Definition: d3d9_private.h:165

Referenced by d3d9_device_SetRenderTarget().

◆ d3d9_surface_GetContainer()

static HRESULT WINAPI d3d9_surface_GetContainer ( IDirect3DSurface9 *  iface,
REFIID  riid,
void **  container 
)
static

Definition at line 196 of file surface.c.

197 {
198  struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
199  HRESULT hr;
200 
201  TRACE("iface %p, riid %s, container %p.\n", iface, debugstr_guid(riid), container);
202 
203  if (!surface->container)
204  return E_NOINTERFACE;
205 
206  hr = IUnknown_QueryInterface(surface->container, riid, container);
207 
208  TRACE("Returning %p.\n", *container);
209 
210  return hr;
211 }
#define E_NOINTERFACE
Definition: winerror.h:2364
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
IUnknown * container
Definition: d3d9_private.h:166
static struct d3d9_surface * impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)
Definition: surface.c:27
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79

◆ d3d9_surface_GetDC()

static HRESULT WINAPI d3d9_surface_GetDC ( IDirect3DSurface9 *  iface,
HDC dc 
)
static

Definition at line 289 of file surface.c.

290 {
291  struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
292  HRESULT hr;
293 
294  TRACE("iface %p, dc %p.\n", iface, dc);
295 
299 
300  return hr;
301 }
HRESULT hr
Definition: shlfolder.c:183
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
HRESULT CDECL wined3d_texture_get_dc(struct wined3d_texture *texture, unsigned int sub_resource_idx, HDC *dc)
Definition: texture.c:3623
struct wined3d_texture * wined3d_texture
Definition: d3d9_private.h:161
static struct d3d9_surface * impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)
Definition: surface.c:27
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
unsigned int sub_resource_idx
Definition: d3d9_private.h:162
static const WCHAR dc[]
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373

◆ d3d9_surface_GetDesc()

static HRESULT WINAPI d3d9_surface_GetDesc ( IDirect3DSurface9 *  iface,
D3DSURFACE_DESC desc 
)
static

Definition at line 213 of file surface.c.

214 {
215  struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
216  struct wined3d_sub_resource_desc wined3d_desc;
217 
218  TRACE("iface %p, desc %p.\n", iface, desc);
219 
223 
224  desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
225  desc->Type = D3DRTYPE_SURFACE;
226  desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage);
227  desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage);
228  desc->MultiSampleType = wined3d_desc.multisample_type;
229  desc->MultiSampleQuality = wined3d_desc.multisample_quality;
230  desc->Width = wined3d_desc.width;
231  desc->Height = wined3d_desc.height;
232 
233  return D3D_OK;
234 }
static D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned int usage)
Definition: d3d8_private.h:285
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
HRESULT CDECL wined3d_texture_get_sub_resource_desc(const struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_sub_resource_desc *desc)
Definition: texture.c:3480
static const WCHAR desc[]
Definition: protectdata.c:36
struct wined3d_texture * wined3d_texture
Definition: d3d9_private.h:161
static struct d3d9_surface * impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)
Definition: surface.c:27
#define TRACE(s)
Definition: solgame.cpp:4
#define D3D_OK
Definition: d3d.h:106
static DWORD d3dusage_from_wined3dusage(unsigned int usage)
Definition: d3d8_private.h:280
D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN
Definition: device.c:44
unsigned int sub_resource_idx
Definition: d3d9_private.h:162
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373

◆ d3d9_surface_GetDevice()

static HRESULT WINAPI d3d9_surface_GetDevice ( IDirect3DSurface9 *  iface,
IDirect3DDevice9 **  device 
)
static

Definition at line 121 of file surface.c.

122 {
123  struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
124 
125  TRACE("iface %p, device %p.\n", iface, device);
126 
127  if (surface->texture)
128  return IDirect3DBaseTexture9_GetDevice(&surface->texture->IDirect3DBaseTexture9_iface, device);
129 
130  *device = (IDirect3DDevice9 *)surface->parent_device;
132 
133  TRACE("Returning device %p.\n", *device);
134 
135  return D3D_OK;
136 }
Definition: devices.h:37
static struct d3d9_surface * impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)
Definition: surface.c:27
#define TRACE(s)
Definition: solgame.cpp:4
#define IDirect3DDevice9_AddRef(p)
Definition: d3d9.h:1507
struct d3d9_texture * texture
Definition: d3d9_private.h:167
#define D3D_OK
Definition: d3d.h:106
IDirect3DDevice9Ex * parent_device
Definition: d3d9_private.h:165
#define IDirect3DBaseTexture9_GetDevice(p, a)
Definition: d3d9.h:837

◆ d3d9_surface_GetPriority()

static DWORD WINAPI d3d9_surface_GetPriority ( IDirect3DSurface9 *  iface)
static

Definition at line 172 of file surface.c.

173 {
174  TRACE("iface %p. Ignored on surfaces.\n", iface);
175  return 0;
176 }
#define TRACE(s)
Definition: solgame.cpp:4

◆ d3d9_surface_GetPrivateData()

static HRESULT WINAPI d3d9_surface_GetPrivateData ( IDirect3DSurface9 *  iface,
REFGUID  guid,
void data,
DWORD data_size 
)
static

Definition at line 148 of file surface.c.

150 {
151  struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
152  TRACE("iface %p, guid %s, data %p, data_size %p.\n",
153  iface, debugstr_guid(guid), data, data_size);
154 
155  return d3d9_resource_get_private_data(&surface->resource, guid, data, data_size);
156 }
const GUID * guid
static struct d3d9_surface * impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)
Definition: surface.c:27
#define debugstr_guid
Definition: kernel32.h:35
HRESULT d3d9_resource_get_private_data(struct d3d9_resource *resource, const GUID *guid, void *data, DWORD *data_size)
Definition: d3d9_main.c:178
#define TRACE(s)
Definition: solgame.cpp:4
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
struct d3d9_resource resource
Definition: d3d9_private.h:160

◆ d3d9_surface_GetType()

static D3DRESOURCETYPE WINAPI d3d9_surface_GetType ( IDirect3DSurface9 *  iface)
static

Definition at line 189 of file surface.c.

190 {
191  TRACE("iface %p.\n", iface);
192 
193  return D3DRTYPE_SURFACE;
194 }
#define TRACE(s)
Definition: solgame.cpp:4

◆ d3d9_surface_LockRect()

static HRESULT WINAPI d3d9_surface_LockRect ( IDirect3DSurface9 *  iface,
D3DLOCKED_RECT locked_rect,
const RECT rect,
DWORD  flags 
)
static

Definition at line 236 of file surface.c.

238 {
239  struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
240  struct wined3d_box box;
241  struct wined3d_map_desc map_desc;
242  HRESULT hr;
243 
244  TRACE("iface %p, locked_rect %p, rect %s, flags %#x.\n",
245  iface, locked_rect, wine_dbgstr_rect(rect), flags);
246 
247  if (rect)
248  wined3d_box_set(&box, rect->left, rect->top, rect->right, rect->bottom, 0, 1);
249 
254 
255  if (SUCCEEDED(hr))
256  {
257  locked_rect->Pitch = map_desc.row_pitch;
258  locked_rect->pBits = map_desc.data;
259  }
260 
261  return hr;
262 }
HRESULT hr
Definition: shlfolder.c:183
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
& rect
Definition: startmenu.cpp:1413
static void wined3d_box_set(struct wined3d_box *box, unsigned int left, unsigned int top, unsigned int right, unsigned int bottom, unsigned int front, unsigned int back)
Definition: wined3d.h:2789
HRESULT CDECL wined3d_resource_map(struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags)
Definition: resource.c:344
struct wined3d_texture * wined3d_texture
Definition: d3d9_private.h:161
smooth NULL
Definition: ftsmooth.c:416
static struct d3d9_surface * impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)
Definition: surface.c:27
#define TRACE(s)
Definition: solgame.cpp:4
struct wined3d_resource *CDECL wined3d_texture_get_resource(struct wined3d_texture *texture)
Definition: texture.c:1052
LONG HRESULT
Definition: typedefs.h:79
const char * wine_dbgstr_rect(const RECT *rect)
GLbitfield flags
Definition: glext.h:7161
unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags) DECLSPEC_HIDDEN
Definition: device.c:144
unsigned int sub_resource_idx
Definition: d3d9_private.h:162
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
#define SUCCEEDED(hr)
Definition: intsafe.h:49
Definition: palette.c:467

◆ d3d9_surface_PreLoad()

static void WINAPI d3d9_surface_PreLoad ( IDirect3DSurface9 *  iface)
static

Definition at line 178 of file surface.c.

179 {
180  struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
181 
182  TRACE("iface %p.\n", iface);
183 
187 }
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
void CDECL wined3d_resource_preload(struct wined3d_resource *resource)
Definition: resource.c:482
struct wined3d_texture * wined3d_texture
Definition: d3d9_private.h:161
static struct d3d9_surface * impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)
Definition: surface.c:27
#define TRACE(s)
Definition: solgame.cpp:4
struct wined3d_resource *CDECL wined3d_texture_get_resource(struct wined3d_texture *texture)
Definition: texture.c:1052
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373

◆ d3d9_surface_QueryInterface()

static HRESULT WINAPI d3d9_surface_QueryInterface ( IDirect3DSurface9 *  iface,
REFIID  riid,
void **  out 
)
static

Definition at line 32 of file surface.c.

33 {
34  TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
35 
36  if (IsEqualGUID(riid, &IID_IDirect3DSurface9)
37  || IsEqualGUID(riid, &IID_IDirect3DResource9)
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 }
#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
const GUID IID_IUnknown
static FILE * out
Definition: regtests2xml.c:44
#define IDirect3DSurface9_AddRef(p)
Definition: d3d9.h:621
#define S_OK
Definition: intsafe.h:51
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112

◆ d3d9_surface_Release()

static ULONG WINAPI d3d9_surface_Release ( IDirect3DSurface9 *  iface)
static

Definition at line 81 of file surface.c.

82 {
83  struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
84  ULONG refcount;
85 
86  TRACE("iface %p.\n", iface);
87 
88  if (surface->texture)
89  {
90  TRACE("Forwarding to %p.\n", surface->texture);
91  return IDirect3DBaseTexture9_Release(&surface->texture->IDirect3DBaseTexture9_iface);
92  }
93 
94  if (!surface->resource.refcount)
95  {
96  WARN("Surface does not have any references.\n");
97  return 0;
98  }
99 
100  refcount = InterlockedDecrement(&surface->resource.refcount);
101  TRACE("%p decreasing refcount to %u.\n", iface, refcount);
102 
103  if (!refcount)
104  {
105  IDirect3DDevice9Ex *parent_device = surface->parent_device;
106 
108  if (surface->wined3d_rtv)
112 
113  /* Release the device last, as it may cause the device to be destroyed. */
114  if (parent_device)
116  }
117 
118  return refcount;
119 }
#define WARN(fmt,...)
Definition: debug.h:112
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
#define IDirect3DDevice9Ex_Release(p)
Definition: d3d9.h:1917
struct wined3d_rendertarget_view * wined3d_rtv
Definition: d3d9_private.h:164
ULONG CDECL wined3d_rendertarget_view_decref(struct wined3d_rendertarget_view *view)
Definition: view.c:348
struct wined3d_texture * wined3d_texture
Definition: d3d9_private.h:161
static struct d3d9_surface * impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)
Definition: surface.c:27
#define TRACE(s)
Definition: solgame.cpp:4
struct d3d9_texture * texture
Definition: d3d9_private.h:167
#define InterlockedDecrement
Definition: armddk.h:52
IDirect3DDevice9Ex * parent_device
Definition: d3d9_private.h:165
ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
Definition: texture.c:1023
#define IDirect3DBaseTexture9_Release(p)
Definition: d3d9.h:835
struct d3d9_resource resource
Definition: d3d9_private.h:160
unsigned int ULONG
Definition: retypes.h:1
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373

Referenced by d3d9_surface_acquire_rendertarget_view(), and d3d9_surface_release_rendertarget_view().

◆ d3d9_surface_release_rendertarget_view()

void d3d9_surface_release_rendertarget_view ( struct d3d9_surface surface,
struct wined3d_rendertarget_view rtv 
)

Definition at line 433 of file surface.c.

435 {
436  if (rtv)
438 }
static ULONG WINAPI d3d9_surface_Release(IDirect3DSurface9 *iface)
Definition: surface.c:81
IDirect3DSurface9 IDirect3DSurface9_iface
Definition: d3d9_private.h:159

Referenced by d3d9_device_ColorFill(), d3d9_device_SetDepthStencilSurface(), and d3d9_device_SetRenderTarget().

◆ d3d9_surface_ReleaseDC()

static HRESULT WINAPI d3d9_surface_ReleaseDC ( IDirect3DSurface9 *  iface,
HDC  dc 
)
static

Definition at line 303 of file surface.c.

304 {
305  struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
306  HRESULT hr;
307 
308  TRACE("iface %p, dc %p.\n", iface, dc);
309 
312  if (SUCCEEDED(hr) && surface->texture)
315 
316  return hr;
317 }
HRESULT hr
Definition: shlfolder.c:183
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
struct wined3d_texture * wined3d_texture
Definition: d3d9_private.h:161
static struct d3d9_surface * impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)
Definition: surface.c:27
HRESULT CDECL wined3d_texture_release_dc(struct wined3d_texture *texture, unsigned int sub_resource_idx, HDC dc)
Definition: texture.c:3671
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
struct d3d9_texture * texture
Definition: d3d9_private.h:167
void d3d9_texture_flag_auto_gen_mipmap(struct d3d9_texture *texture) DECLSPEC_HIDDEN
Definition: texture.c:108
unsigned int sub_resource_idx
Definition: d3d9_private.h:162
static const WCHAR dc[]
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
#define SUCCEEDED(hr)
Definition: intsafe.h:49

◆ d3d9_surface_SetPriority()

static DWORD WINAPI d3d9_surface_SetPriority ( IDirect3DSurface9 *  iface,
DWORD  priority 
)
static

Definition at line 166 of file surface.c.

167 {
168  TRACE("iface %p, priority %u. Ignored on surfaces.\n", iface, priority);
169  return 0;
170 }
#define TRACE(s)
Definition: solgame.cpp:4
static int priority
Definition: timer.c:163

◆ d3d9_surface_SetPrivateData()

static HRESULT WINAPI d3d9_surface_SetPrivateData ( IDirect3DSurface9 *  iface,
REFGUID  guid,
const void data,
DWORD  data_size,
DWORD  flags 
)
static

Definition at line 138 of file surface.c.

140 {
141  struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
142  TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
143  iface, debugstr_guid(guid), data, data_size, flags);
144 
145  return d3d9_resource_set_private_data(&surface->resource, guid, data, data_size, flags);
146 }
HRESULT d3d9_resource_set_private_data(struct d3d9_resource *resource, const GUID *guid, const void *data, DWORD data_size, DWORD flags)
Definition: d3d9_main.c:222
const GUID * guid
static struct d3d9_surface * impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)
Definition: surface.c:27
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
struct d3d9_resource resource
Definition: d3d9_private.h:160

◆ d3d9_surface_UnlockRect()

static HRESULT WINAPI d3d9_surface_UnlockRect ( IDirect3DSurface9 *  iface)
static

Definition at line 264 of file surface.c.

265 {
266  struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
267  HRESULT hr;
268 
269  TRACE("iface %p.\n", iface);
270 
273  if (SUCCEEDED(hr) && surface->texture)
276 
277  if (hr == WINEDDERR_NOTLOCKED)
278  {
280  if (surface->texture)
281  type = IDirect3DBaseTexture9_GetType(&surface->texture->IDirect3DBaseTexture9_iface);
282  else
285  }
286  return hr;
287 }
HRESULT hr
Definition: shlfolder.c:183
HRESULT CDECL wined3d_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx)
Definition: resource.c:382
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
#define D3DERR_INVALIDCALL
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
struct wined3d_texture * wined3d_texture
Definition: d3d9_private.h:161
static struct d3d9_surface * impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)
Definition: surface.c:27
#define IDirect3DBaseTexture9_GetType(p)
Definition: d3d9.h:844
#define TRACE(s)
Definition: solgame.cpp:4
struct wined3d_resource *CDECL wined3d_texture_get_resource(struct wined3d_texture *texture)
Definition: texture.c:1052
LONG HRESULT
Definition: typedefs.h:79
struct d3d9_texture * texture
Definition: d3d9_private.h:167
void d3d9_texture_flag_auto_gen_mipmap(struct d3d9_texture *texture) DECLSPEC_HIDDEN
Definition: texture.c:108
#define WINEDDERR_NOTLOCKED
Definition: wined3d.h:50
#define D3D_OK
Definition: d3d.h:106
unsigned int sub_resource_idx
Definition: d3d9_private.h:162
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
enum _D3DRESOURCETYPE D3DRESOURCETYPE
#define SUCCEEDED(hr)
Definition: intsafe.h:49

◆ impl_from_IDirect3DSurface9()

static struct d3d9_surface* impl_from_IDirect3DSurface9 ( IDirect3DSurface9 *  iface)
inlinestatic

Definition at line 27 of file surface.c.

28 {
30 }
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
IDirect3DSurface9 IDirect3DSurface9_iface
Definition: d3d9_private.h:159

Referenced by d3d9_surface_AddRef(), d3d9_surface_FreePrivateData(), d3d9_surface_GetContainer(), d3d9_surface_GetDC(), d3d9_surface_GetDesc(), d3d9_surface_GetDevice(), d3d9_surface_GetPrivateData(), d3d9_surface_LockRect(), d3d9_surface_PreLoad(), d3d9_surface_Release(), d3d9_surface_ReleaseDC(), d3d9_surface_SetPrivateData(), d3d9_surface_UnlockRect(), and unsafe_impl_from_IDirect3DSurface9().

◆ surface_init()

void surface_init ( struct d3d9_surface surface,
struct wined3d_texture wined3d_texture,
unsigned int  sub_resource_idx,
const struct wined3d_parent_ops **  parent_ops 
)

Definition at line 355 of file surface.c.

357 {
358  IDirect3DBaseTexture9 *texture;
359 
360  surface->IDirect3DSurface9_iface.lpVtbl = &d3d9_surface_vtbl;
361  d3d9_resource_init(&surface->resource);
362  surface->resource.refcount = 0;
363  list_init(&surface->rtv_entry);
365  surface->wined3d_texture = wined3d_texture;
367 
368  if (surface->container && SUCCEEDED(IUnknown_QueryInterface(surface->container,
369  &IID_IDirect3DBaseTexture9, (void **)&texture)))
370  {
373  }
374 
375  *parent_ops = &d3d9_surface_wined3d_parent_ops;
376 }
struct d3d9_texture * unsafe_impl_from_IDirect3DBaseTexture9(IDirect3DBaseTexture9 *iface) DECLSPEC_HIDDEN
Definition: texture.c:1269
void d3d9_resource_init(struct d3d9_resource *resource)
Definition: d3d9_main.c:216
struct wined3d_texture * wined3d_texture
Definition: d3d9_private.h:161
IUnknown * container
Definition: d3d9_private.h:166
struct list rtv_entry
Definition: d3d9_private.h:163
static const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops
Definition: surface.c:350
GLenum GLuint texture
Definition: glext.h:6295
static const struct IDirect3DSurface9Vtbl d3d9_surface_vtbl
Definition: surface.c:319
struct d3d9_texture * texture
Definition: d3d9_private.h:167
void *CDECL wined3d_texture_get_parent(const struct wined3d_texture *texture)
Definition: texture.c:1121
#define IDirect3DBaseTexture9_Release(p)
Definition: d3d9.h:835
struct d3d9_resource resource
Definition: d3d9_private.h:160
unsigned int sub_resource_idx
Definition: d3d9_private.h:162
IDirect3DSurface9 IDirect3DSurface9_iface
Definition: d3d9_private.h:159
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
#define SUCCEEDED(hr)
Definition: intsafe.h:49

◆ surface_wined3d_object_destroyed()

static void STDMETHODCALLTYPE surface_wined3d_object_destroyed ( void parent)
static

Definition at line 343 of file surface.c.

344 {
345  struct d3d9_surface *surface = parent;
346  d3d9_resource_cleanup(&surface->resource);
347  heap_free(surface);
348 }
r parent
Definition: btrfs.c:2944
struct d3d9_resource resource
Definition: d3d9_private.h:160
void d3d9_resource_cleanup(struct d3d9_resource *resource)
Definition: d3d9_main.c:155
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ unsafe_impl_from_IDirect3DSurface9()

struct d3d9_surface* unsafe_impl_from_IDirect3DSurface9 ( IDirect3DSurface9 *  iface)

Definition at line 440 of file surface.c.

441 {
442  if (!iface)
443  return NULL;
444  assert(iface->lpVtbl == &d3d9_surface_vtbl);
445 
446  return impl_from_IDirect3DSurface9(iface);
447 }
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
static struct d3d9_surface * impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)
Definition: surface.c:27
static const struct IDirect3DSurface9Vtbl d3d9_surface_vtbl
Definition: surface.c:319

Referenced by d3d9_device_ColorFill(), d3d9_device_GetFrontBufferData(), d3d9_device_GetRenderTargetData(), d3d9_device_SetCursorProperties(), d3d9_device_SetDepthStencilSurface(), d3d9_device_SetRenderTarget(), d3d9_device_StretchRect(), d3d9_device_UpdateSurface(), and d3d9_swapchain_GetFrontBufferData().

◆ view_wined3d_object_destroyed()

static void STDMETHODCALLTYPE view_wined3d_object_destroyed ( void parent)
static

Definition at line 378 of file surface.c.

379 {
380  struct d3d9_surface *surface = parent;
381 
382  /* If the surface reference count drops to zero, we release our reference
383  * to the view, but don't clear the pointer yet, in case e.g. a
384  * GetRenderTarget() call brings the surface back before the view is
385  * actually destroyed. When the view is destroyed, we need to clear the
386  * pointer, or a subsequent surface AddRef() would reference it again.
387  *
388  * This is safe because as long as the view still has a reference to the
389  * texture, the surface is also still alive, and we're called before the
390  * view releases that reference. */
391  surface->wined3d_rtv = NULL;
392  list_remove(&surface->rtv_entry);
393 }
struct wined3d_rendertarget_view * wined3d_rtv
Definition: d3d9_private.h:164
smooth NULL
Definition: ftsmooth.c:416
struct list rtv_entry
Definition: d3d9_private.h:163
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
r parent
Definition: btrfs.c:2944

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3d9  )

Variable Documentation

◆ d3d9_surface_vtbl

const struct IDirect3DSurface9Vtbl d3d9_surface_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI d3d9_surface_QueryInterface(IDirect3DSurface9 *iface, REFIID riid, void **out)
Definition: surface.c:32
static HRESULT WINAPI d3d9_surface_LockRect(IDirect3DSurface9 *iface, D3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags)
Definition: surface.c:236
static DWORD WINAPI d3d9_surface_SetPriority(IDirect3DSurface9 *iface, DWORD priority)
Definition: surface.c:166
static HRESULT WINAPI d3d9_surface_ReleaseDC(IDirect3DSurface9 *iface, HDC dc)
Definition: surface.c:303
static HRESULT WINAPI d3d9_surface_GetPrivateData(IDirect3DSurface9 *iface, REFGUID guid, void *data, DWORD *data_size)
Definition: surface.c:148
static HRESULT WINAPI d3d9_surface_UnlockRect(IDirect3DSurface9 *iface)
Definition: surface.c:264
static HRESULT WINAPI d3d9_surface_GetContainer(IDirect3DSurface9 *iface, REFIID riid, void **container)
Definition: surface.c:196
static DWORD WINAPI d3d9_surface_GetPriority(IDirect3DSurface9 *iface)
Definition: surface.c:172
static ULONG WINAPI d3d9_surface_Release(IDirect3DSurface9 *iface)
Definition: surface.c:81
static HRESULT WINAPI d3d9_surface_FreePrivateData(IDirect3DSurface9 *iface, REFGUID guid)
Definition: surface.c:158
static HRESULT WINAPI d3d9_surface_GetDC(IDirect3DSurface9 *iface, HDC *dc)
Definition: surface.c:289
static HRESULT WINAPI d3d9_surface_SetPrivateData(IDirect3DSurface9 *iface, REFGUID guid, const void *data, DWORD data_size, DWORD flags)
Definition: surface.c:138
static HRESULT WINAPI d3d9_surface_GetDesc(IDirect3DSurface9 *iface, D3DSURFACE_DESC *desc)
Definition: surface.c:213
static ULONG WINAPI d3d9_surface_AddRef(IDirect3DSurface9 *iface)
Definition: surface.c:51
static void WINAPI d3d9_surface_PreLoad(IDirect3DSurface9 *iface)
Definition: surface.c:178
static D3DRESOURCETYPE WINAPI d3d9_surface_GetType(IDirect3DSurface9 *iface)
Definition: surface.c:189
static HRESULT WINAPI d3d9_surface_GetDevice(IDirect3DSurface9 *iface, IDirect3DDevice9 **device)
Definition: surface.c:121

Definition at line 319 of file surface.c.

Referenced by surface_init(), and unsafe_impl_from_IDirect3DSurface9().

◆ d3d9_surface_wined3d_parent_ops

const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops
static
Initial value:
=
{
}
static void STDMETHODCALLTYPE surface_wined3d_object_destroyed(void *parent)
Definition: surface.c:343

Definition at line 350 of file surface.c.

Referenced by surface_init().

◆ d3d9_view_wined3d_parent_ops

const struct wined3d_parent_ops d3d9_view_wined3d_parent_ops
static
Initial value:
=
{
}
static void STDMETHODCALLTYPE view_wined3d_object_destroyed(void *parent)
Definition: surface.c:378

Definition at line 395 of file surface.c.

Referenced by d3d9_surface_acquire_rendertarget_view().