ReactOS  0.4.14-dev-358-gbef841c
surface.c File Reference
#include "config.h"
#include "d3d8_private.h"
Include dependency graph for surface.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d8)
 
static struct d3d8_surfaceimpl_from_IDirect3DSurface8 (IDirect3DSurface8 *iface)
 
static HRESULT WINAPI d3d8_surface_QueryInterface (IDirect3DSurface8 *iface, REFIID riid, void **out)
 
static ULONG WINAPI d3d8_surface_AddRef (IDirect3DSurface8 *iface)
 
static ULONG WINAPI d3d8_surface_Release (IDirect3DSurface8 *iface)
 
static HRESULT WINAPI d3d8_surface_GetDevice (IDirect3DSurface8 *iface, IDirect3DDevice8 **device)
 
static HRESULT WINAPI d3d8_surface_SetPrivateData (IDirect3DSurface8 *iface, REFGUID guid, const void *data, DWORD data_size, DWORD flags)
 
static HRESULT WINAPI d3d8_surface_GetPrivateData (IDirect3DSurface8 *iface, REFGUID guid, void *data, DWORD *data_size)
 
static HRESULT WINAPI d3d8_surface_FreePrivateData (IDirect3DSurface8 *iface, REFGUID guid)
 
static HRESULT WINAPI d3d8_surface_GetContainer (IDirect3DSurface8 *iface, REFIID riid, void **container)
 
static HRESULT WINAPI d3d8_surface_GetDesc (IDirect3DSurface8 *iface, D3DSURFACE_DESC *desc)
 
static HRESULT WINAPI d3d8_surface_LockRect (IDirect3DSurface8 *iface, D3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags)
 
static HRESULT WINAPI d3d8_surface_UnlockRect (IDirect3DSurface8 *iface)
 
static void STDMETHODCALLTYPE surface_wined3d_object_destroyed (void *parent)
 
void surface_init (struct d3d8_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 d3d8_deviced3d8_surface_get_device (const struct d3d8_surface *surface)
 
struct wined3d_rendertarget_viewd3d8_surface_acquire_rendertarget_view (struct d3d8_surface *surface)
 
void d3d8_surface_release_rendertarget_view (struct d3d8_surface *surface, struct wined3d_rendertarget_view *rtv)
 
struct d3d8_surfaceunsafe_impl_from_IDirect3DSurface8 (IDirect3DSurface8 *iface)
 

Variables

static const IDirect3DSurface8Vtbl d3d8_surface_vtbl
 
static const struct wined3d_parent_ops d3d8_surface_wined3d_parent_ops
 
static const struct wined3d_parent_ops d3d8_view_wined3d_parent_ops
 

Function Documentation

◆ d3d8_surface_acquire_rendertarget_view()

struct wined3d_rendertarget_view* d3d8_surface_acquire_rendertarget_view ( struct d3d8_surface surface)

Definition at line 369 of file surface.c.

370 {
371  HRESULT hr;
372 
373  /* The surface reference count can be equal to 0 when this function is
374  * called. In order to properly manage the render target view reference
375  * count, we temporarily increment the surface reference count. */
377 
378  if (surface->wined3d_rtv)
379  return surface->wined3d_rtv;
380 
382  surface->sub_resource_idx, surface, &d3d8_view_wined3d_parent_ops, &surface->wined3d_rtv)))
383  {
384  ERR("Failed to create rendertarget view, hr %#x.\n", hr);
386  return NULL;
387  }
388 
389  if (surface->texture)
390  list_add_head(&surface->texture->rtv_list, &surface->rtv_entry);
391 
392  return surface->wined3d_rtv;
393 }
HRESULT hr
Definition: shlfolder.c:183
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
IDirect3DSurface8 IDirect3DSurface8_iface
Definition: d3d8_private.h:176
unsigned int sub_resource_idx
Definition: d3d8_private.h:179
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
LONG HRESULT
Definition: typedefs.h:77
struct d3d8_texture * texture
Definition: d3d8_private.h:184
struct wined3d_texture * wined3d_texture
Definition: d3d8_private.h:178
#define ERR(fmt,...)
Definition: debug.h:109
struct list rtv_entry
Definition: d3d8_private.h:180
struct wined3d_rendertarget_view * wined3d_rtv
Definition: d3d8_private.h:181
static ULONG WINAPI d3d8_surface_AddRef(IDirect3DSurface8 *iface)
Definition: surface.c:50
static ULONG WINAPI d3d8_surface_Release(IDirect3DSurface8 *iface)
Definition: surface.c:80
static const struct wined3d_parent_ops d3d8_view_wined3d_parent_ops
Definition: surface.c:357

