More consistent handling of resolution changes. Should help #7995

This commit is contained in:
Henrik Rydgard 2015-09-23 12:25:38 +02:00
parent 7e70a743ca
commit ec63663ad5
6 changed files with 73 additions and 61 deletions

View File

@ -16,6 +16,9 @@
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include <algorithm> #include <algorithm>
#include <sstream>
#include "i18n/i18n.h"
#include "Common/Common.h" #include "Common/Common.h"
#include "Core/Config.h" #include "Core/Config.h"
#include "Core/CoreParameter.h" #include "Core/CoreParameter.h"
@ -25,6 +28,7 @@
#include "GPU/Common/FramebufferCommon.h" #include "GPU/Common/FramebufferCommon.h"
#include "GPU/GPUInterface.h" #include "GPU/GPUInterface.h"
#include "GPU/GPUState.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) { void CenterRect(float *x, float *y, float *w, float *h, float origW, float origH, float frameW, float frameH, int rotation) {
float outW; float outW;
@ -829,3 +833,15 @@ void FramebufferManagerCommon::UpdateFramebufUsage(VirtualFramebuffer *vfb) {
checkFlag(FB_USAGE_TEXTURE, vfb->last_frame_used); checkFlag(FB_USAGE_TEXTURE, vfb->last_frame_used);
checkFlag(FB_USAGE_RENDERTARGET, vfb->last_frame_render); 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);
}

View File

@ -230,6 +230,8 @@ protected:
virtual void NotifyRenderFramebufferSwitched(VirtualFramebuffer *prevVfb, VirtualFramebuffer *vfb, bool isClearingDepth) = 0; virtual void NotifyRenderFramebufferSwitched(VirtualFramebuffer *prevVfb, VirtualFramebuffer *vfb, bool isClearingDepth) = 0;
virtual void NotifyRenderFramebufferUpdated(VirtualFramebuffer *vfb, bool vfbFormatChanged) = 0; virtual void NotifyRenderFramebufferUpdated(VirtualFramebuffer *vfb, bool vfbFormatChanged) = 0;
void ShowScreenResolution();
bool ShouldDownloadFramebuffer(const VirtualFramebuffer *vfb) const; 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; 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;

View File

