[PATCH 4/5] ddraw: Only set DDSCAPS_FRONTBUFFER on flippable surfaces.
Henri Verbeet
hverbeet at codeweavers.com
Tue Dec 3 02:59:18 CST 2013
---
dlls/ddraw/surface.c | 34 ++++++++++++++++++----------------
dlls/ddraw/tests/dsurface.c | 30 +++++++++---------------------
2 files changed, 27 insertions(+), 37 deletions(-)
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index 26e2648..980b83a 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -939,7 +939,7 @@ static HRESULT surface_lock(struct ddraw_surface *This,
}
}
- if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER)
+ if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
hr = ddraw_surface_update_frontbuffer(This, Rect, TRUE);
if (SUCCEEDED(hr))
hr = wined3d_surface_map(This->wined3d_surface, &map_desc, Rect, Flags);
@@ -959,7 +959,7 @@ static HRESULT surface_lock(struct ddraw_surface *This,
}
}
- if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER)
+ if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
if (Flags & DDLOCK_READONLY)
memset(&This->ddraw->primary_lock, 0, sizeof(This->ddraw->primary_lock));
@@ -1121,7 +1121,7 @@ static HRESULT WINAPI ddraw_surface7_Unlock(IDirectDrawSurface7 *iface, RECT *pR
hr = wined3d_surface_unmap(surface->wined3d_surface);
if (SUCCEEDED(hr))
{
- if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER)
+ if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
hr = ddraw_surface_update_frontbuffer(surface, &surface->ddraw->primary_lock, FALSE);
surface->surface_desc.lpSurface = NULL;
}
@@ -1225,7 +1225,7 @@ static HRESULT WINAPI ddraw_surface7_Flip(IDirectDrawSurface7 *iface, IDirectDra
}
hr = wined3d_surface_flip(surface->wined3d_surface, Override->wined3d_surface, Flags);
- if (SUCCEEDED(hr) && surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER)
+ if (SUCCEEDED(hr) && surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
hr = ddraw_surface_update_frontbuffer(surface, NULL, FALSE);
wined3d_mutex_unlock();
@@ -1292,12 +1292,12 @@ static HRESULT ddraw_surface_blt_clipped(struct ddraw_surface *dst_surface, cons
if (!dst_surface->clipper)
{
- if (src_surface && src_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER)
+ if (src_surface && src_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
hr = ddraw_surface_update_frontbuffer(src_surface, src_rect_in, TRUE);
if (SUCCEEDED(hr))
hr = wined3d_surface_blt(dst_surface->wined3d_surface, dst_rect_in,
wined3d_src_surface, src_rect_in, flags, fx, filter);
- if (SUCCEEDED(hr) && (dst_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER))
+ if (SUCCEEDED(hr) && (dst_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
hr = ddraw_surface_update_frontbuffer(dst_surface, dst_rect_in, FALSE);
return hr;
@@ -1376,7 +1376,7 @@ static HRESULT ddraw_surface_blt_clipped(struct ddraw_surface *dst_surface, cons
src_rect_clipped.right -= (LONG)((dst_rect.right - clip_rect[i].right) * scale_x);
src_rect_clipped.bottom -= (LONG)((dst_rect.bottom - clip_rect[i].bottom) * scale_y);
- if (src_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER)
+ if (src_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
if (FAILED(hr = ddraw_surface_update_frontbuffer(src_surface, &src_rect_clipped, TRUE)))
break;
@@ -1387,7 +1387,7 @@ static HRESULT ddraw_surface_blt_clipped(struct ddraw_surface *dst_surface, cons
wined3d_src_surface, &src_rect_clipped, flags, fx, filter)))
break;
- if (dst_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER)
+ if (dst_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
if (FAILED(hr = ddraw_surface_update_frontbuffer(dst_surface, &clip_rect[i], FALSE)))
break;
@@ -1935,7 +1935,7 @@ static HRESULT WINAPI ddraw_surface7_GetDC(IDirectDrawSurface7 *iface, HDC *hdc)
return DDERR_INVALIDPARAMS;
wined3d_mutex_lock();
- if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER)
+ if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
hr = ddraw_surface_update_frontbuffer(surface, NULL, TRUE);
if (SUCCEEDED(hr))
hr = wined3d_surface_getdc(surface->wined3d_surface, hdc);
@@ -2011,7 +2011,7 @@ static HRESULT WINAPI ddraw_surface7_ReleaseDC(IDirectDrawSurface7 *iface, HDC h
wined3d_mutex_lock();
hr = wined3d_surface_releasedc(surface->wined3d_surface, hdc);
- if (SUCCEEDED(hr) && (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER))
+ if (SUCCEEDED(hr) && (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
hr = ddraw_surface_update_frontbuffer(surface, NULL, FALSE);
wined3d_mutex_unlock();
@@ -3970,12 +3970,12 @@ static HRESULT WINAPI ddraw_surface7_BltFast(IDirectDrawSurface7 *iface, DWORD d
return DDERR_BLTFASTCANTCLIP;
}
- if (src->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER)
+ if (src->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
hr = ddraw_surface_update_frontbuffer(src, rsrc, TRUE);
if (SUCCEEDED(hr))
hr = wined3d_surface_blt(This->wined3d_surface, &dst_rect,
src->wined3d_surface, rsrc, flags, NULL, WINED3D_TEXF_POINT);
- if (SUCCEEDED(hr) && (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER))
+ if (SUCCEEDED(hr) && (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
hr = ddraw_surface_update_frontbuffer(This, &dst_rect, FALSE);
wined3d_mutex_unlock();
@@ -4711,15 +4711,15 @@ static HRESULT WINAPI ddraw_surface7_SetPalette(IDirectDrawSurface7 *iface, IDir
/* Release the old palette */
if(oldPal) IDirectDrawPalette_Release(oldPal);
- /* Update the wined3d frontbuffer if this is the frontbuffer. */
- if ((This->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER) && This->ddraw->wined3d_frontbuffer)
+ /* Update the wined3d frontbuffer if this is the primary. */
+ if ((This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) && This->ddraw->wined3d_frontbuffer)
wined3d_surface_set_palette(This->ddraw->wined3d_frontbuffer,
palette_impl ? palette_impl->wineD3DPalette : NULL);
/* If this is a front buffer, also update the back buffers
* TODO: How do things work for palettized cube textures?
*/
- if(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER)
+ if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER)
{
/* For primary surfaces the tree is just a list, so the simpler scheme fits too */
DDSCAPS2 caps2 = { DDSCAPS_FLIP, 0, 0, 0 };
@@ -5734,7 +5734,9 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
{
/* The first surface is a front buffer, the back buffers are created
* afterwards. */
- desc->ddsCaps.dwCaps |= DDSCAPS_VISIBLE | DDSCAPS_FRONTBUFFER;
+ if (desc->ddsCaps.dwCaps & DDSCAPS_FLIP)
+ desc->ddsCaps.dwCaps |= DDSCAPS_FRONTBUFFER;
+ desc->ddsCaps.dwCaps |= DDSCAPS_VISIBLE;
if (ddraw->cooperative_level & DDSCL_EXCLUSIVE)
{
struct wined3d_swapchain_desc swapchain_desc;
diff --git a/dlls/ddraw/tests/dsurface.c b/dlls/ddraw/tests/dsurface.c
index 383ced2..dce6456 100644
--- a/dlls/ddraw/tests/dsurface.c
+++ b/dlls/ddraw/tests/dsurface.c
@@ -3097,11 +3097,9 @@ static void SurfaceCapsTest(void)
};
UINT i;
- /* Tests various surface flags, what changes do they undergo during surface creation. Forsaken
- * engine expects texture surfaces without memory flag to get a video memory flag right after
- * creation. Currently, Wine adds DDSCAPS_FRONTBUFFER to primary surface, but native doesn't do this
- * for single buffered primaries. Because of this primary surface creation tests are todo_wine. No real
- * app is known so far to care about this. */
+ /* Tests various surface flags, what changes do they undergo during
+ * surface creation. Forsaken engine expects texture surfaces without
+ * memory flag to get a video memory flag right after creation. */
if (!(ddcaps.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
{
@@ -3142,14 +3140,9 @@ static void SurfaceCapsTest(void)
hr = IDirectDrawSurface_GetSurfaceDesc(surface1, &desc);
ok(hr == DD_OK, "IDirectDrawSurface_GetSurfaceDesc failed with %08x\n", hr);
- if (!(create_caps[i] & DDSCAPS_PRIMARYSURFACE))
- ok(desc.ddsCaps.dwCaps == expected_caps[i],
- "GetSurfaceDesc test %d returned caps %x, expected %x\n", i,
- desc.ddsCaps.dwCaps, expected_caps[i]);
- else
- todo_wine ok(desc.ddsCaps.dwCaps == expected_caps[i],
- "GetSurfaceDesc test %d returned caps %x, expected %x\n", i,
- desc.ddsCaps.dwCaps, expected_caps[i]);
+ ok(desc.ddsCaps.dwCaps == expected_caps[i],
+ "GetSurfaceDesc test %d returned caps %x, expected %x\n",
+ i, desc.ddsCaps.dwCaps, expected_caps[i]);
IDirectDrawSurface_Release(surface1);
}
@@ -3197,14 +3190,9 @@ static void SurfaceCapsTest(void)
hr = IDirectDrawSurface7_GetSurfaceDesc(surface7, &desc2);
ok(hr == DD_OK, "IDirectDrawSurface_GetSurfaceDesc failed with %08x\n", hr);
- if (!(create_caps[i] & DDSCAPS_PRIMARYSURFACE))
- ok(desc2.ddsCaps.dwCaps == expected_caps[i],
- "GetSurfaceDesc test %d returned caps %x, expected %x\n", i,
- desc2.ddsCaps.dwCaps, expected_caps[i]);
- else
- todo_wine ok(desc2.ddsCaps.dwCaps == expected_caps[i],
- "GetSurfaceDesc test %d returned caps %x, expected %x\n", i,
- desc2.ddsCaps.dwCaps, expected_caps[i]);
+ ok(desc2.ddsCaps.dwCaps == expected_caps[i],
+ "GetSurfaceDesc test %d returned caps %x, expected %x\n",
+ i, desc2.ddsCaps.dwCaps, expected_caps[i]);
IDirectDrawSurface7_Release(surface7);
}
--
1.7.10.4
More information about the wine-patches
mailing list