Referenced by d3d8_device_SetRenderTarget().

◆ d3d8_surface_AddRef()

static ULONG WINAPI d3d8_surface_AddRef ( IDirect3DSurface8 *  iface)
static

Definition at line 50 of file surface.c.

51 {
52  struct d3d8_surface *surface = impl_from_IDirect3DSurface8(iface);
53  ULONG refcount;
54 
55  TRACE("iface %p.\n", iface);
56 
57  if (surface->texture)
58  {
59  TRACE("Forwarding to %p.\n", surface->texture);
60  return IDirect3DBaseTexture8_AddRef(&surface->texture->IDirect3DBaseTexture8_iface);
61  }
62 
63  refcount = InterlockedIncrement(&surface->resource.refcount);
64  TRACE("%p increasing refcount to %u.\n", iface, refcount);
65 
66  if (refcount == 1)
67  {
68  if (surface->parent_device)
71  if (surface->wined3d_rtv)
75  }
76 
77  return refcount;
78 }
IDirect3DDevice8 * parent_device
Definition: d3d8_private.h:182
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
#define IDirect3DBaseTexture8_AddRef(p)
Definition: d3d8.h:545
#define TRACE(s)
Definition: solgame.cpp:4
struct d3d8_texture * texture
Definition: d3d8_private.h:184
struct d3d8_resource resource
Definition: d3d8_private.h:177
struct wined3d_texture * wined3d_texture
Definition: d3d8_private.h:178
struct wined3d_rendertarget_view * wined3d_rtv
Definition: d3d8_private.h:181
#define InterlockedIncrement
Definition: armddk.h:53
#define IDirect3DDevice8_AddRef(p)
Definition: d3d8.h:947
static struct d3d8_surface * impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface)
Definition: surface.c:26
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
ULONG CDECL wined3d_texture_incref(struct wined3d_texture *texture)
Definition: texture.c:994

Referenced by d3d8_surface_acquire_rendertarget_view().

◆ d3d8_surface_FreePrivateData()

static HRESULT WINAPI d3d8_surface_FreePrivateData ( IDirect3DSurface8 *  iface,
REFGUID  guid 
)
static

Definition at line 156 of file surface.c.

157 {
158  struct d3d8_surface *surface = impl_from_IDirect3DSurface8(iface);
159  TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
160 
161  return d3d8_resource_free_private_data(&surface->resource, guid);
162 }
HRESULT d3d8_resource_free_private_data(struct d3d8_resource *resource, const GUID *guid)
Definition: d3d8_main.c:135
const GUID * guid
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
struct d3d8_resource resource
Definition: d3d8_private.h:177
static struct d3d8_surface * impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface)
Definition: surface.c:26

◆ d3d8_surface_get_device()

struct d3d8_device* d3d8_surface_get_device ( const struct d3d8_surface surface)

Definition at line 362 of file surface.c.

363 {
364  IDirect3DDevice8 *device;
365  device = surface->texture ? surface->texture->parent_device : surface->parent_device;
367 }
IDirect3DDevice8 * parent_device
Definition: d3d8_private.h:182
Definition: devices.h:37
struct d3d8_texture * texture
Definition: d3d8_private.h:184
static struct d3d8_device * impl_from_IDirect3DDevice8(IDirect3DDevice8 *iface)
Definition: d3d8_private.h:132

Referenced by d3d8_device_SetRenderTarget().

◆ d3d8_surface_GetContainer()

static HRESULT WINAPI d3d8_surface_GetContainer ( IDirect3DSurface8 *  iface,
REFIID  riid,
void **  container 
)
static

Definition at line 164 of file surface.c.

