From a77b202767d98ae0904e6f42efb10a38c4c40c4e Mon Sep 17 00:00:00 2001 From: Michael Lutz Date: Sun, 21 Feb 2021 19:16:18 +0100 Subject: Codechange: [SDL] Move dirty_rect to class scope. --- src/video/sdl2_v.cpp | 12 +++++------- src/video/sdl2_v.h | 1 + 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/video/sdl2_v.cpp b/src/video/sdl2_v.cpp index 72ecb97c1..86774fc56 100644 --- a/src/video/sdl2_v.cpp +++ b/src/video/sdl2_v.cpp @@ -44,12 +44,10 @@ static SDL_Palette *_sdl_palette; static bool _cursor_new_in_window = false; #endif -static Rect _dirty_rect; - void VideoDriver_SDL::MakeDirty(int left, int top, int width, int height) { Rect r = {left, top, left + width, top + height}; - _dirty_rect = BoundingRect(_dirty_rect, r); + this->dirty_rect = BoundingRect(this->dirty_rect, r); } void VideoDriver_SDL::UpdatePalette() @@ -116,7 +114,7 @@ void VideoDriver_SDL::Paint() { PerformanceMeasurer framerate(PFE_VIDEO); - if (IsEmptyRect(_dirty_rect) && _cur_palette.count_dirty == 0) return; + if (IsEmptyRect(this->dirty_rect) && _cur_palette.count_dirty == 0) return; if (_cur_palette.count_dirty != 0) { Blitter *blitter = BlitterFactory::GetCurrentBlitter(); @@ -146,14 +144,14 @@ void VideoDriver_SDL::Paint() _cur_palette.count_dirty = 0; } - SDL_Rect r = { _dirty_rect.left, _dirty_rect.top, _dirty_rect.right - _dirty_rect.left, _dirty_rect.bottom - _dirty_rect.top }; + SDL_Rect r = { this->dirty_rect.left, this->dirty_rect.top, this->dirty_rect.right - this->dirty_rect.left, this->dirty_rect.bottom - this->dirty_rect.top }; if (_sdl_surface != _sdl_real_surface) { SDL_BlitSurface(_sdl_surface, &r, _sdl_real_surface, &r); } SDL_UpdateWindowSurfaceRects(this->sdl_window, &r, 1); - _dirty_rect = {}; + this->dirty_rect = {}; } void VideoDriver_SDL::PaintThread() @@ -363,7 +361,7 @@ bool VideoDriver_SDL::AllocateBackingStore(int w, int h, bool force) * gotten smaller, reset our dirty rects. GameSizeChanged() a bit lower * will mark the whole screen dirty again anyway, but this time with the * new dimensions. */ - _dirty_rect = {}; + this->dirty_rect = {}; _screen.width = _sdl_surface->w; _screen.height = _sdl_surface->h; diff --git a/src/video/sdl2_v.h b/src/video/sdl2_v.h index 19c208cfe..cfd82d151 100644 --- a/src/video/sdl2_v.h +++ b/src/video/sdl2_v.h @@ -53,6 +53,7 @@ protected: std::condition_variable_any *draw_signal = nullptr; ///< Signal to draw the next frame. volatile bool draw_continue; ///< Should we keep continue drawing? bool buffer_locked; ///< Video buffer was locked by the main thread. + Rect dirty_rect; ///< Rectangle encompassing the dirty area of the video buffer. Dimension GetScreenSize() const override; void InputLoop() override; -- cgit v1.2.3-54-g00ecf