1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:07:47 +00:00

WindowServer: Load multiple scaled versions of Bitmaps and Cursors

This enables rendering of mixed-scale screen layouts with e.g. high
resolution cursors and window button icons on high-dpi screens while
using lower resolution bitmaps on regular screens.
This commit is contained in:
Tom 2021-06-18 19:21:30 -06:00 committed by Andreas Kling
parent aa15bf81e4
commit 61af9d882e
15 changed files with 269 additions and 99 deletions

View file

@ -23,6 +23,7 @@ NonnullOwnPtrVector<Screen, default_screen_count> Screen::s_screens;
Screen* Screen::s_main_screen { nullptr };
Gfx::IntRect Screen::s_bounding_screens_rect {};
ScreenLayout Screen::s_layout;
Vector<int, default_scale_factors_in_use_count> Screen::s_scale_factors_in_use;
ScreenInput& ScreenInput::the()
{
@ -83,9 +84,25 @@ bool Screen::apply_layout(ScreenLayout&& screen_layout, String& error_msg)
rollback.disarm();
update_bounding_rect();
update_scale_factors_in_use();
return true;
}
void Screen::update_scale_factors_in_use()
{
s_scale_factors_in_use.clear();
for_each([&](auto& screen) {
auto scale_factor = screen.scale_factor();
// The This doesn't have to be extremely efficient as this
// code is only run when we start up or the screen configuration
// changes. But using a vector allows for efficient iteration,
// which is the most common use case.
if (!s_scale_factors_in_use.contains_slow(scale_factor))
s_scale_factors_in_use.append(scale_factor);
return IterationDecision::Continue;
});
}
Screen::Screen(ScreenLayout::Screen& screen_info)
: m_virtual_rect(screen_info.location, { screen_info.resolution.width() / screen_info.scale_factor, screen_info.resolution.height() / screen_info.scale_factor })
, m_info(screen_info)