@ -39,6 +39,8 @@
#include <algorithm> #include <algorithm>
void ShowScreenResolution();
namespace DX9 { namespace DX9 {
static void ConvertFromRGBA8888(u8 *dst, u8 *src, u32 dstStride, u32 srcStride, u32 width, u32 height, GEBufferFormat format); 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() { void FramebufferManagerDX9::EndFrame() {
if (resized_) { if (resized_) {
DestroyAllFBOs(); 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; resized_ = false;
} }
#if 0 #if 0
// We flush to memory last requested framebuffer, if any // We flush to memory last requested framebuffer, if any
PackFramebufferAsync_(NULL); PackFramebufferAsync_(NULL);
#endif #endif
ShowScreenResolution();
} }
void FramebufferManagerDX9::DeviceLost() { void FramebufferManagerDX9::DeviceLost() {

View File

@ -1653,18 +1653,41 @@ void FramebufferManager::PackFramebufferSync_(VirtualFramebuffer *vfb, int x, in
fbo_unbind_read(); fbo_unbind_read();
} }
#ifdef _WIN32
void ShowScreenResolution();
#endif
void FramebufferManager::EndFrame() { void FramebufferManager::EndFrame() {
if (resized_) { if (resized_) {
DestroyAllFBOs(); DestroyAllFBOs();
glstate.viewport.set(0, 0, pixelWidth_, pixelHeight_); 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; int zoom = g_Config.iInternalResolution;
if (zoom == 0) // auto mode if (zoom == 0) { // auto mode
// Use the longest dimension
if (g_Config.IsPortrait()) {
zoom = (pixelWidth_ + 479) / 480; 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().renderWidth = 480 * zoom;
PSP_CoreParameter().renderHeight = 272 * zoom; PSP_CoreParameter().renderHeight = 272 * zoom;
#endif }
resized_ = false; resized_ = false;
#ifdef _WIN32
ShowScreenResolution();
#endif
} }
#ifndef USING_GLES2 #ifndef USING_GLES2

View File

@ -200,45 +200,6 @@ namespace MainWindow
rcOuter.top = g_Config.iWindowY; 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() { static bool IsWindowSmall() {
// Can't take this from config as it will not be set if windows is maximized. // Can't take this from config as it will not be set if windows is maximized.
RECT rc; RECT rc;
@ -259,7 +220,6 @@ namespace MainWindow
GetWindowRectAtResolution(480 * (int)zoom, 272 * (int)zoom, rc, rcOuter); GetWindowRectAtResolution(480 * (int)zoom, 272 * (int)zoom, rc, rcOuter);
} }
MoveWindow(hwndMain, rcOuter.left, rcOuter.top, rcOuter.right - rcOuter.left, rcOuter.bottom - rcOuter.top, TRUE); MoveWindow(hwndMain, rcOuter.left, rcOuter.top, rcOuter.right - rcOuter.left, rcOuter.bottom - rcOuter.top, TRUE);
ShowScreenResolution();
} }
void SetInternalResolution(int res) { void SetInternalResolution(int res) {
@ -276,9 +236,6 @@ namespace MainWindow
if (gpu) if (gpu)
gpu->Resized(); gpu->Resized();
UpdateRenderResolution();
ShowScreenResolution();
} }
void CorrectCursor() { void CorrectCursor() {
@ -320,8 +277,6 @@ namespace MainWindow
PSP_CoreParameter().pixelHeight = height; PSP_CoreParameter().pixelHeight = height;
} }
UpdateRenderResolution();
if (UpdateScreenScale(width, height, IsWindowSmall())) { if (UpdateScreenScale(width, height, IsWindowSmall())) {
NativeMessageReceived("gpu resized", ""); NativeMessageReceived("gpu resized", "");
} }
@ -395,10 +350,6 @@ namespace MainWindow
CorrectCursor(); CorrectCursor();
bool showOSM = (g_Config.iInternalResolution == RESOLUTION_AUTO);
if (showOSM) {
ShowScreenResolution();
}
ShowOwnedPopups(hwndMain, goingFullscreen ? FALSE : TRUE); ShowOwnedPopups(hwndMain, goingFullscreen ? FALSE : TRUE);
W32Util::MakeTopMost(hwndMain, g_Config.bTopMost); W32Util::MakeTopMost(hwndMain, g_Config.bTopMost);
@ -902,10 +853,6 @@ namespace MainWindow
TranslateMenus(hwndMain, menu); TranslateMenus(hwndMain, menu);
break; break;
case WM_USER_UPDATE_SCREEN:
ShowScreenResolution();
break;
case WM_USER_WINDOW_TITLE_CHANGED: case WM_USER_WINDOW_TITLE_CHANGED:
UpdateWindowTitle(); UpdateWindowTitle();
break; break;

View File

@ -11,7 +11,6 @@ namespace MainWindow
enum { enum {
WM_USER_SAVESTATE_FINISH = WM_USER + 100, WM_USER_SAVESTATE_FINISH = WM_USER + 100,
WM_USER_UPDATE_UI = WM_USER + 101, WM_USER_UPDATE_UI = WM_USER + 101,
WM_USER_UPDATE_SCREEN = WM_USER + 102,
WM_USER_WINDOW_TITLE_CHANGED = WM_USER + 103, WM_USER_WINDOW_TITLE_CHANGED = WM_USER + 103,
WM_USER_BROWSE_BOOT_DONE = WM_USER + 104, WM_USER_BROWSE_BOOT_DONE = WM_USER + 104,
WM_USER_TOGGLE_FULLSCREEN = WM_USER + 105, WM_USER_TOGGLE_FULLSCREEN = WM_USER + 105,