Skip to content

Commit

Permalink
Partly clean up SDL resize code, should help #11974
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jun 23, 2020
1 parent af7995c commit f9cef5b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
2 changes: 2 additions & 0 deletions Common/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ void AndroidAssertLog(const char *func, const char *file, int line, const char *
#if MAX_LOGLEVEL >= DEBUG_LEVEL
#define _dbg_assert_(_t_, _a_) \
if (!(_a_)) {\
printf(#_a_ "\n\nError...\n\n Line: %d\n File: %s\n\n", \
__LINE__, __FILE__); \
ERROR_LOG(_t_, #_a_ "\n\nError...\n\n Line: %d\n File: %s\n\nIgnore and continue?", \
__LINE__, __FILE__); \
if (!PanicYesNo("*** Assertion ***\n")) { Crash(); } \
Expand Down
2 changes: 1 addition & 1 deletion Core/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ bool UpdateScreenScale(int width, int height) {
dp_yres = new_dp_yres;
pixel_xres = width;
pixel_yres = height;
DEBUG_LOG(SYSTEM, "pixel_res: %dx%d. Calling NativeResized()", pixel_xres, pixel_yres);
ILOG("pixel_res: %dx%d. Calling NativeResized()", pixel_xres, pixel_yres);
NativeResized();
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion GPU/GPUCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ class GPUCommon : public GPUInterface, public GPUDebugInterface {
bool dumpThisFrame_;
bool debugRecording_;
bool interruptsEnabled_;
bool resized_;
bool resized_ = false;
DrawType lastDraw_ = DRAW_UNKNOWN;
GEPrimitiveType lastPrim_ = GE_PRIM_INVALID;

Expand Down
2 changes: 1 addition & 1 deletion GPU/Vulkan/GPU_Vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ void GPU_Vulkan::BeginHostFrame() {
if (vulkan_->GetDeviceFeatures().enabled.wideLines) {
drawEngine_.SetLineWidth(PSP_CoreParameter().renderWidth / 480.0f);
}
resized_ = false;
}
resized_ = false;

textureCacheVulkan_->StartFrame();

Expand Down
11 changes: 5 additions & 6 deletions SDL/SDLMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,19 +776,18 @@ int main(int argc, char *argv[]) {
case SDL_WINDOWEVENT:
switch (event.window.event) {
case SDL_WINDOWEVENT_SIZE_CHANGED: // better than RESIZED, more general
case SDL_WINDOWEVENT_MAXIMIZED:
case SDL_WINDOWEVENT_RESTORED:
{
int new_width = event.window.data1;
int new_height = event.window.data2;

windowHidden = false;
Core_NotifyWindowHidden(windowHidden);

Uint32 window_flags = SDL_GetWindowFlags(window);
bool fullscreen = (window_flags & SDL_WINDOW_FULLSCREEN);

if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
UpdateScreenScale(event.window.data1, event.window.data2);
}
NativeMessageReceived("gpu_resized", "");
// This one calls NativeResized if the size changed.
UpdateScreenScale(new_width, new_height);

// Set variable here in case fullscreen was toggled by hotkey
g_Config.bFullScreen = fullscreen;
Expand Down
12 changes: 5 additions & 7 deletions UI/NativeApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1087,13 +1087,11 @@ void NativeRender(GraphicsContext *graphicsContext) {
graphicsContext->Resize();
screenManager->resized();

// TODO: Move this to new GraphicsContext objects for each backend.
#ifndef _WIN32
if (GetGPUBackend() == GPUBackend::OPENGL) {
PSP_CoreParameter().pixelWidth = pixel_xres;
PSP_CoreParameter().pixelHeight = pixel_yres;
NativeMessageReceived("gpu_resized", "");
}
// TODO: Move this to the GraphicsContext objects for each backend.
#if !defined(_WIN32) && !defined(ANDROID)
PSP_CoreParameter().pixelWidth = pixel_xres;
PSP_CoreParameter().pixelHeight = pixel_yres;
NativeMessageReceived("gpu_resized", "");
#endif
} else {
// ILOG("Polling graphics context");
Expand Down

0 comments on commit f9cef5b

Please sign in to comment.