diff options
author | Guilherme Felipe <guilhermefelipecgs@gmail.com> | 2019-07-08 17:37:18 -0300 |
---|---|---|
committer | Guilherme Felipe <guilhermefelipecgs@gmail.com> | 2019-07-09 19:38:25 -0300 |
commit | a9a0d0fb15cc5e028dbf8dab8b46d3dc197c4678 (patch) | |
tree | 9c6109f8ec2147375a1334fc19cea94b65aa2015 /platform/osx | |
parent | 5e495750a37e3314a8cd85cb3f7be9a676420c44 (diff) | |
download | redot-engine-a9a0d0fb15cc5e028dbf8dab8b46d3dc197c4678.tar.gz |
Fix cursor blinking in integrated GPUs
Optimization for Input::set_custom_mouse_cursor when used inside
_process function. (Avoids cursor blinking in low end devices)
Diffstat (limited to 'platform/osx')
-rw-r--r-- | platform/osx/os_osx.h | 1 | ||||
-rw-r--r-- | platform/osx/os_osx.mm | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 1e996608af..a83d5084ed 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -119,6 +119,7 @@ public: CursorShape cursor_shape; NSCursor *cursors[CURSOR_MAX]; + Map<CursorShape, Vector<Variant> > cursors_cache; MouseMode mouse_mode; String title; diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 4f84ae9c50..726882438b 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1770,7 +1770,20 @@ OS::CursorShape OS_OSX::get_cursor_shape() const { } void OS_OSX::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) { + if (p_cursor.is_valid()) { + + Map<CursorShape, Vector<Variant> >::Element *cursor_c = cursors_cache.find(p_shape); + + if (cursor_c) { + if (cursor_c->get()[0] == p_cursor && cursor_c->get()[1] == p_hotspot) { + set_cursor_shape(p_shape); + return; + } + + cursors_cache.erase(p_shape); + } + Ref<Texture> texture = p_cursor; Ref<AtlasTexture> atlas_texture = p_cursor; Ref<Image> image; @@ -1855,6 +1868,11 @@ void OS_OSX::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c [cursors[p_shape] release]; cursors[p_shape] = cursor; + Vector<Variant> params; + params.push_back(p_cursor); + params.push_back(p_hotspot); + cursors_cache.insert(p_shape, params); + if (p_shape == cursor_shape) { if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) { [cursor set]; |