165 {
166  struct d3d8_surface *surface = impl_from_IDirect3DSurface8(iface);
167  HRESULT hr;
168 
169  TRACE("iface %p, riid %s, container %p.\n", iface, debugstr_guid(riid), container);
170 
171  if (!surface->container)
172  return E_NOINTERFACE;
173 
174  hr = IUnknown_QueryInterface(surface->container, riid, container);
175 
176  TRACE("Returning %p.\n", *container);
177 
178  return hr;
179 }
#define E_NOINTERFACE
Definition: winerror.h:2364
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
IUnknown * container
Definition: d3d8_private.h:183
static struct d3d8_surface * impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface)
Definition: surface.c:26

◆ d3d8_surface_GetDesc()

static HRESULT WINAPI d3d8_surface_GetDesc ( IDirect3DSurface8 *  iface,
D3DSURFACE_DESC desc 
)
static

Definition at line 181 of file surface.c.

182 {
183  struct d3d8_surface *surface = impl_from_IDirect3DSurface8(iface);
184  struct wined3d_sub_resource_desc wined3d_desc;
185 
186  TRACE("iface %p, desc %p.\n", iface, desc);
187 
191 
192  desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
193  desc->Type = D3DRTYPE_SURFACE;
194  desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage);
195  desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage);
196  desc->Size = wined3d_desc.size;
197  desc->MultiSampleType = wined3d_desc.multisample_type;
198  desc->Width = wined3d_desc.width;
199  desc->Height = wined3d_desc.height;
200 
201  return D3D_OK;
202 }
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
unsigned int sub_resource_idx
Definition: d3d8_private.h:179
#define TRACE(s)
Definition: solgame.cpp:4
struct wined3d_texture * wined3d_texture
Definition: d3d8_private.h:178
#define D3D_OK
Definition: d3d.h:106
static DWORD d3dusage_from_wined3dusage(unsigned int usage)
Definition: d3d8_private.h:280
static struct d3d8_surface * impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface)
Definition: surface.c:26
D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN
Definition: device.c:44
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373

◆ d3d8_surface_GetDevice()

static HRESULT WINAPI d3d8_surface_GetDevice ( IDirect3DSurface8 *  iface,
IDirect3DDevice8 **  device 
)
static

Definition at line 119 of file surface.c.

120 {
121  struct d3d8_surface *surface = impl_from_IDirect3DSurface8(iface);
122 
123  TRACE("iface %p, device %p.\n", iface, device);
124 
125  if (surface->texture)
126  return IDirect3DBaseTexture8_GetDevice(&surface->texture->IDirect3DBaseTexture8_iface, device);
127 
128  *device = surface->parent_device;
130 
131  TRACE("Returning device %p.\n", *device);
132 
133  return D3D_OK;
134 }
IDirect3DDevice8 * parent_device
Definition: d3d8_private.h:182
Definition: devices.h:37
#define TRACE(s)
Definition: solgame.cpp:4
struct d3d8_texture * texture
Definition: d3d8_private.h:184
#define D3D_OK
Definition: d3d.h:106
#define IDirect3DDevice8_AddRef(p)
Definition: d3d8.h:947
static struct d3d8_surface * impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface)
Definition: surface.c:26
#define IDirect3DBaseTexture8_GetDevice(p, a)
Definition: d3d8.h:548

◆ d3d8_surface_GetPrivateData()

static HRESULT WINAPI d3d8_surface_GetPrivateData ( IDirect3DSurface8 *  iface,
REFGUID  guid,
void data,
DWORD data_size 
)
static

Definition at line 146 of file surface.c.

148 {
149  struct d3d8_surface *surface = impl_from_IDirect3DSurface8(iface);
150  TRACE("iface %p, guid %s, data %p, data_size %p.\n",
151  iface, debugstr_guid(guid), data, data_size);
152 
153  return d3d8_resource_get_private_data(&surface->resource, guid, data, data_size);
154 }
const GUID * guid
#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
struct d3d8_resource resource
Definition: d3d8_private.h:177
static struct d3d8_surface * impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface)
Definition: surface.c:26
HRESULT d3d8_resource_get_private_data(struct d3d8_resource *resource, const GUID *guid, void *data, DWORD *data_size)
Definition: d3d8_main.c:153

