#pragma once #include #include "CompatVtable.h" #include "DDrawTypes.h" #include "DirectDrawSurfaceVtblVisitor.h" template class CompatDirectDrawSurface : public CompatVtable, TSurface> { public: typedef typename Types::TSurfaceDesc TSurfaceDesc; typedef typename Types::TDdsCaps TDdsCaps; typedef typename Types::TUnlockParam TUnlockParam; static void setCompatVtable(Vtable& vtable); template static HRESULT createCompatPrimarySurface( TDirectDraw& dd, TSurfaceDesc compatDesc, TSurface*& compatSurface); static void fixSurfacePtrs(TSurface& surface); static HRESULT STDMETHODCALLTYPE Blt( TSurface* This, LPRECT lpDestRect, TSurface* lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx); static HRESULT STDMETHODCALLTYPE BltFast( TSurface* This, DWORD dwX, DWORD dwY, TSurface* lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans); static HRESULT STDMETHODCALLTYPE Flip( TSurface* This, TSurface* lpDDSurfaceTargetOverride, DWORD dwFlags); static HRESULT STDMETHODCALLTYPE GetCaps(TSurface* This, TDdsCaps* lpDDSCaps); static HRESULT STDMETHODCALLTYPE GetSurfaceDesc(TSurface* This, TSurfaceDesc* lpDDSurfaceDesc); static HRESULT STDMETHODCALLTYPE IsLost(TSurface* This); static HRESULT STDMETHODCALLTYPE Lock( TSurface* This, LPRECT lpDestRect, TSurfaceDesc* lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent); static HRESULT STDMETHODCALLTYPE QueryInterface(TSurface* This, REFIID riid, LPVOID* obp); static HRESULT STDMETHODCALLTYPE ReleaseDC(TSurface* This, HDC hDC); static HRESULT STDMETHODCALLTYPE Restore(TSurface* This); static HRESULT STDMETHODCALLTYPE SetClipper(TSurface* This, LPDIRECTDRAWCLIPPER lpDDClipper); static HRESULT STDMETHODCALLTYPE SetPalette(TSurface* This, LPDIRECTDRAWPALETTE lpDDPalette); static HRESULT STDMETHODCALLTYPE Unlock(TSurface* This, TUnlockParam lpRect); static const IID& s_iid; private: static void restorePrimaryCaps(TDdsCaps& caps); }; namespace Compat { template struct IsDirectDrawSurfaceIntf : std::false_type {}; template<> struct IsDirectDrawSurfaceIntf : std::true_type {}; template<> struct IsDirectDrawSurfaceIntf : std::true_type {}; template<> struct IsDirectDrawSurfaceIntf : std::true_type {}; template<> struct IsDirectDrawSurfaceIntf : std::true_type {}; template<> struct IsDirectDrawSurfaceIntf : std::true_type {}; template std::enable_if_t::value && IsDirectDrawSurfaceIntf::value> queryInterface(OrigIntf& origIntf, NewIntf*& newIntf) { CompatDirectDrawSurface::s_origVtable.QueryInterface( &origIntf, CompatDirectDrawSurface::s_iid, reinterpret_cast(&newIntf)); } template std::enable_if_t::value> queryInterface(IUnknown& origIntf, NewIntf*& newIntf) { CompatDirectDrawSurface::s_origVtable.QueryInterface( reinterpret_cast(&origIntf), CompatDirectDrawSurface::s_iid, reinterpret_cast(&newIntf)); } template std::enable_if_t::value> queryInterface(OrigIntf& origIntf, IUnknown*& newIntf) { CompatDirectDrawSurface::s_origVtable.QueryInterface( &origIntf, IID_IUnknown, reinterpret_cast(&newIntf)); } }