Skip to content

Commit

Permalink
Force a full redraw on resize events.
Browse files Browse the repository at this point in the history
This fixes the worst of the resize-related artefacts during gameplay
by forcing a full redraw on every resize event. These changes will be
revisited as a part of #23934.
  • Loading branch information
aginor committed Dec 18, 2015
1 parent 5c187a5 commit 3240d4a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/gui/widgets/window.cpp
Expand Up @@ -1446,7 +1446,7 @@ void twindow::signal_handler_sdl_video_resize(const event::tevent event,
const tpoint& new_size)
{
DBG_GUI_E << LOG_HEADER << ' ' << event << ".\n";

#if !SDL_VERSION_ATLEAST(2, 0, 0)
if(new_size.x < preferences::min_allowed_width()
|| new_size.y < preferences::min_allowed_height()) {

Expand All @@ -1461,6 +1461,7 @@ void twindow::signal_handler_sdl_video_resize(const event::tevent event,
handled = true;
return;
}
#endif

if(!preferences::set_resolution(video_, new_size.x, new_size.y)) {

Expand Down
4 changes: 3 additions & 1 deletion src/preferences_display.cpp
Expand Up @@ -176,11 +176,13 @@ bool set_resolution(CVideo& video
int bpp = video.bppForMode(width, height, flags);

if(bpp != 0) {
video.setMode(width, height, bpp, flags);
//video.setMode(width, height, bpp, flags);

#if !SDL_VERSION_ATLEAST(2, 0, 0)
if(disp) {
disp->redraw_everything();
}
#endif

} else {
// grzywacz: is this even true?
Expand Down
8 changes: 8 additions & 0 deletions src/video.cpp
Expand Up @@ -30,6 +30,7 @@
#include "sdl/window.hpp"
#include "video.hpp"
#include "sdl/gpu.hpp"
#include "display.hpp"

#include <boost/foreach.hpp>

Expand All @@ -47,11 +48,18 @@ namespace {
GPU_Target *render_target_;
}
void resize_monitor::process(events::pump_info &info) {
#if !SDL_VERSION_ATLEAST(2, 0, 0)
if(info.resize_dimensions.first >= preferences::min_allowed_width()
&& info.resize_dimensions.second >= preferences::min_allowed_height()
&& disallow_resize == 0) {
preferences::set_resolution(info.resize_dimensions);
}
#else
if(info.resize_dimensions.first > 0 &&
info.resize_dimensions.second > 0
&& display::get_singleton())
display::get_singleton()->redraw_everything();
#endif
}

resize_lock::resize_lock()
Expand Down

0 comments on commit 3240d4a

Please sign in to comment.