File diff r24881:5db3ebe7cd4e → r24882:93b227b5ef29
src/video/win32_v.cpp
Show inline comments
 
@@ -61,14 +61,12 @@ static std::recursive_mutex *_draw_mutex
 
/** Signal to draw the next frame. */
 
static std::condition_variable_any *_draw_signal = nullptr;
 
/** Should we keep continue drawing? */
 
static volatile bool _draw_continue;
 
/** Local copy of the palette for use in the drawing thread. */
 
static Palette _local_palette;
 
/** Region of the screen that needs redrawing. */
 
static Rect _dirty_rect;
 

	
 
bool VideoDriver_Win32Base::ClaimMousePointer()
 
{
 
	MyShowCursor(false, true);
 
	return true;
 
}
 
@@ -883,13 +881,13 @@ void VideoDriver_Win32Base::Stop()
 
	if (this->fullscreen) ChangeDisplaySettings(nullptr, 0);
 
	MyShowCursor(true);
 
}
 
void VideoDriver_Win32Base::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_Win32Base::CheckPaletteAnim()
 
{
 
	if (_cur_palette.count_dirty == 0) return;
 

	
 
@@ -1240,13 +1238,13 @@ void VideoDriver_Win32GDI::PaletteChange
 
}
 

	
 
void VideoDriver_Win32GDI::Paint()
 
{
 
	PerformanceMeasurer framerate(PFE_VIDEO);
 

	
 
	if (IsEmptyRect(_dirty_rect)) return;
 
	if (IsEmptyRect(this->dirty_rect)) return;
 

	
 
	HDC dc = GetDC(this->main_wnd);
 
	HDC dc2 = CreateCompatibleDC(dc);
 

	
 
	HBITMAP old_bmp = (HBITMAP)SelectObject(dc2, this->dib_sect);
 
	HPALETTE old_palette = SelectPalette(dc, this->gdi_palette, FALSE);
 
@@ -1276,13 +1274,13 @@ void VideoDriver_Win32GDI::Paint()
 
	SelectPalette(dc, old_palette, TRUE);
 
	SelectObject(dc2, old_bmp);
 
	DeleteDC(dc2);
 

	
 
	ReleaseDC(this->main_wnd, dc);
 

	
 
	_dirty_rect = {};
 
	this->dirty_rect = {};
 
}
 

	
 
void VideoDriver_Win32GDI::PaintThread()
 
{
 
	/* First tell the main thread we're started */
 
	std::unique_lock<std::recursive_mutex> lock(*_draw_mutex);
 
@@ -1443,21 +1441,25 @@ bool VideoDriver_Win32OpenGL::AllocateBa
 

	
 
	_wnd.width = w = std::max(w, 64);
 
	_wnd.height = h = std::max(h, 64);
 

	
 
	if (this->gl_rc == nullptr) return false;
 

	
 
	this->dirty_rect = {};
 

	
 
	bool res = OpenGLBackend::Get()->Resize(w, h);
 
	_wnd.buffer_bits = OpenGLBackend::Get()->GetVideoBuffer();
 
	return res;
 
}
 

	
 
void VideoDriver_Win32OpenGL::Paint()
 
{
 
	PerformanceMeasurer framerate(PFE_VIDEO);
 

	
 
	if (IsEmptyRect(this->dirty_rect)) return;
 

	
 
	if (_cur_palette.count_dirty != 0) {
 
		Blitter *blitter = BlitterFactory::GetCurrentBlitter();
 

	
 
		switch (blitter->UsePaletteAnimation()) {
 
			case Blitter::PALETTE_ANIMATION_BLITTER:
 
				blitter->PaletteAnimate(_local_palette);
 
@@ -1470,11 +1472,13 @@ void VideoDriver_Win32OpenGL::Paint()
 
			default:
 
				NOT_REACHED();
 
		}
 
		_cur_palette.count_dirty = 0;
 
	}
 

	
 
	OpenGLBackend::Get()->Paint();
 
	OpenGLBackend::Get()->Paint(this->dirty_rect);
 
	SwapBuffers(this->dc);
 

	
 
	this->dirty_rect = {};
 
}
 

	
 
#endif /* WITH_OPENGL */