wined3d: Generalize AddDirtyRect() / AddDirtyBox() to AddDirtyRegion().

This commit is contained in:
Henri Verbeet 2011-03-14 21:02:59 +01:00 committed by Alexandre Julliard
parent e409b83bcb
commit 4a10bbc76d
12 changed files with 132 additions and 67 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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 */

View File

@ -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;

View File

@ -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;

View File

@ -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,

View File

@ -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);
}

View File

@ -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,

View File

@ -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,

View File

@ -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;

View File

@ -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
);
}
[