Commit 82666af8 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Simplify wined3d_surface_set_mem.

parent 2a012ba1
...@@ -2619,54 +2619,29 @@ HRESULT CDECL wined3d_surface_set_mem(struct wined3d_surface *surface, void *mem ...@@ -2619,54 +2619,29 @@ HRESULT CDECL wined3d_surface_set_mem(struct wined3d_surface *surface, void *mem
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
if (mem && mem != surface->user_memory) if (surface->flags & SFLAG_DIBSECTION)
{ {
/* Do I have to copy the old surface content? */ DeleteDC(surface->hDC);
if (surface->flags & SFLAG_DIBSECTION) DeleteObject(surface->dib.DIBsection);
{ surface->dib.bitmap_data = NULL;
DeleteDC(surface->hDC); surface->resource.allocatedMemory = NULL;
DeleteObject(surface->dib.DIBsection); surface->hDC = NULL;
surface->dib.bitmap_data = NULL; surface->flags &= ~SFLAG_DIBSECTION;
surface->resource.allocatedMemory = NULL;
surface->hDC = NULL;
surface->flags &= ~SFLAG_DIBSECTION;
}
else if (!(surface->flags & SFLAG_USERPTR))
{
wined3d_resource_free_sysmem(&surface->resource);
surface->resource.allocatedMemory = NULL;
}
surface->user_memory = mem;
surface->flags |= SFLAG_USERPTR;
/* Now the surface memory is most up do date. Invalidate drawable and texture. */
surface_validate_location(surface, SFLAG_INSYSMEM);
surface_invalidate_location(surface, ~SFLAG_INSYSMEM);
/* For client textures OpenGL has to be notified. */
if (surface->flags & SFLAG_CLIENT)
surface_release_client_storage(surface);
} }
else if (surface->flags & SFLAG_USERPTR) else if (!(surface->flags & SFLAG_USERPTR))
{ {
/* heap_memory should be NULL already. */ wined3d_resource_free_sysmem(&surface->resource);
if (surface->resource.heap_memory) surface->resource.allocatedMemory = NULL;
ERR("User pointer surface has heap memory allocated.\n"); }
if (!mem)
{
surface->user_memory = NULL;
surface->flags &= ~(SFLAG_USERPTR | SFLAG_INSYSMEM);
if (surface->flags & SFLAG_CLIENT)
surface_release_client_storage(surface);
surface_prepare_system_memory(surface); surface->user_memory = mem;
} surface->flags |= SFLAG_USERPTR;
surface_validate_location(surface, SFLAG_INSYSMEM);
surface_invalidate_location(surface, ~SFLAG_INSYSMEM);
surface_validate_location(surface, SFLAG_INSYSMEM); /* For client textures OpenGL has to be notified. */
surface_invalidate_location(surface, ~SFLAG_INSYSMEM); if (surface->flags & SFLAG_CLIENT)
} surface_release_client_storage(surface);
surface->pitch = pitch; surface->pitch = pitch;
......
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