diff options
| author | NeoBrainX <NeoBrainX@gmail.com> | 2012-09-29 00:19:28 +0200 |
|---|---|---|
| committer | NeoBrainX <NeoBrainX@gmail.com> | 2012-11-16 14:29:09 +0100 |
| commit | a38bb488d205752dd3c3e59bae55924ae286c4ec (patch) | |
| tree | a28590246ad849e74484f9753013dac1e6178c0f /Source/Core/VideoCommon | |
| parent | 78031c2d54b4acbca14747c57572b34e2530e474 (diff) | |
Remove Renderer::xScale and Renderer::yScale.
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/Src/FramebufferManagerBase.cpp | 28 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/FramebufferManagerBase.h | 3 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/RenderBase.cpp | 43 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/RenderBase.h | 11 |
4 files changed, 42 insertions, 43 deletions
diff --git a/Source/Core/VideoCommon/Src/FramebufferManagerBase.cpp b/Source/Core/VideoCommon/Src/FramebufferManagerBase.cpp index fbb042c227..be6109decf 100644 --- a/Source/Core/VideoCommon/Src/FramebufferManagerBase.cpp +++ b/Source/Core/VideoCommon/Src/FramebufferManagerBase.cpp @@ -229,3 +229,31 @@ void FramebufferManagerBase::ReplaceVirtualXFB() } } } + +unsigned int FramebufferManagerBase::ScaleToVirtualXfbWidth(unsigned int width, unsigned int backbuffer_width) +{ + if (g_ActiveConfig.RealXFBEnabled()) + return width; + + if (g_ActiveConfig.b3DVision) + { + // This works, yet the version in the else doesn't. No idea why. + return width * (backbuffer_width-1) / (FramebufferManagerBase::LastXfbWidth()-1); + } + else + return width * (Renderer::GetTargetRectangle().GetWidth() - 1) / (float)(FramebufferManagerBase::LastXfbWidth()-1); +} + +unsigned int FramebufferManagerBase::ScaleToVirtualXfbHeight(unsigned int height, unsigned int backbuffer_height) +{ + if (g_ActiveConfig.RealXFBEnabled()) + return height; + + if (g_ActiveConfig.b3DVision) + { + // This works, yet the version in the else doesn't. No idea why. + return height * (backbuffer_height-1) / (FramebufferManagerBase::LastXfbHeight()-1); + } + else + return height * (Renderer::GetTargetRectangle().GetHeight() - 1) / (float)(FramebufferManagerBase::LastXfbHeight()-1); +} diff --git a/Source/Core/VideoCommon/Src/FramebufferManagerBase.h b/Source/Core/VideoCommon/Src/FramebufferManagerBase.h index a28a941e5b..d915130ac4 100644 --- a/Source/Core/VideoCommon/Src/FramebufferManagerBase.h +++ b/Source/Core/VideoCommon/Src/FramebufferManagerBase.h @@ -55,6 +55,9 @@ public: static unsigned int LastXfbWidth() { return s_last_xfb_width; } static unsigned int LastXfbHeight() { return s_last_xfb_height; } + static unsigned int ScaleToVirtualXfbWidth(unsigned int width, unsigned int backbuffer_width); + static unsigned int ScaleToVirtualXfbHeight(unsigned int height, unsigned int backbuffer_height); + protected: struct VirtualXFB { diff --git a/Source/Core/VideoCommon/Src/RenderBase.cpp b/Source/Core/VideoCommon/Src/RenderBase.cpp index 84eac4ec7f..8bb6ab6750 100644 --- a/Source/Core/VideoCommon/Src/RenderBase.cpp +++ b/Source/Core/VideoCommon/Src/RenderBase.cpp @@ -67,10 +67,6 @@ int Renderer::s_target_height; int Renderer::s_backbuffer_width; int Renderer::s_backbuffer_height; -// ratio of backbuffer size and render area size -float Renderer::xScale; -float Renderer::yScale; - TargetRectangle Renderer::target_rc; int Renderer::s_LastEFBScale; @@ -165,19 +161,23 @@ void Renderer::CalculateTargetScale(int x, int y, int &scaledX, int &scaledY) } // return true if target size changed -bool Renderer::CalculateTargetSize(int multiplier) +bool Renderer::CalculateTargetSize(unsigned int framebuffer_width, unsigned int framebuffer_height, int multiplier) { int newEFBWidth, newEFBHeight; switch (s_LastEFBScale) { case 0: // fractional - newEFBWidth = (int)(EFB_WIDTH * xScale); - newEFBHeight = (int)(EFB_HEIGHT * yScale); - break; case 1: // integral - newEFBWidth = EFB_WIDTH * (int)ceilf(xScale); - newEFBHeight = EFB_HEIGHT * (int)ceilf(yScale); + newEFBWidth = FramebufferManagerBase::ScaleToVirtualXfbWidth(EFB_WIDTH, framebuffer_width); + newEFBHeight = FramebufferManagerBase::ScaleToVirtualXfbHeight(EFB_HEIGHT, framebuffer_height); + + if (s_LastEFBScale) + { + newEFBWidth = ((newEFBWidth-1) / EFB_WIDTH + 1) * EFB_WIDTH; + newEFBHeight = ((newEFBHeight-1) / EFB_HEIGHT + 1) * EFB_HEIGHT; + } break; + default: CalculateTargetScale(EFB_WIDTH, EFB_HEIGHT, newEFBWidth, newEFBHeight); break; @@ -310,29 +310,6 @@ void Renderer::DrawDebugText() } } -void Renderer::CalculateXYScale(const TargetRectangle& dst_rect) -{ - if (g_ActiveConfig.RealXFBEnabled()) - { - xScale = 1.0f; - yScale = 1.0f; - } - else - { - if (g_ActiveConfig.b3DVision) - { - // This works, yet the version in the else doesn't. No idea why. - xScale = (float)(s_backbuffer_width-1) / (float)(FramebufferManagerBase::LastXfbWidth()-1); - yScale = (float)(s_backbuffer_height-1) / (float)(FramebufferManagerBase::LastXfbHeight()-1); - } - else - { - xScale = (float)(dst_rect.right - dst_rect.left - 1) / (float)(FramebufferManagerBase::LastXfbWidth()-1); - yScale = (float)(dst_rect.bottom - dst_rect.top - 1) / (float)(FramebufferManagerBase::LastXfbHeight()-1); - } - } -} - // TODO: remove extern bool g_aspect_wide; diff --git a/Source/Core/VideoCommon/Src/RenderBase.h b/Source/Core/VideoCommon/Src/RenderBase.h index 3a3231ed5e..534aa732fe 100644 --- a/Source/Core/VideoCommon/Src/RenderBase.h +++ b/Source/Core/VideoCommon/Src/RenderBase.h @@ -74,10 +74,6 @@ public: static int GetBackbufferWidth() { return s_backbuffer_width; } static int GetBackbufferHeight() { return s_backbuffer_height; } - // XFB scale - TODO: Remove this and add two XFBToScaled functions instead - static float GetXFBScaleX() { return xScale; } - static float GetXFBScaleY() { return yScale; } - static void SetWindowSize(int width, int height); // EFB coordinate conversion functions @@ -137,8 +133,7 @@ public: protected: static void CalculateTargetScale(int x, int y, int &scaledX, int &scaledY); - static bool CalculateTargetSize(int multiplier = 1); - static void CalculateXYScale(const TargetRectangle& dst_rect); + static bool CalculateTargetSize(unsigned int framebuffer_width, unsigned int framebuffer_height, int multiplier = 1); static void CheckFifoRecording(); static void RecordVideoMemory(); @@ -163,10 +158,6 @@ protected: static int s_backbuffer_width; static int s_backbuffer_height; - // ratio of backbuffer size and render area size - TODO: Remove these! - static float xScale; - static float yScale; - static TargetRectangle target_rc; // can probably eliminate this static var |