◆ d3d8_surface_LockRect()

static HRESULT WINAPI d3d8_surface_LockRect ( IDirect3DSurface8 *  iface,
D3DLOCKED_RECT locked_rect,
const RECT rect,
DWORD  flags 
)
static

Definition at line 204 of file surface.c.

206 {
207  struct d3d8_surface *surface = impl_from_IDirect3DSurface8(iface);
208  struct wined3d_box box;
209  struct wined3d_map_desc map_desc;
210  HRESULT hr;
212 
213  TRACE("iface %p, locked_rect %p, rect %s, flags %#x.\n",
214  iface, locked_rect, wine_dbgstr_rect(rect), flags);
215 
217 
218  if (surface->texture)
219  type = IDirect3DBaseTexture8_GetType(&surface->texture->IDirect3DBaseTexture8_iface);
220  else
222 
223  if (rect)
224  {
227 
228  if (type != D3DRTYPE_TEXTURE
229  && ((rect->left < 0)
230  || (rect->top < 0)
231  || (rect->left >= rect->right)
232  || (rect->top >= rect->bottom)
233  || (rect->right > desc.Width)
234  || (rect->bottom > desc.Height)))
235  {
236  WARN("Trying to lock an invalid rectangle, returning D3DERR_INVALIDCALL\n");
238 
239  locked_rect->Pitch = 0;
240  locked_rect->pBits = NULL;
241  return D3DERR_INVALIDCALL;
242  }
243  wined3d_box_set(&box, rect->left, rect->top, rect->right, rect->bottom, 0, 1);
244  }
245 
249 
250  if (SUCCEEDED(hr))
251  {
252  locked_rect->Pitch = map_desc.row_pitch;
253  locked_rect->pBits = map_desc.data;
254  }
255  else if (type != D3DRTYPE_TEXTURE)
256  {
257  locked_rect->Pitch = 0;
258  locked_rect->pBits = NULL;
259  }
260 
261  return hr;
262 }
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DBaseTexture8_GetType(p)
Definition: d3d8.h:555
#define WARN(fmt,...)
Definition: debug.h:111
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
#define D3DERR_INVALIDCALL
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
& 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
#define IDirect3DSurface8_GetDesc(p, a)
Definition: d3d8.h:317
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
static const WCHAR desc[]
Definition: protectdata.c:36
unsigned int sub_resource_idx
Definition: d3d8_private.h:179
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
const char * wine_dbgstr_rect(const RECT *rect)
struct wined3d_resource *CDECL wined3d_texture_get_resource(struct wined3d_texture *texture)
Definition: texture.c:1052
struct d3d8_texture * texture
Definition: d3d8_private.h:184
GLbitfield flags
Definition: glext.h:7161
struct wined3d_texture * wined3d_texture
Definition: d3d8_private.h:178
static struct d3d8_surface * impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface)
Definition: surface.c:26
unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags) DECLSPEC_HIDDEN
Definition: device.c:144
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
enum _D3DRESOURCETYPE D3DRESOURCETYPE
#define SUCCEEDED(hr)
Definition: intsafe.h:57
Definition: palette.c:467

◆ d3d8_surface_QueryInterface()

static HRESULT WINAPI d3d8_surface_QueryInterface ( IDirect3DSurface8 *  iface,
REFIID  riid,
void **  out 
)
static

Definition at line 31 of file surface.c.

