mirror of
https://github.com/libretro/ppsspp.git
synced 2025-02-24 19:00:54 +00:00
More consistent handling of resolution changes. Should help #7995
This commit is contained in:
parent
7e70a743ca
commit
ec63663ad5
@ -16,6 +16,9 @@
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
|
||||
#include "i18n/i18n.h"
|
||||
#include "Common/Common.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/CoreParameter.h"
|
||||
@ -25,6 +28,7 @@
|
||||
#include "GPU/Common/FramebufferCommon.h"
|
||||
#include "GPU/GPUInterface.h"
|
||||
#include "GPU/GPUState.h"
|
||||
#include "UI/OnScreenDisplay.h" // Gross dependency!
|
||||
|
||||
void CenterRect(float *x, float *y, float *w, float *h, float origW, float origH, float frameW, float frameH, int rotation) {
|
||||
float outW;
|
||||
@ -829,3 +833,15 @@ void FramebufferManagerCommon::UpdateFramebufUsage(VirtualFramebuffer *vfb) {
|
||||
checkFlag(FB_USAGE_TEXTURE, vfb->last_frame_used);
|
||||
checkFlag(FB_USAGE_RENDERTARGET, vfb->last_frame_render);
|
||||
}
|
||||
|
||||
void FramebufferManagerCommon::ShowScreenResolution() {
|
||||
I18NCategory *gr = GetI18NCategory("Graphics");
|
||||
|
||||
std::ostringstream messageStream;
|
||||
messageStream << gr->T("Internal Resolution") << ": ";
|
||||
messageStream << PSP_CoreParameter().renderWidth << "x" << PSP_CoreParameter().renderHeight << " ";
|
||||
messageStream << gr->T("Window Size") << ": ";
|
||||
messageStream << PSP_CoreParameter().pixelWidth << "x" << PSP_CoreParameter().pixelHeight;
|
||||
|
||||
osm.Show(messageStream.str(), 2.0f);
|
||||
}
|
@ -230,6 +230,8 @@ protected:
|
||||
virtual void NotifyRenderFramebufferSwitched(VirtualFramebuffer *prevVfb, VirtualFramebuffer *vfb, bool isClearingDepth) = 0;
|
||||
virtual void NotifyRenderFramebufferUpdated(VirtualFramebuffer *vfb, bool vfbFormatChanged) = 0;
|
||||
|
||||
void ShowScreenResolution();
|
||||
|
||||
bool ShouldDownloadFramebuffer(const VirtualFramebuffer *vfb) const;
|
||||
void FindTransferFramebuffers(VirtualFramebuffer *&dstBuffer, VirtualFramebuffer *&srcBuffer, u32 dstBasePtr, int dstStride, int &dstX, int &dstY, u32 srcBasePtr, int srcStride, int &srcX, int &srcY, int &srcWidth, int &srcHeight, int &dstWidth, int &dstHeight, int bpp) const;
|
||||
|
||||
|
@ -39,6 +39,8 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
void ShowScreenResolution();
|
||||
|
||||
namespace DX9 {
|
||||
static void ConvertFromRGBA8888(u8 *dst, u8 *src, u32 dstStride, u32 srcStride, u32 width, u32 height, GEBufferFormat format);
|
||||
|
||||
@ -1107,13 +1109,36 @@ namespace DX9 {
|
||||
void FramebufferManagerDX9::EndFrame() {
|
||||
if (resized_) {
|
||||
DestroyAllFBOs();
|
||||
dxstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
|
||||
dxstate.viewport.set(0, 0, pixelWidth_, pixelHeight_);
|
||||
// Actually, auto mode should be more granular...
|
||||
// Round up to a zoom factor for the render size.
|
||||
int zoom = g_Config.iInternalResolution;
|
||||
if (zoom == 0) { // auto mode
|
||||
// Use the longest dimension
|
||||
if (g_Config.IsPortrait()) {
|
||||
zoom = (pixelWidth_ + 479) / 480;
|
||||
} else {
|
||||
zoom = (pixelHeight_ + 479) / 480;
|
||||
}
|
||||
}
|
||||
if (zoom <= 1)
|
||||
zoom = 1;
|
||||
|
||||
if (g_Config.IsPortrait()) {
|
||||
PSP_CoreParameter().renderWidth = 272 * zoom;
|
||||
PSP_CoreParameter().renderHeight = 480 * zoom;
|
||||
} else {
|
||||
PSP_CoreParameter().renderWidth = 480 * zoom;
|
||||
PSP_CoreParameter().renderHeight = 272 * zoom;
|
||||
}
|
||||
|
||||
resized_ = false;
|
||||
}
|
||||
#if 0
|
||||
// We flush to memory last requested framebuffer, if any
|
||||
PackFramebufferAsync_(NULL);
|
||||
#endif
|
||||
ShowScreenResolution();
|
||||
}
|
||||
|
||||
void FramebufferManagerDX9::DeviceLost() {
|
||||
|
@ -1653,18 +1653,41 @@ void FramebufferManager::PackFramebufferSync_(VirtualFramebuffer *vfb, int x, in
|
||||
fbo_unbind_read();
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
void ShowScreenResolution();
|
||||
#endif
|
||||
|
||||
void FramebufferManager::EndFrame() {
|
||||
if (resized_) {
|
||||
DestroyAllFBOs();
|
||||
glstate.viewport.set(0, 0, pixelWidth_, pixelHeight_);
|
||||
#ifndef _WIN32 // We do the same thing elsewhere
|
||||
|
||||
// Actually, auto mode should be more granular...
|
||||
// Round up to a zoom factor for the render size.
|
||||
int zoom = g_Config.iInternalResolution;
|
||||
if (zoom == 0) // auto mode
|
||||
zoom = (pixelWidth_ + 479) / 480;
|
||||
PSP_CoreParameter().renderWidth = 480 * zoom;
|
||||
PSP_CoreParameter().renderHeight = 272 * zoom;
|
||||
#endif
|
||||
if (zoom == 0) { // auto mode
|
||||
// Use the longest dimension
|
||||
if (g_Config.IsPortrait()) {
|
||||
zoom = (pixelWidth_ + 479) / 480;
|
||||
} else {
|
||||
zoom = (pixelHeight_ + 479) / 480;
|
||||
}
|
||||
}
|
||||
if (zoom <= 1)
|
||||
zoom = 1;
|
||||
|
||||
if (g_Config.IsPortrait()) {
|
||||
PSP_CoreParameter().renderWidth = 272 * zoom;
|
||||
PSP_CoreParameter().renderHeight = 480 * zoom;
|
||||
} else {
|
||||
PSP_CoreParameter().renderWidth = 480 * zoom;
|
||||
PSP_CoreParameter().renderHeight = 272 * zoom;
|
||||
}
|
||||
|
||||
resized_ = false;
|
||||
#ifdef _WIN32
|
||||
ShowScreenResolution();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef USING_GLES2
|
||||
|
@ -200,45 +200,6 @@ namespace MainWindow
|
||||
rcOuter.top = g_Config.iWindowY;
|
||||
}
|
||||
|
||||
static void ShowScreenResolution() {
|
||||
I18NCategory *gr = GetI18NCategory("Graphics");
|
||||
|
||||
std::ostringstream messageStream;
|
||||
messageStream << gr->T("Internal Resolution") << ": ";
|
||||
messageStream << PSP_CoreParameter().renderWidth << "x" << PSP_CoreParameter().renderHeight << " ";
|
||||
messageStream << gr->T("Window Size") << ": ";
|
||||
messageStream << PSP_CoreParameter().pixelWidth << "x" << PSP_CoreParameter().pixelHeight;
|
||||
|
||||
osm.Show(messageStream.str(), 2.0f);
|
||||
}
|
||||
|
||||
static void UpdateRenderResolution() {
|
||||
RECT rc;
|
||||
GetClientRect(hwndMain, &rc);
|
||||
|
||||
// Actually, auto mode should be more granular...
|
||||
// Round up to a zoom factor for the render size.
|
||||
int zoom = g_Config.iInternalResolution;
|
||||
if (zoom == 0) { // auto mode
|
||||
// Use the longest dimension
|
||||
if (g_Config.IsPortrait()) {
|
||||
zoom = (rc.bottom - rc.top + 479) / 480;
|
||||
} else {
|
||||
zoom = (rc.right - rc.left + 479) / 480;
|
||||
}
|
||||
}
|
||||
if (zoom <= 1)
|
||||
zoom = 1;
|
||||
|
||||
if (g_Config.IsPortrait()) {
|
||||
PSP_CoreParameter().renderWidth = 272 * zoom;
|
||||
PSP_CoreParameter().renderHeight = 480 * zoom;
|
||||
} else {
|
||||
PSP_CoreParameter().renderWidth = 480 * zoom;
|
||||
PSP_CoreParameter().renderHeight = 272 * zoom;
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsWindowSmall() {
|
||||
// Can't take this from config as it will not be set if windows is maximized.
|
||||
RECT rc;
|
||||
@ -259,7 +220,6 @@ namespace MainWindow
|
||||
GetWindowRectAtResolution(480 * (int)zoom, 272 * (int)zoom, rc, rcOuter);
|
||||
}
|
||||
MoveWindow(hwndMain, rcOuter.left, rcOuter.top, rcOuter.right - rcOuter.left, rcOuter.bottom - rcOuter.top, TRUE);
|
||||
ShowScreenResolution();
|
||||
}
|
||||
|
||||
void SetInternalResolution(int res) {
|
||||
@ -276,9 +236,6 @@ namespace MainWindow
|
||||
|
||||
if (gpu)
|
||||
gpu->Resized();
|
||||
|
||||
UpdateRenderResolution();
|
||||
ShowScreenResolution();
|
||||
}
|
||||
|
||||
void CorrectCursor() {
|
||||
@ -320,8 +277,6 @@ namespace MainWindow
|
||||
PSP_CoreParameter().pixelHeight = height;
|
||||
}
|
||||
|
||||
UpdateRenderResolution();
|
||||
|
||||
if (UpdateScreenScale(width, height, IsWindowSmall())) {
|
||||
NativeMessageReceived("gpu resized", "");
|
||||
}
|
||||
@ -395,10 +350,6 @@ namespace MainWindow
|
||||
|
||||
CorrectCursor();
|
||||
|
||||
bool showOSM = (g_Config.iInternalResolution == RESOLUTION_AUTO);
|
||||
if (showOSM) {
|
||||
ShowScreenResolution();
|
||||
}
|
||||
ShowOwnedPopups(hwndMain, goingFullscreen ? FALSE : TRUE);
|
||||
W32Util::MakeTopMost(hwndMain, g_Config.bTopMost);
|
||||
|
||||
@ -902,10 +853,6 @@ namespace MainWindow
|
||||
TranslateMenus(hwndMain, menu);
|
||||
break;
|
||||
|
||||
case WM_USER_UPDATE_SCREEN:
|
||||
ShowScreenResolution();
|
||||
break;
|
||||
|
||||
case WM_USER_WINDOW_TITLE_CHANGED:
|
||||
UpdateWindowTitle();
|
||||
break;
|
||||
|
@ -11,7 +11,6 @@ namespace MainWindow
|
||||
enum {
|
||||
WM_USER_SAVESTATE_FINISH = WM_USER + 100,
|
||||
WM_USER_UPDATE_UI = WM_USER + 101,
|
||||
WM_USER_UPDATE_SCREEN = WM_USER + 102,
|
||||
WM_USER_WINDOW_TITLE_CHANGED = WM_USER + 103,
|
||||
WM_USER_BROWSE_BOOT_DONE = WM_USER + 104,
|
||||
WM_USER_TOGGLE_FULLSCREEN = WM_USER + 105,
|
||||
|
Loading…
x
Reference in New Issue
Block a user