Changeset - r25012:2450cb173b81
[Not reviewed]
master
0 3 0
Patric Stout - 3 years ago 2021-02-27 11:11:58
truebrain@openttd.org
Codechange: remove the unused lock around Blitter
3 files changed with 0 insertions and 20 deletions:
0 comments (0 inline, 0 general)
src/gfx.cpp
Show inline comments
 
@@ -1477,15 +1477,13 @@ void DrawDirtyBlocks()
 
		_modal_progress_work_mutex.unlock();
 

	
 
		/* Wait a while and hope the modal gives us a bit of time to draw the GUI. */
 
		if (!IsFirstModalProgressLoop()) CSleep(MODAL_PROGRESS_REDRAW_TIMEOUT);
 

	
 
		/* Modal progress thread may need blitter access while we are waiting for it. */
 
		VideoDriver::GetInstance()->ReleaseBlitterLock();
 
		_modal_progress_paint_mutex.lock();
 
		VideoDriver::GetInstance()->AcquireBlitterLock();
 
		_modal_progress_work_mutex.lock();
 

	
 
		/* When we ended with the modal progress, do not draw the blocks.
 
		 * Simply let the next run do so, otherwise we would be loading
 
		 * the new state (and possibly change the blitter) when we hold
 
		 * the drawing lock, which we must not do. */
src/gfxinit.cpp
Show inline comments
 
@@ -292,24 +292,21 @@ static bool SwitchNewGRFBlitter()
 
		{ "32bpp-anim",      1,  8, 32,  8, 32 },
 
	};
 

	
 
	const bool animation_wanted = HasBit(_display_opt, DO_FULL_ANIMATION);
 
	const char *cur_blitter = BlitterFactory::GetCurrentBlitter()->GetName();
 

	
 
	VideoDriver::GetInstance()->AcquireBlitterLock();
 

	
 
	for (uint i = 0; i < lengthof(replacement_blitters); i++) {
 
		if (animation_wanted && (replacement_blitters[i].animation == 0)) continue;
 
		if (!animation_wanted && (replacement_blitters[i].animation == 1)) continue;
 

	
 
		if (!IsInsideMM(depth_wanted_by_base, replacement_blitters[i].min_base_depth, replacement_blitters[i].max_base_depth + 1)) continue;
 
		if (!IsInsideMM(depth_wanted_by_grf, replacement_blitters[i].min_grf_depth, replacement_blitters[i].max_grf_depth + 1)) continue;
 
		const char *repl_blitter = replacement_blitters[i].name;
 

	
 
		if (strcmp(repl_blitter, cur_blitter) == 0) {
 
			VideoDriver::GetInstance()->ReleaseBlitterLock();
 
			return false;
 
		}
 
		if (BlitterFactory::GetBlitterFactory(repl_blitter) == nullptr) continue;
 

	
 
		DEBUG(misc, 1, "Switching blitter from '%s' to '%s'... ", cur_blitter, repl_blitter);
 
		Blitter *new_blitter = BlitterFactory::SelectBlitter(repl_blitter);
 
@@ -320,14 +317,12 @@ static bool SwitchNewGRFBlitter()
 

	
 
	if (!VideoDriver::GetInstance()->AfterBlitterChange()) {
 
		/* Failed to switch blitter, let's hope we can return to the old one. */
 
		if (BlitterFactory::SelectBlitter(cur_blitter) == nullptr || !VideoDriver::GetInstance()->AfterBlitterChange()) usererror("Failed to reinitialize video driver. Specify a fixed blitter in the config");
 
	}
 

	
 
	VideoDriver::GetInstance()->ReleaseBlitterLock();
 

	
 
	return true;
 
}
 

	
 
/** Check whether we still use the right blitter, or use another (better) one. */
 
void CheckBlitter()
 
{
src/video/video_driver.hpp
Show inline comments
 
@@ -59,32 +59,19 @@ public:
 
	 * @return True if the change succeeded.
 
	 */
 
	virtual bool ToggleFullscreen(bool fullscreen) = 0;
 

	
 
	/**
 
	 * Callback invoked after the blitter was changed.
 
	 * This may only be called between AcquireBlitterLock and ReleaseBlitterLock.
 
	 * @return True if no error.
 
	 */
 
	virtual bool AfterBlitterChange()
 
	{
 
		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;
 
	}
 

	
 
	/**
0 comments (0 inline, 0 general)