32 {
33  TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
34 
35  if (IsEqualGUID(riid, &IID_IDirect3DSurface8)
36  || IsEqualGUID(riid, &IID_IDirect3DResource8)
38  {
40  *out = iface;
41  return S_OK;
42  }
43 
44  WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
45 
46  *out = NULL;
47  return E_NOINTERFACE;
48 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
#define WARN(fmt,...)
Definition: debug.h:111
#define IDirect3DSurface8_AddRef(p)
Definition: d3d8.h:309
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 S_OK
Definition: intsafe.h:59
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112

◆ d3d8_surface_Release()

static ULONG WINAPI d3d8_surface_Release ( IDirect3DSurface8 *  iface)
static

Definition at line 80 of file surface.c.

81 {
82  struct d3d8_surface *surface = impl_from_IDirect3DSurface8(iface);
83  ULONG refcount;
84 
85  TRACE("iface %p.\n", iface);
86 
87  if (surface->texture)
88  {
89  TRACE("Forwarding to %p.\n", surface->texture);
90  return IDirect3DBaseTexture8_Release(&surface->texture->IDirect3DBaseTexture8_iface);
91  }
92 
93  if (!surface->resource.refcount)
94  {
95  WARN("Surface does not have any references.\n");
96  return 0;
97  }
98 
99  refcount = InterlockedDecrement(&surface->resource.refcount);
100  TRACE("%p decreasing refcount to %u.\n", iface, refcount);
101 
102  if (!refcount)
103  {
104  IDirect3DDevice8 *parent_device = surface->parent_device;
105 
107  if (surface->wined3d_rtv)
111 
112  if (parent_device)
114  }
115 
116  return refcount;
117 }
IDirect3DDevice8 * parent_device
Definition: d3d8_private.h:182
#define WARN(fmt,...)
Definition: debug.h:111
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
#define IDirect3DBaseTexture8_Release(p)
Definition: d3d8.h:546
ULONG CDECL wined3d_rendertarget_view_decref(struct wined3d_rendertarget_view *view)
Definition: view.c:348
#define TRACE(s)
Definition: solgame.cpp:4
struct d3d8_texture * texture
Definition: d3d8_private.h:184
struct d3d8_resource resource
Definition: d3d8_private.h:177
#define InterlockedDecrement
Definition: armddk.h:52
struct wined3d_texture * wined3d_texture
Definition: d3d8_private.h:178
struct wined3d_rendertarget_view * wined3d_rtv
Definition: d3d8_private.h:181
static struct d3d8_surface * impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface)
Definition: surface.c:26
#define IDirect3DDevice8_Release(p)
Definition: d3d8.h:948
unsigned int ULONG
Definition: retypes.h:1
ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
Definition: texture.c:1023
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373

Referenced by d3d8_surface_acquire_rendertarget_view(), and d3d8_surface_release_rendertarget_view().

◆ d3d8_surface_release_rendertarget_view()

void d3d8_surface_release_rendertarget_view ( struct d3d8_surface surface,
struct wined3d_rendertarget_view rtv 
)

Definition at line 395 of file surface.c.

397 {
398  if (rtv)
400 }
IDirect3DSurface8 IDirect3DSurface8_iface
Definition: d3d8_private.h:176
static ULONG WINAPI d3d8_surface_Release(IDirect3DSurface8 *iface)
Definition: surface.c:80

Referenced by d3d8_device_SetRenderTarget().

◆ d3d8_surface_SetPrivateData()

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

Definition at line 136 of file surface.c.

138 {
139  struct d3d8_surface *surface = impl_from_IDirect3DSurface8(iface);
140  TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
141  iface, debugstr_guid(guid), data, data_size, flags);
142 
143  return d3d8_resource_set_private_data(&surface->resource, guid, data, data_size, flags);
144 }
HRESULT d3d8_resource_set_private_data(struct d3d8_resource *resource, const GUID *guid, const void *data, DWORD data_size, DWORD flags)
Definition: d3d8_main.c:197
const GUID * guid
#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 d3d8_resource resource
Definition: d3d8_private.h:177
static struct d3d8_surface * impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface)
Definition: surface.c:26

◆ d3d8_surface_UnlockRect()

static HRESULT WINAPI d3d8_surface_UnlockRect ( IDirect3DSurface8 *  iface)
static

Definition at line 264 of file surface.c.

