wined3d: Get rid of SFLAG_LOCKED.

This commit is contained in:
Henri Verbeet 2012-05-21 20:48:34 +02:00 committed by Alexandre Julliard
parent f2fb3f11f9
commit 5ec56c9bc4
3 changed files with 14 additions and 17 deletions

View File

@ -581,7 +581,7 @@ static void surface_prepare_system_memory(struct wined3d_surface *surface)
static void surface_evict_sysmem(struct wined3d_surface *surface)
{
if (surface->flags & SFLAG_DONOTFREE)
if (surface->resource.map_count || (surface->flags & SFLAG_DONOTFREE))
return;
HeapFree(GetProcessHeap(), 0, surface->resource.heapMemory);
@ -1441,7 +1441,7 @@ HRESULT CDECL wined3d_surface_blt(struct wined3d_surface *dst_surface, const REC
fx->ddckSrcColorkey.color_space_high_value);
}
if ((dst_surface->flags & SFLAG_LOCKED) || (src_surface && (src_surface->flags & SFLAG_LOCKED)))
if (dst_surface->resource.map_count || (src_surface && src_surface->resource.map_count))
{
WARN("Surface is busy, returning WINEDDERR_SURFACEBUSY.\n");
return WINEDDERR_SURFACEBUSY;
@ -2257,7 +2257,7 @@ static void surface_upload_data(struct wined3d_surface *surface, const struct wi
surface, gl_info, debug_d3dformat(format->id), wine_dbgstr_rect(src_rect), src_pitch,
wine_dbgstr_point(dst_point), srgb, data->buffer_object, data->addr);
if (surface->flags & SFLAG_LOCKED)
if (surface->resource.map_count)
{
WARN("Uploading a surface that is currently mapped, setting SFLAG_PIN_SYSMEM.\n");
surface->flags |= SFLAG_PIN_SYSMEM;
@ -3081,9 +3081,9 @@ HRESULT CDECL wined3d_surface_set_mem(struct wined3d_surface *surface, void *mem
{
TRACE("surface %p, mem %p.\n", surface, mem);
if (surface->flags & (SFLAG_LOCKED | SFLAG_DCINUSE))
if (surface->resource.map_count || (surface->flags & SFLAG_DCINUSE))
{
WARN("Surface is locked or the DC is in use.\n");
WARN("Surface is mapped or the DC is in use.\n");
return WINED3DERR_INVALIDCALL;
}
@ -3673,12 +3673,12 @@ HRESULT CDECL wined3d_surface_unmap(struct wined3d_surface *surface)
{
TRACE("surface %p.\n", surface);
if (!(surface->flags & SFLAG_LOCKED))
if (!surface->resource.map_count)
{
WARN("Trying to unmap unmapped surface.\n");
return WINEDDERR_NOTLOCKED;
}
surface->flags &= ~SFLAG_LOCKED;
--surface->resource.map_count;
surface->surface_ops->surface_unmap(surface);
@ -3693,7 +3693,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
TRACE("surface %p, map_desc %p, rect %s, flags %#x.\n",
surface, map_desc, wine_dbgstr_rect(rect), flags);
if (surface->flags & SFLAG_LOCKED)
if (surface->resource.map_count)
{
WARN("Surface is already mapped.\n");
return WINED3DERR_INVALIDCALL;
@ -3717,7 +3717,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
}
}
surface->flags |= SFLAG_LOCKED;
++surface->resource.map_count;
if (!(surface->flags & SFLAG_LOCKABLE))
WARN("Trying to lock unlockable surface.\n");
@ -3797,7 +3797,7 @@ HRESULT CDECL wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc)
return WINEDDERR_DCALREADYCREATED;
/* Can't GetDC if the surface is locked. */
if (surface->flags & SFLAG_LOCKED)
if (surface->resource.map_count)
return WINED3DERR_INVALIDCALL;
/* Create a DIB section if there isn't a dc yet. */
@ -5486,7 +5486,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(struct wined3d_surface *dst_surfa
fb_copy_to_texture_hwstretch(dst_surface, src_surface, src_rect, dst_rect, filter);
}
if (!(dst_surface->flags & SFLAG_DONOTFREE))
if (!dst_surface->resource.map_count && !(dst_surface->flags & SFLAG_DONOTFREE))
{
HeapFree(GetProcessHeap(), 0, dst_surface->resource.heapMemory);
dst_surface->resource.allocatedMemory = NULL;

View File

@ -714,7 +714,7 @@ void x11_copy_to_screen(const struct wined3d_swapchain *swapchain, const RECT *r
if (!(front->resource.usage & WINED3DUSAGE_RENDERTARGET))
return;
if (front->flags & SFLAG_LOCKED)
if (front->resource.map_count)
ERR("Trying to blit a mapped surface.\n");
TRACE("Copying surface %p to screen.\n", front);

View File

@ -2140,7 +2140,7 @@ void flip_surface(struct wined3d_surface *front, struct wined3d_surface *back) D
#define SFLAG_NORMCOORD 0x00000008 /* Set if GL texture coordinates are normalized (non-texture rectangle). */
#define SFLAG_LOCKABLE 0x00000010 /* Surface can be locked. */
#define SFLAG_DYNLOCK 0x00000020 /* Surface is often locked by the application. */
#define SFLAG_LOCKED 0x00000040 /* Surface is currently locked. */
#define SFLAG_PIN_SYSMEM 0x00000040 /* Keep the surface in sysmem, at the same address. */
#define SFLAG_DCINUSE 0x00000080 /* Set between GetDC and ReleaseDC calls. */
#define SFLAG_LOST 0x00000100 /* Surface lost flag for ddraw. */
#define SFLAG_GLCKEY 0x00000200 /* The GL texture was created with a color key. */
@ -2157,20 +2157,17 @@ void flip_surface(struct wined3d_surface *front, struct wined3d_surface *back) D
#define SFLAG_INDRAWABLE 0x00100000 /* The GL drawable is current. */
#define SFLAG_INRB_MULTISAMPLE 0x00200000 /* The multisample renderbuffer is current. */
#define SFLAG_INRB_RESOLVED 0x00400000 /* The resolved renderbuffer is current. */
#define SFLAG_PIN_SYSMEM 0x02000000 /* Keep the surface in sysmem, at the same address. */
#define SFLAG_DISCARDED 0x04000000 /* Surface was discarded, allocating new location is enough. */
#define SFLAG_DISCARDED 0x00800000 /* Surface was discarded, allocating new location is enough. */
/* In some conditions the surface memory must not be freed:
* SFLAG_CONVERTED: Converting the data back would take too long
* SFLAG_DIBSECTION: The dib code manages the memory
* SFLAG_LOCKED: The app requires access to the surface data
* SFLAG_DYNLOCK: Avoid freeing the data for performance
* SFLAG_PBO: PBOs don't use 'normal' memory. It is either allocated by the driver or must be NULL.
* SFLAG_CLIENT: OpenGL uses our memory as backup
*/
#define SFLAG_DONOTFREE (SFLAG_CONVERTED | \
SFLAG_DYNLOCK | \
SFLAG_LOCKED | \
SFLAG_CLIENT | \
SFLAG_DIBSECTION | \
SFLAG_USERPTR | \