diff options
Diffstat (limited to 'Source/Core/VideoCommon/RenderBase.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/RenderBase.cpp | 85 |
1 files changed, 53 insertions, 32 deletions
diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index a688c86792..55a6cb8760 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -28,6 +28,8 @@ #include "Core/Movie.h" #include "Core/FifoPlayer/FifoRecorder.h" +#include "Core/HW/VideoInterface.h" + #include "VideoCommon/AVIDump.h" #include "VideoCommon/BPMemory.h" #include "VideoCommon/CommandProcessor.h" @@ -112,22 +114,23 @@ Renderer::~Renderer() #endif } -void Renderer::RenderToXFB(u32 xfbAddr, const EFBRectangle& sourceRc, u32 fbWidth, u32 fbHeight, float Gamma) +void Renderer::RenderToXFB(u32 xfbAddr, const EFBRectangle& sourceRc, u32 fbStride, u32 fbHeight, float Gamma) { CheckFifoRecording(); - if (!fbWidth || !fbHeight) + if (!fbStride || !fbHeight) return; XFBWrited = true; if (g_ActiveConfig.bUseXFB) { - FramebufferManagerBase::CopyToXFB(xfbAddr, fbWidth, fbHeight, sourceRc, Gamma); + FramebufferManagerBase::CopyToXFB(xfbAddr, fbStride, fbHeight, sourceRc, Gamma); } else { - Swap(xfbAddr, fbWidth, fbWidth, fbHeight, sourceRc, Gamma); + // below div two to convert from bytes to pixels - it expects width, not stride + Swap(xfbAddr, fbStride/2, fbStride/2, fbHeight, sourceRc, Gamma); } } @@ -359,15 +362,14 @@ void Renderer::DrawDebugText() case ASPECT_AUTO: ar_text = "Auto"; break; - case ASPECT_FORCE_16_9: - ar_text = "16:9"; - break; - case ASPECT_FORCE_4_3: - ar_text = "4:3"; - break; case ASPECT_STRETCH: ar_text = "Stretch"; break; + case ASPECT_ANALOG: + ar_text = "Force 4:3"; + break; + case ASPECT_ANALOG_WIDE: + ar_text = "Force 16:9"; } const char* const efbcopy_text = g_ActiveConfig.bSkipEFBCopyToRam ? "to Texture" : "to RAM"; @@ -400,7 +402,7 @@ void Renderer::DrawDebugText() } } - final_cyan += Profiler::ToString(); + final_cyan += Common::Profiler::ToString(); if (g_ActiveConfig.bOverlayStats) final_cyan += Statistics::ToString(); @@ -424,31 +426,27 @@ void Renderer::UpdateDrawRectangle(int backbuffer_width, int backbuffer_height) const float WinWidth = FloatGLWidth; const float WinHeight = FloatGLHeight; - // Handle aspect ratio. - // Default to auto. - bool use16_9 = g_aspect_wide; - // Update aspect ratio hack values // Won't take effect until next frame // Don't know if there is a better place for this code so there isn't a 1 frame delay if (g_ActiveConfig.bWidescreenHack) { - float source_aspect = use16_9 ? (16.0f / 9.0f) : (4.0f / 3.0f); + float source_aspect = VideoInterface::GetAspectRatio(g_aspect_wide); float target_aspect; switch (g_ActiveConfig.iAspectRatio) { - case ASPECT_FORCE_16_9: - target_aspect = 16.0f / 9.0f; - break; - case ASPECT_FORCE_4_3: - target_aspect = 4.0f / 3.0f; - break; case ASPECT_STRETCH: target_aspect = WinWidth / WinHeight; break; + case ASPECT_ANALOG: + target_aspect = VideoInterface::GetAspectRatio(false); + break; + case ASPECT_ANALOG_WIDE: + target_aspect = VideoInterface::GetAspectRatio(true); + break; default: - // ASPECT_AUTO == no hacking + // ASPECT_AUTO target_aspect = source_aspect; break; } @@ -475,16 +473,24 @@ void Renderer::UpdateDrawRectangle(int backbuffer_width, int backbuffer_height) } // Check for force-settings and override. - if (g_ActiveConfig.iAspectRatio == ASPECT_FORCE_16_9) - use16_9 = true; - else if (g_ActiveConfig.iAspectRatio == ASPECT_FORCE_4_3) - use16_9 = false; + + // The rendering window aspect ratio as a proportion of the 4:3 or 16:9 ratio + float Ratio; + switch (g_ActiveConfig.iAspectRatio) + { + case ASPECT_ANALOG_WIDE: + Ratio = (WinWidth / WinHeight) / VideoInterface::GetAspectRatio(true); + break; + case ASPECT_ANALOG: + Ratio = (WinWidth / WinHeight) / VideoInterface::GetAspectRatio(false); + break; + default: + Ratio = (WinWidth / WinHeight) / VideoInterface::GetAspectRatio(g_aspect_wide); + break; + } if (g_ActiveConfig.iAspectRatio != ASPECT_STRETCH) { - // The rendering window aspect ratio as a proportion of the 4:3 or 16:9 ratio - float Ratio = (WinWidth / WinHeight) / (!use16_9 ? (4.0f / 3.0f) : (16.0f / 9.0f)); - // Check if height or width is the limiting factor. If ratio > 1 the picture is too wide and have to limit the width. if (Ratio > 1.0f) { // Scale down and center in the X direction. @@ -501,12 +507,27 @@ void Renderer::UpdateDrawRectangle(int backbuffer_width, int backbuffer_height) } // ----------------------------------------------------------------------- - // Crop the picture from 4:3 to 5:4 or from 16:9 to 16:10. + // Crop the picture from Analog to 4:3 or from Analog (Wide) to 16:9. // Output: FloatGLWidth, FloatGLHeight, FloatXOffset, FloatYOffset // ------------------ if (g_ActiveConfig.iAspectRatio != ASPECT_STRETCH && g_ActiveConfig.bCrop) { - float Ratio = !use16_9 ? ((4.0f / 3.0f) / (5.0f / 4.0f)) : (((16.0f / 9.0f) / (16.0f / 10.0f))); + switch (g_ActiveConfig.iAspectRatio) + { + case ASPECT_ANALOG_WIDE: + Ratio = (16.0f / 9.0f) / VideoInterface::GetAspectRatio(true); + break; + case ASPECT_ANALOG: + Ratio = (4.0f / 3.0f) / VideoInterface::GetAspectRatio(false); + break; + default: + Ratio = (!g_aspect_wide ? (4.0f / 3.0f) : (16.0f / 9.0f)) / VideoInterface::GetAspectRatio(g_aspect_wide); + break; + } + if (Ratio <= 1.0f) + { + Ratio = 1.0f / Ratio; + } // The width and height we will add (calculate this before FloatGLWidth and FloatGLHeight is adjusted) float IncreasedWidth = (Ratio - 1.0f) * FloatGLWidth; float IncreasedHeight = (Ratio - 1.0f) * FloatGLHeight; |
