mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
Kernel/Graphics: Choose VMObject considering enabled state when mmaping
When mmaping a Framebuffer from userspace, we need to check whether the framebuffer device is actually enabled (e.g. graphical mode is being used) or a textual VirtualConsole is active. Considering the above state, we mmap the right VMObject to ensure we don't have graphical artifacts if we change the resolution from DisplaySettings, changed to textual mode and after the resolution change was reverted, we will see the Desktop reappearing even though we are still in textual mode.
This commit is contained in:
parent
87f8f892d8
commit
db268efa69
Notes:
sideshowbarker
2024-07-18 17:39:04 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/db268efa693 Pull-request: https://github.com/SerenityOS/serenity/pull/7258 Issue: https://github.com/SerenityOS/serenity/issues/7241 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/tomuta
@ -22,6 +22,7 @@ namespace Kernel {
|
||||
|
||||
KResultOr<Region*> FramebufferDevice::mmap(Process& process, FileDescription&, const Range& range, u64 offset, int prot, bool shared)
|
||||
{
|
||||
ScopedSpinLock lock(m_activation_lock);
|
||||
REQUIRE_PROMISE(video);
|
||||
if (!shared)
|
||||
return ENODEV;
|
||||
@ -40,9 +41,15 @@ KResultOr<Region*> FramebufferDevice::mmap(Process& process, FileDescription&, c
|
||||
m_real_framebuffer_region = MM.allocate_kernel_region_with_vmobject(*m_real_framebuffer_vmobject, page_round_up(framebuffer_size_in_bytes()), "Framebuffer", Region::Access::Read | Region::Access::Write);
|
||||
m_swapped_framebuffer_region = MM.allocate_kernel_region_with_vmobject(*m_swapped_framebuffer_vmobject, page_round_up(framebuffer_size_in_bytes()), "Framebuffer Swap (Blank)", Region::Access::Read | Region::Access::Write);
|
||||
|
||||
RefPtr<VMObject> chosen_vmobject;
|
||||
if (m_graphical_writes_enabled) {
|
||||
chosen_vmobject = m_real_framebuffer_vmobject;
|
||||
} else {
|
||||
chosen_vmobject = m_swapped_framebuffer_vmobject;
|
||||
}
|
||||
auto result = process.space().allocate_region_with_vmobject(
|
||||
range,
|
||||
vmobject.release_nonnull(),
|
||||
chosen_vmobject.release_nonnull(),
|
||||
0,
|
||||
"Framebuffer",
|
||||
prot,
|
||||
@ -62,6 +69,7 @@ void FramebufferDevice::dectivate_writes()
|
||||
auto vmobject = m_swapped_framebuffer_vmobject;
|
||||
m_userspace_framebuffer_region->set_vmobject(vmobject.release_nonnull());
|
||||
m_userspace_framebuffer_region->remap();
|
||||
m_graphical_writes_enabled = false;
|
||||
}
|
||||
void FramebufferDevice::activate_writes()
|
||||
{
|
||||
@ -75,6 +83,7 @@ void FramebufferDevice::activate_writes()
|
||||
auto vmobject = m_userspace_real_framebuffer_vmobject;
|
||||
m_userspace_framebuffer_region->set_vmobject(vmobject.release_nonnull());
|
||||
m_userspace_framebuffer_region->remap();
|
||||
m_graphical_writes_enabled = true;
|
||||
}
|
||||
|
||||
String FramebufferDevice::device_name() const
|
||||
|
@ -59,6 +59,8 @@ private:
|
||||
OwnPtr<Region> m_real_framebuffer_region;
|
||||
OwnPtr<Region> m_swapped_framebuffer_region;
|
||||
|
||||
bool m_graphical_writes_enabled { true };
|
||||
|
||||
RefPtr<AnonymousVMObject> m_userspace_real_framebuffer_vmobject;
|
||||
Region* m_userspace_framebuffer_region { nullptr };
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user