1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:47:35 +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

@ -9,6 +9,7 @@
#include "ScreenLayout.h"
#include <AK/NonnullOwnPtrVector.h>
#include <Kernel/API/KeyCode.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/Color.h>
#include <LibGfx/Rect.h>
#include <LibGfx/Size.h>
@ -23,6 +24,8 @@ constexpr unsigned scroll_step_size_min = 1;
// Most people will probably have 4 screens or less
constexpr size_t default_screen_count = 4;
// We currently only support 2 scale factors: 1x and 2x
constexpr size_t default_scale_factors_in_use_count = 2;
class Screen;
@ -125,6 +128,17 @@ public:
return IterationDecision::Continue;
}
template<typename F>
static IterationDecision for_each_scale_factor_in_use(F f)
{
for (auto& scale_factor : s_scale_factors_in_use) {
IterationDecision decision = f(scale_factor);
if (decision != IterationDecision::Continue)
return decision;
}
return IterationDecision::Continue;
}
void make_main_screen() { s_main_screen = this; }
bool is_main_screen() const { return s_main_screen == this; }
@ -158,6 +172,7 @@ private:
s_screens[i].m_index = i;
}
static void update_bounding_rect();
static void update_scale_factors_in_use();
bool is_opened() const { return m_framebuffer_fd >= 0; }
@ -165,6 +180,7 @@ private:
static Screen* s_main_screen;
static Gfx::IntRect s_bounding_screens_rect;
static ScreenLayout s_layout;
static Vector<int, default_scale_factors_in_use_count> s_scale_factors_in_use;
size_t m_index { 0 };
size_t m_size_in_bytes;