2000-04-09 16:30:50 +02:00
|
|
|
/* DirectDrawSurface base implementation
|
|
|
|
*
|
|
|
|
* Copyright 1997-2000 Marcus Meissner
|
|
|
|
* Copyright 1998-2000 Lionel Ulmer (most of Direct3D stuff)
|
2001-04-16 21:35:18 +02:00
|
|
|
* Copyright 2000-2001 TransGaming Technologies Inc.
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2000-04-09 16:30:50 +02:00
|
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2003-01-07 21:36:20 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
|
|
|
#include "winerror.h"
|
2002-09-26 05:20:07 +02:00
|
|
|
#include "mesa_private.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2000-04-09 16:30:50 +02:00
|
|
|
#include "ddraw_private.h"
|
2001-01-04 23:44:55 +01:00
|
|
|
#include "dsurface/main.h"
|
|
|
|
#include "ddraw/main.h"
|
|
|
|
#include "dsurface/thunks.h"
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/** Creation/Destruction functions */
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT
|
|
|
|
Main_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl *This,
|
|
|
|
IDirectDrawImpl *pDD,
|
|
|
|
const DDSURFACEDESC2 *pDDSD)
|
|
|
|
{
|
2002-11-04 23:34:11 +01:00
|
|
|
TRACE("(%p)->(%p,%p)\n", This, pDD, pDDSD);
|
|
|
|
|
2001-02-12 04:43:53 +01:00
|
|
|
if (pDDSD != &This->surface_desc) {
|
|
|
|
This->surface_desc.dwSize = sizeof(This->surface_desc);
|
|
|
|
DD_STRUCT_COPY_BYSIZE(&(This->surface_desc),pDDSD);
|
|
|
|
}
|
2001-01-04 23:44:55 +01:00
|
|
|
This->uniqueness_value = 1; /* unchecked */
|
|
|
|
This->ref = 1;
|
|
|
|
|
2001-04-16 21:35:18 +02:00
|
|
|
This->local.lpSurfMore = &This->more;
|
|
|
|
This->local.lpGbl = &This->global;
|
|
|
|
This->local.dwProcessId = GetCurrentProcessId();
|
|
|
|
This->local.dwFlags = 0; /* FIXME */
|
|
|
|
This->local.ddsCaps.dwCaps = This->surface_desc.ddsCaps.dwCaps;
|
|
|
|
/* FIXME: more local stuff */
|
|
|
|
This->more.lpDD_lcl = &pDD->local;
|
|
|
|
This->more.ddsCapsEx.dwCaps2 = This->surface_desc.ddsCaps.dwCaps2;
|
|
|
|
This->more.ddsCapsEx.dwCaps3 = This->surface_desc.ddsCaps.dwCaps3;
|
|
|
|
This->more.ddsCapsEx.dwCaps4 = This->surface_desc.ddsCaps.dwCaps4;
|
|
|
|
/* FIXME: more more stuff */
|
|
|
|
This->gmore = &This->global_more;
|
|
|
|
This->global.u3.lpDD = pDD->local.lpGbl;
|
|
|
|
/* FIXME: more global stuff */
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
This->final_release = Main_DirectDrawSurface_final_release;
|
2001-04-16 21:35:18 +02:00
|
|
|
This->late_allocate = Main_DirectDrawSurface_late_allocate;
|
2001-01-04 23:44:55 +01:00
|
|
|
This->attach = Main_DirectDrawSurface_attach;
|
|
|
|
This->detach = Main_DirectDrawSurface_detach;
|
|
|
|
This->lock_update = Main_DirectDrawSurface_lock_update;
|
|
|
|
This->unlock_update = Main_DirectDrawSurface_unlock_update;
|
|
|
|
This->lose_surface = Main_DirectDrawSurface_lose_surface;
|
|
|
|
This->set_palette = Main_DirectDrawSurface_set_palette;
|
|
|
|
This->update_palette = Main_DirectDrawSurface_update_palette;
|
|
|
|
This->get_display_window = Main_DirectDrawSurface_get_display_window;
|
2001-04-16 21:35:18 +02:00
|
|
|
This->get_gamma_ramp = Main_DirectDrawSurface_get_gamma_ramp;
|
|
|
|
This->set_gamma_ramp = Main_DirectDrawSurface_set_gamma_ramp;
|
2001-01-04 23:44:55 +01:00
|
|
|
|
|
|
|
ICOM_INIT_INTERFACE(This, IDirectDrawSurface3,
|
|
|
|
DDRAW_IDDS3_Thunk_VTable);
|
2001-04-16 21:35:18 +02:00
|
|
|
ICOM_INIT_INTERFACE(This, IDirectDrawGammaControl,
|
|
|
|
DDRAW_IDDGC_VTable);
|
2002-12-16 23:48:20 +01:00
|
|
|
|
2002-12-15 02:17:59 +01:00
|
|
|
/* There is no generic implementation of IDDS7 or texture */
|
2001-01-04 23:44:55 +01:00
|
|
|
|
|
|
|
Main_DirectDraw_AddSurface(pDD, This);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
2000-05-10 00:33:12 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
void Main_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This)
|
|
|
|
{
|
|
|
|
Main_DirectDraw_RemoveSurface(This->ddraw_owner, This);
|
|
|
|
}
|
2000-05-10 00:33:12 +02:00
|
|
|
|
2001-04-16 21:35:18 +02:00
|
|
|
HRESULT Main_DirectDrawSurface_late_allocate(IDirectDrawSurfaceImpl* This)
|
|
|
|
{
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
static void Main_DirectDrawSurface_Destroy(IDirectDrawSurfaceImpl* This)
|
|
|
|
{
|
2003-01-02 20:59:49 +01:00
|
|
|
if (This->palette) {
|
|
|
|
IDirectDrawPalette_Release(ICOM_INTERFACE(This->palette, IDirectDrawPalette));
|
|
|
|
This->palette = NULL;
|
|
|
|
}
|
2001-01-04 23:44:55 +01:00
|
|
|
This->final_release(This);
|
|
|
|
if (This->private != This+1) HeapFree(GetProcessHeap(), 0, This->private);
|
2002-12-15 02:17:59 +01:00
|
|
|
if (This->tex_private) HeapFree(GetProcessHeap(), 0, This->tex_private);
|
2001-01-04 23:44:55 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
void Main_DirectDrawSurface_ForceDestroy(IDirectDrawSurfaceImpl* This)
|
|
|
|
{
|
|
|
|
WARN("destroying surface %p with refcnt %lu\n", This, This->ref);
|
|
|
|
Main_DirectDrawSurface_Destroy(This);
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
ULONG WINAPI Main_DirectDrawSurface_Release(LPDIRECTDRAWSURFACE7 iface)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
|
|
|
|
2002-11-04 23:34:11 +01:00
|
|
|
TRACE("(%p)->(): decreasing from %ld\n", This, This->ref);
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
if (--This->ref == 0)
|
|
|
|
{
|
|
|
|
if (This->aux_release)
|
|
|
|
This->aux_release(This->aux_ctx, This->aux_data);
|
|
|
|
Main_DirectDrawSurface_Destroy(This);
|
2002-11-04 23:34:11 +01:00
|
|
|
|
|
|
|
TRACE("released surface %p\n", This);
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
return 0;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
2001-01-04 23:44:55 +01:00
|
|
|
|
|
|
|
return This->ref;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
ULONG WINAPI Main_DirectDrawSurface_AddRef(LPDIRECTDRAWSURFACE7 iface)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
2000-05-10 00:33:12 +02:00
|
|
|
|
2002-11-04 23:34:11 +01:00
|
|
|
TRACE("(%p)->(): increasing from %ld\n", This, This->ref);
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
return ++This->ref;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_QueryInterface(LPDIRECTDRAWSURFACE7 iface, REFIID riid,
|
|
|
|
LPVOID* ppObj)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
|
|
|
TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppObj);
|
|
|
|
|
2002-12-15 02:17:59 +01:00
|
|
|
*ppObj = NULL;
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
if (IsEqualGUID(&IID_IUnknown, riid)
|
|
|
|
|| IsEqualGUID(&IID_IDirectDrawSurface7, riid)
|
|
|
|
|| IsEqualGUID(&IID_IDirectDrawSurface4, riid))
|
|
|
|
{
|
|
|
|
This->ref++;
|
|
|
|
*ppObj = ICOM_INTERFACE(This, IDirectDrawSurface7);
|
|
|
|
return S_OK;
|
2000-07-12 00:05:21 +02:00
|
|
|
}
|
2001-01-04 23:44:55 +01:00
|
|
|
else if (IsEqualGUID(&IID_IDirectDrawSurface, riid)
|
|
|
|
|| IsEqualGUID(&IID_IDirectDrawSurface2, riid)
|
|
|
|
|| IsEqualGUID(&IID_IDirectDrawSurface3, riid))
|
|
|
|
{
|
|
|
|
This->ref++;
|
|
|
|
*ppObj = ICOM_INTERFACE(This, IDirectDrawSurface3);
|
|
|
|
return S_OK;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
2001-04-16 21:35:18 +02:00
|
|
|
else if (IsEqualGUID(&IID_IDirectDrawGammaControl, riid))
|
|
|
|
{
|
|
|
|
This->ref++;
|
|
|
|
*ppObj = ICOM_INTERFACE(This, IDirectDrawGammaControl);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2002-09-26 05:20:07 +02:00
|
|
|
#ifdef HAVE_OPENGL
|
2002-11-21 22:04:16 +01:00
|
|
|
else if ( IsEqualGUID( &IID_D3DDEVICE_OpenGL, riid ) ||
|
|
|
|
IsEqualGUID( &IID_IDirect3DHALDevice, riid) )
|
2002-09-26 05:20:07 +02:00
|
|
|
{
|
2002-11-21 22:04:16 +01:00
|
|
|
IDirect3DDeviceImpl *d3ddevimpl;
|
|
|
|
HRESULT ret_value;
|
|
|
|
|
2002-11-27 22:38:28 +01:00
|
|
|
ret_value = d3ddevice_create(&d3ddevimpl, This->ddraw_owner->d3d, This);
|
2002-11-21 22:04:16 +01:00
|
|
|
if (FAILED(ret_value)) return ret_value;
|
|
|
|
|
|
|
|
*ppObj = ICOM_INTERFACE(d3ddevimpl, IDirect3DDevice);
|
|
|
|
TRACE(" returning Direct3DDevice interface at %p.\n", *ppObj);
|
|
|
|
|
|
|
|
This->ref++; /* No idea if this is correct.. Need to check using real Windows */
|
|
|
|
return ret_value;
|
2002-09-26 05:20:07 +02:00
|
|
|
}
|
2002-12-15 02:17:59 +01:00
|
|
|
else if (IsEqualGUID( &IID_IDirect3DTexture, riid ) ||
|
|
|
|
IsEqualGUID( &IID_IDirect3DTexture2, riid ))
|
2002-09-26 05:20:07 +02:00
|
|
|
{
|
2002-12-15 02:17:59 +01:00
|
|
|
HRESULT ret_value = S_OK;
|
|
|
|
|
|
|
|
if ((This->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE) == 0) return E_NOINTERFACE;
|
2003-01-02 20:39:57 +01:00
|
|
|
|
|
|
|
/* In case the texture surface was created before the D3D creation */
|
2002-12-16 23:48:20 +01:00
|
|
|
if (This->tex_private == NULL) {
|
2002-12-15 02:17:59 +01:00
|
|
|
if (This->ddraw_owner->d3d == NULL) {
|
|
|
|
ERR("Texture created with no D3D object yet.. Not supported !\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2003-01-02 20:39:57 +01:00
|
|
|
ret_value = This->ddraw_owner->d3d->create_texture(This->ddraw_owner->d3d, This, FALSE, This->mip_main);
|
2002-12-15 02:17:59 +01:00
|
|
|
if (FAILED(ret_value)) return ret_value;
|
|
|
|
}
|
|
|
|
if (IsEqualGUID( &IID_IDirect3DTexture, riid )) {
|
|
|
|
*ppObj = ICOM_INTERFACE(This, IDirect3DTexture);
|
|
|
|
TRACE(" returning Direct3DTexture interface at %p.\n", *ppObj);
|
|
|
|
} else {
|
|
|
|
*ppObj = ICOM_INTERFACE(This, IDirect3DTexture2);
|
|
|
|
TRACE(" returning Direct3DTexture2 interface at %p.\n", *ppObj);
|
|
|
|
}
|
|
|
|
This->ref++;
|
2002-11-21 22:04:16 +01:00
|
|
|
return ret_value;
|
2002-10-11 01:27:32 +02:00
|
|
|
}
|
2002-09-26 05:20:07 +02:00
|
|
|
#endif
|
2002-11-21 22:04:16 +01:00
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/*** Callbacks */
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
BOOL
|
|
|
|
Main_DirectDrawSurface_attach(IDirectDrawSurfaceImpl *This,
|
|
|
|
IDirectDrawSurfaceImpl *to)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
BOOL Main_DirectDrawSurface_detach(IDirectDrawSurfaceImpl *This)
|
|
|
|
{
|
|
|
|
return TRUE;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
void
|
2001-09-11 01:12:16 +02:00
|
|
|
Main_DirectDrawSurface_lock_update(IDirectDrawSurfaceImpl* This, LPCRECT pRect,
|
|
|
|
DWORD dwFlags)
|
2001-01-04 23:44:55 +01:00
|
|
|
{
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
void
|
|
|
|
Main_DirectDrawSurface_unlock_update(IDirectDrawSurfaceImpl* This,
|
|
|
|
LPCRECT pRect)
|
|
|
|
{
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
void
|
|
|
|
Main_DirectDrawSurface_lose_surface(IDirectDrawSurfaceImpl* This)
|
|
|
|
{
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
void
|
|
|
|
Main_DirectDrawSurface_set_palette(IDirectDrawSurfaceImpl* This,
|
|
|
|
IDirectDrawPaletteImpl* pal)
|
|
|
|
{
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
void
|
|
|
|
Main_DirectDrawSurface_update_palette(IDirectDrawSurfaceImpl* This,
|
|
|
|
IDirectDrawPaletteImpl* pal,
|
|
|
|
DWORD dwStart, DWORD dwCount,
|
|
|
|
LPPALETTEENTRY palent)
|
|
|
|
{
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HWND
|
|
|
|
Main_DirectDrawSurface_get_display_window(IDirectDrawSurfaceImpl* This)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2000-11-28 00:06:36 +01:00
|
|
|
|
2001-04-16 21:35:18 +02:00
|
|
|
HRESULT
|
|
|
|
Main_DirectDrawSurface_get_gamma_ramp(IDirectDrawSurfaceImpl* This,
|
|
|
|
DWORD dwFlags,
|
|
|
|
LPDDGAMMARAMP lpGammaRamp)
|
|
|
|
{
|
|
|
|
HDC hDC;
|
|
|
|
HRESULT hr;
|
|
|
|
hr = This->get_dc(This, &hDC);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
hr = GetDeviceGammaRamp(hDC, lpGammaRamp) ? DD_OK : DDERR_UNSUPPORTED;
|
|
|
|
This->release_dc(This, hDC);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
Main_DirectDrawSurface_set_gamma_ramp(IDirectDrawSurfaceImpl* This,
|
|
|
|
DWORD dwFlags,
|
|
|
|
LPDDGAMMARAMP lpGammaRamp)
|
|
|
|
{
|
|
|
|
HDC hDC;
|
|
|
|
HRESULT hr;
|
|
|
|
hr = This->get_dc(This, &hDC);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
hr = SetDeviceGammaRamp(hDC, lpGammaRamp) ? DD_OK : DDERR_UNSUPPORTED;
|
|
|
|
This->release_dc(This, hDC);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/*** Interface functions */
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_AddAttachedSurface(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
LPDIRECTDRAWSURFACE7 pAttach)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
|
|
|
IDirectDrawSurfaceImpl* surf = ICOM_OBJECT(IDirectDrawSurfaceImpl,
|
|
|
|
IDirectDrawSurface7, pAttach);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
TRACE("(%p)->(%p)\n",This,pAttach);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/* Does windows check this? */
|
|
|
|
if (surf == This)
|
|
|
|
return DDERR_CANNOTATTACHSURFACE; /* unchecked */
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/* Does windows check this? */
|
|
|
|
if (surf->ddraw_owner != This->ddraw_owner)
|
|
|
|
return DDERR_CANNOTATTACHSURFACE; /* unchecked */
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
if (surf->surface_owner != NULL)
|
|
|
|
return DDERR_SURFACEALREADYATTACHED; /* unchecked */
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/* TODO MSDN: "You can attach only z-buffer surfaces with this method."
|
|
|
|
* But apparently backbuffers and mipmaps can be attached too. */
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-04-17 19:36:28 +02:00
|
|
|
/* 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) */
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/* 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))
|
|
|
|
return DDERR_CANNOTATTACHSURFACE;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/* check: Where should it go in the chain? This puts it on the head. */
|
|
|
|
if (This->attached)
|
|
|
|
This->attached->prev_attached = surf;
|
|
|
|
surf->next_attached = This->attached;
|
|
|
|
surf->prev_attached = NULL;
|
|
|
|
This->attached = surf;
|
|
|
|
surf->surface_owner = This;
|
|
|
|
|
|
|
|
IDirectDrawSurface7_AddRef(pAttach);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/* MSDN: "not currently implemented." */
|
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_AddOverlayDirtyRect(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
LPRECT pRect)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%p)\n",iface,pRect);
|
|
|
|
return DDERR_UNSUPPORTED; /* unchecked */
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/* MSDN: "not currently implemented." */
|
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_BltBatch(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
LPDDBLTBATCH pBatch, DWORD dwCount,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%p,%ld,%08lx)\n",iface,pBatch,dwCount,dwFlags);
|
|
|
|
return DDERR_UNSUPPORTED; /* unchecked */
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_ChangeUniquenessValue(LPDIRECTDRAWSURFACE7 iface)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
|
|
|
volatile IDirectDrawSurfaceImpl* vThis = This;
|
|
|
|
|
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
/* A uniquness value of 0 is apparently special.
|
|
|
|
* This needs to be checked. */
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
DWORD old_uniqueness_value = vThis->uniqueness_value;
|
|
|
|
DWORD new_uniqueness_value = old_uniqueness_value+1;
|
|
|
|
|
|
|
|
if (old_uniqueness_value == 0) break;
|
|
|
|
if (new_uniqueness_value == 0) new_uniqueness_value = 1;
|
|
|
|
|
2001-08-09 23:21:13 +02:00
|
|
|
if (InterlockedCompareExchange((LONG*)&vThis->uniqueness_value,
|
|
|
|
old_uniqueness_value,
|
|
|
|
new_uniqueness_value)
|
|
|
|
== old_uniqueness_value)
|
2001-01-04 23:44:55 +01:00
|
|
|
break;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_DeleteAttachedSurface(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
DWORD dwFlags,
|
|
|
|
LPDIRECTDRAWSURFACE7 pAttach)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
|
|
|
IDirectDrawSurfaceImpl* surf = ICOM_OBJECT(IDirectDrawSurfaceImpl,
|
|
|
|
IDirectDrawSurface7, pAttach);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%08lx,%p)\n",This,dwFlags,pAttach);
|
|
|
|
|
|
|
|
if (!surf || (surf->surface_owner != This))
|
|
|
|
return DDERR_SURFACENOTATTACHED; /* unchecked */
|
|
|
|
|
|
|
|
surf->detach(surf);
|
|
|
|
|
2001-04-17 19:36:28 +02:00
|
|
|
/* 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 */
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
if (surf->next_attached)
|
|
|
|
surf->next_attached->prev_attached = surf->prev_attached;
|
|
|
|
if (surf->prev_attached)
|
|
|
|
surf->prev_attached->next_attached = surf->next_attached;
|
|
|
|
if (This->attached == surf)
|
|
|
|
This->attached = surf->next_attached;
|
|
|
|
|
|
|
|
IDirectDrawSurface7_Release(pAttach);
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_EnumAttachedSurfaces(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
LPVOID context,
|
|
|
|
LPDDENUMSURFACESCALLBACK7 cb)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
|
|
|
IDirectDrawSurfaceImpl* surf;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p,%p)\n",This,context,cb);
|
|
|
|
|
|
|
|
for (surf = This->attached; surf != NULL; surf = surf->next_attached)
|
|
|
|
{
|
|
|
|
/* check: != DDENUMRET_OK or == DDENUMRET_CANCEL? */
|
|
|
|
if (cb(ICOM_INTERFACE(surf, IDirectDrawSurface7), &surf->surface_desc,
|
|
|
|
context) == DDENUMRET_CANCEL)
|
|
|
|
break;
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_EnumOverlayZOrders(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
DWORD dwFlags, LPVOID context,
|
|
|
|
LPDDENUMSURFACESCALLBACK7 cb)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%08lx,%p,%p)\n",iface,dwFlags,context,cb);
|
|
|
|
return DD_OK;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2001-04-16 21:06:13 +02:00
|
|
|
BOOL Main_DirectDrawSurface_flip_data(IDirectDrawSurfaceImpl* front,
|
|
|
|
IDirectDrawSurfaceImpl* back,
|
|
|
|
DWORD dwFlags)
|
2001-01-04 23:44:55 +01:00
|
|
|
{
|
|
|
|
/* uniqueness_value? */
|
|
|
|
/* This is necessary. But is it safe? */
|
|
|
|
{
|
|
|
|
HDC tmp = front->hDC;
|
|
|
|
front->hDC = back->hDC;
|
|
|
|
back->hDC = tmp;
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
{
|
|
|
|
BOOL tmp = front->dc_in_use;
|
|
|
|
front->dc_in_use = back->dc_in_use;
|
|
|
|
back->dc_in_use = tmp;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
2001-04-16 21:06:13 +02:00
|
|
|
|
2001-04-17 19:36:28 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2001-04-16 21:06:13 +02:00
|
|
|
return TRUE;
|
2001-01-04 23:44:55 +01:00
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_Flip(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
LPDIRECTDRAWSURFACE7 override, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
|
|
|
IDirectDrawSurfaceImpl* target;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p,%08lx)\n",This,override,dwFlags);
|
|
|
|
|
|
|
|
/* MSDN: "This method can be called only for a surface that has the
|
|
|
|
* DDSCAPS_FLIP and DDSCAPS_FRONTBUFFER capabilities." */
|
|
|
|
if ((This->surface_desc.ddsCaps.dwCaps&(DDSCAPS_FLIP|DDSCAPS_FRONTBUFFER))
|
|
|
|
!= (DDSCAPS_FLIP|DDSCAPS_FRONTBUFFER))
|
|
|
|
return DDERR_NOTFLIPPABLE;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
if (This->aux_flip)
|
|
|
|
if (This->aux_flip(This->aux_ctx, This->aux_data))
|
|
|
|
return DD_OK;
|
|
|
|
|
|
|
|
/* 1. find the flip target */
|
|
|
|
/* XXX I don't think this algorithm works for more than 1 backbuffer. */
|
|
|
|
if (override == NULL)
|
|
|
|
{
|
2001-01-13 00:18:22 +01:00
|
|
|
static DDSCAPS2 back_caps = { DDSCAPS_BACKBUFFER };
|
2001-01-04 23:44:55 +01:00
|
|
|
LPDIRECTDRAWSURFACE7 tgt;
|
|
|
|
|
|
|
|
hr = IDirectDrawSurface7_GetAttachedSurface(iface, &back_caps, &tgt);
|
|
|
|
if (FAILED(hr)) return DDERR_NOTFLIPPABLE; /* unchecked */
|
|
|
|
|
|
|
|
target = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7,
|
|
|
|
tgt);
|
|
|
|
IDirectDrawSurface7_Release(tgt);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BOOL on_chain = FALSE;
|
|
|
|
IDirectDrawSurfaceImpl* surf;
|
|
|
|
|
|
|
|
/* MSDN: "The method fails if the specified [override] surface is not
|
|
|
|
* a member of the flipping chain." */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/* Verify that override is on this flip chain. We assume that
|
|
|
|
* surf is the head of the flipping chain, because it's the front
|
|
|
|
* buffer. */
|
|
|
|
target = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7,
|
|
|
|
override);
|
|
|
|
|
|
|
|
/* Either target is (indirectly) attached to This or This is
|
|
|
|
* (indirectly) attached to target. */
|
|
|
|
for (surf = target; surf != NULL; surf = surf->surface_owner)
|
|
|
|
{
|
|
|
|
if (surf == This)
|
|
|
|
{
|
|
|
|
on_chain = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
2001-01-04 23:44:55 +01:00
|
|
|
|
|
|
|
if (!on_chain)
|
|
|
|
return DDERR_INVALIDPARAMS; /* unchecked */
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
2000-08-28 21:31:18 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
TRACE("flip to backbuffer: %p\n",target);
|
2001-04-16 21:06:13 +02:00
|
|
|
if (This->flip_data(This, target, dwFlags))
|
|
|
|
This->flip_update(This, dwFlags);
|
2001-01-04 23:44:55 +01:00
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
static PrivateData* find_private_data(IDirectDrawSurfaceImpl *This,
|
|
|
|
REFGUID tag)
|
|
|
|
{
|
|
|
|
PrivateData* data;
|
|
|
|
for (data = This->private_data; data != NULL; data = data->next)
|
|
|
|
{
|
|
|
|
if (IsEqualGUID(&data->tag, tag)) break;
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
return data;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_FreePrivateData(LPDIRECTDRAWSURFACE7 iface, REFGUID tag)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
|
|
|
PrivateData *data;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
data = find_private_data(This, tag);
|
|
|
|
if (data == NULL) return DDERR_NOTFOUND;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
if (data->prev)
|
|
|
|
data->prev->next = data->next;
|
|
|
|
if (data->next)
|
|
|
|
data->next->prev = data->prev;
|
|
|
|
|
|
|
|
if (data->flags & DDSPD_IUNKNOWNPTR)
|
|
|
|
{
|
|
|
|
if (data->ptr.object != NULL)
|
|
|
|
IUnknown_Release(data->ptr.object);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
HeapFree(GetProcessHeap(), 0, data->ptr.data);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_GetAttachedSurface(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
LPDDSCAPS2 pCaps,
|
|
|
|
LPDIRECTDRAWSURFACE7* ppSurface)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
|
|
|
IDirectDrawSurfaceImpl* surf;
|
|
|
|
IDirectDrawSurfaceImpl* found = NULL;
|
2002-11-04 23:34:11 +01:00
|
|
|
DDSCAPS2 our_caps;
|
|
|
|
|
|
|
|
if (TRACE_ON(ddraw)) {
|
|
|
|
TRACE("(%p)->Looking for caps: %lx,%lx,%lx,%lx output: %p\n",This,pCaps->dwCaps, pCaps->dwCaps2,
|
|
|
|
pCaps->dwCaps3, pCaps->dwCaps4, ppSurface);
|
2003-03-15 01:12:42 +01:00
|
|
|
TRACE(" Caps are : "); DDRAW_dump_DDSCAPS2(pCaps); TRACE("\n");
|
2002-11-04 23:34:11 +01:00
|
|
|
}
|
2001-01-04 23:44:55 +01:00
|
|
|
|
2002-11-04 23:34:11 +01:00
|
|
|
our_caps = *pCaps;
|
|
|
|
if ((This->ddraw_owner->local.dwLocalFlags & DDRAWILCL_DIRECTDRAW7) == 0) {
|
|
|
|
/* As this is not a DirectDraw7 application, remove the garbage that some games
|
|
|
|
put in the new fields of the DDSCAPS2 structure. */
|
|
|
|
our_caps.dwCaps2 = 0;
|
|
|
|
our_caps.dwCaps3 = 0;
|
|
|
|
our_caps.dwCaps4 = 0;
|
|
|
|
if (TRACE_ON(ddraw)) {
|
2003-03-15 01:12:42 +01:00
|
|
|
TRACE(" Real caps are : "); DDRAW_dump_DDSCAPS2(&our_caps); TRACE("\n");
|
2002-11-04 23:34:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
for (surf = This->attached; surf != NULL; surf = surf->next_attached)
|
|
|
|
{
|
2002-11-04 23:34:11 +01:00
|
|
|
if (TRACE_ON(ddraw)) {
|
|
|
|
TRACE("Surface: (%p) caps: %lx,%lx,%lx,%lx \n",surf ,
|
|
|
|
surf->surface_desc.ddsCaps.dwCaps,
|
|
|
|
surf->surface_desc.ddsCaps.dwCaps2,
|
|
|
|
surf->surface_desc.ddsCaps.dwCaps3,
|
|
|
|
surf->surface_desc.ddsCaps.dwCaps4);
|
2003-03-15 01:12:42 +01:00
|
|
|
TRACE(" Surface caps are : "); DDRAW_dump_DDSCAPS2(&(surf->surface_desc.ddsCaps)); TRACE("\n");
|
2002-11-04 23:34:11 +01:00
|
|
|
}
|
|
|
|
if (((surf->surface_desc.ddsCaps.dwCaps & our_caps.dwCaps) == our_caps.dwCaps) &&
|
|
|
|
((surf->surface_desc.ddsCaps.dwCaps2 & our_caps.dwCaps2) == our_caps.dwCaps2))
|
2001-01-04 23:44:55 +01:00
|
|
|
{
|
|
|
|
/* MSDN: "This method fails if more than one surface is attached
|
|
|
|
* that matches the capabilities requested." */
|
|
|
|
if (found != NULL)
|
|
|
|
{
|
|
|
|
FIXME("More than one attached surface matches requested caps. What should we do here?\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
/* Previous code returned 'DDERR_NOTFOUND'. That appears not
|
|
|
|
to be correct, given what 3DMark expects from MipMapped surfaces.
|
2001-01-04 23:44:55 +01:00
|
|
|
We shall just continue instead. */
|
|
|
|
}
|
|
|
|
|
|
|
|
found = surf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-04 23:34:11 +01:00
|
|
|
if (found == NULL) {
|
|
|
|
TRACE("Did not find any valid surface\n");
|
2001-01-04 23:44:55 +01:00
|
|
|
return DDERR_NOTFOUND;
|
2002-11-04 23:34:11 +01:00
|
|
|
}
|
2001-01-04 23:44:55 +01:00
|
|
|
|
|
|
|
*ppSurface = ICOM_INTERFACE(found, IDirectDrawSurface7);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2002-11-04 23:34:11 +01:00
|
|
|
if (TRACE_ON(ddraw)) {
|
|
|
|
TRACE("Returning surface %p with description : \n", *ppSurface);
|
|
|
|
DDRAW_dump_surface_desc(&(found->surface_desc));
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/* XXX d3dframe.cpp sometimes AddRefs things that it gets from us. */
|
|
|
|
IDirectDrawSurface7_AddRef(ICOM_INTERFACE(found, IDirectDrawSurface7));
|
2000-04-09 16:30:50 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_GetBltStatus(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%08lx)\n",iface,dwFlags);
|
|
|
|
|
|
|
|
switch (dwFlags)
|
|
|
|
{
|
|
|
|
case DDGBS_CANBLT:
|
|
|
|
case DDGBS_ISBLTDONE:
|
|
|
|
return DD_OK;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return DDERR_INVALIDPARAMS;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
2001-01-04 23:44:55 +01:00
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_GetCaps(LPDIRECTDRAWSURFACE7 iface, LPDDSCAPS2 pCaps)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n",This,pCaps);
|
|
|
|
*pCaps = This->surface_desc.ddsCaps;
|
2000-04-09 16:30:50 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_GetClipper(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
LPDIRECTDRAWCLIPPER* ppClipper)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
TRACE("(%p)->(%p)\n",This,ppClipper);
|
|
|
|
if (This->clipper == NULL)
|
|
|
|
return DDERR_NOCLIPPERATTACHED;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
*ppClipper = ICOM_INTERFACE(This->clipper, IDirectDrawClipper);
|
|
|
|
IDirectDrawClipper_AddRef(ICOM_INTERFACE(This->clipper,
|
|
|
|
IDirectDrawClipper));
|
|
|
|
return DD_OK;
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_GetColorKey(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags,
|
|
|
|
LPDDCOLORKEY pCKey)
|
|
|
|
{
|
|
|
|
/* There is a DDERR_NOCOLORKEY error, but how do we know if a color key
|
|
|
|
* isn't there? That's like saying that an int isn't there. (Which MS
|
|
|
|
* has done in other docs.) */
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
TRACE("(%p)->(%08lx,%p)\n",This,dwFlags,pCKey);
|
2003-01-03 22:16:03 +01:00
|
|
|
if (TRACE_ON(ddraw)) {
|
|
|
|
TRACE(" - colorkey flags : ");
|
|
|
|
DDRAW_dump_colorkeyflag(dwFlags);
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
switch (dwFlags)
|
|
|
|
{
|
|
|
|
case DDCKEY_DESTBLT:
|
|
|
|
*pCKey = This->surface_desc.ddckCKDestBlt;
|
|
|
|
break;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
case DDCKEY_DESTOVERLAY:
|
|
|
|
*pCKey = This->surface_desc.u3.ddckCKDestOverlay;
|
|
|
|
break;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
case DDCKEY_SRCBLT:
|
|
|
|
*pCKey = This->surface_desc.ddckCKSrcBlt;
|
|
|
|
break;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
case DDCKEY_SRCOVERLAY:
|
|
|
|
*pCKey = This->surface_desc.ddckCKSrcOverlay;
|
|
|
|
break;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
default:
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
return DD_OK;
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/* XXX We need to do something with the DC if the surface gets lost. */
|
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_GetDC(LPDIRECTDRAWSURFACE7 iface, HDC *phDC)
|
|
|
|
{
|
|
|
|
DDSURFACEDESC2 ddsd;
|
|
|
|
HRESULT hr;
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
TRACE("(%p)->(%p)\n",This,phDC);
|
|
|
|
CHECK_LOST(This);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
LOCK_OBJECT(This);
|
2000-05-15 00:53:51 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
if (This->dc_in_use)
|
|
|
|
{
|
|
|
|
UNLOCK_OBJECT(This);
|
|
|
|
return DDERR_DCALREADYCREATED;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/* Lock as per MSDN.
|
|
|
|
* Strange: Lock lists DDERR_SURFACEBUSY as an error, meaning that another
|
|
|
|
* thread has it locked, but GetDC does not. */
|
|
|
|
ddsd.dwSize = sizeof(ddsd);
|
2001-09-11 01:12:16 +02:00
|
|
|
hr = IDirectDrawSurface7_Lock(iface, NULL, &ddsd, DDLOCK_READONLY, 0);
|
2001-01-04 23:44:55 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
UNLOCK_OBJECT(This);
|
|
|
|
return hr;
|
2000-05-15 00:53:51 +02:00
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
hr = This->get_dc(This, &This->hDC);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2002-10-19 01:48:57 +02:00
|
|
|
TRACE("returning %p\n",This->hDC);
|
2001-01-04 23:44:55 +01:00
|
|
|
|
|
|
|
*phDC = This->hDC;
|
|
|
|
This->dc_in_use = TRUE;
|
2000-05-15 00:53:51 +02:00
|
|
|
}
|
2001-01-04 23:44:55 +01:00
|
|
|
else WARN("No DC! Prepare for trouble\n");
|
|
|
|
|
|
|
|
UNLOCK_OBJECT(This);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_GetDDInterface(LPDIRECTDRAWSURFACE7 iface, LPVOID* pDD)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
TRACE("(%p)->(%p)\n",This,pDD);
|
|
|
|
*pDD = ICOM_INTERFACE(This->ddraw_owner, IDirectDraw7);
|
|
|
|
IDirectDraw7_AddRef(ICOM_INTERFACE(This->ddraw_owner, IDirectDraw7));
|
2000-04-09 16:30:50 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_GetFlipStatus(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
/* XXX: DDERR_INVALIDSURFACETYPE */
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
TRACE("(%p)->(%08lx)\n",iface,dwFlags);
|
|
|
|
switch (dwFlags)
|
|
|
|
{
|
|
|
|
case DDGFS_CANFLIP:
|
|
|
|
case DDGFS_ISFLIPDONE:
|
|
|
|
return DD_OK;
|
2000-05-15 00:53:51 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
default:
|
|
|
|
return DDERR_INVALIDPARAMS;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
2001-01-04 23:44:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_GetLOD(LPDIRECTDRAWSURFACE7 iface, LPDWORD pdwMaxLOD)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n",This,pdwMaxLOD);
|
|
|
|
CHECK_TEXTURE(This);
|
|
|
|
|
|
|
|
*pdwMaxLOD = This->max_lod;
|
2000-04-09 16:30:50 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_GetOverlayPosition(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
LPLONG pX, LPLONG pY)
|
|
|
|
{
|
|
|
|
return DDERR_NOTAOVERLAYSURFACE;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_GetPalette(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
LPDIRECTDRAWPALETTE* ppPalette)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n",This,ppPalette);
|
|
|
|
if (This->palette == NULL)
|
|
|
|
return DDERR_NOPALETTEATTACHED;
|
|
|
|
|
|
|
|
*ppPalette = ICOM_INTERFACE(This->palette, IDirectDrawPalette);
|
|
|
|
IDirectDrawPalette_AddRef(ICOM_INTERFACE(This->palette,
|
|
|
|
IDirectDrawPalette));
|
|
|
|
return DD_OK;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_GetPixelFormat(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
LPDDPIXELFORMAT pDDPixelFormat)
|
|
|
|
{
|
|
|
|
/* What is DDERR_INVALIDSURFACETYPE for here? */
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n",This,pDDPixelFormat);
|
2001-02-12 04:43:53 +01:00
|
|
|
DD_STRUCT_COPY_BYSIZE(pDDPixelFormat,&This->surface_desc.u4.ddpfPixelFormat);
|
2000-04-09 16:30:50 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_GetPriority(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
LPDWORD pdwPriority)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n",This,pdwPriority);
|
|
|
|
CHECK_TEXTURE(This);
|
|
|
|
|
|
|
|
*pdwPriority = This->priority;
|
2000-04-09 16:30:50 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_GetPrivateData(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
REFGUID tag, LPVOID pBuffer,
|
|
|
|
LPDWORD pcbBufferSize)
|
2000-04-09 16:30:50 +02:00
|
|
|
{
|
2001-01-04 23:44:55 +01:00
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
|
|
|
PrivateData* data;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
data = find_private_data(This, tag);
|
|
|
|
if (data == NULL) return DDERR_NOTFOUND;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/* This may not be right. */
|
|
|
|
if ((data->flags & DDSPD_VOLATILE)
|
|
|
|
&& data->uniqueness_value != This->uniqueness_value)
|
|
|
|
return DDERR_EXPIRED;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
if (*pcbBufferSize < data->size)
|
|
|
|
{
|
|
|
|
*pcbBufferSize = data->size;
|
|
|
|
return DDERR_MOREDATA;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
if (data->flags & DDSPD_IUNKNOWNPTR)
|
|
|
|
{
|
|
|
|
*(LPUNKNOWN *)pBuffer = data->ptr.object;
|
|
|
|
IUnknown_AddRef(data->ptr.object);
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
2001-01-04 23:44:55 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
memcpy(pBuffer, data->ptr.data, data->size);
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
2001-01-04 23:44:55 +01:00
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_GetSurfaceDesc(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
LPDDSURFACEDESC2 pDDSD)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
TRACE("(%p)->(%p)\n",This,pDDSD);
|
2002-06-01 01:06:46 +02:00
|
|
|
if ((pDDSD->dwSize < sizeof(DDSURFACEDESC)) ||
|
2001-01-29 00:15:17 +01:00
|
|
|
(pDDSD->dwSize > sizeof(DDSURFACEDESC2))) {
|
|
|
|
ERR("Impossible/Strange struct size %ld.\n",pDDSD->dwSize);
|
|
|
|
return DDERR_GENERIC;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-01-29 00:15:17 +01:00
|
|
|
DD_STRUCT_COPY_BYSIZE(pDDSD,&This->surface_desc);
|
2002-07-16 03:16:14 +02:00
|
|
|
if (TRACE_ON(ddraw)) {
|
|
|
|
DDRAW_dump_surface_desc(pDDSD);
|
|
|
|
}
|
2001-01-04 23:44:55 +01:00
|
|
|
return DD_OK;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_GetUniquenessValue(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
LPDWORD pValue)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n",This,pValue);
|
|
|
|
*pValue = This->uniqueness_value;
|
2000-04-09 16:30:50 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_Initialize(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
LPDIRECTDRAW pDD, LPDDSURFACEDESC2 pDDSD)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%p,%p)\n",iface,pDD,pDDSD);
|
|
|
|
return DDERR_ALREADYINITIALIZED;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_IsLost(LPDIRECTDRAWSURFACE7 iface)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
TRACE("(%p) is%s lost\n",This, (This->lost ? "" : " not"));
|
|
|
|
return This->lost ? DDERR_SURFACELOST : DD_OK;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/* XXX This doesn't actually do any locking or keep track of the locked
|
|
|
|
* rectangles. The behaviour is poorly documented. */
|
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_Lock(LPDIRECTDRAWSURFACE7 iface, LPRECT prect,
|
|
|
|
LPDDSURFACEDESC2 pDDSD, DWORD flags, HANDLE h)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
|
|
|
|
2002-11-25 03:42:04 +01:00
|
|
|
if (TRACE_ON(ddraw)) {
|
|
|
|
TRACE("(%p)->Lock(%p,%p,%08lx,%08lx)\n",This,prect,pDDSD,flags,(DWORD)h);
|
|
|
|
TRACE(" - locking flags : "); DDRAW_dump_lockflag(flags);
|
|
|
|
}
|
2002-12-23 03:04:12 +01:00
|
|
|
if (WARN_ON(ddraw)) {
|
2002-12-23 03:09:20 +01:00
|
|
|
if (flags & ~(DDLOCK_WAIT|DDLOCK_READONLY|DDLOCK_WRITEONLY)) {
|
2002-12-23 03:04:12 +01:00
|
|
|
WARN(" - unsupported locking flag : "); DDRAW_dump_lockflag(flags & ~(DDLOCK_WAIT|DDLOCK_READONLY|DDLOCK_WRITEONLY));
|
2002-12-23 03:09:20 +01:00
|
|
|
}
|
2002-12-23 03:04:12 +01:00
|
|
|
}
|
2001-01-04 23:44:55 +01:00
|
|
|
|
|
|
|
/* First, copy the Surface description */
|
2001-02-12 04:43:53 +01:00
|
|
|
DD_STRUCT_COPY_BYSIZE(pDDSD,&(This->surface_desc));
|
|
|
|
|
2002-10-11 00:47:02 +02:00
|
|
|
TRACE("locked surface returning description : \n");
|
|
|
|
if (TRACE_ON(ddraw)) DDRAW_dump_surface_desc(pDDSD);
|
2002-11-27 22:38:28 +01:00
|
|
|
|
|
|
|
/* Used to optimize the D3D Device locking */
|
|
|
|
This->lastlocktype = flags & (DDLOCK_READONLY|DDLOCK_WRITEONLY);
|
2002-10-11 00:47:02 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/* If asked only for a part, change the surface pointer.
|
|
|
|
* (Not documented.) */
|
|
|
|
if (prect != NULL) {
|
2003-01-08 22:09:25 +01:00
|
|
|
TRACE(" lprect: %ldx%ld-%ldx%ld\n",
|
2001-01-04 23:44:55 +01:00
|
|
|
prect->top,prect->left,prect->bottom,prect->right
|
|
|
|
);
|
|
|
|
if ((prect->top < 0) ||
|
|
|
|
(prect->left < 0) ||
|
|
|
|
(prect->bottom < 0) ||
|
|
|
|
(prect->right < 0)) {
|
|
|
|
ERR(" Negative values in LPRECT !!!\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2001-09-11 01:12:16 +02:00
|
|
|
This->lock_update(This, prect, flags);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
pDDSD->lpSurface = (char *)This->surface_desc.lpSurface
|
|
|
|
+ prect->top * This->surface_desc.u1.lPitch
|
|
|
|
+ prect->left * GET_BPP(This->surface_desc);
|
2001-09-11 01:12:16 +02:00
|
|
|
} else {
|
|
|
|
This->lock_update(This, NULL, flags);
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
2001-01-04 23:44:55 +01:00
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_PageLock(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
/* Some surface types should return DDERR_CANTPAGELOCK. */
|
|
|
|
return DD_OK;
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_PageUnlock(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
/* Some surface types should return DDERR_CANTPAGEUNLOCK, and we should
|
|
|
|
* keep track so we can return DDERR_NOTPAGELOCKED as appropriate. */
|
2000-04-09 16:30:50 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_ReleaseDC(LPDIRECTDRAWSURFACE7 iface, HDC hDC)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2002-10-19 01:48:57 +02:00
|
|
|
TRACE("(%p)->(%p)\n",This,hDC);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
if (!This->dc_in_use || This->hDC != hDC)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
This->release_dc(This, hDC);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
hr = IDirectDrawSurface7_Unlock(iface, NULL);
|
|
|
|
if (FAILED(hr)) return hr;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
This->dc_in_use = FALSE;
|
|
|
|
This->hDC = 0;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/* Restore */
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_SetClipper(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
LPDIRECTDRAWCLIPPER pDDClipper)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n",This,pDDClipper);
|
|
|
|
if (pDDClipper == ICOM_INTERFACE(This->clipper, IDirectDrawClipper))
|
|
|
|
return DD_OK;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
if (This->clipper != NULL)
|
|
|
|
IDirectDrawClipper_Release(ICOM_INTERFACE(This->clipper,
|
|
|
|
IDirectDrawClipper));
|
|
|
|
|
|
|
|
This->clipper = ICOM_OBJECT(IDirectDrawClipperImpl, IDirectDrawClipper,
|
|
|
|
pDDClipper);
|
|
|
|
if (pDDClipper != NULL)
|
|
|
|
IDirectDrawClipper_AddRef(pDDClipper);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_SetColorKey(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
DWORD dwFlags, LPDDCOLORKEY pCKey)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
2003-01-03 22:16:03 +01:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
TRACE("(%p)->(%08lx,%p)\n",This,dwFlags,pCKey);
|
2003-01-03 22:16:03 +01:00
|
|
|
|
|
|
|
if (TRACE_ON(ddraw)) {
|
|
|
|
TRACE(" - colorkey flags : ");
|
|
|
|
DDRAW_dump_colorkeyflag(dwFlags);
|
2001-01-04 23:44:55 +01:00
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2003-01-03 22:16:03 +01:00
|
|
|
if ((dwFlags & DDCKEY_COLORSPACE) != 0) {
|
|
|
|
FIXME(" colorkey value not supported (%08lx) !\n", dwFlags);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO: investigate if this function can take multiple bits set at the same
|
|
|
|
time (ie setting multiple colorkey values at the same time with only
|
|
|
|
one API call).
|
|
|
|
*/
|
|
|
|
if (pCKey) {
|
|
|
|
switch (dwFlags & ~DDCKEY_COLORSPACE) {
|
|
|
|
case DDCKEY_DESTBLT:
|
|
|
|
This->surface_desc.ddckCKDestBlt = *pCKey;
|
|
|
|
This->surface_desc.dwFlags |= DDSD_CKDESTBLT;
|
|
|
|
break;
|
2000-06-23 18:50:24 +02:00
|
|
|
|
2003-01-03 22:16:03 +01:00
|
|
|
case DDCKEY_DESTOVERLAY:
|
|
|
|
This->surface_desc.u3.ddckCKDestOverlay = *pCKey;
|
|
|
|
This->surface_desc.dwFlags |= DDSD_CKDESTOVERLAY;
|
|
|
|
break;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2003-01-03 22:16:03 +01:00
|
|
|
case DDCKEY_SRCOVERLAY:
|
|
|
|
This->surface_desc.ddckCKSrcOverlay = *pCKey;
|
|
|
|
This->surface_desc.dwFlags |= DDSD_CKSRCOVERLAY;
|
|
|
|
break;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2003-01-03 22:16:03 +01:00
|
|
|
case DDCKEY_SRCBLT:
|
|
|
|
This->surface_desc.ddckCKSrcBlt = *pCKey;
|
|
|
|
This->surface_desc.dwFlags |= DDSD_CKSRCBLT;
|
|
|
|
break;
|
2001-01-04 23:44:55 +01:00
|
|
|
|
2003-01-03 22:16:03 +01:00
|
|
|
default:
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (dwFlags & ~DDCKEY_COLORSPACE) {
|
|
|
|
case DDCKEY_DESTBLT:
|
|
|
|
This->surface_desc.dwFlags &= ~DDSD_CKDESTBLT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DDCKEY_DESTOVERLAY:
|
|
|
|
This->surface_desc.dwFlags &= ~DDSD_CKDESTOVERLAY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DDCKEY_SRCOVERLAY:
|
|
|
|
This->surface_desc.dwFlags &= ~DDSD_CKSRCOVERLAY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DDCKEY_SRCBLT:
|
|
|
|
This->surface_desc.dwFlags &= ~DDSD_CKSRCBLT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2001-01-04 23:44:55 +01:00
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2003-01-03 22:16:03 +01:00
|
|
|
if (This->aux_setcolorkey_cb) This->aux_setcolorkey_cb(This, dwFlags, pCKey);
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_SetLOD(LPDIRECTDRAWSURFACE7 iface, DWORD dwMaxLOD)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
TRACE("(%p)->(%08lx)\n",This,dwMaxLOD);
|
|
|
|
CHECK_TEXTURE(This);
|
|
|
|
|
|
|
|
This->max_lod = dwMaxLOD;
|
2000-04-09 16:30:50 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_SetOverlayPosition(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
LONG X, LONG Y)
|
|
|
|
{
|
|
|
|
return DDERR_NOTAOVERLAYSURFACE;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_SetPalette(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
LPDIRECTDRAWPALETTE pPalette)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n",This,pPalette);
|
|
|
|
if (pPalette == ICOM_INTERFACE(This->palette, IDirectDrawPalette))
|
|
|
|
return DD_OK;
|
|
|
|
|
|
|
|
if (This->palette != NULL) {
|
|
|
|
if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
2002-07-10 05:05:43 +02:00
|
|
|
This->palette->global.dwFlags &= ~DDPCAPS_PRIMARYSURFACE;
|
2001-01-04 23:44:55 +01:00
|
|
|
IDirectDrawPalette_Release(ICOM_INTERFACE(This->palette,
|
|
|
|
IDirectDrawPalette));
|
|
|
|
}
|
|
|
|
|
|
|
|
This->palette = ICOM_OBJECT(IDirectDrawPaletteImpl, IDirectDrawPalette,
|
|
|
|
pPalette);
|
|
|
|
if (pPalette != NULL) {
|
|
|
|
IDirectDrawPalette_AddRef(pPalette);
|
|
|
|
if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
2002-07-10 05:05:43 +02:00
|
|
|
This->palette->global.dwFlags |= DDPCAPS_PRIMARYSURFACE;
|
2001-01-04 23:44:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
This->set_palette(This, This->palette);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_SetPriority(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
DWORD dwPriority)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
TRACE("(%p)->(%08lx)\n",This,dwPriority);
|
|
|
|
CHECK_TEXTURE(This);
|
|
|
|
|
|
|
|
This->priority = dwPriority;
|
2000-04-09 16:30:50 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/* Be careful when locking this: it is risky to call the object's AddRef
|
|
|
|
* or Release holding a lock. */
|
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_SetPrivateData(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
REFGUID tag, LPVOID pData,
|
|
|
|
DWORD cbSize, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
PrivateData* data;
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl, iface);
|
|
|
|
|
|
|
|
data = find_private_data(This, tag);
|
|
|
|
if (data == NULL)
|
|
|
|
{
|
|
|
|
data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data));
|
|
|
|
if (data == NULL) return DDERR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
data->tag = *tag;
|
|
|
|
data->flags = dwFlags;
|
|
|
|
data->uniqueness_value = This->uniqueness_value;
|
|
|
|
|
|
|
|
if (dwFlags & DDSPD_IUNKNOWNPTR)
|
|
|
|
{
|
|
|
|
data->ptr.object = (LPUNKNOWN)pData;
|
|
|
|
data->size = sizeof(LPUNKNOWN);
|
|
|
|
IUnknown_AddRef(data->ptr.object);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
data->ptr.data = HeapAlloc(GetProcessHeap(), 0, cbSize);
|
|
|
|
if (data->ptr.data == NULL)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
|
|
|
return DDERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* link it in */
|
|
|
|
data->next = This->private_data;
|
|
|
|
data->prev = NULL;
|
|
|
|
if (This->private_data)
|
|
|
|
This->private_data->prev = data;
|
|
|
|
This->private_data = data;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* I don't actually know how windows handles this case. The only
|
|
|
|
* reason I don't just call FreePrivateData is because I want to
|
|
|
|
* guarantee SetPrivateData working when using LPUNKNOWN or data
|
|
|
|
* that is no larger than the old data. */
|
|
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/* SetSurfaceDesc */
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_Unlock(LPDIRECTDRAWSURFACE7 iface, LPRECT pRect)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl,iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->Unlock(%p)\n",This,pRect);
|
|
|
|
|
|
|
|
This->unlock_update(This, pRect);
|
|
|
|
if (This->aux_unlock)
|
|
|
|
This->aux_unlock(This->aux_ctx, This->aux_data, pRect);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_UpdateOverlay(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
LPRECT pSrcRect,
|
|
|
|
LPDIRECTDRAWSURFACE7 pDstSurface,
|
|
|
|
LPRECT pDstRect, DWORD dwFlags,
|
|
|
|
LPDDOVERLAYFX pFX)
|
|
|
|
{
|
|
|
|
return DDERR_UNSUPPORTED;
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/* MSDN: "not currently implemented." */
|
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_UpdateOverlayDisplay(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
return DDERR_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
Main_DirectDrawSurface_UpdateOverlayZOrder(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
DWORD dwFlags,
|
|
|
|
LPDIRECTDRAWSURFACE7 pDDSRef)
|
|
|
|
{
|
|
|
|
return DDERR_NOTAOVERLAYSURFACE;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|