Henri Verbeet : ddraw: Use offscreen backbuffers.

Alexandre Julliard julliard at winehq.org
Fri Sep 16 13:28:30 CDT 2011


Module: wine
Branch: master
Commit: 1aeee59bd8b6172c848c8029e1a55ddac1f93c44
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1aeee59bd8b6172c848c8029e1a55ddac1f93c44

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Thu Sep 15 20:01:50 2011 +0200

ddraw: Use offscreen backbuffers.

In principle this allows us to use more than one backbuffer in ddraw. It's
also a requirement for the next patch.

---

 dlls/ddraw/ddraw.c |   46 +++++++---------------------------------------
 1 files changed, 7 insertions(+), 39 deletions(-)

diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index 7e6d372..a8b8985 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -2794,8 +2794,6 @@ static HRESULT ddraw_create_swapchain(IDirectDrawImpl *ddraw, IDirectDrawSurface
     presentation_parameters.BackBufferWidth = target->surface_desc.dwWidth;
     presentation_parameters.BackBufferHeight = target->surface_desc.dwHeight;
     presentation_parameters.BackBufferFormat = PixelFormat_DD2WineD3D(&target->surface_desc.u4.ddpfPixelFormat);
-    presentation_parameters.BackBufferCount = (target->surface_desc.dwFlags & DDSD_BACKBUFFERCOUNT)
-            ? target->surface_desc.dwBackBufferCount : 0;
     presentation_parameters.SwapEffect = WINED3DSWAPEFFECT_COPY;
     presentation_parameters.hDeviceWindow = ddraw->dest_window;
     presentation_parameters.Windowed = !(ddraw->cooperative_level & DDSCL_FULLSCREEN);
@@ -5644,27 +5642,6 @@ static HRESULT CDECL device_parent_create_surface(struct wined3d_device_parent *
     return D3D_OK;
 }
 
-static HRESULT WINAPI findRenderTarget(IDirectDrawSurface7 *surface, DDSURFACEDESC2 *surface_desc, void *ctx)
-{
-    IDirectDrawSurfaceImpl *s = impl_from_IDirectDrawSurface7(surface);
-    IDirectDrawSurfaceImpl **target = ctx;
-
-    if (!s->isRenderTarget)
-    {
-        *target = s;
-        IDirectDrawSurface7_Release(surface);
-        return DDENUMRET_CANCEL;
-    }
-
-    /* Recurse into the surface tree */
-    IDirectDrawSurface7_EnumAttachedSurfaces(surface, ctx, findRenderTarget);
-
-    IDirectDrawSurface7_Release(surface);
-    if (*target) return DDENUMRET_CANCEL;
-
-    return DDENUMRET_OK;
-}
-
 static HRESULT CDECL device_parent_create_rendertarget(struct wined3d_device_parent *device_parent,
         void *container_parent, UINT width, UINT height, enum wined3d_format_id format,
         WINED3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality, BOOL lockable,
@@ -5672,33 +5649,24 @@ static HRESULT CDECL device_parent_create_rendertarget(struct wined3d_device_par
 {
     struct IDirectDrawImpl *ddraw = ddraw_from_device_parent(device_parent);
     IDirectDrawSurfaceImpl *d3d_surface = ddraw->d3d_target;
-    IDirectDrawSurfaceImpl *target = NULL;
 
     TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, multisample_type %#x,\n"
             "\tmultisample_quality %u, lockable %u, surface %p.\n",
             device_parent, container_parent, width, height, format, multisample_type,
             multisample_quality, lockable, surface);
 
-    if (d3d_surface->isRenderTarget)
-    {
-        IDirectDrawSurface7_EnumAttachedSurfaces(&d3d_surface->IDirectDrawSurface7_iface, &target, findRenderTarget);
-    }
-    else
-    {
-        target = d3d_surface;
-    }
+    /* TODO: Return failure if the dimensions do not match, but this shouldn't
+     * happen. */
 
-    if (!target)
+    if (d3d_surface->isRenderTarget)
     {
-        target = ddraw->d3d_target;
-        ERR(" (%p) : No DirectDrawSurface found to create the back buffer. Using the front buffer as back buffer. Uncertain consequences\n", ddraw);
+        ERR("Frontbuffer already created.\n");
+        return E_FAIL;
     }
+    d3d_surface->isRenderTarget = TRUE;
 
-    /* TODO: Return failure if the dimensions do not match, but this shouldn't happen */
-
-    *surface = target->wined3d_surface;
+    *surface = d3d_surface->wined3d_surface;
     wined3d_surface_incref(*surface);
-    target->isRenderTarget = TRUE;
 
     TRACE("Returning wineD3DSurface %p, it belongs to surface %p\n", *surface, d3d_surface);
 




More information about the wine-cvs mailing list