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

WindowServer: Add an Overlay class for flicker-free overlay rendering

An Overlay is similar to a transparent window, but has less overhead
and does not get rendered within the window stack. Basically, the area
that an Overlay occupies forces transparency rendering for any window
underneath, which allows us to render them flicker-free.

This also adds a new API that allows displaying the screen numbers,
e.g. while the user configures the screen layout in DisplaySettings

Because other things like drag&drop or the window-size label are not
yet converted to use this new mechanism, they will be drawn over the
screen-number currently.
This commit is contained in:
Tom 2021-06-20 13:23:43 -06:00 committed by Andreas Kling
parent 42cb38b71a
commit 41859ad3fe
14 changed files with 638 additions and 7 deletions

View file

@ -25,6 +25,17 @@ const Gfx::Bitmap& MultiScaleBitmaps::bitmap(int scale_factor) const
return it->value;
}
Gfx::Bitmap const* MultiScaleBitmaps::find_bitmap(int scale_factor) const
{
auto it = m_bitmaps.find(scale_factor);
return it != m_bitmaps.end() ? it->value.ptr() : nullptr;
}
RefPtr<MultiScaleBitmaps> MultiScaleBitmaps::create_empty()
{
return adopt_ref(*new MultiScaleBitmaps());
}
RefPtr<MultiScaleBitmaps> MultiScaleBitmaps::create(StringView const& filename, StringView const& default_filename)
{
auto per_scale_bitmap = adopt_ref(*new MultiScaleBitmaps());
@ -51,6 +62,7 @@ bool MultiScaleBitmaps::load(StringView const& filename, StringView const& defau
did_load_any = true;
m_bitmaps.set(scale_factor, bitmap.release_nonnull());
} else {
// Gracefully ignore, we have at least one bitmap already
dbgln("Bitmap {} (scale {}) has format inconsistent with the other per-scale bitmaps", path, bitmap->scale());
}
}
@ -69,4 +81,17 @@ bool MultiScaleBitmaps::load(StringView const& filename, StringView const& defau
return did_load_any;
}
void MultiScaleBitmaps::add_bitmap(int scale_factor, NonnullRefPtr<Gfx::Bitmap>&& bitmap)
{
auto bitmap_format = bitmap->format();
if (m_format == Gfx::BitmapFormat::Invalid || m_format == bitmap_format) {
if (m_format == Gfx::BitmapFormat::Invalid)
m_format = bitmap_format;
m_bitmaps.set(scale_factor, move(bitmap));
} else {
dbgln("MultiScaleBitmaps::add_bitmap (scale {}) has format inconsistent with the other per-scale bitmaps", bitmap->scale());
VERIFY_NOT_REACHED(); // The caller of this function should have made sure it is consistent!
}
}
}