From c55578367fa43cd538b1f119eb4f6ed22d27b8bd Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Thu, 16 Jan 2014 00:17:41 +0100 Subject: [PATCH] Add option "Small Display", useful for large tablets to avoid overlapping touch controls with the screen. Will later replace with a multiselect of different sizes, or something more advanced like multitouch drag & zoom of the screen to get it exactly where you want it. --- Core/Config.cpp | 5 ++++ Core/Config.h | 1 + GPU/GLES/Framebuffer.cpp | 56 +++++++++++++++++++++------------------ UI/GameSettingsScreen.cpp | 2 ++ 4 files changed, 38 insertions(+), 26 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index c55ede83db..eda2d8c908 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -247,8 +247,12 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) { #ifdef BLACKBERRY partialStretchDefault = pixel_xres < 1.3 * pixel_yres; #endif + + // TODO: Replace these settings with a list of options graphics->Get("PartialStretch", &bPartialStretch, partialStretchDefault); graphics->Get("StretchToDisplay", &bStretchToDisplay, false); + graphics->Get("SmallDisplay", &bSmallDisplay, false); + graphics->Get("TrueColor", &bTrueColor, true); graphics->Get("MipMap", &bMipMap, true); @@ -555,6 +559,7 @@ void Config::Save() { #endif graphics->Set("PartialStretch", bPartialStretch); graphics->Set("StretchToDisplay", bStretchToDisplay); + graphics->Set("SmallDisplay", &bSmallDisplay); graphics->Set("TrueColor", bTrueColor); graphics->Set("MipMap", bMipMap); graphics->Set("TexScalingLevel", iTexScalingLevel); diff --git a/Core/Config.h b/Core/Config.h index 744257becf..e9263e55ab 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -89,6 +89,7 @@ public: int iTexFiltering; // 1 = off , 2 = nearest , 3 = linear , 4 = linear(CG) bool bPartialStretch; bool bStretchToDisplay; + bool bSmallDisplay; // Useful on large tablets with touch controls to not overlap the image. Temporary setting - will be replaced by more comprehensive display size settings. bool bVSync; int iFrameSkip; bool bFrameSkipUnthrottle; diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index d8f83eaf09..01290f53e6 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -119,35 +119,39 @@ void ConvertFromRGBA8888(u8 *dst, u8 *src, u32 stride, u32 height, GEBufferForma void CenterRect(float *x, float *y, float *w, float *h, float origW, float origH, float frameW, float frameH) { + float outW; + float outH; + if (g_Config.bStretchToDisplay) { - *x = 0; - *y = 0; - *w = frameW; - *h = frameH; - return; - } - - float origRatio = origW/origH; - float frameRatio = frameW/frameH; - - if (origRatio > frameRatio) { - // Image is wider than frame. Center vertically. - float scale = origW / frameW; - *x = 0.0f; - *w = frameW; - *h = frameW / origRatio; - // Stretch a little bit - if (g_Config.bPartialStretch) - *h = (frameH + *h) / 2.0f; // (408 + 720) / 2 = 564 - *y = (frameH - *h) / 2.0f; + outW = frameW; + outH = frameH; } else { - // Image is taller than frame. Center horizontally. - float scale = origH / frameH; - *y = 0.0f; - *h = frameH; - *w = frameH * origRatio; - *x = (frameW - *w) / 2.0f; + float origRatio = origW / origH; + float frameRatio = frameW / frameH; + if (origRatio > frameRatio) { + // Image is wider than frame. Center vertically. + outW = frameW; + outH = frameW / origRatio; + // Stretch a little bit + if (g_Config.bPartialStretch) + outH = (frameH + outH) / 2.0f; // (408 + 720) / 2 = 564 + } + else { + // Image is taller than frame. Center horizontally. + outW = frameH * origRatio; + outH = frameH; + } } + + if (g_Config.bSmallDisplay) { + outW /= 2.0f; + outH /= 2.0f; + } + + *x = (frameW - outW) / 2.0f; + *y = (frameH - outH) / 2.0f; + *w = outW; + *h = outH; } static void ClearBuffer() { diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index bb03655c6f..ede85cdffc 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -128,6 +128,8 @@ void GameSettingsScreen::CreateViews() { graphicsSettings->Add(new CheckBox(&g_Config.bFullScreen, gs->T("FullScreen")))->OnClick.Handle(this, &GameSettingsScreen::OnFullscreenChange); #endif graphicsSettings->Add(new CheckBox(&g_Config.bStretchToDisplay, gs->T("Stretch to Display"))); + // Small Display: To avoid overlapping touch controls on large tablets. Better control over this will be coming later. + graphicsSettings->Add(new CheckBox(&g_Config.bSmallDisplay, gs->T("Small Display"))); if (pixel_xres < pixel_yres * 1.3) // Smaller than 4:3 graphicsSettings->Add(new CheckBox(&g_Config.bPartialStretch, gs->T("Partial Vertical Stretch"))); graphicsSettings->Add(new CheckBox(&g_Config.bMipMap, gs->T("Mipmapping")));