Changeset - r24901:373764ef362c
[Not reviewed]
master
0 3 0
Michael Lutz - 4 years ago 2021-01-16 15:43:33
michi@icosahedron.de
Codechange: Allow video drivers to handle the cursor themselves.
3 files changed with 23 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/gfx.cpp
Show inline comments
 
@@ -1345,12 +1345,15 @@ void ScreenSizeChanged()
 
	/* screen size changed and the old bitmap is invalid now, so we don't want to undraw it */
 
	_cursor.visible = false;
 
}
 

	
 
void UndrawMouseCursor()
 
{
 
	/* Don't undraw mouse cursor if it is handled by the video driver. */
 
	if (VideoDriver::GetInstance()->UseSystemCursor()) return;
 

	
 
	/* Don't undraw the mouse cursor if the screen is not ready */
 
	if (_screen.dst_ptr == nullptr) return;
 

	
 
	if (_cursor.visible) {
 
		Blitter *blitter = BlitterFactory::GetCurrentBlitter();
 
		_cursor.visible = false;
 
@@ -1358,12 +1361,15 @@ void UndrawMouseCursor()
 
		VideoDriver::GetInstance()->MakeDirty(_cursor.draw_pos.x, _cursor.draw_pos.y, _cursor.draw_size.x, _cursor.draw_size.y);
 
	}
 
}
 

	
 
void DrawMouseCursor()
 
{
 
	/* Don't draw mouse cursor if it is handled by the video driver. */
 
	if (VideoDriver::GetInstance()->UseSystemCursor()) return;
 

	
 
	/* Don't draw the mouse cursor if the screen is not ready */
 
	if (_screen.dst_ptr == nullptr) return;
 

	
 
	Blitter *blitter = BlitterFactory::GetCurrentBlitter();
 

	
 
	/* Redraw mouse cursor but only when it's inside the window */
src/spritecache.cpp
Show inline comments
 
@@ -14,12 +14,13 @@
 
#include "error.h"
 
#include "zoom_func.h"
 
#include "settings_type.h"
 
#include "blitter/factory.hpp"
 
#include "core/math_func.hpp"
 
#include "core/mem_func.hpp"
 
#include "video/video_driver.hpp"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "table/palette_convert.h"
 

	
 
#include "safeguards.h"
 
@@ -974,9 +975,11 @@ void GfxClearSpriteCache()
 
{
 
	/* Clear sprite ptr for all cached items */
 
	for (uint i = 0; i != _spritecache_items; i++) {
 
		SpriteCache *sc = GetSpriteCache(i);
 
		if (sc->type != ST_RECOLOUR && sc->ptr != nullptr) DeleteEntryFromSpriteCache(i);
 
	}
 

	
 
	VideoDriver::GetInstance()->ClearSystemSprites();
 
}
 

	
 
/* static */ ReusableBuffer<SpriteLoader::CommonPixel> SpriteLoader::Sprite::buffer[ZOOM_LVL_COUNT];
src/video/video_driver.hpp
Show inline comments
 
@@ -83,12 +83,26 @@ public:
 
	virtual bool ClaimMousePointer()
 
	{
 
		return true;
 
	}
 

	
 
	/**
 
	 * Get whether the mouse cursor is drawn by the video driver.
 
	 * @return True if cursor drawing is done by the video driver.
 
	 */
 
	virtual bool UseSystemCursor()
 
	{
 
		return false;
 
	}
 

	
 
	/**
 
	 * Clear all cached sprites.
 
	 */
 
	virtual void ClearSystemSprites() {}
 

	
 
	/**
 
	 * Whether the driver has a graphical user interface with the end user.
 
	 * Or in other words, whether we should spawn a thread for world generation
 
	 * and NewGRF scanning so the graphical updates can keep coming. Otherwise
 
	 * progress has to be shown on the console, which uses by definition another
 
	 * thread/process for display purposes.
 
	 * @return True for all drivers except null and dedicated.
0 comments (0 inline, 0 general)