From e37b1d31a8b0629e0e47b01d484ba7743bb20337 Mon Sep 17 00:00:00 2001 From: Ove Kaaven Date: Mon, 16 Apr 2001 19:35:18 +0000 Subject: [PATCH] Implemented the IDirectDrawGammaControl interface. --- dlls/ddraw/Makefile.in | 1 + dlls/ddraw/dsurface/gamma.c | 66 +++++++++++++++++++++++++++++++++++++ dlls/ddraw/dsurface/main.c | 61 +++++++++++++++++++++++++++++++++- dlls/ddraw/dsurface/main.h | 15 ++++++++- 4 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 dlls/ddraw/dsurface/gamma.c diff --git a/dlls/ddraw/Makefile.in b/dlls/ddraw/Makefile.in index 36fb2795ef0..36d4636215e 100644 --- a/dlls/ddraw/Makefile.in +++ b/dlls/ddraw/Makefile.in @@ -33,6 +33,7 @@ C_SRCS = \ dsurface/dib.c \ dsurface/dibtexture.c \ dsurface/fakezbuffer.c \ + dsurface/gamma.c \ dsurface/main.c \ dsurface/thunks.c \ dsurface/user.c \ diff --git a/dlls/ddraw/dsurface/gamma.c b/dlls/ddraw/dsurface/gamma.c new file mode 100644 index 00000000000..8632ad7c51e --- /dev/null +++ b/dlls/ddraw/dsurface/gamma.c @@ -0,0 +1,66 @@ +/* DirectDrawGammaControl implementation + * + * Copyright 2001 TransGaming Technologies Inc. + */ + +#include "config.h" +#include "winerror.h" + +#include +#include + +#include "debugtools.h" +#include "ddraw_private.h" +#include "dsurface/main.h" + +DEFAULT_DEBUG_CHANNEL(ddraw); + +#define CONVERT(pddgc) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, \ + IDirectDrawGammaControl, \ + IDirectDrawSurface7, \ + (pddgc)) + +static HRESULT WINAPI +DirectDrawGammaControl_QueryInterface(LPDIRECTDRAWGAMMACONTROL iface, REFIID riid, + LPVOID *ppObj) +{ + TRACE("(%p)->(%s,%p)\n", iface, debugstr_guid(riid), ppObj); + return E_NOINTERFACE; +} + +static ULONG WINAPI +DirectDrawGammaControl_AddRef(LPDIRECTDRAWGAMMACONTROL iface) +{ + return IDirectDrawSurface7_AddRef(CONVERT(iface)); +} + +static ULONG WINAPI +DirectDrawGammaControl_Release(LPDIRECTDRAWGAMMACONTROL iface) +{ + return IDirectDrawSurface7_Release(CONVERT(iface)); +} + +static HRESULT WINAPI +DirectDrawGammaControl_GetGammaRamp(LPDIRECTDRAWGAMMACONTROL iface, DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp) +{ + ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface); + TRACE("(%p)->(%08lx,%p)\n", iface,dwFlags,lpGammaRamp); + return This->get_gamma_ramp(This, dwFlags, lpGammaRamp); +} + +static HRESULT WINAPI +DirectDrawGammaControl_SetGammaRamp(LPDIRECTDRAWGAMMACONTROL iface, DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp) +{ + ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface); + TRACE("(%p)->(%08lx,%p)\n", iface,dwFlags,lpGammaRamp); + return This->set_gamma_ramp(This, dwFlags, lpGammaRamp); +} + +ICOM_VTABLE(IDirectDrawGammaControl) DDRAW_IDDGC_VTable = +{ + DirectDrawGammaControl_QueryInterface, + DirectDrawGammaControl_AddRef, + DirectDrawGammaControl_Release, + DirectDrawGammaControl_GetGammaRamp, + DirectDrawGammaControl_SetGammaRamp +}; diff --git a/dlls/ddraw/dsurface/main.c b/dlls/ddraw/dsurface/main.c index 28c29a28c42..45431c1523d 100644 --- a/dlls/ddraw/dsurface/main.c +++ b/dlls/ddraw/dsurface/main.c @@ -2,7 +2,7 @@ * * Copyright 1997-2000 Marcus Meissner * Copyright 1998-2000 Lionel Ulmer (most of Direct3D stuff) - * Copyright 2000 TransGaming Technologies Inc. + * Copyright 2000-2001 TransGaming Technologies Inc. */ #include "config.h" #include "winerror.h" @@ -32,7 +32,23 @@ Main_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl *This, This->uniqueness_value = 1; /* unchecked */ This->ref = 1; + 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 */ + This->final_release = Main_DirectDrawSurface_final_release; + This->late_allocate = Main_DirectDrawSurface_late_allocate; This->attach = Main_DirectDrawSurface_attach; This->detach = Main_DirectDrawSurface_detach; This->lock_update = Main_DirectDrawSurface_lock_update; @@ -41,9 +57,13 @@ Main_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl *This, This->set_palette = Main_DirectDrawSurface_set_palette; This->update_palette = Main_DirectDrawSurface_update_palette; This->get_display_window = Main_DirectDrawSurface_get_display_window; + This->get_gamma_ramp = Main_DirectDrawSurface_get_gamma_ramp; + This->set_gamma_ramp = Main_DirectDrawSurface_set_gamma_ramp; ICOM_INIT_INTERFACE(This, IDirectDrawSurface3, DDRAW_IDDS3_Thunk_VTable); + ICOM_INIT_INTERFACE(This, IDirectDrawGammaControl, + DDRAW_IDDGC_VTable); /* There is no generic implementation of IDDS7 */ Main_DirectDraw_AddSurface(pDD, This); @@ -55,6 +75,11 @@ void Main_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This) Main_DirectDraw_RemoveSurface(This->ddraw_owner, This); } +HRESULT Main_DirectDrawSurface_late_allocate(IDirectDrawSurfaceImpl* This) +{ + return DD_OK; +} + static void Main_DirectDrawSurface_Destroy(IDirectDrawSurfaceImpl* This) { This->final_release(This); @@ -113,6 +138,12 @@ Main_DirectDrawSurface_QueryInterface(LPDIRECTDRAWSURFACE7 iface, REFIID riid, *ppObj = ICOM_INTERFACE(This, IDirectDrawSurface3); return S_OK; } + else if (IsEqualGUID(&IID_IDirectDrawGammaControl, riid)) + { + This->ref++; + *ppObj = ICOM_INTERFACE(This, IDirectDrawGammaControl); + return S_OK; + } else return E_NOINTERFACE; } @@ -167,6 +198,34 @@ Main_DirectDrawSurface_get_display_window(IDirectDrawSurfaceImpl* This) return 0; } +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; +} + /*** Interface functions */ diff --git a/dlls/ddraw/dsurface/main.h b/dlls/ddraw/dsurface/main.h index 3fe2c1f1e9e..16e93412f16 100644 --- a/dlls/ddraw/dsurface/main.h +++ b/dlls/ddraw/dsurface/main.h @@ -1,4 +1,4 @@ -/* Copyright 2000 TransGaming Technologies Inc. */ +/* Copyright 2000-2001 TransGaming Technologies Inc. */ #ifndef DDRAW_DSURFACE_MAIN_H_INCLUDED #define DDRAW_DSURFACE_MAIN_H_INCLUDED @@ -25,6 +25,8 @@ typedef struct PrivateData DWORD size; } PrivateData; +extern ICOM_VTABLE(IDirectDrawGammaControl) DDRAW_IDDGC_VTable; + /* Non-interface functions */ HRESULT Main_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl* This, @@ -34,6 +36,8 @@ void Main_DirectDrawSurface_ForceDestroy(IDirectDrawSurfaceImpl* This); void Main_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This); +HRESULT +Main_DirectDrawSurface_late_allocate(IDirectDrawSurfaceImpl* This); BOOL Main_DirectDrawSurface_attach(IDirectDrawSurfaceImpl *This, IDirectDrawSurfaceImpl *to); @@ -57,6 +61,15 @@ Main_DirectDrawSurface_update_palette(IDirectDrawSurfaceImpl* This, HWND Main_DirectDrawSurface_get_display_window(IDirectDrawSurfaceImpl* This); +HRESULT +Main_DirectDrawSurface_get_gamma_ramp(IDirectDrawSurfaceImpl* This, + DWORD dwFlags, + LPDDGAMMARAMP lpGammaRamp); +HRESULT +Main_DirectDrawSurface_set_gamma_ramp(IDirectDrawSurfaceImpl* This, + DWORD dwFlags, + LPDDGAMMARAMP lpGammaRamp); + BOOL Main_DirectDrawSurface_flip_data(IDirectDrawSurfaceImpl* front, IDirectDrawSurfaceImpl* back, DWORD dwFlags);