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/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
|
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(GetSurfaceDesc);
|
||||||
SET_COMPAT_METHOD(IsLost);
|
SET_COMPAT_METHOD(IsLost);
|
||||||
SET_COMPAT_METHOD(Lock);
|
SET_COMPAT_METHOD(Lock);
|
||||||
SET_COMPAT_METHOD(QueryInterface);
|
|
||||||
SET_COMPAT_METHOD(ReleaseDC);
|
SET_COMPAT_METHOD(ReleaseDC);
|
||||||
SET_COMPAT_METHOD(Restore);
|
SET_COMPAT_METHOD(Restore);
|
||||||
SET_COMPAT_METHOD(SetClipper);
|
SET_COMPAT_METHOD(SetClipper);
|
||||||
|
@ -320,6 +320,17 @@ namespace DDraw
|
|||||||
return result;
|
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()
|
CompatWeakPtr<IDirectDrawSurface7> RealPrimarySurface::getSurface()
|
||||||
{
|
{
|
||||||
return g_frontBuffer;
|
return g_frontBuffer;
|
||||||
@ -380,6 +391,17 @@ namespace DDraw
|
|||||||
g_clipper = clipper;
|
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()
|
void RealPrimarySurface::setPalette()
|
||||||
{
|
{
|
||||||
if (g_surfaceDesc.ddpfPixelFormat.dwRGBBitCount <= 8)
|
if (g_surfaceDesc.ddpfPixelFormat.dwRGBBitCount <= 8)
|
||||||
|
@ -18,6 +18,7 @@ namespace DDraw
|
|||||||
static void disableUpdates();
|
static void disableUpdates();
|
||||||
static void enableUpdates();
|
static void enableUpdates();
|
||||||
static HRESULT flip(DWORD flags);
|
static HRESULT flip(DWORD flags);
|
||||||
|
static HRESULT getGammaRamp(DDGAMMARAMP* rampData);
|
||||||
static CompatWeakPtr<IDirectDrawSurface7> getSurface();
|
static CompatWeakPtr<IDirectDrawSurface7> getSurface();
|
||||||
static bool isFullScreen();
|
static bool isFullScreen();
|
||||||
static bool isLost();
|
static bool isLost();
|
||||||
@ -25,6 +26,7 @@ namespace DDraw
|
|||||||
static void removeUpdateThread();
|
static void removeUpdateThread();
|
||||||
static HRESULT restore();
|
static HRESULT restore();
|
||||||
static void setClipper(CompatWeakPtr<IDirectDrawClipper> clipper);
|
static void setClipper(CompatWeakPtr<IDirectDrawClipper> clipper);
|
||||||
|
static HRESULT setGammaRamp(DDGAMMARAMP* rampData);
|
||||||
static void setPalette();
|
static void setPalette();
|
||||||
static void update();
|
static void update();
|
||||||
static void updatePalette(DWORD startingEntry, DWORD count);
|
static void updatePalette(DWORD startingEntry, DWORD count);
|
||||||
|
@ -147,17 +147,6 @@ namespace DDraw
|
|||||||
return result;
|
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>
|
template <typename TSurface>
|
||||||
HRESULT PrimarySurfaceImpl<TSurface>::ReleaseDC(TSurface* This, HDC hDC)
|
HRESULT PrimarySurfaceImpl<TSurface>::ReleaseDC(TSurface* This, HDC hDC)
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,6 @@ namespace DDraw
|
|||||||
virtual HRESULT IsLost(TSurface* This) override;
|
virtual HRESULT IsLost(TSurface* This) override;
|
||||||
virtual HRESULT Lock(TSurface* This, LPRECT lpDestRect, TSurfaceDesc* lpDDSurfaceDesc,
|
virtual HRESULT Lock(TSurface* This, LPRECT lpDestRect, TSurfaceDesc* lpDDSurfaceDesc,
|
||||||
DWORD dwFlags, HANDLE hEvent) override;
|
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 ReleaseDC(TSurface* This, HDC hDC) override;
|
||||||
virtual HRESULT Restore(TSurface* This) override;
|
virtual HRESULT Restore(TSurface* This) override;
|
||||||
virtual HRESULT SetClipper(TSurface* This, LPDIRECTDRAWCLIPPER lpDDClipper) override;
|
virtual HRESULT SetClipper(TSurface* This, LPDIRECTDRAWCLIPPER lpDDClipper) override;
|
||||||
|
@ -261,12 +261,6 @@ namespace DDraw
|
|||||||
return result;
|
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>
|
template <typename TSurface>
|
||||||
HRESULT SurfaceImpl<TSurface>::ReleaseDC(TSurface* This, HDC hDC)
|
HRESULT SurfaceImpl<TSurface>::ReleaseDC(TSurface* This, HDC hDC)
|
||||||
{
|
{
|
||||||
|
@ -47,7 +47,6 @@ namespace DDraw
|
|||||||
virtual HRESULT IsLost(TSurface* This);
|
virtual HRESULT IsLost(TSurface* This);
|
||||||
virtual HRESULT Lock(TSurface* This, LPRECT lpDestRect, TSurfaceDesc* lpDDSurfaceDesc,
|
virtual HRESULT Lock(TSurface* This, LPRECT lpDestRect, TSurfaceDesc* lpDDSurfaceDesc,
|
||||||
DWORD dwFlags, HANDLE hEvent);
|
DWORD dwFlags, HANDLE hEvent);
|
||||||
virtual HRESULT QueryInterface(TSurface* This, REFIID riid, LPVOID* obp);
|
|
||||||
virtual HRESULT ReleaseDC(TSurface* This, HDC hDC);
|
virtual HRESULT ReleaseDC(TSurface* This, HDC hDC);
|
||||||
virtual HRESULT Restore(TSurface* This);
|
virtual HRESULT Restore(TSurface* This);
|
||||||
virtual HRESULT SetClipper(TSurface* This, LPDIRECTDRAWCLIPPER lpDDClipper);
|
virtual HRESULT SetClipper(TSurface* This, LPDIRECTDRAWCLIPPER lpDDClipper);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user