summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-01-16 16:43:33 +0100
committerMichael Lutz <michi@icosahedron.de>2021-02-22 22:16:07 +0100
commit3e49aff35c49190ee9f9f18fcef8db7175d0559a (patch)
tree9632ce9284acc41d73221daee7266f3795945522 /src
parent6776229047c0f5aac540fc9c367e4abbf5302322 (diff)
downloadopenttd-3e49aff35c49190ee9f9f18fcef8db7175d0559a.tar.xz
Codechange: Allow video drivers to handle the cursor themselves.
Diffstat (limited to 'src')
-rw-r--r--src/gfx.cpp6
-rw-r--r--src/spritecache.cpp3
-rw-r--r--src/video/video_driver.hpp14
3 files changed, 23 insertions, 0 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp
index 9f42a7b53..50f00805e 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -1348,6 +1348,9 @@ void ScreenSizeChanged()
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;
@@ -1361,6 +1364,9 @@ void UndrawMouseCursor()
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;
diff --git a/src/spritecache.cpp b/src/spritecache.cpp
index 9e23d7d2a..8460f33ed 100644
--- a/src/spritecache.cpp
+++ b/src/spritecache.cpp
@@ -17,6 +17,7 @@
#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"
@@ -977,6 +978,8 @@ void GfxClearSpriteCache()
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];
diff --git a/src/video/video_driver.hpp b/src/video/video_driver.hpp
index 57945862a..74bb20f4c 100644
--- a/src/video/video_driver.hpp
+++ b/src/video/video_driver.hpp
@@ -86,6 +86,20 @@ public:
}
/**
+ * 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