From 6fb7ed8fa74069c4ab62acc0460e4af108258924 Mon Sep 17 00:00:00 2001 From: Lionel Ulmer Date: Thu, 2 Jan 2003 19:51:25 +0000 Subject: [PATCH] Added 'blt' and 'bltfast' override functions. --- dlls/ddraw/d3ddevice/mesa.c | 38 ++++++++++++++++++++++++++++++++----- dlls/ddraw/d3dtexture.c | 4 ++-- dlls/ddraw/ddraw_private.h | 4 +++- dlls/ddraw/dsurface/dib.c | 10 ++++++++++ 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/dlls/ddraw/d3ddevice/mesa.c b/dlls/ddraw/d3ddevice/mesa.c index 5a5fc92bf17..70b5dd9ab5c 100644 --- a/dlls/ddraw/d3ddevice/mesa.c +++ b/dlls/ddraw/d3ddevice/mesa.c @@ -1685,14 +1685,16 @@ static HRESULT d3ddevice_clear(IDirect3DDeviceImpl *This, TRACE("(%p)->(%08lx,%p,%08lx,%08lx,%f,%08lx)\n", This, dwCount, lpRects, dwFlags, dwColor, dvZ, dwStencil); if (TRACE_ON(ddraw)) { - int i; - TRACE(" rectangles : \n"); - for (i = 0; i < dwCount; i++) { - TRACE(" - %ld x %ld %ld x %ld\n", lpRects[i].u1.x1, lpRects[i].u2.y1, lpRects[i].u3.x2, lpRects[i].u4.y2); + if (dwCount > 0) { + int i; + TRACE(" rectangles : \n"); + for (i = 0; i < dwCount; i++) { + TRACE(" - %ld x %ld %ld x %ld\n", lpRects[i].u1.x1, lpRects[i].u2.y1, lpRects[i].u3.x2, lpRects[i].u4.y2); + } } } - if (dwCount != 1) { + if (dwCount > 1) { WARN(" Warning, this function only for now clears the whole screen...\n"); } @@ -1745,6 +1747,29 @@ static HRESULT d3ddevice_clear(IDirect3DDeviceImpl *This, return DD_OK; } +HRESULT +d3ddevice_blt(IDirectDrawSurfaceImpl *This, LPRECT rdst, + LPDIRECTDRAWSURFACE7 src, LPRECT rsrc, + DWORD dwFlags, LPDDBLTFX lpbltfx) +{ + if (dwFlags & DDBLT_COLORFILL) { + /* This is easy to handle for the D3D Device... */ + DWORD color = lpbltfx->u5.dwFillColor; + TRACE(" executing D3D Device override.\n"); + d3ddevice_clear(This->d3ddevice, 0, NULL, D3DCLEAR_TARGET, color, 0.0, 0x00000000); + return DD_OK; + } + return DDERR_INVALIDPARAMS; +} + +HRESULT +d3ddevice_bltfast(IDirectDrawSurfaceImpl *This, DWORD dstx, + DWORD dsty, LPDIRECTDRAWSURFACE7 src, + LPRECT rsrc, DWORD trans) +{ + return DDERR_INVALIDPARAMS; +} + /* TODO for both these functions : - change / restore OpenGL parameters for pictures transfers in case they are ever modified @@ -1916,6 +1941,9 @@ d3ddevice_create(IDirect3DDeviceImpl **obj, IDirect3DImpl *d3d, IDirectDrawSurfa /* Override the Lock / Unlock function for all these surfaces */ surf->lock_update = d3ddevice_lock_update; surf->unlock_update = d3ddevice_unlock_update; + /* And install also the blt / bltfast overrides */ + surf->aux_blt = d3ddevice_blt; + surf->aux_bltfast = d3ddevice_bltfast; } surf->d3ddevice = object; } diff --git a/dlls/ddraw/d3dtexture.c b/dlls/ddraw/d3dtexture.c index 800b7effa82..96c21eb32c7 100644 --- a/dlls/ddraw/d3dtexture.c +++ b/dlls/ddraw/d3dtexture.c @@ -60,7 +60,7 @@ static void snoop_texture(IDirectDrawSurfaceImpl *This) { /******************************************************************************* * IDirectSurface callback methods */ -HRESULT WINAPI gltex_setcolorkey_cb(IDirectDrawSurfaceImpl *texture, DWORD dwFlags, LPDDCOLORKEY ckey ) +HRESULT gltex_setcolorkey_cb(IDirectDrawSurfaceImpl *texture, DWORD dwFlags, LPDDCOLORKEY ckey ) { DDSURFACEDESC *tex_d; GLuint current_texture; @@ -689,7 +689,7 @@ HRESULT d3dtexture_create(IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *surf, BOOL surf->lock_update = gltex_lock_update; surf->unlock_update = gltex_unlock_update; surf->tex_private = private; - surf->SetColorKey_cb = gltex_setcolorkey_cb; + surf->aux_setcolorkey_cb = gltex_setcolorkey_cb; ENTER_GL(); if (surf->mipmap_level == 0) { diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index 1be6dc4db97..7d444e92669 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -294,7 +294,9 @@ struct IDirectDrawSurfaceImpl void (*aux_release)(LPVOID ctx, LPVOID data); BOOL (*aux_flip)(LPVOID ctx, LPVOID data); void (*aux_unlock)(LPVOID ctx, LPVOID data, LPRECT lpRect); - HRESULT (WINAPI *SetColorKey_cb)(struct IDirectDrawSurfaceImpl *texture, DWORD dwFlags, LPDDCOLORKEY ckey ) ; + HRESULT (*aux_blt)(struct IDirectDrawSurfaceImpl *This, LPRECT rdst, LPDIRECTDRAWSURFACE7 src, LPRECT rsrc, DWORD dwFlags, LPDDBLTFX lpbltfx); + HRESULT (*aux_bltfast)(struct IDirectDrawSurfaceImpl *This, DWORD dstx, DWORD dsty, LPDIRECTDRAWSURFACE7 src, LPRECT rsrc, DWORD trans); + HRESULT (*aux_setcolorkey_cb)(struct IDirectDrawSurfaceImpl *texture, DWORD dwFlags, LPDDCOLORKEY ckey ); /* This is to get the D3DDevice object associated to this surface */ struct IDirect3DDeviceImpl *d3ddevice; /* This is for texture */ diff --git a/dlls/ddraw/dsurface/dib.c b/dlls/ddraw/dsurface/dib.c index 82cebf4fc2f..8a6b4fe9700 100644 --- a/dlls/ddraw/dsurface/dib.c +++ b/dlls/ddraw/dsurface/dib.c @@ -365,6 +365,11 @@ DIB_DirectDrawSurface_Blt(LPDIRECTDRAWSURFACE7 iface, LPRECT rdst, } } + /* First, check if the possible override function handles this case */ + if (This->aux_blt != NULL) { + if (This->aux_blt(This, rdst, src, rsrc, dwFlags, lpbltfx) == DD_OK) return DD_OK; + } + DD_STRUCT_INIT(&ddesc); DD_STRUCT_INIT(&sdesc); @@ -814,6 +819,11 @@ DIB_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dstx, FIXME(" srcrect: NULL\n"); } + /* First, check if the possible override function handles this case */ + if (This->aux_bltfast != NULL) { + if (This->aux_bltfast(This, dstx, dsty, src, rsrc, trans) == DD_OK) return DD_OK; + } + /* We need to lock the surfaces, or we won't get refreshes when done. */ sdesc.dwSize = sizeof(sdesc); IDirectDrawSurface7_Lock(src, NULL,&sdesc,DDLOCK_READONLY, 0);