From 4a10bbc76d5e6b6654717d590dde7354eff5d396 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Mon, 14 Mar 2011 21:02:59 +0100 Subject: [PATCH] wined3d: Generalize AddDirtyRect() / AddDirtyBox() to AddDirtyRegion(). --- dlls/d3d8/cubetexture.c | 22 ++++++++++++++++++---- dlls/d3d8/texture.c | 23 ++++++++++++++++++----- dlls/d3d8/volumetexture.c | 10 ++++++---- dlls/d3d9/cubetexture.c | 25 ++++++++++++++++++++----- dlls/d3d9/texture.c | 23 +++++++++++++++++++---- dlls/d3d9/volumetexture.c | 12 ++++++------ dlls/wined3d/cubetexture.c | 15 ++++++--------- dlls/wined3d/surface.c | 29 ++++++++++++++++++++++------- dlls/wined3d/texture.c | 12 ++++++------ dlls/wined3d/volumetexture.c | 12 ++++++------ dlls/wined3d/wined3d_private.h | 2 +- include/wine/wined3d.idl | 14 ++++---------- 12 files changed, 132 insertions(+), 67 deletions(-) diff --git a/dlls/d3d8/cubetexture.c b/dlls/d3d8/cubetexture.c index 1ecf47c8b0a..7b5305c22a7 100644 --- a/dlls/d3d8/cubetexture.c +++ b/dlls/d3d8/cubetexture.c @@ -351,15 +351,29 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_UnlockRect(IDirect3DCubeTexture8 } static HRESULT WINAPI IDirect3DCubeTexture8Impl_AddDirtyRect(IDirect3DCubeTexture8 *iface, - D3DCUBEMAP_FACES FaceType, const RECT *pDirtyRect) + D3DCUBEMAP_FACES face, const RECT *dirty_rect) { - IDirect3DCubeTexture8Impl *This = impl_from_IDirect3DCubeTexture8(iface); + IDirect3DCubeTexture8Impl *texture = impl_from_IDirect3DCubeTexture8(iface); HRESULT hr; - TRACE("iface %p, face %#x, dirty_rect %p.\n", iface, FaceType, pDirtyRect); + TRACE("iface %p, face %#x, dirty_rect %s.\n", + iface, face, wine_dbgstr_rect(dirty_rect)); wined3d_mutex_lock(); - hr = IWineD3DCubeTexture_AddDirtyRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, pDirtyRect); + if (!dirty_rect) + hr = IWineD3DCubeTexture_AddDirtyRegion(texture->wineD3DCubeTexture, face, NULL); + else + { + WINED3DBOX dirty_region; + + dirty_region.Left = dirty_rect->left; + dirty_region.Top = dirty_rect->top; + dirty_region.Right = dirty_rect->right; + dirty_region.Bottom = dirty_rect->bottom; + dirty_region.Front = 0; + dirty_region.Back = 1; + hr = IWineD3DCubeTexture_AddDirtyRegion(texture->wineD3DCubeTexture, face, &dirty_region); + } wined3d_mutex_unlock(); return hr; diff --git a/dlls/d3d8/texture.c b/dlls/d3d8/texture.c index d153b8f2a6b..6aa25be1968 100644 --- a/dlls/d3d8/texture.c +++ b/dlls/d3d8/texture.c @@ -339,16 +339,29 @@ static HRESULT WINAPI IDirect3DTexture8Impl_UnlockRect(IDirect3DTexture8 *iface, return hr; } -static HRESULT WINAPI IDirect3DTexture8Impl_AddDirtyRect(IDirect3DTexture8 *iface, - const RECT *pDirtyRect) +static HRESULT WINAPI IDirect3DTexture8Impl_AddDirtyRect(IDirect3DTexture8 *iface, const RECT *dirty_rect) { - IDirect3DTexture8Impl *This = impl_from_IDirect3DTexture8(iface); + IDirect3DTexture8Impl *texture = impl_from_IDirect3DTexture8(iface); HRESULT hr; - TRACE("iface %p, dirty_rect %p.\n", iface, pDirtyRect); + TRACE("iface %p, dirty_rect %s.\n", + iface, wine_dbgstr_rect(dirty_rect)); wined3d_mutex_lock(); - hr = IWineD3DTexture_AddDirtyRect(This->wineD3DTexture, pDirtyRect); + if (!dirty_rect) + hr = IWineD3DTexture_AddDirtyRegion(texture->wineD3DTexture, 0, NULL); + else + { + WINED3DBOX dirty_region; + + dirty_region.Left = dirty_rect->left; + dirty_region.Top = dirty_rect->top; + dirty_region.Right = dirty_rect->right; + dirty_region.Bottom = dirty_rect->bottom; + dirty_region.Front = 0; + dirty_region.Back = 1; + hr = IWineD3DTexture_AddDirtyRegion(texture->wineD3DTexture, 0, &dirty_region); + } wined3d_mutex_unlock(); return hr; diff --git a/dlls/d3d8/volumetexture.c b/dlls/d3d8/volumetexture.c index 8c693f00881..7bd6f316eef 100644 --- a/dlls/d3d8/volumetexture.c +++ b/dlls/d3d8/volumetexture.c @@ -316,14 +316,16 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_UnlockBox(IDirect3DVolumeTextu return hr; } -static HRESULT WINAPI IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE8 iface, CONST D3DBOX *pDirtyBox) { - IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface; +static HRESULT WINAPI IDirect3DVolumeTexture8Impl_AddDirtyBox(IDirect3DVolumeTexture8 *iface, + const D3DBOX *dirty_box) +{ + IDirect3DVolumeTexture8Impl *texture = (IDirect3DVolumeTexture8Impl *)iface; HRESULT hr; - TRACE("iface %p, dirty_box %p.\n", iface, pDirtyBox); + TRACE("iface %p, dirty_box %p.\n", iface, dirty_box); wined3d_mutex_lock(); - hr = IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, (CONST WINED3DBOX *) pDirtyBox); + hr = IWineD3DVolumeTexture_AddDirtyRegion(texture->wineD3DVolumeTexture, 0, (const WINED3DBOX *)dirty_box); wined3d_mutex_unlock(); return hr; diff --git a/dlls/d3d9/cubetexture.c b/dlls/d3d9/cubetexture.c index 798ffc9ced4..fb52e375af9 100644 --- a/dlls/d3d9/cubetexture.c +++ b/dlls/d3d9/cubetexture.c @@ -365,20 +365,35 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_UnlockRect(IDirect3DCubeTexture9 return hr; } -static HRESULT WINAPI IDirect3DCubeTexture9Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect) { - IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface; +static HRESULT WINAPI IDirect3DCubeTexture9Impl_AddDirtyRect(IDirect3DCubeTexture9 *iface, + D3DCUBEMAP_FACES face, const RECT *dirty_rect) +{ + IDirect3DCubeTexture9Impl *texture = (IDirect3DCubeTexture9Impl *)iface; HRESULT hr; - TRACE("iface %p, face %#x, dirty_rect %p.\n", iface, FaceType, pDirtyRect); + TRACE("iface %p, face %#x, dirty_rect %s.\n", + iface, face, wine_dbgstr_rect(dirty_rect)); wined3d_mutex_lock(); - hr = IWineD3DCubeTexture_AddDirtyRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, pDirtyRect); + if (!dirty_rect) + hr = IWineD3DCubeTexture_AddDirtyRegion(texture->wineD3DCubeTexture, face, NULL); + else + { + WINED3DBOX dirty_region; + + dirty_region.Left = dirty_rect->left; + dirty_region.Top = dirty_rect->top; + dirty_region.Right = dirty_rect->right; + dirty_region.Bottom = dirty_rect->bottom; + dirty_region.Front = 0; + dirty_region.Back = 1; + hr = IWineD3DCubeTexture_AddDirtyRegion(texture->wineD3DCubeTexture, face, &dirty_region); + } wined3d_mutex_unlock(); return hr; } - static const IDirect3DCubeTexture9Vtbl Direct3DCubeTexture9_Vtbl = { /* IUnknown */ diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c index 9816bfb4fe8..09ceb4cf7df 100644 --- a/dlls/d3d9/texture.c +++ b/dlls/d3d9/texture.c @@ -354,14 +354,29 @@ static HRESULT WINAPI IDirect3DTexture9Impl_UnlockRect(IDirect3DTexture9 *iface, return hr; } -static HRESULT WINAPI IDirect3DTexture9Impl_AddDirtyRect(LPDIRECT3DTEXTURE9 iface, CONST RECT* pDirtyRect) { - IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface; +static HRESULT WINAPI IDirect3DTexture9Impl_AddDirtyRect(IDirect3DTexture9 *iface, const RECT *dirty_rect) +{ + IDirect3DTexture9Impl *texture = (IDirect3DTexture9Impl *)iface; HRESULT hr; - TRACE("iface %p, dirty_rect %p.\n", iface, pDirtyRect); + TRACE("iface %p, dirty_rect %s.\n", + iface, wine_dbgstr_rect(dirty_rect)); wined3d_mutex_lock(); - hr = IWineD3DTexture_AddDirtyRect(This->wineD3DTexture, pDirtyRect); + if (!dirty_rect) + hr = IWineD3DTexture_AddDirtyRegion(texture->wineD3DTexture, 0, NULL); + else + { + WINED3DBOX dirty_region; + + dirty_region.Left = dirty_rect->left; + dirty_region.Top = dirty_rect->top; + dirty_region.Right = dirty_rect->right; + dirty_region.Bottom = dirty_rect->bottom; + dirty_region.Front = 0; + dirty_region.Back = 1; + hr = IWineD3DTexture_AddDirtyRegion(texture->wineD3DTexture, 0, &dirty_region); + } wined3d_mutex_unlock(); return hr; diff --git a/dlls/d3d9/volumetexture.c b/dlls/d3d9/volumetexture.c index 0a8932c4fed..a423ff389b9 100644 --- a/dlls/d3d9/volumetexture.c +++ b/dlls/d3d9/volumetexture.c @@ -378,16 +378,16 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_UnlockBox(IDirect3DVolumeTextu return hr; } -static HRESULT WINAPI IDirect3DVolumeTexture9Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE9 iface, CONST D3DBOX* pDirtyBox) { - IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface; +static HRESULT WINAPI IDirect3DVolumeTexture9Impl_AddDirtyBox(IDirect3DVolumeTexture9 *iface, + const D3DBOX *dirty_box) +{ + IDirect3DVolumeTexture9Impl *texture = (IDirect3DVolumeTexture9Impl *)iface; HRESULT hr; - TRACE("iface %p, dirty_box %p.\n", iface, pDirtyBox); + TRACE("iface %p, dirty_box %p.\n", iface, dirty_box); wined3d_mutex_lock(); - - hr = IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, (CONST WINED3DBOX *)pDirtyBox); - + hr = IWineD3DVolumeTexture_AddDirtyRegion(texture->wineD3DVolumeTexture, 0, (const WINED3DBOX *)dirty_box); wined3d_mutex_unlock(); return hr; diff --git a/dlls/wined3d/cubetexture.c b/dlls/wined3d/cubetexture.c index db5cbd3a2f8..4171d55878d 100644 --- a/dlls/wined3d/cubetexture.c +++ b/dlls/wined3d/cubetexture.c @@ -336,24 +336,22 @@ static struct wined3d_resource * WINAPI IWineD3DCubeTextureImpl_GetSubResource(I return basetexture_get_sub_resource(texture, sub_resource_idx); } -static HRESULT WINAPI IWineD3DCubeTextureImpl_AddDirtyRect(IWineD3DCubeTexture *iface, - WINED3DCUBEMAP_FACES face, const RECT *dirty_rect) +static HRESULT WINAPI IWineD3DCubeTextureImpl_AddDirtyRegion(IWineD3DCubeTexture *iface, + UINT layer, const WINED3DBOX *dirty_region) { IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface; - UINT sub_resource_idx = face * texture->baseTexture.level_count; struct wined3d_resource *sub_resource; - TRACE("iface %p, face %u, dirty_rect %s.\n", - iface, face, wine_dbgstr_rect(dirty_rect)); + TRACE("iface %p, layer %u, dirty_region %p.\n", iface, layer, dirty_region); - if (!(sub_resource = basetexture_get_sub_resource(texture, sub_resource_idx))) + if (!(sub_resource = basetexture_get_sub_resource(texture, layer * texture->baseTexture.level_count))) { WARN("Failed to get sub-resource.\n"); return WINED3DERR_INVALIDCALL; } basetexture_set_dirty(texture, TRUE); - surface_add_dirty_rect(surface_from_resource(sub_resource), dirty_rect); + surface_add_dirty_rect(surface_from_resource(sub_resource), dirty_region); return WINED3D_OK; } @@ -382,8 +380,7 @@ static const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl = IWineD3DCubeTextureImpl_GenerateMipSubLevels, IWineD3DCubeTextureImpl_IsCondNP2, IWineD3DCubeTextureImpl_GetSubResource, - /* IWineD3DCubeTexture */ - IWineD3DCubeTextureImpl_AddDirtyRect + IWineD3DCubeTextureImpl_AddDirtyRegion, }; HRESULT cubetexture_init(IWineD3DCubeTextureImpl *texture, UINT edge_length, UINT levels, diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index ace0c65b870..745bd7782d2 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -1188,9 +1188,9 @@ GLenum surface_get_gl_buffer(IWineD3DSurfaceImpl *surface) } /* Slightly inefficient way to handle multiple dirty rects but it works :) */ -void surface_add_dirty_rect(IWineD3DSurfaceImpl *surface, const RECT *dirty_rect) +void surface_add_dirty_rect(IWineD3DSurfaceImpl *surface, const WINED3DBOX *dirty_rect) { - TRACE("surface %p, dirty_rect %s.\n", surface, wine_dbgstr_rect(dirty_rect)); + TRACE("surface %p, dirty_rect %p.\n", surface, dirty_rect); if (!(surface->flags & SFLAG_INSYSMEM) && (surface->flags & SFLAG_INTEXTURE)) /* No partial locking for textures yet. */ @@ -1199,10 +1199,10 @@ void surface_add_dirty_rect(IWineD3DSurfaceImpl *surface, const RECT *dirty_rect surface_modify_location(surface, SFLAG_INSYSMEM, TRUE); if (dirty_rect) { - surface->dirtyRect.left = min(surface->dirtyRect.left, dirty_rect->left); - surface->dirtyRect.top = min(surface->dirtyRect.top, dirty_rect->top); - surface->dirtyRect.right = max(surface->dirtyRect.right, dirty_rect->right); - surface->dirtyRect.bottom = max(surface->dirtyRect.bottom, dirty_rect->bottom); + surface->dirtyRect.left = min(surface->dirtyRect.left, dirty_rect->Left); + surface->dirtyRect.top = min(surface->dirtyRect.top, dirty_rect->Top); + surface->dirtyRect.right = max(surface->dirtyRect.right, dirty_rect->Right); + surface->dirtyRect.bottom = max(surface->dirtyRect.bottom, dirty_rect->Bottom); } else { @@ -1924,7 +1924,22 @@ lock_end: } if (!(flags & (WINED3DLOCK_NO_DIRTY_UPDATE | WINED3DLOCK_READONLY))) - surface_add_dirty_rect(This, pRect); + { + if (!pRect) + surface_add_dirty_rect(This, NULL); + else + { + WINED3DBOX b; + + b.Left = pRect->left; + b.Top = pRect->top; + b.Right = pRect->right; + b.Bottom = pRect->bottom; + b.Front = 0; + b.Back = 1; + surface_add_dirty_rect(This, &b); + } + } return IWineD3DBaseSurfaceImpl_Map(iface, pLockedRect, pRect, flags); } diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 99446b6c7ba..5e8ccae6afb 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -361,21 +361,22 @@ static struct wined3d_resource * WINAPI IWineD3DTextureImpl_GetSubResource(IWine return basetexture_get_sub_resource(texture, sub_resource_idx); } -static HRESULT WINAPI IWineD3DTextureImpl_AddDirtyRect(IWineD3DTexture *iface, const RECT *dirty_rect) +static HRESULT WINAPI IWineD3DTextureImpl_AddDirtyRegion(IWineD3DTexture *iface, + UINT layer, const WINED3DBOX *dirty_region) { IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface; struct wined3d_resource *sub_resource; - TRACE("iface %p, dirty_rect %s.\n", iface, wine_dbgstr_rect(dirty_rect)); + TRACE("iface %p, layer %u, dirty_region %p.\n", iface, layer, dirty_region); - if (!(sub_resource = basetexture_get_sub_resource(texture, 0))) + if (!(sub_resource = basetexture_get_sub_resource(texture, layer * texture->baseTexture.level_count))) { WARN("Failed to get sub-resource.\n"); return WINED3DERR_INVALIDCALL; } basetexture_set_dirty(texture, TRUE); - surface_add_dirty_rect(surface_from_resource(sub_resource), dirty_rect); + surface_add_dirty_rect(surface_from_resource(sub_resource), dirty_region); return WINED3D_OK; } @@ -404,8 +405,7 @@ static const IWineD3DTextureVtbl IWineD3DTexture_Vtbl = IWineD3DTextureImpl_GenerateMipSubLevels, IWineD3DTextureImpl_IsCondNP2, IWineD3DTextureImpl_GetSubResource, - /* IWineD3DTexture */ - IWineD3DTextureImpl_AddDirtyRect + IWineD3DTextureImpl_AddDirtyRegion, }; HRESULT texture_init(IWineD3DTextureImpl *texture, UINT width, UINT height, UINT levels, diff --git a/dlls/wined3d/volumetexture.c b/dlls/wined3d/volumetexture.c index 9d942d70e1a..5da99846f27 100644 --- a/dlls/wined3d/volumetexture.c +++ b/dlls/wined3d/volumetexture.c @@ -273,21 +273,22 @@ static struct wined3d_resource * WINAPI IWineD3DVolumeTextureImpl_GetSubResource return basetexture_get_sub_resource(texture, sub_resource_idx); } -static HRESULT WINAPI IWineD3DVolumeTextureImpl_AddDirtyBox(IWineD3DVolumeTexture *iface, const WINED3DBOX *dirty_box) +static HRESULT WINAPI IWineD3DVolumeTextureImpl_AddDirtyRegion(IWineD3DVolumeTexture *iface, + UINT layer, const WINED3DBOX *dirty_region) { IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface; struct wined3d_resource *sub_resource; - TRACE("iface %p, dirty_box %p.\n", iface, dirty_box); + TRACE("iface %p, layer %u, dirty_region %p.\n", iface, layer, dirty_region); - if (!(sub_resource = basetexture_get_sub_resource(texture, 0))) + if (!(sub_resource = basetexture_get_sub_resource(texture, layer * texture->baseTexture.level_count))) { WARN("Failed to get sub-resource.\n"); return WINED3DERR_INVALIDCALL; } basetexture_set_dirty(texture, TRUE); - volume_add_dirty_box(volume_from_resource(sub_resource), dirty_box); + volume_add_dirty_box(volume_from_resource(sub_resource), dirty_region); return WINED3D_OK; } @@ -316,8 +317,7 @@ static const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl = IWineD3DVolumeTextureImpl_GenerateMipSubLevels, IWineD3DVolumeTextureImpl_IsCondNP2, IWineD3DVolumeTextureImpl_GetSubResource, - /* volume texture */ - IWineD3DVolumeTextureImpl_AddDirtyBox + IWineD3DVolumeTextureImpl_AddDirtyRegion, }; HRESULT volumetexture_init(IWineD3DVolumeTextureImpl *texture, UINT width, UINT height, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 8fc6df50dcc..35d88bac6e8 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2158,7 +2158,7 @@ static inline GLuint surface_get_texture_name(IWineD3DSurfaceImpl *surface, ? surface->texture_name_srgb : surface->texture_name; } -void surface_add_dirty_rect(IWineD3DSurfaceImpl *surface, const RECT *dirty_rect) DECLSPEC_HIDDEN; +void surface_add_dirty_rect(IWineD3DSurfaceImpl *surface, const WINED3DBOX *dirty_rect) DECLSPEC_HIDDEN; void surface_bind(IWineD3DSurfaceImpl *surface, const struct wined3d_gl_info *gl_info, BOOL srgb) DECLSPEC_HIDDEN; HRESULT surface_color_fill(IWineD3DSurfaceImpl *s, const RECT *rect, const WINED3DCOLORVALUE *color) DECLSPEC_HIDDEN; void surface_gdi_cleanup(IWineD3DSurfaceImpl *This) DECLSPEC_HIDDEN; diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl index 34449d0e64e..75dc46a300c 100644 --- a/include/wine/wined3d.idl +++ b/include/wine/wined3d.idl @@ -2361,6 +2361,10 @@ interface IWineD3DBaseTexture : IWineD3DResource struct wined3d_resource *GetSubResource( [in] UINT sub_resource_idx ); + HRESULT AddDirtyRegion( + [in] UINT layer, + [in] const WINED3DBOX *dirty_region + ); } [ @@ -2370,9 +2374,6 @@ interface IWineD3DBaseTexture : IWineD3DResource ] interface IWineD3DTexture : IWineD3DBaseTexture { - HRESULT AddDirtyRect( - [in] const RECT *dirty_rect - ); } [ @@ -2382,10 +2383,6 @@ interface IWineD3DTexture : IWineD3DBaseTexture ] interface IWineD3DCubeTexture : IWineD3DBaseTexture { - HRESULT AddDirtyRect( - [in] WINED3DCUBEMAP_FACES face, - [in] const RECT *dirty_rect - ); } [ @@ -2395,9 +2392,6 @@ interface IWineD3DCubeTexture : IWineD3DBaseTexture ] interface IWineD3DVolumeTexture : IWineD3DBaseTexture { - HRESULT AddDirtyBox( - [in] const WINED3DBOX *dirty_box - ); } [