Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move "Display Rotation" and stretching options to display layout editor. #8182

Merged
merged 9 commits into from
Jan 17, 2016
16 changes: 9 additions & 7 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,15 @@ static int DefaultInternalResolution() {
#endif
}

static bool DefaultPartialStretch() {
static int DefaultZoomType() {
#ifdef BLACKBERRY
return pixel_xres < 1.3 * pixel_yres;
if (pixel_xres < 1.3 * pixel_yres) {
return 1;
} else {
return 2;
}
#else
return false;
return 2;
#endif
}

Expand Down Expand Up @@ -465,12 +469,10 @@ static ConfigSetting graphicsSettings[] = {
#endif

// TODO: Replace these settings with a list of options
ConfigSetting("PartialStretch", &g_Config.bPartialStretch, &DefaultPartialStretch, true, true),
ConfigSetting("StretchToDisplay", &g_Config.bStretchToDisplay, false, true, true),
ConfigSetting("SmallDisplayZoom", &g_Config.iSmallDisplayZoom, 0, true, true),
ConfigSetting("SmallDisplayZoomType", &g_Config.iSmallDisplayZoomType, &DefaultZoomType, true, true),
ConfigSetting("SmallDisplayOffsetX", &g_Config.fSmallDisplayOffsetX, 0.5f, true, true),
ConfigSetting("SmallDisplayOffsetY", &g_Config.fSmallDisplayOffsetY, 0.5f, true, true),
ConfigSetting("SmallDisplayCustomZoom", &g_Config.fSmallDisplayCustomZoom, 8.0f, true, true),
ConfigSetting("SmallDisplayZoomLevel", &g_Config.fSmallDisplayZoomLevel, 1.0f, true, true),
ConfigSetting("ImmersiveMode", &g_Config.bImmersiveMode, false, true, true),

ReportedConfigSetting("TrueColor", &g_Config.bTrueColor, true, true, true),
Expand Down
6 changes: 2 additions & 4 deletions Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,10 @@ struct Config {
int iRenderingMode; // 0 = non-buffered rendering 1 = buffered rendering 2 = Read Framebuffer to memory (CPU) 3 = Read Framebuffer to memory (GPU)
int iTexFiltering; // 1 = off , 2 = nearest , 3 = linear , 4 = linear(CG)
int iBufFilter; // 1 = linear, 2 = nearest
bool bPartialStretch;
bool bStretchToDisplay;
int iSmallDisplayZoom; // Used to fit display into screen 0 = auto, anything higher is used to set's integer zoom of psp resolution and allows manual editing
int iSmallDisplayZoomType; // Used to fit display into screen 0 = stretch, 1 = partial stretch, 2 = auto scaling, 3 = manual scaling.
float fSmallDisplayOffsetX; // Along with Y it goes from 0.0 to 1.0, XY (0.5, 0.5) = center of the screen
float fSmallDisplayOffsetY;
float fSmallDisplayCustomZoom; //This is actually used for zoom, both in and out.
float fSmallDisplayZoomLevel; //This is used for zoom values, both in and out.
bool bImmersiveMode; // Mode on Android Kitkat 4.4 that hides the back button etc.
bool bVSync;
int iFrameSkip;
Expand Down
78 changes: 36 additions & 42 deletions GPU/Common/FramebufferCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,67 +36,61 @@ void CenterDisplayOutputRect(float *x, float *y, float *w, float *h, float origW

bool rotated = rotation == ROTATION_LOCKED_VERTICAL || rotation == ROTATION_LOCKED_VERTICAL180;

if (g_Config.bStretchToDisplay) {
if (g_Config.iSmallDisplayZoomType == 0) { // Stretching
outW = frameW;
outH = frameH;
} else {
bool fullScreenZoom = true;
#ifndef MOBILE_DEVICE
// This would turn off small display in window mode. I think it's better to allow it.
// fullScreenZoom = g_Config.bFullScreen;
#endif
if (fullScreenZoom) {
if (g_Config.iSmallDisplayZoom != 0) {
float offsetX = (g_Config.fSmallDisplayOffsetX - 0.5f) * 2.0f * frameW;
float offsetY = (g_Config.fSmallDisplayOffsetY - 0.5f) * 2.0f * frameH;
// Have to invert Y for GL
if (GetGPUBackend() == GPUBackend::OPENGL) {
offsetY = offsetY * -1.0f;
}
float customZoom = g_Config.fSmallDisplayCustomZoom / 8.0f;
float smallDisplayW = origW * customZoom;
float smallDisplayH = origH * customZoom;
if (!rotated) {
*x = floorf(((frameW - smallDisplayW) / 2.0f) + offsetX);
*y = floorf(((frameH - smallDisplayH) / 2.0f) + offsetY);
*w = floorf(smallDisplayW);
*h = floorf(smallDisplayH);
return;
} else {
*x = floorf(((frameW - smallDisplayH) / 2.0f) + offsetX);
*y = floorf(((frameH - smallDisplayW) / 2.0f) + offsetY);
*w = floorf(smallDisplayH);
*h = floorf(smallDisplayW);
return;
}
if (g_Config.iSmallDisplayZoomType == 3) { // Manual Scaling
float offsetX = (g_Config.fSmallDisplayOffsetX - 0.5f) * 2.0f * frameW;
float offsetY = (g_Config.fSmallDisplayOffsetY - 0.5f) * 2.0f * frameH;
// Have to invert Y for GL
if (GetGPUBackend() == GPUBackend::OPENGL) {
offsetY = offsetY * -1.0f;
}
float customZoom = g_Config.fSmallDisplayZoomLevel;
float smallDisplayW = origW * customZoom;
float smallDisplayH = origH * customZoom;
if (!rotated) {
*x = floorf(((frameW - smallDisplayW) / 2.0f) + offsetX);
*y = floorf(((frameH - smallDisplayH) / 2.0f) + offsetY);
*w = floorf(smallDisplayW);
*h = floorf(smallDisplayH);
return;
} else {
float pixelCrop = frameH / 270.0f;
float resCommonWidescreen = pixelCrop - floor(pixelCrop);
if (!rotated && resCommonWidescreen == 0.0f) {
*x = 0;
*y = floorf(-pixelCrop);
*w = floorf(frameW);
*h = floorf(pixelCrop * 272.0f);
return;
}
*x = floorf(((frameW - smallDisplayH) / 2.0f) + offsetX);
*y = floorf(((frameH - smallDisplayW) / 2.0f) + offsetY);
*w = floorf(smallDisplayH);
*h = floorf(smallDisplayW);
return;
}
} else if (g_Config.iSmallDisplayZoomType == 2) { // Auto Scaling
float pixelCrop = frameH / 270.0f;
float resCommonWidescreen = pixelCrop - floor(pixelCrop);
if (!rotated && resCommonWidescreen == 0.0f) {
*x = 0;
*y = floorf(-pixelCrop);
*w = floorf(frameW);
*h = floorf(pixelCrop * 272.0f);
return;
}
}


float origRatio = !rotated ? origW / origH : origH / origW;
float frameRatio = frameW / frameH;

if (origRatio > frameRatio) {
// Image is wider than frame. Center vertically.
outW = frameW;
outH = frameW / origRatio;
// Stretch a little bit
if (!rotated && g_Config.bPartialStretch)
if (!rotated && g_Config.iSmallDisplayZoomType == 1) // Partial Stretch
outH = (frameH + outH) / 2.0f; // (408 + 720) / 2 = 564
} else {
// Image is taller than frame. Center horizontally.
outW = frameH * origRatio;
outH = frameH;
if (rotated && g_Config.iSmallDisplayZoomType == 1) // Partial Stretch
outW = (frameH + outH) / 2.0f; // (408 + 720) / 2 = 564
}
}

Expand Down
24 changes: 15 additions & 9 deletions Qt/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ void MainWindow::updateMenus()
}
}

foreach(QAction * action, displayLayoutGroup->actions()) {
if (g_Config.iSmallDisplayZoomType == action->data().toInt()) {

if (gpu)
gpu->Resized();

action->setChecked(true);
break;
}
}

int defaultLevel = LogManager::GetInstance()->GetLogLevel(LogTypes::COMMON);
foreach(QAction * action, defaultLogGroup->actions()) {
if (defaultLevel == action->data().toInt()) {
Expand Down Expand Up @@ -334,13 +345,6 @@ void MainWindow::memviewTexAct()
memoryTexWindow->show();
}

void MainWindow::stretchAct()
{
g_Config.bStretchToDisplay = !g_Config.bStretchToDisplay;
if (gpu)
gpu->Resized();
}

void MainWindow::raiseTopMost()
{

Expand Down Expand Up @@ -539,8 +543,10 @@ void MainWindow::createMenus()
QList<int>() << 1 << 2 << 3 << 4,
QList<int>() << Qt::CTRL + Qt::Key_1 << Qt::CTRL + Qt::Key_2 << Qt::CTRL + Qt::Key_3 << Qt::CTRL + Qt::Key_4);

videoMenu->add(new MenuAction(this, SLOT(stretchAct()), QT_TR_NOOP("&Stretch to Display")))
->addEventChecked(&g_Config.bStretchToDisplay);
MenuTree* displayLayoutMenu = new MenuTree(this, videoMenu, QT_TR_NOOP("&Display Layout Options"));
displayLayoutGroup = new MenuActionGroup(this, displayLayoutMenu, SLOT(displayLayoutGroup_triggered(QAction *)),
QStringList() << "Stretched" << "Partialy stretched" << "Auto Scaling" << "Manual Scaling",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*Partially.... does this get translated?

-[Unknown]

QList<int>() << 0 << 1 << 2 << 3);
videoMenu->addSeparator();
videoMenu->add(new MenuAction(this, SLOT(transformAct()), QT_TR_NOOP("&Hardware Transform"), Qt::Key_F6))
->addEventChecked(&g_Config.bHardwareTransform);
Expand Down
4 changes: 2 additions & 2 deletions Qt/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private slots:

void screenGroup_triggered(QAction *action) { SetZoom(action->data().toInt()); }

void stretchAct();
void displayLayoutGroup_triggered(QAction *action) { g_Config.iSmallDisplayZoomType = action->data().toInt(); }
void transformAct() { g_Config.bHardwareTransform = !g_Config.bHardwareTransform; }
void vertexCacheAct() { g_Config.bVertexCache = !g_Config.bVertexCache; }
void frameskipAct() { g_Config.iFrameSkip = !g_Config.iFrameSkip; }
Expand Down Expand Up @@ -154,7 +154,7 @@ private slots:
Debugger_MemoryTex *memoryTexWindow;
Debugger_DisplayList *displaylistWindow;

QActionGroup *anisotropicGroup, *screenGroup,
QActionGroup *anisotropicGroup, *screenGroup, *displayLayoutGroup,
*defaultLogGroup, *g3dLogGroup, *hleLogGroup;
};

Expand Down
Loading