(svn r27775) -Fix [FS#6510]: Insufficient thread synchronisation when switching blitters. (JGR)

This commit is contained in:
frosch
2017-03-11 13:05:54 +00:00
parent 5b7a04ca27
commit 51c6ae62d1
6 changed files with 47 additions and 5 deletions

View File

@@ -817,11 +817,18 @@ bool VideoDriver_SDL::ToggleFullscreen(bool fullscreen)
}
bool VideoDriver_SDL::AfterBlitterChange()
{
return CreateMainSurface(_screen.width, _screen.height);
}
void VideoDriver_SDL::AcquireBlitterLock()
{
if (_draw_mutex != NULL) _draw_mutex->BeginCritical(true);
bool ret = CreateMainSurface(_screen.width, _screen.height);
}
void VideoDriver_SDL::ReleaseBlitterLock()
{
if (_draw_mutex != NULL) _draw_mutex->EndCritical(true);
return ret;
}
#endif /* WITH_SDL */

View File

@@ -31,6 +31,10 @@ public:
/* virtual */ bool AfterBlitterChange();
/* virtual */ void AcquireBlitterLock();
/* virtual */ void ReleaseBlitterLock();
/* virtual */ bool ClaimMousePointer();
/* virtual */ const char *GetName() const { return "sdl"; }

View File

@@ -49,6 +49,7 @@ public:
/**
* Callback invoked after the blitter was changed.
* This may only be called between AcquireBlitterLock and ReleaseBlitterLock.
* @return True if no error.
*/
virtual bool AfterBlitterChange()
@@ -56,6 +57,18 @@ public:
return true;
}
/**
* Acquire any lock(s) required to be held when changing blitters.
* These lock(s) may not be acquired recursively.
*/
virtual void AcquireBlitterLock() { }
/**
* Release any lock(s) required to be held when changing blitters.
* These lock(s) may not be acquired recursively.
*/
virtual void ReleaseBlitterLock() { }
virtual bool ClaimMousePointer()
{
return true;

View File

@@ -1333,11 +1333,18 @@ bool VideoDriver_Win32::ToggleFullscreen(bool full_screen)
}
bool VideoDriver_Win32::AfterBlitterChange()
{
return AllocateDibSection(_screen.width, _screen.height, true) && this->MakeWindow(_fullscreen);
}
void VideoDriver_Win32::AcquireBlitterLock()
{
if (_draw_mutex != NULL) _draw_mutex->BeginCritical(true);
bool ret = AllocateDibSection(_screen.width, _screen.height, true) && this->MakeWindow(_fullscreen);
}
void VideoDriver_Win32::ReleaseBlitterLock()
{
if (_draw_mutex != NULL) _draw_mutex->EndCritical(true);
return ret;
}
void VideoDriver_Win32::EditBoxLostFocus()

View File

@@ -31,6 +31,10 @@ public:
/* virtual */ bool AfterBlitterChange();
/* virtual */ void AcquireBlitterLock();
/* virtual */ void ReleaseBlitterLock();
/* virtual */ bool ClaimMousePointer();
/* virtual */ void EditBoxLostFocus();