mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:47:35 +00:00
Share GraphicsBitmaps between the windowing server and the client process.
This is pretty cool. :^) GraphicsBitmaps are now mapped into both the server and the client address space (usually at different addresses but that doesn't matter.) Added a GUI syscall for getting a window's backing store, and another one for invalidating a window so that the server redraws it.
This commit is contained in:
parent
b0e3f73375
commit
0c5ecd303c
13 changed files with 139 additions and 46 deletions
|
@ -33,6 +33,13 @@ struct GUI_CreateWindowParameters {
|
|||
char title[128];
|
||||
};
|
||||
|
||||
struct GUI_WindowBackingStoreInfo {
|
||||
GUI_Size size;
|
||||
size_t bpp;
|
||||
size_t pitch;
|
||||
RGBA32* pixels;
|
||||
};
|
||||
|
||||
enum class GUI_MouseButton : unsigned char {
|
||||
NoButton = 0,
|
||||
Left = 1,
|
||||
|
|
|
@ -192,6 +192,8 @@ public:
|
|||
|
||||
int gui$create_window(const GUI_CreateWindowParameters*);
|
||||
int gui$destroy_window(int window_id);
|
||||
int gui$get_window_backing_store(int window_id, GUI_WindowBackingStoreInfo*);
|
||||
int gui$invalidate_window(int window_id);
|
||||
|
||||
DisplayInfo get_display_info();
|
||||
|
||||
|
|
|
@ -25,8 +25,11 @@ void Process::initialize_gui_statics()
|
|||
int Process::make_window_id()
|
||||
{
|
||||
int new_id = m_next_window_id++;
|
||||
while (!new_id || m_windows.contains(new_id))
|
||||
while (!new_id || m_windows.contains(new_id)) {
|
||||
new_id = m_next_window_id++;
|
||||
if (new_id < 0)
|
||||
new_id = 1;
|
||||
}
|
||||
return new_id;
|
||||
}
|
||||
|
||||
|
@ -74,11 +77,40 @@ int Process::gui$destroy_window(int window_id)
|
|||
dbgprintf("%s<%u> gui$destroy_window (window_id=%d)\n", name().characters(), pid(), window_id);
|
||||
if (window_id < 0)
|
||||
return -EINVAL;
|
||||
if (window_id >= static_cast<int>(m_windows.size()))
|
||||
return -EBADWINDOW;
|
||||
auto it = m_windows.find(window_id);
|
||||
if (it == m_windows.end())
|
||||
return -EBADWINDOW;
|
||||
m_windows.remove(window_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Process::gui$get_window_backing_store(int window_id, GUI_WindowBackingStoreInfo* info)
|
||||
{
|
||||
dbgprintf("%s<%u> gui$get_window_backing_store (window_id=%d, info=%p)\n", name().characters(), pid(), window_id, info);
|
||||
if (!validate_write_typed(info))
|
||||
return -EFAULT;
|
||||
if (window_id < 0)
|
||||
return -EINVAL;
|
||||
auto it = m_windows.find(window_id);
|
||||
if (it == m_windows.end())
|
||||
return -EBADWINDOW;
|
||||
auto& window = *(*it).value;
|
||||
info->bpp = sizeof(RGBA32);
|
||||
info->pitch = window.backing()->pitch();
|
||||
info->size = window.backing()->size();
|
||||
info->pixels = reinterpret_cast<RGBA32*>(window.backing()->client_region()->linearAddress.asPtr());
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Process::gui$invalidate_window(int window_id)
|
||||
{
|
||||
dbgprintf("%s<%u> gui$invalidate_window (window_id=%d)\n", name().characters(), pid(), window_id);
|
||||
if (window_id < 0)
|
||||
return -EINVAL;
|
||||
auto it = m_windows.find(window_id);
|
||||
if (it == m_windows.end())
|
||||
return -EBADWINDOW;
|
||||
auto& window = *(*it).value;
|
||||
WindowManager::the().invalidate(window);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -191,6 +191,10 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2,
|
|||
return current->gui$create_window((const GUI_CreateWindowParameters*)arg1);
|
||||
case Syscall::SC_gui_destroy_window:
|
||||
return current->gui$destroy_window((int)arg1);
|
||||
case Syscall::SC_gui_get_window_backing_store:
|
||||
return current->gui$get_window_backing_store((int)arg1, (GUI_WindowBackingStoreInfo*)arg2);
|
||||
case Syscall::SC_gui_invalidate_window:
|
||||
return current->gui$invalidate_window((int)arg1);
|
||||
default:
|
||||
kprintf("<%u> int0x80: Unknown function %u requested {%x, %x, %x}\n", current->pid(), function, arg1, arg2, arg3);
|
||||
break;
|
||||
|
|
|
@ -68,6 +68,9 @@
|
|||
__ENUMERATE_SYSCALL(sync) \
|
||||
__ENUMERATE_SYSCALL(gui_create_window) \
|
||||
__ENUMERATE_SYSCALL(gui_destroy_window) \
|
||||
__ENUMERATE_SYSCALL(gui_get_window_backing_store) \
|
||||
__ENUMERATE_SYSCALL(gui_invalidate_window) \
|
||||
|
||||
|
||||
namespace Syscall {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue