Codechange: use RAII to automatically restore _cur_dpi after use

This commit is contained in:
Rubidium
2023-01-26 19:21:36 +01:00
committed by rubidium42
parent b7a5d8e296
commit f001e84e5e
18 changed files with 122 additions and 136 deletions

View File

@@ -8,6 +8,7 @@
/** @file screenshot.cpp The creation of screenshots! */
#include "stdafx.h"
#include "core/backup_type.hpp"
#include "fileio_func.h"
#include "viewport_func.h"
#include "gfx_func.h"
@@ -617,7 +618,7 @@ static void CurrentScreenCallback(void *userdata, void *buf, uint y, uint pitch,
static void LargeWorldCallback(void *userdata, void *buf, uint y, uint pitch, uint n)
{
Viewport *vp = (Viewport *)userdata;
DrawPixelInfo dpi, *old_dpi;
DrawPixelInfo dpi;
int wx, left;
/* We are no longer rendering to the screen */
@@ -630,8 +631,7 @@ static void LargeWorldCallback(void *userdata, void *buf, uint y, uint pitch, ui
_screen.pitch = pitch;
_screen_disable_anim = true;
old_dpi = _cur_dpi;
_cur_dpi = &dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &dpi);
dpi.dst_ptr = buf;
dpi.height = n;
@@ -655,8 +655,6 @@ static void LargeWorldCallback(void *userdata, void *buf, uint y, uint pitch, ui
);
}
_cur_dpi = old_dpi;
/* Switch back to rendering to the screen */
_screen = old_screen;
_screen_disable_anim = old_disable_anim;