From f983f778f27ca17b1a45f62d367c174ab0c0b5c5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 17 Apr 2015 21:39:07 +0200 Subject: [PATCH] - moved ScaleCoordsFromWindow to the BaseWinFB base class to eliminate two identical implementations. (GZDoom would have had to implement a third identical copy in its GL framebuffer as well.) --- src/win32/fb_d3d9.cpp | 22 ---------------------- src/win32/fb_ddraw.cpp | 13 ------------- src/win32/win32iface.h | 6 ++++-- src/win32/win32video.cpp | 23 +++++++++++++++++++++++ 4 files changed, 27 insertions(+), 37 deletions(-) diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 9fd185431..e23275734 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -1028,28 +1028,6 @@ bool D3DFB::IsFullscreen () return !Windowed; } -//========================================================================== -// -// D3DFB :: ScaleCoordsFromWindow -// -// Given coordinates in window space, return coordinates in what the game -// thinks screen space is. -// -//========================================================================== - -void D3DFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y) -{ - RECT rect; - - if (GetClientRect(Window, &rect)) - { - x = SWORD(x * Width / (rect.right - rect.left)); - y = SWORD(y * TrueHeight / (rect.bottom - rect.top)); - } - // Subtract letterboxing borders - y -= (TrueHeight - Height) / 2; -} - //========================================================================== // // D3DFB :: Lock diff --git a/src/win32/fb_ddraw.cpp b/src/win32/fb_ddraw.cpp index ecf570ff8..2aa694f3b 100644 --- a/src/win32/fb_ddraw.cpp +++ b/src/win32/fb_ddraw.cpp @@ -806,19 +806,6 @@ bool DDrawFB::Is8BitMode() return vid_displaybits == 8; } -void DDrawFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y) -{ - RECT rect; - - if (GetClientRect(Window, &rect)) - { - x = SWORD(x * Width / (rect.right - rect.left)); - y = SWORD(y * TrueHeight / (rect.bottom - rect.top)); - } - // Subtract letterboxing borders - y -= (TrueHeight - Height) / 2; -} - bool DDrawFB::IsValid () { return PrimarySurf != NULL; diff --git a/src/win32/win32iface.h b/src/win32/win32iface.h index 9699157cd..934931ea0 100644 --- a/src/win32/win32iface.h +++ b/src/win32/win32iface.h @@ -127,10 +127,12 @@ public: virtual void Blank () = 0; virtual bool PaintToWindow () = 0; virtual HRESULT GetHR () = 0; + virtual void ScaleCoordsFromWindow(SWORD &x, SWORD &y); protected: virtual bool CreateResources () = 0; virtual void ReleaseResources () = 0; + virtual int GetTrueHeight() { return GetHeight(); } bool Windowed; @@ -165,7 +167,7 @@ public: void NewRefreshRate(); HRESULT GetHR (); bool Is8BitMode(); - void ScaleCoordsFromWindow(SWORD &x, SWORD &y); + virtual int GetTrueHeight() { return TrueHeight; } void Blank (); bool PaintToWindow (); @@ -270,7 +272,7 @@ public: void WipeCleanup(); HRESULT GetHR (); bool Is8BitMode() { return false; } - void ScaleCoordsFromWindow(SWORD &x, SWORD &y); + virtual int GetTrueHeight() { return TrueHeight; } private: friend class D3DTex; diff --git a/src/win32/win32video.cpp b/src/win32/win32video.cpp index 3071ae8e7..8aa74bfb5 100644 --- a/src/win32/win32video.cpp +++ b/src/win32/win32video.cpp @@ -736,6 +736,29 @@ void Win32Video::SetWindowedScale (float scale) // FIXME } +//========================================================================== +// +// BaseWinFB :: ScaleCoordsFromWindow +// +// Given coordinates in window space, return coordinates in what the game +// thinks screen space is. +// +//========================================================================== + +void BaseWinFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y) +{ + RECT rect; + + int TrueHeight = GetTrueHeight(); + if (GetClientRect(Window, &rect)) + { + x = SWORD(x * Width / (rect.right - rect.left)); + y = SWORD(y * TrueHeight / (rect.bottom - rect.top)); + } + // Subtract letterboxing borders + y -= (TrueHeight - Height) / 2; +} + //========================================================================== // // SetFPSLimit