mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:17:36 +00:00
WindowServer: Detect framebuffer capabilities and settings
The main changes are twofold: * Buffer flipping is now controlled by the m_screen_can_set_buffer flag in WSCompositor. This flag, in turn, is impacted by m_can_set_buffer flag, in WSScreen. m_can_set_buffer is set in the WSScreen constructor by checking the return value of fb_set_buffer. If the framebuffer supports this operation, it will succeed, and we record this fact. This information is then used by WSCompositor to set its own m_screen_can_set_buffer flag. * WSScreen now only requests a resolution change of the framebuffer. The driver itself is ultimately responsible for what resolution or mode is actually set, so WSScreen has to read the response from that request, and has no choice but to accept the answer. This allows the driver to choose a "close enough" value to what was requested, or simply ignore it. The result of this is that there is no special configuration necessary for WindowServer to work with reduced-capability framebuffer devices.
This commit is contained in:
parent
3932dfbb04
commit
23b6ef29dd
4 changed files with 68 additions and 51 deletions
|
@ -31,16 +31,9 @@ WallpaperMode mode_to_enum(const String& name)
|
|||
|
||||
WSCompositor::WSCompositor()
|
||||
{
|
||||
auto size = WSScreen::the().size();
|
||||
m_front_bitmap = GraphicsBitmap::create_wrapper(GraphicsBitmap::Format::RGB32, size, WSScreen::the().scanline(0));
|
||||
m_screen_can_set_buffer = WSScreen::the().can_set_buffer();
|
||||
|
||||
if (can_flip_buffers())
|
||||
m_back_bitmap = GraphicsBitmap::create_wrapper(GraphicsBitmap::Format::RGB32, size, WSScreen::the().scanline(size.height()));
|
||||
else
|
||||
m_back_bitmap = GraphicsBitmap::create(GraphicsBitmap::Format::RGB32, size);
|
||||
|
||||
m_front_painter = make<Painter>(*m_front_bitmap);
|
||||
m_back_painter = make<Painter>(*m_back_bitmap);
|
||||
init_bitmaps();
|
||||
|
||||
m_wallpaper_path = "/res/wallpapers/retro.rgb";
|
||||
m_wallpaper = GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, m_wallpaper_path, { 1024, 768 });
|
||||
|
@ -63,6 +56,25 @@ WSCompositor::WSCompositor()
|
|||
m_immediate_compose_timer.set_interval(0);
|
||||
}
|
||||
|
||||
void WSCompositor::init_bitmaps()
|
||||
{
|
||||
auto size = WSScreen::the().size();
|
||||
|
||||
m_front_bitmap = GraphicsBitmap::create_wrapper(GraphicsBitmap::Format::RGB32, size, WSScreen::the().scanline(0));
|
||||
|
||||
if (m_screen_can_set_buffer)
|
||||
m_back_bitmap = GraphicsBitmap::create_wrapper(GraphicsBitmap::Format::RGB32, size, WSScreen::the().scanline(size.height()));
|
||||
else
|
||||
m_back_bitmap = GraphicsBitmap::create(GraphicsBitmap::Format::RGB32, size);
|
||||
|
||||
m_front_painter = make<Painter>(*m_front_bitmap);
|
||||
m_back_painter = make<Painter>(*m_back_bitmap);
|
||||
|
||||
m_buffers_are_flipped = false;
|
||||
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void WSCompositor::compose()
|
||||
{
|
||||
auto& wm = WSWindowManager::the();
|
||||
|
@ -172,7 +184,7 @@ void WSCompositor::compose()
|
|||
m_front_painter->fill_rect(rect, Color::Yellow);
|
||||
}
|
||||
|
||||
if (can_flip_buffers())
|
||||
if (m_screen_can_set_buffer)
|
||||
flip_buffers();
|
||||
|
||||
for (auto& r : dirty_rects.rects())
|
||||
|
@ -203,7 +215,7 @@ void WSCompositor::flush(const Rect& a_rect)
|
|||
RGBA32* to_ptr;
|
||||
const RGBA32* from_ptr;
|
||||
|
||||
if (can_flip_buffers()) {
|
||||
if (m_screen_can_set_buffer) {
|
||||
to_ptr = back_ptr;
|
||||
from_ptr = front_ptr;
|
||||
} else {
|
||||
|
@ -289,28 +301,22 @@ void WSCompositor::finish_setting_wallpaper(const String& path, NonnullRefPtr<Gr
|
|||
|
||||
void WSCompositor::flip_buffers()
|
||||
{
|
||||
ASSERT(can_flip_buffers());
|
||||
ASSERT(m_screen_can_set_buffer);
|
||||
swap(m_front_bitmap, m_back_bitmap);
|
||||
swap(m_front_painter, m_back_painter);
|
||||
int new_y_offset = m_buffers_are_flipped ? 0 : WSScreen::the().height();
|
||||
WSScreen::the().set_y_offset(new_y_offset);
|
||||
WSScreen::the().set_buffer(m_buffers_are_flipped ? 0 : 1);
|
||||
m_buffers_are_flipped = !m_buffers_are_flipped;
|
||||
}
|
||||
|
||||
void WSCompositor::set_resolution(int width, int height)
|
||||
void WSCompositor::set_resolution(int desired_width, int desired_height)
|
||||
{
|
||||
auto screen_rect = WSScreen::the().rect();
|
||||
if (screen_rect.width() == width && screen_rect.height() == height)
|
||||
if (screen_rect.width() == desired_width && screen_rect.height() == desired_height)
|
||||
return;
|
||||
m_wallpaper_path = {};
|
||||
m_wallpaper = nullptr;
|
||||
WSScreen::the().set_resolution(width, height);
|
||||
m_front_bitmap = GraphicsBitmap::create_wrapper(GraphicsBitmap::Format::RGB32, { width, height }, WSScreen::the().scanline(0));
|
||||
m_back_bitmap = GraphicsBitmap::create_wrapper(GraphicsBitmap::Format::RGB32, { width, height }, WSScreen::the().scanline(height));
|
||||
m_front_painter = make<Painter>(*m_front_bitmap);
|
||||
m_back_painter = make<Painter>(*m_back_bitmap);
|
||||
m_buffers_are_flipped = false;
|
||||
invalidate();
|
||||
WSScreen::the().set_resolution(desired_width, desired_height);
|
||||
init_bitmaps();
|
||||
compose();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue