Changeset - r24916:2d0cdad1b8b0
[Not reviewed]
master
0 2 0
Michael Lutz - 4 years ago 2021-02-21 18:16:18
michi@icosahedron.de
Codechange: [SDL] Move dirty_rect to class scope.
2 files changed with 6 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/video/sdl2_v.cpp
Show inline comments
 
@@ -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::AllocateBackingSto
 
	 * 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;
src/video/sdl2_v.h
Show inline comments
 
@@ -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;
0 comments (0 inline, 0 general)