Commit fe01f0e7 authored by Ove Kaaven's avatar Ove Kaaven Committed by Alexandre Julliard

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).
parent 04b7b7a8
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* *
* Copyright 1997-2000 Marcus Meissner * Copyright 1997-2000 Marcus Meissner
* Copyright 1998-2000 Lionel Ulmer * Copyright 1998-2000 Lionel Ulmer
* Copyright 2000 TransGaming Technologies Inc. * Copyright 2000-2001 TransGaming Technologies Inc.
*/ */
#include "config.h" #include "config.h"
...@@ -137,6 +137,9 @@ static HRESULT create_dib(IDirectDrawSurfaceImpl* This) ...@@ -137,6 +137,9 @@ static HRESULT create_dib(IDirectDrawSurfaceImpl* This)
if (priv->dib.bitmap_data != This->surface_desc.lpSurface) if (priv->dib.bitmap_data != This->surface_desc.lpSurface)
ERR("unexpected error creating DirectDrawSurface DIB section\n"); 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; return S_OK;
} }
...@@ -804,9 +807,29 @@ void DIB_DirectDrawSurface_update_palette(IDirectDrawSurfaceImpl* This, ...@@ -804,9 +807,29 @@ void DIB_DirectDrawSurface_update_palette(IDirectDrawSurfaceImpl* This,
This->get_dc(This, &dc); This->get_dc(This, &dc);
SetDIBColorTable(dc, dwStart, dwCount, col); SetDIBColorTable(dc, dwStart, dwCount, col);
This->release_dc(This, dc); 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 */ /* SetPalette: generic */
/* SetPriority: generic */ /* SetPriority: generic */
...@@ -816,10 +839,42 @@ HRESULT WINAPI ...@@ -816,10 +839,42 @@ HRESULT WINAPI
DIB_DirectDrawSurface_SetSurfaceDesc(LPDIRECTDRAWSURFACE7 iface, DIB_DirectDrawSurface_SetSurfaceDesc(LPDIRECTDRAWSURFACE7 iface,
LPDDSURFACEDESC2 pDDSD, DWORD dwFlags) LPDDSURFACEDESC2 pDDSD, DWORD dwFlags)
{ {
/* XXX */ ICOM_THIS(IDirectDrawSurfaceImpl,iface);
FIXME("(%p)->(%p,%08lx)\n",iface,pDDSD,dwFlags); 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(); abort();
return E_FAIL; hr = E_FAIL;
}
return hr;
} }
/* Unlock: ???, need callback */ /* Unlock: ???, need callback */
......
/* Copyright 2000 TransGaming Technologies Inc. */ /* Copyright 2000-2001 TransGaming Technologies Inc. */
#ifndef DDRAW_DSURFACE_DIB_H_INCLUDED #ifndef DDRAW_DSURFACE_DIB_H_INCLUDED
#define DDRAW_DSURFACE_DIB_H_INCLUDED #define DDRAW_DSURFACE_DIB_H_INCLUDED
......
...@@ -253,6 +253,14 @@ Main_DirectDrawSurface_AddAttachedSurface(LPDIRECTDRAWSURFACE7 iface, ...@@ -253,6 +253,14 @@ Main_DirectDrawSurface_AddAttachedSurface(LPDIRECTDRAWSURFACE7 iface,
/* TODO MSDN: "You can attach only z-buffer surfaces with this method." /* TODO MSDN: "You can attach only z-buffer surfaces with this method."
* But apparently backbuffers and mipmaps can be attached too. */ * 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 /* 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.) */ * attached. (e.g. maybe the Z-buffer tells the renderer to use it.) */
if (!surf->attach(surf, This)) if (!surf->attach(surf, This))
...@@ -333,6 +341,14 @@ Main_DirectDrawSurface_DeleteAttachedSurface(LPDIRECTDRAWSURFACE7 iface, ...@@ -333,6 +341,14 @@ Main_DirectDrawSurface_DeleteAttachedSurface(LPDIRECTDRAWSURFACE7 iface,
surf->detach(surf); 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) if (surf->next_attached)
surf->next_attached->prev_attached = surf->prev_attached; surf->next_attached->prev_attached = surf->prev_attached;
if (surf->prev_attached) if (surf->prev_attached)
...@@ -393,6 +409,18 @@ BOOL Main_DirectDrawSurface_flip_data(IDirectDrawSurfaceImpl* front, ...@@ -393,6 +409,18 @@ BOOL Main_DirectDrawSurface_flip_data(IDirectDrawSurfaceImpl* front,
back->dc_in_use = tmp; 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; return TRUE;
} }
......
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