dsurface/main.c and dsurface/dib.c

Ove Kaaven ovehk at ping.uio.no
Mon Apr 16 18:31:51 CDT 2001


Log:
Ove Kaaven <ovek at transgaming.com>
Fill in some more HAL fields. Flip some of them when appropriate.
Allow SetSurfaceDesc to change client memory surface address.
Propagate DIB color table updates to backbuffers too (thanks to
Stephen Clouse).

Index: wine/dlls/ddraw/dsurface/main.c
diff -u wine/dlls/ddraw/dsurface/main.c:1.1.1.10 wine/dlls/ddraw/dsurface/main.c:1.39
--- wine/dlls/ddraw/dsurface/main.c:1.1.1.10	Mon Apr 16 14:28:45 2001
+++ wine/dlls/ddraw/dsurface/main.c	Mon Apr 16 14:55:44 2001
@@ -253,6 +253,14 @@
     /* TODO MSDN: "You can attach only z-buffer surfaces with this method."
      * But apparently backbuffers and mipmaps can be attached too. */
 
+    /* Set MIPMAPSUBLEVEL if this seems to be one */
+    if (This->surface_desc.ddsCaps.dwCaps &
+	surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP) {
+	surf->surface_desc.ddsCaps.dwCaps2 |= DDSCAPS2_MIPMAPSUBLEVEL;
+	/* FIXME: we should probably also add to dwMipMapCount of this
+	 * and all parent surfaces (update create_texture if you do) */
+    }
+
     /* Callback to allow the surface to do something special now that it is
      * attached. (e.g. maybe the Z-buffer tells the renderer to use it.) */
     if (!surf->attach(surf, This))
@@ -333,6 +341,14 @@
 
     surf->detach(surf);
 
+    /* Remove MIPMAPSUBLEVEL if this seemed to be one */
+    if (This->surface_desc.ddsCaps.dwCaps &
+	surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP) {
+	surf->surface_desc.ddsCaps.dwCaps2 &= ~DDSCAPS2_MIPMAPSUBLEVEL;
+	/* FIXME: we should probably also subtract from dwMipMapCount of this
+	 * and all parent surfaces */
+    }
+
     if (surf->next_attached)
 	surf->next_attached->prev_attached = surf->prev_attached;
     if (surf->prev_attached)
@@ -391,6 +407,18 @@
 	BOOL tmp = front->dc_in_use;
 	front->dc_in_use = back->dc_in_use;
 	back->dc_in_use = tmp;
+    }
+
+    {
+	FLATPTR tmp = front->global.fpVidMem;
+	front->global.fpVidMem = back->global.fpVidMem;
+	back->global.fpVidMem = tmp;
+    }
+
+    {
+	ULONG_PTR tmp = front->global_more.hKernelSurface;
+	front->global_more.hKernelSurface = back->global_more.hKernelSurface;
+	back->global_more.hKernelSurface = tmp;
     }
 
     return TRUE;
Index: wine/dlls/ddraw/dsurface/dib.c
diff -u wine/dlls/ddraw/dsurface/dib.c:1.1.1.3 wine/dlls/ddraw/dsurface/dib.c:1.20
--- wine/dlls/ddraw/dsurface/dib.c:1.1.1.3	Mon Apr 16 14:28:43 2001
+++ wine/dlls/ddraw/dsurface/dib.c	Fri Apr  6 11:32:47 2001
@@ -2,7 +2,7 @@
  *
  * Copyright 1997-2000 Marcus Meissner
  * Copyright 1998-2000 Lionel Ulmer
- * Copyright 2000 TransGaming Technologies Inc.
+ * Copyright 2000-2001 TransGaming Technologies Inc.
  */
 
 #include "config.h"
@@ -137,6 +137,9 @@
     if (priv->dib.bitmap_data != This->surface_desc.lpSurface)
 	ERR("unexpected error creating DirectDrawSurface DIB section\n");
 
+    /* this seems like a good place to put the handle for HAL driver use */
+    This->global_more.hKernelSurface = priv->dib.DIBsection;
+
     return S_OK;
 }
 
@@ -804,9 +807,29 @@
     This->get_dc(This, &dc);
     SetDIBColorTable(dc, dwStart, dwCount, col);
     This->release_dc(This, dc);
-    /* FIXME: propagate change to backbuffers */
-}
 
+    /* Propagate change to backbuffers if there are any */
+    /* Basically this is a modification of the Flip code to find the backbuffer */
+    /* and duplicate the palette update there as well */
+    if ((This->surface_desc.ddsCaps.dwCaps&(DDSCAPS_FLIP|DDSCAPS_FRONTBUFFER))
+	== (DDSCAPS_FLIP|DDSCAPS_FRONTBUFFER))
+    {
+	static DDSCAPS2 back_caps = { DDSCAPS_BACKBUFFER };
+	LPDIRECTDRAWSURFACE7 tgt;
+
+	HRESULT hr = IDirectDrawSurface7_GetAttachedSurface(ICOM_INTERFACE(This,IDirectDrawSurface7),
+							    &back_caps, &tgt);
+	if (!FAILED(hr))
+	{
+	    IDirectDrawSurfaceImpl* target = ICOM_OBJECT(IDirectDrawSurfaceImpl,
+							 IDirectDrawSurface7,tgt);
+	    IDirectDrawSurface7_Release(tgt);
+	    target->get_dc(target, &dc);
+	    SetDIBColorTable(dc, dwStart, dwCount, col);
+	    target->release_dc(target, dc);
+	}
+    }
+}
 
 /* SetPalette: generic */
 /* SetPriority: generic */
@@ -816,10 +839,42 @@
 DIB_DirectDrawSurface_SetSurfaceDesc(LPDIRECTDRAWSURFACE7 iface,
 				     LPDDSURFACEDESC2 pDDSD, DWORD dwFlags)
 {
-    /* XXX */
-    FIXME("(%p)->(%p,%08lx)\n",iface,pDDSD,dwFlags);
-    abort();
-    return E_FAIL;
+    ICOM_THIS(IDirectDrawSurfaceImpl,iface);
+    DIB_PRIV_VAR(priv, This);
+    HRESULT hr = DD_OK;
+
+    TRACE("(%p)->(%p,%08lx)\n",iface,pDDSD,dwFlags);
+    if (pDDSD->dwFlags == DDSD_LPSURFACE) {
+	HBITMAP oldbmp = priv->dib.DIBsection;
+	LPVOID oldsurf = This->surface_desc.lpSurface;
+	BOOL oldc = priv->dib.client_memory;
+
+	TRACE("new lpSurface=%p\n",pDDSD->lpSurface);
+	This->surface_desc.lpSurface = pDDSD->lpSurface;
+	priv->dib.client_memory = TRUE;
+
+	hr = create_dib(This);
+	if (FAILED(hr))
+	{
+	    priv->dib.DIBsection = oldbmp;
+	    This->surface_desc.lpSurface = oldsurf;
+	    priv->dib.client_memory = oldc;
+	    return hr;
+	}
+
+	DeleteObject(oldbmp);
+
+	if (!oldc)
+	    VirtualFree(oldsurf, 0, MEM_RELEASE);
+
+	return hr;
+    }
+    else {
+	FIXME("flags=%08lx\n",pDDSD->dwFlags);
+	abort();
+	hr = E_FAIL;
+    }
+    return hr;
 }
 
 /* Unlock: ???, need callback */
Index: wine/dlls/ddraw/dsurface/dib.h
diff -u wine/dlls/ddraw/dsurface/dib.h:1.1.1.2 wine/dlls/ddraw/dsurface/dib.h:1.8
--- wine/dlls/ddraw/dsurface/dib.h:1.1.1.2	Mon Apr 16 14:28:43 2001
+++ wine/dlls/ddraw/dsurface/dib.h	Tue Mar 27 03:36:04 2001
@@ -1,4 +1,4 @@
-/* Copyright 2000 TransGaming Technologies Inc. */
+/* Copyright 2000-2001 TransGaming Technologies Inc. */
 
 #ifndef DDRAW_DSURFACE_DIB_H_INCLUDED
 #define DDRAW_DSURFACE_DIB_H_INCLUDED





More information about the wine-patches mailing list