From 248d75e13b6345b94d608f057b7ab5a3e95fb65d Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Fri, 15 Jan 2021 14:56:01 -0500 Subject: [PATCH] WindowServer: Don't reallocate the cursor back bitmap all the time in HighDPI mode It's in efficient, and it also meant we wouldn't reallocate a bigger backing bitmap in a lowdpi->highdpi transition, leading to minor drawing glitches after such a transition. (Whoops!) --- Userland/Services/WindowServer/Compositor.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Userland/Services/WindowServer/Compositor.cpp b/Userland/Services/WindowServer/Compositor.cpp index d93b163335..4bea8d81a8 100644 --- a/Userland/Services/WindowServer/Compositor.cpp +++ b/Userland/Services/WindowServer/Compositor.cpp @@ -802,8 +802,9 @@ void Compositor::draw_cursor(const Gfx::IntRect& cursor_rect) { auto& wm = WindowManager::the(); - if (!m_cursor_back_bitmap || m_cursor_back_bitmap->size() != cursor_rect.size()) { - m_cursor_back_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::RGB32, cursor_rect.size() * Screen::the().scale_factor()); + auto physical_cursor_size = cursor_rect.size() * Screen::the().scale_factor(); + if (!m_cursor_back_bitmap || m_cursor_back_bitmap->size() != physical_cursor_size) { + m_cursor_back_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::RGB32, physical_cursor_size); m_cursor_back_painter = make(*m_cursor_back_bitmap); }