Commit 8cef8b35 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Unify the wined3d_mapped_rect and wined3d_mapped_box structures.

parent 949f7b45
...@@ -363,7 +363,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_Map(ID3D10Texture3D *iface, UIN ...@@ -363,7 +363,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_Map(ID3D10Texture3D *iface, UIN
D3D10_MAP map_type, UINT map_flags, D3D10_MAPPED_TEXTURE3D *mapped_texture) D3D10_MAP map_type, UINT map_flags, D3D10_MAPPED_TEXTURE3D *mapped_texture)
{ {
struct d3d10_texture3d *texture = impl_from_ID3D10Texture3D(iface); struct d3d10_texture3d *texture = impl_from_ID3D10Texture3D(iface);
struct wined3d_mapped_box wined3d_map_desc; struct wined3d_map_desc wined3d_map_desc;
struct wined3d_resource *sub_resource; struct wined3d_resource *sub_resource;
HRESULT hr; HRESULT hr;
......
...@@ -237,24 +237,28 @@ static HRESULT WINAPI IDirect3DSurface8Impl_GetDesc(IDirect3DSurface8 *iface, D3 ...@@ -237,24 +237,28 @@ static HRESULT WINAPI IDirect3DSurface8Impl_GetDesc(IDirect3DSurface8 *iface, D3
} }
static HRESULT WINAPI IDirect3DSurface8Impl_LockRect(IDirect3DSurface8 *iface, static HRESULT WINAPI IDirect3DSurface8Impl_LockRect(IDirect3DSurface8 *iface,
D3DLOCKED_RECT *pLockedRect, const RECT *pRect, DWORD Flags) D3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags)
{ {
IDirect3DSurface8Impl *This = impl_from_IDirect3DSurface8(iface); IDirect3DSurface8Impl *This = impl_from_IDirect3DSurface8(iface);
struct wined3d_map_desc map_desc;
HRESULT hr; HRESULT hr;
TRACE("iface %p, locked_rect %p, rect %p, flags %#x.\n", iface, pLockedRect, pRect, Flags); TRACE("iface %p, locked_rect %p, rect %s, flags %#x.\n",
iface, locked_rect, wine_dbgstr_rect(rect), flags);
wined3d_mutex_lock(); wined3d_mutex_lock();
if (pRect) { if (rect)
{
D3DSURFACE_DESC desc; D3DSURFACE_DESC desc;
IDirect3DSurface8_GetDesc(iface, &desc); IDirect3DSurface8_GetDesc(iface, &desc);
if ((pRect->left < 0) if ((rect->left < 0)
|| (pRect->top < 0) || (rect->top < 0)
|| (pRect->left >= pRect->right) || (rect->left >= rect->right)
|| (pRect->top >= pRect->bottom) || (rect->top >= rect->bottom)
|| (pRect->right > desc.Width) || (rect->right > desc.Width)
|| (pRect->bottom > desc.Height)) { || (rect->bottom > desc.Height))
{
WARN("Trying to lock an invalid rectangle, returning D3DERR_INVALIDCALL\n"); WARN("Trying to lock an invalid rectangle, returning D3DERR_INVALIDCALL\n");
wined3d_mutex_unlock(); wined3d_mutex_unlock();
...@@ -262,9 +266,12 @@ static HRESULT WINAPI IDirect3DSurface8Impl_LockRect(IDirect3DSurface8 *iface, ...@@ -262,9 +266,12 @@ static HRESULT WINAPI IDirect3DSurface8Impl_LockRect(IDirect3DSurface8 *iface,
} }
} }
hr = wined3d_surface_map(This->wined3d_surface, (struct wined3d_mapped_rect *)pLockedRect, pRect, Flags); hr = wined3d_surface_map(This->wined3d_surface, &map_desc, rect, flags);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
locked_rect->Pitch = map_desc.row_pitch;
locked_rect->pBits = map_desc.data;
return hr; return hr;
} }
......
...@@ -218,19 +218,23 @@ static HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(IDirect3DVolume8 *iface, D3DV ...@@ -218,19 +218,23 @@ static HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(IDirect3DVolume8 *iface, D3DV
} }
static HRESULT WINAPI IDirect3DVolume8Impl_LockBox(IDirect3DVolume8 *iface, static HRESULT WINAPI IDirect3DVolume8Impl_LockBox(IDirect3DVolume8 *iface,
D3DLOCKED_BOX *pLockedVolume, const D3DBOX *pBox, DWORD Flags) D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags)
{ {
IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface); IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
struct wined3d_map_desc map_desc;
HRESULT hr; HRESULT hr;
TRACE("iface %p, locked_box %p, box %p, flags %#x.\n", TRACE("iface %p, locked_box %p, box %p, flags %#x.\n",
iface, pLockedVolume, pBox, Flags); iface, locked_box, box, flags);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_volume_map(This->wined3d_volume, (struct wined3d_mapped_box *)pLockedVolume, hr = wined3d_volume_map(This->wined3d_volume, &map_desc, (const struct wined3d_box *)box, flags);
(const struct wined3d_box *)pBox, Flags);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
locked_box->RowPitch = map_desc.row_pitch;
locked_box->SlicePitch = map_desc.slice_pitch;
locked_box->pBits = map_desc.data;
return hr; return hr;
} }
......
...@@ -285,17 +285,22 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(IDirect3DSurface9 *iface, D3 ...@@ -285,17 +285,22 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(IDirect3DSurface9 *iface, D3
} }
static HRESULT WINAPI IDirect3DSurface9Impl_LockRect(IDirect3DSurface9 *iface, static HRESULT WINAPI IDirect3DSurface9Impl_LockRect(IDirect3DSurface9 *iface,
D3DLOCKED_RECT *pLockedRect, const RECT *pRect, DWORD Flags) D3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags)
{ {
IDirect3DSurface9Impl *This = impl_from_IDirect3DSurface9(iface); IDirect3DSurface9Impl *This = impl_from_IDirect3DSurface9(iface);
struct wined3d_map_desc map_desc;
HRESULT hr; HRESULT hr;
TRACE("iface %p, locked_rect %p, rect %p, flags %#x.\n", iface, pLockedRect, pRect, Flags); TRACE("iface %p, locked_rect %p, rect %s, flags %#x.\n",
iface, locked_rect, wine_dbgstr_rect(rect), flags);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_surface_map(This->wined3d_surface, (struct wined3d_mapped_rect *)pLockedRect, pRect, Flags); hr = wined3d_surface_map(This->wined3d_surface, &map_desc, rect, flags);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
locked_rect->Pitch = map_desc.row_pitch;
locked_rect->pBits = map_desc.data;
return hr; return hr;
} }
......
...@@ -216,19 +216,23 @@ static HRESULT WINAPI IDirect3DVolume9Impl_GetDesc(IDirect3DVolume9 *iface, D3DV ...@@ -216,19 +216,23 @@ static HRESULT WINAPI IDirect3DVolume9Impl_GetDesc(IDirect3DVolume9 *iface, D3DV
} }
static HRESULT WINAPI IDirect3DVolume9Impl_LockBox(IDirect3DVolume9 *iface, static HRESULT WINAPI IDirect3DVolume9Impl_LockBox(IDirect3DVolume9 *iface,
D3DLOCKED_BOX *pLockedVolume, const D3DBOX *pBox, DWORD Flags) D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags)
{ {
IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface); IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface);
struct wined3d_map_desc map_desc;
HRESULT hr; HRESULT hr;
TRACE("iface %p, locked_box %p, box %p, flags %#x.\n", TRACE("iface %p, locked_box %p, box %p, flags %#x.\n",
iface, pLockedVolume, pBox, Flags); iface, locked_box, box, flags);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_volume_map(This->wined3d_volume, (struct wined3d_mapped_box *)pLockedVolume, hr = wined3d_volume_map(This->wined3d_volume, &map_desc, (const struct wined3d_box *)box, flags);
(const struct wined3d_box *)pBox, Flags);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
locked_box->RowPitch = map_desc.row_pitch;
locked_box->SlicePitch = map_desc.slice_pitch;
locked_box->pBits = map_desc.data;
return hr; return hr;
} }
......
...@@ -938,7 +938,7 @@ static HRESULT WINAPI ddraw_surface1_GetAttachedSurface(IDirectDrawSurface *ifac ...@@ -938,7 +938,7 @@ static HRESULT WINAPI ddraw_surface1_GetAttachedSurface(IDirectDrawSurface *ifac
static HRESULT surface_lock(struct ddraw_surface *This, static HRESULT surface_lock(struct ddraw_surface *This,
RECT *Rect, DDSURFACEDESC2 *DDSD, DWORD Flags, HANDLE h) RECT *Rect, DDSURFACEDESC2 *DDSD, DWORD Flags, HANDLE h)
{ {
struct wined3d_mapped_rect mapped_rect; struct wined3d_map_desc map_desc;
HRESULT hr = DD_OK; HRESULT hr = DD_OK;
TRACE("This %p, rect %s, surface_desc %p, flags %#x, h %p.\n", TRACE("This %p, rect %s, surface_desc %p, flags %#x, h %p.\n",
...@@ -974,7 +974,7 @@ static HRESULT surface_lock(struct ddraw_surface *This, ...@@ -974,7 +974,7 @@ static HRESULT surface_lock(struct ddraw_surface *This,
if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER) if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER)
hr = ddraw_surface_update_frontbuffer(This, Rect, TRUE); hr = ddraw_surface_update_frontbuffer(This, Rect, TRUE);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = wined3d_surface_map(This->wined3d_surface, &mapped_rect, Rect, Flags); hr = wined3d_surface_map(This->wined3d_surface, &map_desc, Rect, Flags);
if (FAILED(hr)) if (FAILED(hr))
{ {
wined3d_mutex_unlock(); wined3d_mutex_unlock();
...@@ -1005,7 +1005,7 @@ static HRESULT surface_lock(struct ddraw_surface *This, ...@@ -1005,7 +1005,7 @@ static HRESULT surface_lock(struct ddraw_surface *This,
* does not set the LPSURFACE flag on locked surfaces !?!. * does not set the LPSURFACE flag on locked surfaces !?!.
* DDSD->dwFlags |= DDSD_LPSURFACE; * DDSD->dwFlags |= DDSD_LPSURFACE;
*/ */
This->surface_desc.lpSurface = mapped_rect.data; This->surface_desc.lpSurface = map_desc.data;
DD_STRUCT_COPY_BYSIZE(DDSD,&(This->surface_desc)); DD_STRUCT_COPY_BYSIZE(DDSD,&(This->surface_desc));
TRACE("locked surface returning description :\n"); TRACE("locked surface returning description :\n");
...@@ -5109,7 +5109,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu ...@@ -5109,7 +5109,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
} }
else else
{ {
struct wined3d_mapped_rect src_rect, dst_rect; struct wined3d_map_desc src_map_desc, dst_map_desc;
/* Copy the src blit color key if the source has one, don't erase /* Copy the src blit color key if the source has one, don't erase
* the destination's ckey if the source has none */ * the destination's ckey if the source has none */
...@@ -5122,7 +5122,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu ...@@ -5122,7 +5122,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
/* Copy the main memory texture into the surface that corresponds /* Copy the main memory texture into the surface that corresponds
* to the OpenGL texture object. */ * to the OpenGL texture object. */
hr = wined3d_surface_map(src_surface->wined3d_surface, &src_rect, NULL, 0); hr = wined3d_surface_map(src_surface->wined3d_surface, &src_map_desc, NULL, 0);
if (FAILED(hr)) if (FAILED(hr))
{ {
ERR("Failed to lock source surface, hr %#x.\n", hr); ERR("Failed to lock source surface, hr %#x.\n", hr);
...@@ -5130,7 +5130,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu ...@@ -5130,7 +5130,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
return D3DERR_TEXTURE_LOAD_FAILED; return D3DERR_TEXTURE_LOAD_FAILED;
} }
hr = wined3d_surface_map(dst_surface->wined3d_surface, &dst_rect, NULL, 0); hr = wined3d_surface_map(dst_surface->wined3d_surface, &dst_map_desc, NULL, 0);
if (FAILED(hr)) if (FAILED(hr))
{ {
ERR("Failed to lock destination surface, hr %#x.\n", hr); ERR("Failed to lock destination surface, hr %#x.\n", hr);
...@@ -5140,9 +5140,9 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu ...@@ -5140,9 +5140,9 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
} }
if (dst_surface->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_FOURCC) if (dst_surface->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_FOURCC)
memcpy(dst_rect.data, src_rect.data, src_surface->surface_desc.u1.dwLinearSize); memcpy(dst_map_desc.data, src_map_desc.data, src_surface->surface_desc.u1.dwLinearSize);
else else
memcpy(dst_rect.data, src_rect.data, src_rect.row_pitch * src_desc->dwHeight); memcpy(dst_map_desc.data, src_map_desc.data, src_map_desc.row_pitch * src_desc->dwHeight);
wined3d_surface_unmap(src_surface->wined3d_surface); wined3d_surface_unmap(src_surface->wined3d_surface);
wined3d_surface_unmap(dst_surface->wined3d_surface); wined3d_surface_unmap(dst_surface->wined3d_surface);
......
...@@ -4223,8 +4223,8 @@ HRESULT CDECL wined3d_device_draw_indexed_primitive_strided(struct wined3d_devic ...@@ -4223,8 +4223,8 @@ HRESULT CDECL wined3d_device_draw_indexed_primitive_strided(struct wined3d_devic
static HRESULT device_update_volume(struct wined3d_device *device, static HRESULT device_update_volume(struct wined3d_device *device,
struct wined3d_volume *src_volume, struct wined3d_volume *dst_volume) struct wined3d_volume *src_volume, struct wined3d_volume *dst_volume)
{ {
struct wined3d_mapped_box src; struct wined3d_map_desc src;
struct wined3d_mapped_box dst; struct wined3d_map_desc dst;
HRESULT hr; HRESULT hr;
TRACE("device %p, src_volume %p, dst_volume %p.\n", TRACE("device %p, src_volume %p, dst_volume %p.\n",
...@@ -4889,8 +4889,6 @@ HRESULT CDECL wined3d_device_set_depth_stencil(struct wined3d_device *device, st ...@@ -4889,8 +4889,6 @@ HRESULT CDECL wined3d_device_set_depth_stencil(struct wined3d_device *device, st
HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device, HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device,
UINT x_hotspot, UINT y_hotspot, struct wined3d_surface *cursor_image) UINT x_hotspot, UINT y_hotspot, struct wined3d_surface *cursor_image)
{ {
struct wined3d_mapped_rect mapped_rect;
TRACE("device %p, x_hotspot %u, y_hotspot %u, cursor_image %p.\n", TRACE("device %p, x_hotspot %u, y_hotspot %u, cursor_image %p.\n",
device, x_hotspot, y_hotspot, cursor_image); device, x_hotspot, y_hotspot, cursor_image);
...@@ -4907,7 +4905,7 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device ...@@ -4907,7 +4905,7 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device
if (cursor_image) if (cursor_image)
{ {
struct wined3d_mapped_rect rect; struct wined3d_map_desc map_desc;
/* MSDN: Cursor must be A8R8G8B8 */ /* MSDN: Cursor must be A8R8G8B8 */
if (cursor_image->resource.format->id != WINED3DFMT_B8G8R8A8_UNORM) if (cursor_image->resource.format->id != WINED3DFMT_B8G8R8A8_UNORM)
...@@ -4935,12 +4933,12 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device ...@@ -4935,12 +4933,12 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device
* instead. */ * instead. */
device->cursorWidth = cursor_image->resource.width; device->cursorWidth = cursor_image->resource.width;
device->cursorHeight = cursor_image->resource.height; device->cursorHeight = cursor_image->resource.height;
if (SUCCEEDED(wined3d_surface_map(cursor_image, &rect, NULL, WINED3DLOCK_READONLY))) if (SUCCEEDED(wined3d_surface_map(cursor_image, &map_desc, NULL, WINED3DLOCK_READONLY)))
{ {
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_format *format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM); const struct wined3d_format *format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM);
struct wined3d_context *context; struct wined3d_context *context;
char *mem, *bits = rect.data; char *mem, *bits = map_desc.data;
GLint intfmt = format->glInternal; GLint intfmt = format->glInternal;
GLint gl_format = format->glFormat; GLint gl_format = format->glFormat;
GLint type = format->glType; GLint type = format->glType;
...@@ -4952,8 +4950,8 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device ...@@ -4952,8 +4950,8 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device
/* Reformat the texture memory (pitch and width can be /* Reformat the texture memory (pitch and width can be
* different) */ * different) */
mem = HeapAlloc(GetProcessHeap(), 0, width * height * bpp); mem = HeapAlloc(GetProcessHeap(), 0, width * height * bpp);
for(i = 0; i < height; i++) for (i = 0; i < height; ++i)
memcpy(&mem[width * bpp * i], &bits[rect.row_pitch * i], width * bpp); memcpy(&mem[width * bpp * i], &bits[map_desc.row_pitch * i], width * bpp);
wined3d_surface_unmap(cursor_image); wined3d_surface_unmap(cursor_image);
context = context_acquire(device, NULL); context = context_acquire(device, NULL);
...@@ -5004,7 +5002,7 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device ...@@ -5004,7 +5002,7 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device
* to ensure we still get a fully transparent cursor. */ * to ensure we still get a fully transparent cursor. */
maskBits = HeapAlloc(GetProcessHeap(), 0, mask_size); maskBits = HeapAlloc(GetProcessHeap(), 0, mask_size);
memset(maskBits, 0xff, mask_size); memset(maskBits, 0xff, mask_size);
wined3d_surface_map(cursor_image, &mapped_rect, NULL, wined3d_surface_map(cursor_image, &map_desc, NULL,
WINED3DLOCK_NO_DIRTY_UPDATE | WINED3DLOCK_READONLY); WINED3DLOCK_NO_DIRTY_UPDATE | WINED3DLOCK_READONLY);
TRACE("width: %u height: %u.\n", cursor_image->resource.width, cursor_image->resource.height); TRACE("width: %u height: %u.\n", cursor_image->resource.width, cursor_image->resource.height);
...@@ -5014,7 +5012,7 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device ...@@ -5014,7 +5012,7 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device
cursorInfo.hbmMask = CreateBitmap(cursor_image->resource.width, cursor_image->resource.height, cursorInfo.hbmMask = CreateBitmap(cursor_image->resource.width, cursor_image->resource.height,
1, 1, maskBits); 1, 1, maskBits);
cursorInfo.hbmColor = CreateBitmap(cursor_image->resource.width, cursor_image->resource.height, cursorInfo.hbmColor = CreateBitmap(cursor_image->resource.width, cursor_image->resource.height,
1, 32, mapped_rect.data); 1, 32, map_desc.data);
wined3d_surface_unmap(cursor_image); wined3d_surface_unmap(cursor_image);
/* Create our cursor and clean up. */ /* Create our cursor and clean up. */
cursor = CreateIconIndirect(&cursorInfo); cursor = CreateIconIndirect(&cursorInfo);
......
...@@ -3571,7 +3571,7 @@ static inline const struct d3dfmt_convertor_desc *find_convertor(enum wined3d_fo ...@@ -3571,7 +3571,7 @@ static inline const struct d3dfmt_convertor_desc *find_convertor(enum wined3d_fo
*****************************************************************************/ *****************************************************************************/
static struct wined3d_surface *surface_convert_format(struct wined3d_surface *source, enum wined3d_format_id to_fmt) static struct wined3d_surface *surface_convert_format(struct wined3d_surface *source, enum wined3d_format_id to_fmt)
{ {
struct wined3d_mapped_rect src_map, dst_map; struct wined3d_map_desc src_map, dst_map;
const struct d3dfmt_convertor_desc *conv; const struct d3dfmt_convertor_desc *conv;
struct wined3d_surface *ret = NULL; struct wined3d_surface *ret = NULL;
HRESULT hr; HRESULT hr;
...@@ -3698,12 +3698,12 @@ HRESULT CDECL wined3d_surface_unmap(struct wined3d_surface *surface) ...@@ -3698,12 +3698,12 @@ HRESULT CDECL wined3d_surface_unmap(struct wined3d_surface *surface)
} }
HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface, HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
struct wined3d_mapped_rect *mapped_rect, const RECT *rect, DWORD flags) struct wined3d_map_desc *map_desc, const RECT *rect, DWORD flags)
{ {
const struct wined3d_format *format = surface->resource.format; const struct wined3d_format *format = surface->resource.format;
TRACE("surface %p, mapped_rect %p, rect %s, flags %#x.\n", TRACE("surface %p, map_desc %p, rect %s, flags %#x.\n",
surface, mapped_rect, wine_dbgstr_rect(rect), flags); surface, map_desc, wine_dbgstr_rect(rect), flags);
if (surface->flags & SFLAG_LOCKED) if (surface->flags & SFLAG_LOCKED)
{ {
...@@ -3750,13 +3750,14 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface, ...@@ -3750,13 +3750,14 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
surface->surface_ops->surface_map(surface, rect, flags); surface->surface_ops->surface_map(surface, rect, flags);
if (format->flags & WINED3DFMT_FLAG_BROKEN_PITCH) if (format->flags & WINED3DFMT_FLAG_BROKEN_PITCH)
mapped_rect->row_pitch = surface->resource.width * format->byte_count; map_desc->row_pitch = surface->resource.width * format->byte_count;
else else
mapped_rect->row_pitch = wined3d_surface_get_pitch(surface); map_desc->row_pitch = wined3d_surface_get_pitch(surface);
map_desc->slice_pitch = 0;
if (!rect) if (!rect)
{ {
mapped_rect->data = surface->resource.allocatedMemory; map_desc->data = surface->resource.allocatedMemory;
surface->lockedRect.left = 0; surface->lockedRect.left = 0;
surface->lockedRect.top = 0; surface->lockedRect.top = 0;
surface->lockedRect.right = surface->resource.width; surface->lockedRect.right = surface->resource.width;
...@@ -3768,14 +3769,14 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface, ...@@ -3768,14 +3769,14 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
{ {
/* Compressed textures are block based, so calculate the offset of /* Compressed textures are block based, so calculate the offset of
* the block that contains the top-left pixel of the locked rectangle. */ * the block that contains the top-left pixel of the locked rectangle. */
mapped_rect->data = surface->resource.allocatedMemory map_desc->data = surface->resource.allocatedMemory
+ ((rect->top / format->block_height) * mapped_rect->row_pitch) + ((rect->top / format->block_height) * map_desc->row_pitch)
+ ((rect->left / format->block_width) * format->block_byte_count); + ((rect->left / format->block_width) * format->block_byte_count);
} }
else else
{ {
mapped_rect->data = surface->resource.allocatedMemory map_desc->data = surface->resource.allocatedMemory
+ (mapped_rect->row_pitch * rect->top) + (map_desc->row_pitch * rect->top)
+ (rect->left * format->byte_count); + (rect->left * format->byte_count);
} }
surface->lockedRect.left = rect->left; surface->lockedRect.left = rect->left;
...@@ -3785,14 +3786,14 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface, ...@@ -3785,14 +3786,14 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
} }
TRACE("Locked rect %s.\n", wine_dbgstr_rect(&surface->lockedRect)); TRACE("Locked rect %s.\n", wine_dbgstr_rect(&surface->lockedRect));
TRACE("Returning memory %p, pitch %u.\n", mapped_rect->data, mapped_rect->row_pitch); TRACE("Returning memory %p, pitch %u.\n", map_desc->data, map_desc->row_pitch);
return WINED3D_OK; return WINED3D_OK;
} }
HRESULT CDECL wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc) HRESULT CDECL wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc)
{ {
struct wined3d_mapped_rect map; struct wined3d_map_desc map;
HRESULT hr; HRESULT hr;
TRACE("surface %p, dc %p.\n", surface, dc); TRACE("surface %p, dc %p.\n", surface, dc);
...@@ -6613,7 +6614,7 @@ static HRESULT surface_cpu_blt(struct wined3d_surface *dst_surface, const RECT * ...@@ -6613,7 +6614,7 @@ static HRESULT surface_cpu_blt(struct wined3d_surface *dst_surface, const RECT *
int bpp, srcheight, srcwidth, dstheight, dstwidth, width; int bpp, srcheight, srcwidth, dstheight, dstwidth, width;
const struct wined3d_format *src_format, *dst_format; const struct wined3d_format *src_format, *dst_format;
struct wined3d_surface *orig_src = src_surface; struct wined3d_surface *orig_src = src_surface;
struct wined3d_mapped_rect dst_map, src_map; struct wined3d_map_desc dst_map, src_map;
const BYTE *sbase = NULL; const BYTE *sbase = NULL;
HRESULT hr = WINED3D_OK; HRESULT hr = WINED3D_OK;
const BYTE *sbuf; const BYTE *sbuf;
......
...@@ -185,23 +185,23 @@ struct wined3d_resource * CDECL wined3d_volume_get_resource(struct wined3d_volum ...@@ -185,23 +185,23 @@ struct wined3d_resource * CDECL wined3d_volume_get_resource(struct wined3d_volum
} }
HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume, HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume,
struct wined3d_mapped_box *mapped_box, const struct wined3d_box *box, DWORD flags) struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags)
{ {
TRACE("volume %p, mapped_box %p, box %p, flags %#x.\n", TRACE("volume %p, map_desc %p, box %p, flags %#x.\n",
volume, mapped_box, box, flags); volume, map_desc, box, flags);
if (!volume->resource.allocatedMemory) if (!volume->resource.allocatedMemory)
volume->resource.allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, volume->resource.size); volume->resource.allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, volume->resource.size);
TRACE("allocatedMemory %p.\n", volume->resource.allocatedMemory); TRACE("allocatedMemory %p.\n", volume->resource.allocatedMemory);
mapped_box->row_pitch = volume->resource.format->byte_count * volume->resource.width; /* Bytes / row */ map_desc->row_pitch = volume->resource.format->byte_count * volume->resource.width; /* Bytes / row */
mapped_box->slice_pitch = volume->resource.format->byte_count map_desc->slice_pitch = volume->resource.format->byte_count
* volume->resource.width * volume->resource.height; /* Bytes / slice */ * volume->resource.width * volume->resource.height; /* Bytes / slice */
if (!box) if (!box)
{ {
TRACE("No box supplied - all is ok\n"); TRACE("No box supplied - all is ok\n");
mapped_box->data = volume->resource.allocatedMemory; map_desc->data = volume->resource.allocatedMemory;
volume->lockedBox.left = 0; volume->lockedBox.left = 0;
volume->lockedBox.top = 0; volume->lockedBox.top = 0;
volume->lockedBox.front = 0; volume->lockedBox.front = 0;
...@@ -213,9 +213,9 @@ HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume, ...@@ -213,9 +213,9 @@ HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume,
{ {
TRACE("Lock Box (%p) = l %u, t %u, r %u, b %u, fr %u, ba %u\n", TRACE("Lock Box (%p) = l %u, t %u, r %u, b %u, fr %u, ba %u\n",
box, box->left, box->top, box->right, box->bottom, box->front, box->back); box, box->left, box->top, box->right, box->bottom, box->front, box->back);
mapped_box->data = volume->resource.allocatedMemory map_desc->data = volume->resource.allocatedMemory
+ (mapped_box->slice_pitch * box->front) /* FIXME: is front < back or vica versa? */ + (map_desc->slice_pitch * box->front) /* FIXME: is front < back or vica versa? */
+ (mapped_box->row_pitch * box->top) + (map_desc->row_pitch * box->top)
+ (box->left * volume->resource.format->byte_count); + (box->left * volume->resource.format->byte_count);
volume->lockedBox.left = box->left; volume->lockedBox.left = box->left;
volume->lockedBox.top = box->top; volume->lockedBox.top = box->top;
...@@ -234,7 +234,7 @@ HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume, ...@@ -234,7 +234,7 @@ HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume,
volume->locked = TRUE; volume->locked = TRUE;
TRACE("Returning memory %p, row pitch %d, slice pitch %d.\n", TRACE("Returning memory %p, row pitch %d, slice pitch %d.\n",
mapped_box->data, mapped_box->row_pitch, mapped_box->slice_pitch); map_desc->data, map_desc->row_pitch, map_desc->slice_pitch);
return WINED3D_OK; return WINED3D_OK;
} }
......
...@@ -1671,13 +1671,7 @@ struct wined3d_raster_status ...@@ -1671,13 +1671,7 @@ struct wined3d_raster_status
UINT scan_line; UINT scan_line;
}; };
struct wined3d_mapped_rect struct wined3d_map_desc
{
UINT row_pitch;
void *data;
};
struct wined3d_mapped_box
{ {
UINT row_pitch; UINT row_pitch;
UINT slice_pitch; UINT slice_pitch;
...@@ -2319,7 +2313,7 @@ HRESULT __cdecl wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc); ...@@ -2319,7 +2313,7 @@ HRESULT __cdecl wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc);
ULONG __cdecl wined3d_surface_incref(struct wined3d_surface *surface); ULONG __cdecl wined3d_surface_incref(struct wined3d_surface *surface);
HRESULT __cdecl wined3d_surface_is_lost(const struct wined3d_surface *surface); HRESULT __cdecl wined3d_surface_is_lost(const struct wined3d_surface *surface);
HRESULT __cdecl wined3d_surface_map(struct wined3d_surface *surface, HRESULT __cdecl wined3d_surface_map(struct wined3d_surface *surface,
struct wined3d_mapped_rect *mapped_rect, const RECT *rect, DWORD flags); struct wined3d_map_desc *map_desc, const RECT *rect, DWORD flags);
void __cdecl wined3d_surface_preload(struct wined3d_surface *surface); void __cdecl wined3d_surface_preload(struct wined3d_surface *surface);
HRESULT __cdecl wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc); HRESULT __cdecl wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc);
HRESULT __cdecl wined3d_surface_restore(struct wined3d_surface *surface); HRESULT __cdecl wined3d_surface_restore(struct wined3d_surface *surface);
...@@ -2412,7 +2406,7 @@ DWORD __cdecl wined3d_volume_get_priority(const struct wined3d_volume *volume); ...@@ -2412,7 +2406,7 @@ DWORD __cdecl wined3d_volume_get_priority(const struct wined3d_volume *volume);
struct wined3d_resource * __cdecl wined3d_volume_get_resource(struct wined3d_volume *volume); struct wined3d_resource * __cdecl wined3d_volume_get_resource(struct wined3d_volume *volume);
ULONG __cdecl wined3d_volume_incref(struct wined3d_volume *volume); ULONG __cdecl wined3d_volume_incref(struct wined3d_volume *volume);
HRESULT __cdecl wined3d_volume_map(struct wined3d_volume *volume, HRESULT __cdecl wined3d_volume_map(struct wined3d_volume *volume,
struct wined3d_mapped_box *mapped_box, const struct wined3d_box *box, DWORD flags); struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags);
void __cdecl wined3d_volume_preload(struct wined3d_volume *volume); void __cdecl wined3d_volume_preload(struct wined3d_volume *volume);
DWORD __cdecl wined3d_volume_set_priority(struct wined3d_volume *volume, DWORD new_priority); DWORD __cdecl wined3d_volume_set_priority(struct wined3d_volume *volume, DWORD new_priority);
HRESULT __cdecl wined3d_volume_unmap(struct wined3d_volume *volume); HRESULT __cdecl wined3d_volume_unmap(struct wined3d_volume *volume);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment