1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00
DDrawCompat/DDrawCompat/DDraw/DirectDrawGammaControl.cpp

43 lines
1.2 KiB
C++

#include "DDraw/DirectDrawGammaControl.h"
#include "DDraw/RealPrimarySurface.h"
#include "DDraw/Surfaces/PrimarySurface.h"
namespace
{
bool isPrimaryGamma(IDirectDrawGammaControl* gamma)
{
return CompatPtr<IDirectDrawSurface7>::from(gamma) == DDraw::PrimarySurface::getPrimary();
}
HRESULT STDMETHODCALLTYPE getGammaRamp(
IDirectDrawGammaControl* This, DWORD dwFlags, LPDDGAMMARAMP lpRampData)
{
if (0 != dwFlags || !lpRampData || !isPrimaryGamma(This))
{
return DDraw::DirectDrawGammaControl::s_origVtable.GetGammaRamp(This, dwFlags, lpRampData);
}
return DDraw::RealPrimarySurface::getGammaRamp(lpRampData);
}
HRESULT STDMETHODCALLTYPE setGammaRamp(
IDirectDrawGammaControl* This, DWORD dwFlags, LPDDGAMMARAMP lpRampData)
{
if ((0 != dwFlags && DDSGR_CALIBRATE != dwFlags) || !isPrimaryGamma(This))
{
return DDraw::DirectDrawGammaControl::s_origVtable.SetGammaRamp(This, dwFlags, lpRampData);
}
return DDraw::RealPrimarySurface::setGammaRamp(lpRampData);
}
}
namespace DDraw
{
void DirectDrawGammaControl::setCompatVtable(IDirectDrawGammaControlVtbl& vtable)
{
vtable.GetGammaRamp = &getGammaRamp;
vtable.SetGammaRamp = &setGammaRamp;
}
}