265 {
266  struct d3d8_surface *surface = impl_from_IDirect3DSurface8(iface);
267  HRESULT hr;
268 
269  TRACE("iface %p.\n", iface);
270 
274 
275  if (hr == WINEDDERR_NOTLOCKED)
276  {
278  if (surface->texture)
279  type = IDirect3DBaseTexture8_GetType(&surface->texture->IDirect3DBaseTexture8_iface);
280  else
283  }
284  return hr;
285 }
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DBaseTexture8_GetType(p)
Definition: d3d8.h:555
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
unsigned int sub_resource_idx
Definition: d3d8_private.h:179
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
struct wined3d_resource *CDECL wined3d_texture_get_resource(struct wined3d_texture *texture)
Definition: texture.c:1052
struct d3d8_texture * texture
Definition: d3d8_private.h:184
struct wined3d_texture * wined3d_texture
Definition: d3d8_private.h:178
#define WINEDDERR_NOTLOCKED
Definition: wined3d.h:50
#define D3D_OK
Definition: d3d.h:106
static struct d3d8_surface * impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface)
Definition: surface.c:26
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
enum _D3DRESOURCETYPE D3DRESOURCETYPE

◆ impl_from_IDirect3DSurface8()

static struct d3d8_surface* impl_from_IDirect3DSurface8 ( IDirect3DSurface8 *  iface)
inlinestatic

Definition at line 26 of file surface.c.

27 {
29 }
IDirect3DSurface8 IDirect3DSurface8_iface
Definition: d3d8_private.h:176
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_surface_AddRef(), d3d8_surface_FreePrivateData(), d3d8_surface_GetContainer(), d3d8_surface_GetDesc(), d3d8_surface_GetDevice(), d3d8_surface_GetPrivateData(), d3d8_surface_LockRect(), d3d8_surface_Release(), d3d8_surface_SetPrivateData(), d3d8_surface_UnlockRect(), and unsafe_impl_from_IDirect3DSurface8().

◆ surface_init()

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

Definition at line 317 of file surface.c.

319 {
320  IDirect3DBaseTexture8 *texture;
321 
322  surface->IDirect3DSurface8_iface.lpVtbl = &d3d8_surface_vtbl;
323  d3d8_resource_init(&surface->resource);
324  surface->resource.refcount = 0;
325  list_init(&surface->rtv_entry);
327  surface->wined3d_texture = wined3d_texture;
329 
330  if (surface->container && SUCCEEDED(IUnknown_QueryInterface(surface->container,
331  &IID_IDirect3DBaseTexture8, (void **)&texture)))
332  {
335  }
336 
337  *parent_ops = &d3d8_surface_wined3d_parent_ops;
338 }
void *CDECL wined3d_texture_get_parent(const struct wined3d_texture *texture)
Definition: texture.c:1121
#define IDirect3DBaseTexture8_Release(p)
Definition: d3d8.h:546
IDirect3DSurface8 IDirect3DSurface8_iface
Definition: d3d8_private.h:176
unsigned int sub_resource_idx
Definition: d3d8_private.h:179
struct d3d8_texture * unsafe_impl_from_IDirect3DBaseTexture8(IDirect3DBaseTexture8 *iface) DECLSPEC_HIDDEN
Definition: texture.c:1061
GLenum GLuint texture
Definition: glext.h:6295
IUnknown * container
Definition: d3d8_private.h:183
struct d3d8_texture * texture
Definition: d3d8_private.h:184
void d3d8_resource_init(struct d3d8_resource *resource)
Definition: d3d8_main.c:191
struct d3d8_resource resource
Definition: d3d8_private.h:177
static const struct wined3d_parent_ops d3d8_surface_wined3d_parent_ops
Definition: surface.c:312
struct wined3d_texture * wined3d_texture
Definition: d3d8_private.h:178
struct list rtv_entry
Definition: d3d8_private.h:180
static const IDirect3DSurface8Vtbl d3d8_surface_vtbl
Definition: surface.c:287
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by device_parent_surface_created().

◆ surface_wined3d_object_destroyed()

static void STDMETHODCALLTYPE surface_wined3d_object_destroyed ( void parent)
static

Definition at line 305 of file surface.c.

306 {
307  struct d3d8_surface *surface = parent;
308  d3d8_resource_cleanup(&surface->resource);
309  heap_free(surface);
310 }
void d3d8_resource_cleanup(struct d3d8_resource *resource)
Definition: d3d8_main.c:130
r parent
Definition: btrfs.c:2869
struct d3d8_resource resource
Definition: d3d8_private.h:177
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ unsafe_impl_from_IDirect3DSurface8()

