mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Redirect gamma controls to the real primary surface
This commit is contained in:
parent
4b02a40bc9
commit
c81c12df84
@ -1,8 +1,42 @@
|
||||
#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*/)
|
||||
void DirectDrawGammaControl::setCompatVtable(IDirectDrawGammaControlVtbl& vtable)
|
||||
{
|
||||
vtable.GetGammaRamp = &getGammaRamp;
|
||||
vtable.SetGammaRamp = &setGammaRamp;
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,6 @@ namespace DDraw
|
||||
SET_COMPAT_METHOD(GetSurfaceDesc);
|
||||
SET_COMPAT_METHOD(IsLost);
|
||||
SET_COMPAT_METHOD(Lock);
|
||||
SET_COMPAT_METHOD(QueryInterface);
|
||||
SET_COMPAT_METHOD(ReleaseDC);
|
||||
SET_COMPAT_METHOD(Restore);
|
||||
SET_COMPAT_METHOD(SetClipper);
|
||||
|
@ -320,6 +320,17 @@ namespace DDraw
|
||||
return result;
|
||||
}
|
||||
|
||||
HRESULT RealPrimarySurface::getGammaRamp(DDGAMMARAMP* rampData)
|
||||
{
|
||||
auto gammaControl(CompatPtr<IDirectDrawGammaControl>::from(g_frontBuffer.get()));
|
||||
if (!gammaControl)
|
||||
{
|
||||
return DDERR_INVALIDPARAMS;
|
||||
}
|
||||
|
||||
return gammaControl->GetGammaRamp(gammaControl, 0, rampData);
|
||||
}
|
||||
|
||||
CompatWeakPtr<IDirectDrawSurface7> RealPrimarySurface::getSurface()
|
||||
{
|
||||
return g_frontBuffer;
|
||||
@ -380,6 +391,17 @@ namespace DDraw
|
||||
g_clipper = clipper;
|
||||
}
|
||||
|
||||
HRESULT RealPrimarySurface::setGammaRamp(DDGAMMARAMP* rampData)
|
||||
{
|
||||
auto gammaControl(CompatPtr<IDirectDrawGammaControl>::from(g_frontBuffer.get()));
|
||||
if (!gammaControl)
|
||||
{
|
||||
return DDERR_INVALIDPARAMS;
|
||||
}
|
||||
|
||||
return gammaControl->SetGammaRamp(gammaControl, 0, rampData);
|
||||
}
|
||||
|
||||
void RealPrimarySurface::setPalette()
|
||||
{
|
||||
if (g_surfaceDesc.ddpfPixelFormat.dwRGBBitCount <= 8)
|
||||
|
@ -18,6 +18,7 @@ namespace DDraw
|
||||
static void disableUpdates();
|
||||
static void enableUpdates();
|
||||
static HRESULT flip(DWORD flags);
|
||||
static HRESULT getGammaRamp(DDGAMMARAMP* rampData);
|
||||
static CompatWeakPtr<IDirectDrawSurface7> getSurface();
|
||||
static bool isFullScreen();
|
||||
static bool isLost();
|
||||
@ -25,6 +26,7 @@ namespace DDraw
|
||||
static void removeUpdateThread();
|
||||
static HRESULT restore();
|
||||
static void setClipper(CompatWeakPtr<IDirectDrawClipper> clipper);
|
||||
static HRESULT setGammaRamp(DDGAMMARAMP* rampData);
|
||||
static void setPalette();
|
||||
static void update();
|
||||
static void updatePalette(DWORD startingEntry, DWORD count);
|
||||
|
@ -147,17 +147,6 @@ namespace DDraw
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename TSurface>
|
||||
HRESULT PrimarySurfaceImpl<TSurface>::QueryInterface(TSurface* This, REFIID riid, LPVOID* obp)
|
||||
{
|
||||
if (riid == IID_IDirectDrawGammaControl)
|
||||
{
|
||||
auto realPrimary(RealPrimarySurface::getSurface());
|
||||
return realPrimary->QueryInterface(realPrimary, riid, obp);
|
||||
}
|
||||
return m_impl.QueryInterface(This, riid, obp);
|
||||
}
|
||||
|
||||
template <typename TSurface>
|
||||
HRESULT PrimarySurfaceImpl<TSurface>::ReleaseDC(TSurface* This, HDC hDC)
|
||||
{
|
||||
|
@ -27,7 +27,6 @@ namespace DDraw
|
||||
virtual HRESULT IsLost(TSurface* This) override;
|
||||
virtual HRESULT Lock(TSurface* This, LPRECT lpDestRect, TSurfaceDesc* lpDDSurfaceDesc,
|
||||
DWORD dwFlags, HANDLE hEvent) override;
|
||||
virtual HRESULT QueryInterface(TSurface* This, REFIID riid, LPVOID* obp) override;
|
||||
virtual HRESULT ReleaseDC(TSurface* This, HDC hDC) override;
|
||||
virtual HRESULT Restore(TSurface* This) override;
|
||||
virtual HRESULT SetClipper(TSurface* This, LPDIRECTDRAWCLIPPER lpDDClipper) override;
|
||||
|
@ -261,12 +261,6 @@ namespace DDraw
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename TSurface>
|
||||
HRESULT SurfaceImpl<TSurface>::QueryInterface(TSurface* This, REFIID riid, LPVOID* obp)
|
||||
{
|
||||
return s_origVtable.QueryInterface(This, riid, obp);
|
||||
}
|
||||
|
||||
template <typename TSurface>
|
||||
HRESULT SurfaceImpl<TSurface>::ReleaseDC(TSurface* This, HDC hDC)
|
||||
{
|
||||
|
@ -47,7 +47,6 @@ namespace DDraw
|
||||
virtual HRESULT IsLost(TSurface* This);
|
||||
virtual HRESULT Lock(TSurface* This, LPRECT lpDestRect, TSurfaceDesc* lpDDSurfaceDesc,
|
||||
DWORD dwFlags, HANDLE hEvent);
|
||||
virtual HRESULT QueryInterface(TSurface* This, REFIID riid, LPVOID* obp);
|
||||
virtual HRESULT ReleaseDC(TSurface* This, HDC hDC);
|
||||
virtual HRESULT Restore(TSurface* This);
|
||||
virtual HRESULT SetClipper(TSurface* This, LPDIRECTDRAWCLIPPER lpDDClipper);
|
||||
|
Loading…
x
Reference in New Issue
Block a user