wined3d: Be more strict with wined3d_texture_get_dc() calls from d3d9.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2016-04-13 12:18:48 +02:00 committed by Alexandre Julliard
parent c3d74913b7
commit 9e763ab92b
3 changed files with 31 additions and 23 deletions

View File

@ -7716,18 +7716,18 @@ static void test_getdc(void)
hr = IDirect3DSurface9_GetDC(surface, &dc);
ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", testdata[i].name, hr);
hr = IDirect3DSurface9_GetDC(surface2, &dc2);
todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
hr = IDirect3DSurface9_ReleaseDC(surface2, dc2);
todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
hr = IDirect3DSurface9_ReleaseDC(surface, dc);
ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", testdata[i].name, hr);
hr = IDirect3DSurface9_GetDC(surface2, &dc);
ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", testdata[i].name, hr);
hr = IDirect3DSurface9_GetDC(surface, &dc2);
todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
hr = IDirect3DSurface9_ReleaseDC(surface, dc2);
todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
hr = IDirect3DSurface9_ReleaseDC(surface2, dc);
ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", testdata[i].name, hr);
@ -7752,16 +7752,16 @@ static void test_getdc(void)
hr = IDirect3DSurface9_LockRect(surface2, &map_desc, NULL, D3DLOCK_READONLY);
ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", testdata[i].name, hr);
hr = IDirect3DSurface9_GetDC(surface, &dc);
todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
hr = IDirect3DSurface9_ReleaseDC(surface, dc);
todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
hr = IDirect3DSurface9_UnlockRect(surface2);
ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", testdata[i].name, hr);
hr = IDirect3DSurface9_GetDC(surface, &dc);
ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", testdata[i].name, hr);
hr = IDirect3DSurface9_LockRect(surface2, &map_desc, NULL, D3DLOCK_READONLY);
todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
hr = IDirect3DSurface9_UnlockRect(surface2);
ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", testdata[i].name, hr);
hr = IDirect3DSurface9_ReleaseDC(surface, dc);
@ -7770,7 +7770,7 @@ static void test_getdc(void)
hr = IDirect3DSurface9_GetDC(surface2, &dc);
ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", testdata[i].name, hr);
hr = IDirect3DSurface9_LockRect(surface, &map_desc, NULL, D3DLOCK_READONLY);
todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
hr = IDirect3DSurface9_UnlockRect(surface);
ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", testdata[i].name, hr);
hr = IDirect3DSurface9_ReleaseDC(surface2, dc);
@ -7781,7 +7781,7 @@ static void test_getdc(void)
hr = IDirect3DSurface9_GetDC(surface2, &dc);
ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", testdata[i].name, hr);
hr = IDirect3DSurface9_UnlockRect(surface);
todo_wine ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", testdata[i].name, hr);
ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", testdata[i].name, hr);
hr = IDirect3DSurface9_ReleaseDC(surface2, dc);
ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", testdata[i].name, hr);
hr = IDirect3DSurface9_UnlockRect(surface);
@ -7792,7 +7792,7 @@ static void test_getdc(void)
hr = IDirect3DSurface9_GetDC(surface, &dc);
ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", testdata[i].name, hr);
hr = IDirect3DSurface9_UnlockRect(surface2);
todo_wine ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", testdata[i].name, hr);
ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", testdata[i].name, hr);
hr = IDirect3DSurface9_ReleaseDC(surface, dc);
ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", testdata[i].name, hr);
hr = IDirect3DSurface9_UnlockRect(surface2);

View File