struct d3d8_surface* unsafe_impl_from_IDirect3DSurface8 ( IDirect3DSurface8 *  iface)

Definition at line 402 of file surface.c.

403 {
404  if (!iface)
405  return NULL;
406  assert(iface->lpVtbl == &d3d8_surface_vtbl);
407 
408  return impl_from_IDirect3DSurface8(iface);
409 }
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
static struct d3d8_surface * impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface)
Definition: surface.c:26
static const IDirect3DSurface8Vtbl d3d8_surface_vtbl
Definition: surface.c:287

Referenced by d3d8_device_CopyRects(), d3d8_device_GetFrontBuffer(), d3d8_device_SetCursorProperties(), and d3d8_device_SetRenderTarget().

◆ view_wined3d_object_destroyed()

static void STDMETHODCALLTYPE view_wined3d_object_destroyed ( void parent)
static

Definition at line 340 of file surface.c.

341 {
342  struct d3d8_surface *surface = parent;
343 
344  /* If the surface reference count drops to zero, we release our reference
345  * to the view, but don't clear the pointer yet, in case e.g. a
346  * GetRenderTarget() call brings the surface back before the view is
347  * actually destroyed. When the view is destroyed, we need to clear the
348  * pointer, or a subsequent surface AddRef() would reference it again.
349  *
350  * This is safe because as long as the view still has a reference to the
351  * texture, the surface is also still alive, and we're called before the
352  * view releases that reference. */
353  surface->wined3d_rtv = NULL;
354  list_remove(&surface->rtv_entry);
355 }
smooth NULL
Definition: ftsmooth.c:416
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
r parent
Definition: btrfs.c:2869
struct list rtv_entry
Definition: d3d8_private.h:180
struct wined3d_rendertarget_view * wined3d_rtv
Definition: d3d8_private.h:181

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3d8  )

Variable Documentation

◆ d3d8_surface_vtbl

const IDirect3DSurface8Vtbl d3d8_surface_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI d3d8_surface_GetDesc(IDirect3DSurface8 *iface, D3DSURFACE_DESC *desc)
Definition: surface.c:181
static HRESULT WINAPI d3d8_surface_QueryInterface(IDirect3DSurface8 *iface, REFIID riid, void **out)
Definition: surface.c:31
static HRESULT WINAPI d3d8_surface_UnlockRect(IDirect3DSurface8 *iface)
Definition: surface.c:264
static HRESULT WINAPI d3d8_surface_LockRect(IDirect3DSurface8 *iface, D3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags)
Definition: surface.c:204
static HRESULT WINAPI d3d8_surface_GetPrivateData(IDirect3DSurface8 *iface, REFGUID guid, void *data, DWORD *data_size)
Definition: surface.c:146
static HRESULT WINAPI d3d8_surface_SetPrivateData(IDirect3DSurface8 *iface, REFGUID guid, const void *data, DWORD data_size, DWORD flags)
Definition: surface.c:136
static HRESULT WINAPI d3d8_surface_GetContainer(IDirect3DSurface8 *iface, REFIID riid, void **container)
Definition: surface.c:164
static HRESULT WINAPI d3d8_surface_GetDevice(IDirect3DSurface8 *iface, IDirect3DDevice8 **device)
Definition: surface.c:119
static ULONG WINAPI d3d8_surface_AddRef(IDirect3DSurface8 *iface)
Definition: surface.c:50
static ULONG WINAPI d3d8_surface_Release(IDirect3DSurface8 *iface)
Definition: surface.c:80
static HRESULT WINAPI d3d8_surface_FreePrivateData(IDirect3DSurface8 *iface, REFGUID guid)
Definition: surface.c:156

Definition at line 287 of file surface.c.

Referenced by surface_init(), and unsafe_impl_from_IDirect3DSurface8().

◆ d3d8_surface_wined3d_parent_ops

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

Definition at line 312 of file surface.c.

Referenced by surface_init().

◆ d3d8_view_wined3d_parent_ops

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

Definition at line 357 of file surface.c.

Referenced by d3d8_surface_acquire_rendertarget_view().