wined3d: Remove COM from the volume implementation.

oldstable
Henri Verbeet 2011-04-14 22:41:47 +02:00 committed by Alexandre Julliard
parent 44c52c16fd
commit 2c450571e5
15 changed files with 171 additions and 219 deletions

View File

@ -1446,7 +1446,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateDepthStencilSurface(IWineD3
static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent *iface,
void *container_parent, UINT width, UINT height, UINT depth, enum wined3d_format_id format,
WINED3DPOOL pool, DWORD usage, IWineD3DVolume **volume)
WINED3DPOOL pool, DWORD usage, struct wined3d_volume **volume)
{
HRESULT hr;

View File

@ -363,7 +363,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_Map(ID3D10Texture3D *iface, UIN
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx)))
hr = E_INVALIDARG;
else if (SUCCEEDED(hr = IWineD3DVolume_Map(wined3d_volume_from_resource(sub_resource),
else if (SUCCEEDED(hr = wined3d_volume_map(wined3d_volume_from_resource(sub_resource),
&wined3d_map_desc, NULL, 0)))
{
mapped_texture->pData = wined3d_map_desc.pBits;
@ -384,7 +384,7 @@ static void STDMETHODCALLTYPE d3d10_texture3d_Unmap(ID3D10Texture3D *iface, UINT
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx)))
return;
IWineD3DVolume_Unmap(wined3d_volume_from_resource(sub_resource));
wined3d_volume_unmap(wined3d_volume_from_resource(sub_resource));
}
static void STDMETHODCALLTYPE d3d10_texture3d_GetDesc(ID3D10Texture3D *iface, D3D10_TEXTURE3D_DESC *desc)

View File

@ -203,15 +203,9 @@ struct IDirect3DVolume8Impl
{
IDirect3DVolume8 IDirect3DVolume8_iface;
LONG ref;
/* IDirect3DVolume8 fields */
IWineD3DVolume *wineD3DVolume;
/* The volume container */
IUnknown *container;
/* If set forward refcounting to this object */
IUnknown *forwardReference;
struct wined3d_volume *wined3d_volume;
IUnknown *container;
IUnknown *forwardReference;
};
HRESULT volume_init(IDirect3DVolume8Impl *volume, IDirect3DDevice8Impl *device, UINT width, UINT height,

View File

@ -2861,7 +2861,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateDepthStencilSurface(IWineD3
static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent *iface,
void *container_parent, UINT width, UINT height, UINT depth, enum wined3d_format_id format,
WINED3DPOOL pool, DWORD usage, IWineD3DVolume **volume)
WINED3DPOOL pool, DWORD usage, struct wined3d_volume **volume)
{
IDirect3DDevice8Impl *This = impl_from_IWineD3DDeviceParent(iface);
IDirect3DVolume8Impl *object;
@ -2887,8 +2887,8 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent
return hr;
}
*volume = object->wineD3DVolume;
IWineD3DVolume_AddRef(*volume);
*volume = object->wined3d_volume;
wined3d_volume_incref(*volume);
IDirect3DVolume8_Release(&object->IDirect3DVolume8_iface);
object->container = container_parent;

View File

@ -66,7 +66,7 @@ static ULONG WINAPI IDirect3DVolume8Impl_AddRef(IDirect3DVolume8 *iface)
if (ref == 1)
{
wined3d_mutex_lock();
IWineD3DVolume_AddRef(This->wineD3DVolume);
wined3d_volume_incref(This->wined3d_volume);
wined3d_mutex_unlock();
}
@ -93,7 +93,7 @@ static ULONG WINAPI IDirect3DVolume8Impl_Release(IDirect3DVolume8 *iface)
if (ref == 0) {
wined3d_mutex_lock();
IWineD3DVolume_Release(This->wineD3DVolume);
wined3d_volume_decref(This->wined3d_volume);
wined3d_mutex_unlock();
}
@ -132,7 +132,7 @@ static HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(IDirect3DVolume8 *ifac
iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
wined3d_mutex_lock();
hr = IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
hr = wined3d_volume_set_private_data(This->wined3d_volume, refguid, pData, SizeOfData, Flags);
wined3d_mutex_unlock();
return hr;
@ -148,7 +148,7 @@ static HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(IDirect3DVolume8 *ifac
iface, debugstr_guid(refguid), pData, pSizeOfData);
wined3d_mutex_lock();
hr = IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
hr = wined3d_volume_get_private_data(This->wined3d_volume, refguid, pData, pSizeOfData);
wined3d_mutex_unlock();
return hr;
@ -162,7 +162,7 @@ static HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(IDirect3DVolume8 *ifa
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
wined3d_mutex_lock();
hr = IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
hr = wined3d_volume_free_private_data(This->wined3d_volume, refguid);
wined3d_mutex_unlock();
return hr;
@ -195,7 +195,7 @@ static HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(IDirect3DVolume8 *iface, D3DV
TRACE("iface %p, desc %p.\n", iface, desc);
wined3d_mutex_lock();
wined3d_resource = IWineD3DVolume_GetResource(This->wineD3DVolume);
wined3d_resource = wined3d_volume_get_resource(This->wined3d_volume);
wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
wined3d_mutex_unlock();
@ -221,7 +221,7 @@ static HRESULT WINAPI IDirect3DVolume8Impl_LockBox(IDirect3DVolume8 *iface,
iface, pLockedVolume, pBox, Flags);
wined3d_mutex_lock();
hr = IWineD3DVolume_Map(This->wineD3DVolume, (WINED3DLOCKED_BOX *)pLockedVolume,
hr = wined3d_volume_map(This->wined3d_volume, (WINED3DLOCKED_BOX *)pLockedVolume,
(const WINED3DBOX *)pBox, Flags);
wined3d_mutex_unlock();
@ -236,7 +236,7 @@ static HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(IDirect3DVolume8 *iface)
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
hr = IWineD3DVolume_Unmap(This->wineD3DVolume);
hr = wined3d_volume_unmap(This->wined3d_volume);
wined3d_mutex_unlock();
return hr;
@ -278,7 +278,7 @@ HRESULT volume_init(IDirect3DVolume8Impl *volume, IDirect3DDevice8Impl *device,
volume->ref = 1;
hr = IWineD3DDevice_CreateVolume(device->WineD3DDevice, width, height, depth, usage,
format, pool, volume, &d3d8_volume_wined3d_parent_ops, &volume->wineD3DVolume);
format, pool, volume, &d3d8_volume_wined3d_parent_ops, &volume->wined3d_volume);
if (FAILED(hr))
{
WARN("Failed to create wined3d volume, hr %#x.\n", hr);

View File

@ -190,15 +190,9 @@ typedef struct IDirect3DVolume9Impl
/* IUnknown fields */
const IDirect3DVolume9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DVolume9 fields */
IWineD3DVolume *wineD3DVolume;
/* The volume container */
IUnknown *container;
/* If set forward refcounting to this object */
IUnknown *forwardReference;
struct wined3d_volume *wined3d_volume;
IUnknown *container;
IUnknown *forwardReference;
} IDirect3DVolume9Impl;
HRESULT volume_init(IDirect3DVolume9Impl *volume, IDirect3DDevice9Impl *device, UINT width, UINT height,

View File

@ -3120,7 +3120,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateDepthStencilSurface(IWineD3
static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent *iface,
void *container_parent, UINT width, UINT height, UINT depth, enum wined3d_format_id format,
WINED3DPOOL pool, DWORD usage, IWineD3DVolume **volume)
WINED3DPOOL pool, DWORD usage, struct wined3d_volume **volume)
{
struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
IDirect3DVolume9Impl *object;
@ -3146,8 +3146,8 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent
return hr;
}
*volume = object->wineD3DVolume;
IWineD3DVolume_AddRef(*volume);
*volume = object->wined3d_volume;
wined3d_volume_incref(*volume);
IDirect3DVolume9_Release((IDirect3DVolume9 *)object);
object->container = container_parent;

View File

@ -60,7 +60,7 @@ static ULONG WINAPI IDirect3DVolume9Impl_AddRef(LPDIRECT3DVOLUME9 iface) {
if (ref == 1)
{
wined3d_mutex_lock();
IWineD3DVolume_AddRef(This->wineD3DVolume);
wined3d_volume_incref(This->wined3d_volume);
wined3d_mutex_unlock();
}
@ -85,7 +85,7 @@ static ULONG WINAPI IDirect3DVolume9Impl_Release(LPDIRECT3DVOLUME9 iface) {
if (ref == 0) {
wined3d_mutex_lock();
IWineD3DVolume_Release(This->wineD3DVolume);
wined3d_volume_decref(This->wined3d_volume);
wined3d_mutex_unlock();
}
@ -122,9 +122,7 @@ static HRESULT WINAPI IDirect3DVolume9Impl_SetPrivateData(LPDIRECT3DVOLUME9 ifac
iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
wined3d_mutex_lock();
hr = IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
hr = wined3d_volume_set_private_data(This->wined3d_volume, refguid, pData, SizeOfData, Flags);
wined3d_mutex_unlock();
return hr;
@ -138,9 +136,7 @@ static HRESULT WINAPI IDirect3DVolume9Impl_GetPrivateData(LPDIRECT3DVOLUME9 ifac
iface, debugstr_guid(refguid), pData, pSizeOfData);
wined3d_mutex_lock();
hr = IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
hr = wined3d_volume_get_private_data(This->wined3d_volume, refguid, pData, pSizeOfData);
wined3d_mutex_unlock();
return hr;
@ -153,9 +149,7 @@ static HRESULT WINAPI IDirect3DVolume9Impl_FreePrivateData(LPDIRECT3DVOLUME9 ifa
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
wined3d_mutex_lock();
hr = IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
hr = wined3d_volume_free_private_data(This->wined3d_volume, refguid);
wined3d_mutex_unlock();
return hr;
@ -185,7 +179,7 @@ static HRESULT WINAPI IDirect3DVolume9Impl_GetDesc(IDirect3DVolume9 *iface, D3DV
TRACE("iface %p, desc %p.\n", iface, desc);
wined3d_mutex_lock();
wined3d_resource = IWineD3DVolume_GetResource(This->wineD3DVolume);
wined3d_resource = wined3d_volume_get_resource(This->wined3d_volume);
wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
wined3d_mutex_unlock();
@ -208,10 +202,8 @@ static HRESULT WINAPI IDirect3DVolume9Impl_LockBox(LPDIRECT3DVOLUME9 iface, D3DL
iface, pLockedVolume, pBox, Flags);
wined3d_mutex_lock();
hr = IWineD3DVolume_Map(This->wineD3DVolume, (WINED3DLOCKED_BOX *)pLockedVolume,
hr = wined3d_volume_map(This->wined3d_volume, (WINED3DLOCKED_BOX *)pLockedVolume,
(const WINED3DBOX *)pBox, Flags);
wined3d_mutex_unlock();
return hr;
@ -224,9 +216,7 @@ static HRESULT WINAPI IDirect3DVolume9Impl_UnlockBox(LPDIRECT3DVOLUME9 iface) {
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
hr = IWineD3DVolume_Unmap(This->wineD3DVolume);
hr = wined3d_volume_unmap(This->wined3d_volume);
wined3d_mutex_unlock();
return hr;
@ -268,7 +258,7 @@ HRESULT volume_init(IDirect3DVolume9Impl *volume, IDirect3DDevice9Impl *device,
volume->ref = 1;
hr = IWineD3DDevice_CreateVolume(device->WineD3DDevice, width, height, depth, usage & WINED3DUSAGE_MASK,
format, pool, volume, &d3d9_volume_wined3d_parent_ops, &volume->wineD3DVolume);
format, pool, volume, &d3d9_volume_wined3d_parent_ops, &volume->wined3d_volume);
if (FAILED(hr))
{
WARN("Failed to create wined3d volume, hr %#x.\n", hr);

View File

@ -5877,7 +5877,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateDepthStencilSurface(IWineD3
static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent *iface,
void *container_parent, UINT width, UINT height, UINT depth, enum wined3d_format_id format,
WINED3DPOOL pool, DWORD usage, IWineD3DVolume **volume)
WINED3DPOOL pool, DWORD usage, struct wined3d_volume **volume)
{
TRACE("iface %p, container_parent %p, width %u, height %u, depth %u, format %#x, pool %#x, usage %#x, volume %p\n",
iface, container_parent, width, height, depth, format, pool, usage, volume);

View File

@ -5100,22 +5100,22 @@ static HRESULT IWineD3DDeviceImpl_UpdateVolume(IWineD3DDevice *iface,
/* TODO: Implement direct loading into the gl volume instead of using memcpy and
* dirtification to improve loading performance.
*/
hr = IWineD3DVolume_Map(pSourceVolume, &src, NULL, WINED3DLOCK_READONLY);
hr = wined3d_volume_map(pSourceVolume, &src, NULL, WINED3DLOCK_READONLY);
if (FAILED(hr)) return hr;
hr = IWineD3DVolume_Map(pDestinationVolume, &dst, NULL, WINED3DLOCK_DISCARD);
hr = wined3d_volume_map(pDestinationVolume, &dst, NULL, WINED3DLOCK_DISCARD);
if (FAILED(hr))
{
IWineD3DVolume_Unmap(pSourceVolume);
wined3d_volume_unmap(pSourceVolume);
return hr;
}
memcpy(dst.pBits, src.pBits, ((IWineD3DVolumeImpl *) pDestinationVolume)->resource.size);
hr = IWineD3DVolume_Unmap(pDestinationVolume);
hr = wined3d_volume_unmap(pDestinationVolume);
if (FAILED(hr))
IWineD3DVolume_Unmap(pSourceVolume);
wined3d_volume_unmap(pSourceVolume);
else
hr = IWineD3DVolume_Unmap(pSourceVolume);
hr = wined3d_volume_unmap(pSourceVolume);
return hr;
}

View File

@ -1186,7 +1186,7 @@ static void texture3d_sub_resource_cleanup(struct wined3d_resource *sub_resource
/* Cleanup the container. */
volume_set_container(volume, NULL);
IWineD3DVolume_Release((IWineD3DVolume *)volume);
wined3d_volume_decref(volume);
}
/* Do not call while under the GL lock. */

View File

@ -4,7 +4,7 @@
* Copyright 2002-2005 Jason Edmeades
* Copyright 2002-2005 Raphael Junqueira
* Copyright 2005 Oliver Stieber
* Copyright 2009-2010 Henri Verbeet for CodeWeavers
* Copyright 2009-2011 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -27,7 +27,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
/* Context activation is done by the caller. */
static void volume_bind_and_dirtify(struct IWineD3DVolumeImpl *volume, const struct wined3d_gl_info *gl_info)
static void volume_bind_and_dirtify(struct wined3d_volume *volume, const struct wined3d_gl_info *gl_info)
{
struct wined3d_texture *container = volume->container;
DWORD active_sampler;
@ -62,7 +62,7 @@ static void volume_bind_and_dirtify(struct IWineD3DVolumeImpl *volume, const str
container->texture_ops->texture_bind(container, gl_info, FALSE);
}
void volume_add_dirty_box(struct IWineD3DVolumeImpl *volume, const WINED3DBOX *dirty_box)
void volume_add_dirty_box(struct wined3d_volume *volume, const WINED3DBOX *dirty_box)
{
volume->dirty = TRUE;
if (dirty_box)
@ -128,195 +128,160 @@ static void volume_unload(struct wined3d_resource *resource)
resource_unload(resource);
}
/* *******************************************
IWineD3DVolume IUnknown parts follow
******************************************* */
static HRESULT WINAPI IWineD3DVolumeImpl_QueryInterface(IWineD3DVolume *iface, REFIID riid, void **object)
ULONG CDECL wined3d_volume_incref(struct wined3d_volume *volume)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
ULONG refcount = InterlockedIncrement(&volume->resource.ref);
if (IsEqualGUID(riid, &IID_IWineD3DVolume)
|| IsEqualGUID(riid, &IID_IWineD3DResource)
|| IsEqualGUID(riid, &IID_IWineD3DBase)
|| IsEqualGUID(riid, &IID_IUnknown))
{
IUnknown_AddRef(iface);
*object = iface;
return S_OK;
}
TRACE("%p increasing refcount to %u.\n", volume, refcount);
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
*object = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IWineD3DVolumeImpl_AddRef(IWineD3DVolume *iface) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
TRACE("(%p) : AddRef increasing from %d\n", This, This->resource.ref);
return InterlockedIncrement(&This->resource.ref);
return refcount;
}
/* Do not call while under the GL lock. */
static ULONG WINAPI IWineD3DVolumeImpl_Release(IWineD3DVolume *iface) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
ULONG ref;
TRACE("(%p) : Releasing from %d\n", This, This->resource.ref);
ref = InterlockedDecrement(&This->resource.ref);
ULONG CDECL wined3d_volume_decref(struct wined3d_volume *volume)
{
ULONG refcount = InterlockedDecrement(&volume->resource.ref);
if (!ref)
TRACE("%p decreasing refcount to %u.\n", volume, refcount);
if (!refcount)
{
resource_cleanup(&This->resource);
This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
HeapFree(GetProcessHeap(), 0, This);
resource_cleanup(&volume->resource);
volume->resource.parent_ops->wined3d_object_destroyed(volume->resource.parent);
HeapFree(GetProcessHeap(), 0, volume);
}
return ref;
return refcount;
}
/* ****************************************************
IWineD3DVolume IWineD3DResource parts follow
**************************************************** */
static void * WINAPI IWineD3DVolumeImpl_GetParent(IWineD3DVolume *iface)
void * CDECL wined3d_volume_get_parent(const struct wined3d_volume *volume)
{
TRACE("iface %p.\n", iface);
TRACE("volume %p.\n", volume);
return ((IWineD3DVolumeImpl *)iface)->resource.parent;
return volume->resource.parent;
}
static HRESULT WINAPI IWineD3DVolumeImpl_SetPrivateData(IWineD3DVolume *iface,
REFGUID riid, const void *data, DWORD data_size, DWORD flags)
HRESULT CDECL wined3d_volume_set_private_data(struct wined3d_volume *volume,
REFGUID guid, const void *data, DWORD data_size, DWORD flags)
{
return resource_set_private_data(&((IWineD3DVolumeImpl *)iface)->resource, riid, data, data_size, flags);
return resource_set_private_data(&volume->resource, guid, data, data_size, flags);
}
static HRESULT WINAPI IWineD3DVolumeImpl_GetPrivateData(IWineD3DVolume *iface,
HRESULT CDECL wined3d_volume_get_private_data(const struct wined3d_volume *volume,
REFGUID guid, void *data, DWORD *data_size)
{
return resource_get_private_data(&((IWineD3DVolumeImpl *)iface)->resource, guid, data, data_size);
return resource_get_private_data(&volume->resource, guid, data, data_size);
}
static HRESULT WINAPI IWineD3DVolumeImpl_FreePrivateData(IWineD3DVolume *iface, REFGUID refguid)
HRESULT CDECL wined3d_volume_free_private_data(struct wined3d_volume *volume, REFGUID guid)
{
return resource_free_private_data(&((IWineD3DVolumeImpl *)iface)->resource, refguid);
return resource_free_private_data(&volume->resource, guid);
}
static DWORD WINAPI IWineD3DVolumeImpl_SetPriority(IWineD3DVolume *iface, DWORD priority)
DWORD CDECL wined3d_volume_set_priority(struct wined3d_volume *volume, DWORD priority)
{
return resource_set_priority(&((IWineD3DVolumeImpl *)iface)->resource, priority);
return resource_set_priority(&volume->resource, priority);
}
static DWORD WINAPI IWineD3DVolumeImpl_GetPriority(IWineD3DVolume *iface)
DWORD CDECL wined3d_volume_get_priority(const struct wined3d_volume *volume)
{
return resource_get_priority(&((IWineD3DVolumeImpl *)iface)->resource);
return resource_get_priority(&volume->resource);
}
/* Do not call while under the GL lock. */
static void WINAPI IWineD3DVolumeImpl_PreLoad(IWineD3DVolume *iface) {
FIXME("iface %p stub!\n", iface);
void CDECL wined3d_volume_preload(struct wined3d_volume *volume)
{
FIXME("volume %p stub!\n", volume);
}
static WINED3DRESOURCETYPE WINAPI IWineD3DVolumeImpl_GetType(IWineD3DVolume *iface)
WINED3DRESOURCETYPE CDECL wined3d_volume_get_type(const struct wined3d_volume *volume)
{
return resource_get_type(&((IWineD3DVolumeImpl *)iface)->resource);
return resource_get_type(&volume->resource);
}
static struct wined3d_resource * WINAPI IWineD3DVolumeImpl_GetResource(IWineD3DVolume *iface)
struct wined3d_resource * CDECL wined3d_volume_get_resource(struct wined3d_volume *volume)
{
TRACE("iface %p.\n", iface);
TRACE("volume %p.\n", volume);
return &((IWineD3DVolumeImpl *)iface)->resource;
return &volume->resource;
}
static HRESULT WINAPI IWineD3DVolumeImpl_Map(IWineD3DVolume *iface,
WINED3DLOCKED_BOX *pLockedVolume, const WINED3DBOX *pBox, DWORD flags)
HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume,
WINED3DLOCKED_BOX *locked_box, const WINED3DBOX *box, DWORD flags)
{
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
FIXME("(%p) : pBox=%p stub\n", This, pBox);
TRACE("volume %p, locked_box %p, box %p, flags %#x.\n",
volume, locked_box, box, flags);
if(!This->resource.allocatedMemory) {
This->resource.allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->resource.size);
}
if (!volume->resource.allocatedMemory)
volume->resource.allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, volume->resource.size);
/* fixme: should we really lock as such? */
TRACE("(%p) : box=%p, output pbox=%p, allMem=%p\n", This, pBox, pLockedVolume, This->resource.allocatedMemory);
TRACE("allocatedMemory %p.\n", volume->resource.allocatedMemory);
pLockedVolume->RowPitch = This->resource.format->byte_count * This->resource.width; /* Bytes / row */
pLockedVolume->SlicePitch = This->resource.format->byte_count
* This->resource.width * This->resource.height; /* Bytes / slice */
if (!pBox) {
locked_box->RowPitch = volume->resource.format->byte_count * volume->resource.width; /* Bytes / row */
locked_box->SlicePitch = volume->resource.format->byte_count
* volume->resource.width * volume->resource.height; /* Bytes / slice */
if (!box)
{
TRACE("No box supplied - all is ok\n");
pLockedVolume->pBits = This->resource.allocatedMemory;
This->lockedBox.Left = 0;
This->lockedBox.Top = 0;
This->lockedBox.Front = 0;
This->lockedBox.Right = This->resource.width;
This->lockedBox.Bottom = This->resource.height;
This->lockedBox.Back = This->resource.depth;
} else {
TRACE("Lock Box (%p) = l %d, t %d, r %d, b %d, fr %d, ba %d\n", pBox, pBox->Left, pBox->Top, pBox->Right, pBox->Bottom, pBox->Front, pBox->Back);
pLockedVolume->pBits = This->resource.allocatedMemory
+ (pLockedVolume->SlicePitch * pBox->Front) /* FIXME: is front < back or vica versa? */
+ (pLockedVolume->RowPitch * pBox->Top)
+ (pBox->Left * This->resource.format->byte_count);
This->lockedBox.Left = pBox->Left;
This->lockedBox.Top = pBox->Top;
This->lockedBox.Front = pBox->Front;
This->lockedBox.Right = pBox->Right;
This->lockedBox.Bottom = pBox->Bottom;
This->lockedBox.Back = pBox->Back;
locked_box->pBits = volume->resource.allocatedMemory;
volume->lockedBox.Left = 0;
volume->lockedBox.Top = 0;
volume->lockedBox.Front = 0;
volume->lockedBox.Right = volume->resource.width;
volume->lockedBox.Bottom = volume->resource.height;
volume->lockedBox.Back = volume->resource.depth;
}
else
{
TRACE("Lock Box (%p) = l %d, t %d, r %d, b %d, fr %d, ba %d\n",
box, box->Left, box->Top, box->Right, box->Bottom, box->Front, box->Back);
locked_box->pBits = volume->resource.allocatedMemory
+ (locked_box->SlicePitch * box->Front) /* FIXME: is front < back or vica versa? */
+ (locked_box->RowPitch * box->Top)
+ (box->Left * volume->resource.format->byte_count);
volume->lockedBox.Left = box->Left;
volume->lockedBox.Top = box->Top;
volume->lockedBox.Front = box->Front;
volume->lockedBox.Right = box->Right;
volume->lockedBox.Bottom = box->Bottom;
volume->lockedBox.Back = box->Back;
}
if (!(flags & (WINED3DLOCK_NO_DIRTY_UPDATE | WINED3DLOCK_READONLY)))
{
volume_add_dirty_box(This, &This->lockedBox);
wined3d_texture_set_dirty(This->container, TRUE);
volume_add_dirty_box(volume, &volume->lockedBox);
wined3d_texture_set_dirty(volume->container, TRUE);
}
This->locked = TRUE;
TRACE("returning memory@%p rpitch(%d) spitch(%d)\n", pLockedVolume->pBits, pLockedVolume->RowPitch, pLockedVolume->SlicePitch);
volume->locked = TRUE;
TRACE("Returning memory %p, row pitch %d, slice pitch %d.\n",
locked_box->pBits, locked_box->RowPitch, locked_box->SlicePitch);
return WINED3D_OK;
}
IWineD3DVolume * CDECL wined3d_volume_from_resource(struct wined3d_resource *resource)
struct wined3d_volume * CDECL wined3d_volume_from_resource(struct wined3d_resource *resource)
{
return (IWineD3DVolume *)volume_from_resource(resource);
return volume_from_resource(resource);
}
static HRESULT WINAPI IWineD3DVolumeImpl_Unmap(IWineD3DVolume *iface)
HRESULT CDECL wined3d_volume_unmap(struct wined3d_volume *volume)
{
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
if (!This->locked)
TRACE("volume %p.\n", volume);
if (!volume->locked)
{
WARN("Trying to unlock unlocked volume %p.\n", iface);
WARN("Trying to unlock unlocked volume %p.\n", volume);
return WINED3DERR_INVALIDCALL;
}
TRACE("(%p) : unlocking volume\n", This);
This->locked = FALSE;
memset(&This->lockedBox, 0, sizeof(This->lockedBox));
volume->locked = FALSE;
memset(&volume->lockedBox, 0, sizeof(volume->lockedBox));
return WINED3D_OK;
}
static const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl =
{
/* IUnknown */
IWineD3DVolumeImpl_QueryInterface,
IWineD3DVolumeImpl_AddRef,
IWineD3DVolumeImpl_Release,
/* IWineD3DResource */
IWineD3DVolumeImpl_GetParent,
IWineD3DVolumeImpl_SetPrivateData,
IWineD3DVolumeImpl_GetPrivateData,
IWineD3DVolumeImpl_FreePrivateData,
IWineD3DVolumeImpl_SetPriority,
IWineD3DVolumeImpl_GetPriority,
IWineD3DVolumeImpl_PreLoad,
IWineD3DVolumeImpl_GetType,
/* IWineD3DVolume */
IWineD3DVolumeImpl_GetResource,
IWineD3DVolumeImpl_Map,
IWineD3DVolumeImpl_Unmap,
};
static const struct wined3d_resource_ops volume_resource_ops =
{
volume_unload,
@ -336,8 +301,6 @@ HRESULT volume_init(IWineD3DVolumeImpl *volume, IWineD3DDeviceImpl *device, UINT
return WINED3DERR_INVALIDCALL;
}
volume->lpVtbl = &IWineD3DVolume_Vtbl;
hr = resource_init(&volume->resource, device, WINED3DRTYPE_VOLUME, format,
WINED3DMULTISAMPLE_NONE, 0, usage, pool, width, height, depth,
width * height * depth * format->byte_count, parent, parent_ops,

View File

@ -114,4 +114,17 @@
@ cdecl wined3d_vertex_declaration_get_parent(ptr)
@ cdecl wined3d_vertex_declaration_incref(ptr)
@ cdecl wined3d_volume_decref(ptr)
@ cdecl wined3d_volume_free_private_data(ptr ptr)
@ cdecl wined3d_volume_from_resource(ptr)
@ cdecl wined3d_volume_get_parent(ptr)
@ cdecl wined3d_volume_get_priority(ptr)
@ cdecl wined3d_volume_get_private_data(ptr ptr ptr ptr)
@ cdecl wined3d_volume_get_resource(ptr)
@ cdecl wined3d_volume_get_type(ptr)
@ cdecl wined3d_volume_incref(ptr)
@ cdecl wined3d_volume_map(ptr ptr ptr long)
@ cdecl wined3d_volume_preload(ptr)
@ cdecl wined3d_volume_set_priority(ptr long)
@ cdecl wined3d_volume_set_private_data(ptr ptr ptr long long)
@ cdecl wined3d_volume_unmap(ptr)

View File

@ -54,6 +54,8 @@
typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl;
typedef struct IWineD3DDeviceImpl IWineD3DDeviceImpl;
typedef struct wined3d_volume IWineD3DVolumeImpl;
typedef struct wined3d_volume IWineD3DVolume;
/* Texture format fixups */
@ -1942,10 +1944,8 @@ HRESULT volumetexture_init(struct wined3d_texture *texture, UINT width, UINT hei
UINT depth, UINT levels, IWineD3DDeviceImpl *device, DWORD usage, enum wined3d_format_id format_id,
WINED3DPOOL pool, void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
typedef struct IWineD3DVolumeImpl
struct wined3d_volume
{
/* IUnknown & WineD3DResource fields */
const IWineD3DVolumeVtbl *lpVtbl;
struct wined3d_resource resource;
struct wined3d_texture *container;
BOOL lockable;
@ -1953,14 +1953,14 @@ typedef struct IWineD3DVolumeImpl
WINED3DBOX lockedBox;
WINED3DBOX dirtyBox;
BOOL dirty;
} IWineD3DVolumeImpl;
};
static inline IWineD3DVolumeImpl *volume_from_resource(struct wined3d_resource *resource)
{
return CONTAINING_RECORD(resource, IWineD3DVolumeImpl, resource);
}
void volume_add_dirty_box(struct IWineD3DVolumeImpl *volume, const WINED3DBOX *dirty_box) DECLSPEC_HIDDEN;
void volume_add_dirty_box(struct wined3d_volume *volume, const WINED3DBOX *dirty_box) DECLSPEC_HIDDEN;
HRESULT volume_init(IWineD3DVolumeImpl *volume, IWineD3DDeviceImpl *device, UINT width,
UINT height, UINT depth, DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool,
void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;

View File

@ -2087,7 +2087,6 @@ struct wined3d_parent_ops
};
interface IWineD3DSurface;
interface IWineD3DVolume;
interface IWineD3DDevice;
struct wined3d;
struct wined3d_buffer;
@ -2101,6 +2100,7 @@ struct wined3d_stateblock;
struct wined3d_swapchain;
struct wined3d_texture;
struct wined3d_vertex_declaration;
struct wined3d_volume;
[
object,
@ -2154,7 +2154,7 @@ interface IWineD3DDeviceParent : IUnknown
[in] enum wined3d_format_id format_id,
[in] WINED3DPOOL pool,
[in] DWORD usage,
[out] IWineD3DVolume **volume
[out] struct wined3d_volume **volume
);
HRESULT CreateSwapChain(
@ -2307,24 +2307,6 @@ interface IWineD3DSurface : IWineD3DResource
);
}
[
object,
local,
uuid(24769ed8-6f30-11d9-c687-00046142c14f)
]
interface IWineD3DVolume : IWineD3DResource
{
struct wined3d_resource *GetResource(
);
HRESULT Map(
[out] WINED3DLOCKED_BOX *locked_box,
[in] const WINED3DBOX *box,
[in] DWORD flags
);
HRESULT Unmap(
);
}
[
object,
local,
@ -2412,7 +2394,7 @@ interface IWineD3DDevice : IUnknown
[in] WINED3DPOOL pool,
[in] void *parent,
[in] const struct wined3d_parent_ops *parent_ops,
[out] IWineD3DVolume **volume
[out] struct wined3d_volume **volume
);
HRESULT CreateCubeTexture(
[in] UINT edge_length,
@ -3083,4 +3065,20 @@ ULONG __cdecl wined3d_vertex_declaration_decref(struct wined3d_vertex_declaratio
void * __cdecl wined3d_vertex_declaration_get_parent(const struct wined3d_vertex_declaration *declaration);
ULONG __cdecl wined3d_vertex_declaration_incref(struct wined3d_vertex_declaration *declaration);
IWineD3DVolume * __cdecl wined3d_volume_from_resource(struct wined3d_resource *resource);
ULONG __cdecl wined3d_volume_decref(struct wined3d_volume *volume);
HRESULT __cdecl wined3d_volume_free_private_data(struct wined3d_volume *volume, REFGUID guid);
struct wined3d_volume * __cdecl wined3d_volume_from_resource(struct wined3d_resource *resource);
void * __cdecl wined3d_volume_get_parent(const struct wined3d_volume *volume);
DWORD __cdecl wined3d_volume_get_priority(const struct wined3d_volume *volume);
HRESULT __cdecl wined3d_volume_get_private_data(const struct wined3d_volume *volume,
REFGUID guid, void *data, DWORD *data_size);
struct wined3d_resource * __cdecl wined3d_volume_get_resource(struct wined3d_volume *volume);
WINED3DRESOURCETYPE __cdecl wined3d_volume_get_type(const struct wined3d_volume *volume);
ULONG __cdecl wined3d_volume_incref(struct wined3d_volume *volume);
HRESULT __cdecl wined3d_volume_map(struct wined3d_volume *volume,
WINED3DLOCKED_BOX *locked_box, const WINED3DBOX *box, DWORD flags);
void __cdecl wined3d_volume_preload(struct wined3d_volume *volume);
DWORD __cdecl wined3d_volume_set_priority(struct wined3d_volume *volume, DWORD new_priority);
HRESULT __cdecl wined3d_volume_set_private_data(struct wined3d_volume *volume,
REFGUID guid, const void *data, DWORD data_size, DWORD flags);
HRESULT __cdecl wined3d_volume_unmap(struct wined3d_volume *volume);