@ -838,6 +838,12 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
return WINED3DERR_INVALIDCALL;
}
if (texture->resource.map_count)
{
WARN("Texture is mapped.\n");
return WINED3DERR_INVALIDCALL;
}
/* We have no way of supporting a pitch that is not a multiple of the pixel
* byte width short of uploading the texture row-by-row.
* Fortunately that's not an issue since D3D9Ex doesn't allow a custom pitch
@ -851,17 +857,11 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
return WINED3DERR_INVALIDCALL;
}
sub_resource = &texture->sub_resources[0];
surface = sub_resource->u.surface;
if (sub_resource->map_count || (surface->flags & SFLAG_DCINUSE))
{
WARN("Surface is mapped or the DC is in use.\n");
return WINED3DERR_INVALIDCALL;
}
if (device->d3d_initialized)
texture->resource.resource_ops->resource_unload(&texture->resource);
sub_resource = &texture->sub_resources[0];
surface = sub_resource->u.surface;
if (surface->flags & SFLAG_DIBSECTION)
{
DeleteDC(surface->hDC);
@ -1291,6 +1291,12 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour
return WINED3DERR_INVALIDCALL;
}
if (texture->flags & WINED3D_TEXTURE_DC_IN_USE)
{
WARN("DC is in use.\n");
return WINED3DERR_INVALIDCALL;
}
if (sub_resource->map_count)
{
WARN("Sub-resource is already mapped.\n");
@ -1433,6 +1439,8 @@ static HRESULT texture_resource_sub_resource_unmap(struct wined3d_resource *reso
if (!sub_resource->map_count)
{
WARN("Trying to unmap unmapped sub-resource.\n");
if (texture->flags & WINED3D_TEXTURE_DC_IN_USE)
return WINED3D_OK;
return WINEDDERR_NOTLOCKED;
}
@ -2238,7 +2246,7 @@ HRESULT CDECL wined3d_texture_get_dc(struct wined3d_texture *texture, unsigned i
surface = sub_resource->u.surface;
if (sub_resource->map_count && !(texture->flags & WINED3D_TEXTURE_GET_DC_LENIENT))
if (texture->resource.map_count && !(texture->flags & WINED3D_TEXTURE_GET_DC_LENIENT))
return WINED3DERR_INVALIDCALL;
if (device->d3d_initialized)
@ -2266,7 +2274,7 @@ HRESULT CDECL wined3d_texture_get_dc(struct wined3d_texture *texture, unsigned i
context_release(context);
if (!(texture->flags & WINED3D_TEXTURE_GET_DC_LENIENT))
surface->flags |= SFLAG_DCINUSE;
texture->flags |= WINED3D_TEXTURE_DC_IN_USE;
++texture->resource.map_count;
++sub_resource->map_count;
@ -2296,7 +2304,7 @@ HRESULT CDECL wined3d_texture_release_dc(struct wined3d_texture *texture, unsign
surface = sub_resource->u.surface;
if (!(texture->flags & WINED3D_TEXTURE_GET_DC_LENIENT) && !(surface->flags & SFLAG_DCINUSE))
if (!(texture->flags & (WINED3D_TEXTURE_GET_DC_LENIENT | WINED3D_TEXTURE_DC_IN_USE)))
return WINED3DERR_INVALIDCALL;
if (surface->hDC != dc)
@ -2309,7 +2317,7 @@ HRESULT CDECL wined3d_texture_release_dc(struct wined3d_texture *texture, unsign
--sub_resource->map_count;
--texture->resource.map_count;
if (!(texture->flags & WINED3D_TEXTURE_GET_DC_LENIENT))
surface->flags &= ~SFLAG_DCINUSE;
texture->flags &= ~WINED3D_TEXTURE_DC_IN_USE;
if (surface->resource.map_binding == WINED3D_LOCATION_USER_MEMORY
|| (surface->container->flags & WINED3D_TEXTURE_PIN_SYSMEM

View File

@ -2439,6 +2439,7 @@ struct wined3d_texture_ops
#define WINED3D_TEXTURE_PIN_SYSMEM 0x00000200
#define WINED3D_TEXTURE_NORMALIZED_COORDS 0x00000400
#define WINED3D_TEXTURE_GET_DC_LENIENT 0x00000800
#define WINED3D_TEXTURE_DC_IN_USE 0x00001000
#define WINED3D_TEXTURE_ASYNC_COLOR_KEY 0x00000001
@ -2720,7 +2721,6 @@ void draw_textured_quad(const struct wined3d_surface *src_surface, struct wined3
/* Surface flags: */
#define SFLAG_DIBSECTION 0x00000001 /* Has a DIB section attached for GetDC. */
#define SFLAG_DISCARD 0x00000002 /* ??? */
#define SFLAG_DCINUSE 0x00000020 /* Set between GetDC and ReleaseDC calls. */
struct wined3d_sampler
{