mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:47:35 +00:00
Mark the two Regions used GraphicsBitmaps as explicitly shared.
This fixes a goofy problem where forking a GUI process would cowify the GraphicsBitmap for everyone making a hue confusing mess.
This commit is contained in:
parent
d1af5c97ca
commit
76a2881793
3 changed files with 11 additions and 1 deletions
|
@ -563,11 +563,16 @@ RetainPtr<Region> Region::clone()
|
||||||
{
|
{
|
||||||
InterruptDisabler disabler;
|
InterruptDisabler disabler;
|
||||||
|
|
||||||
if (is_readable && !is_writable) {
|
if (m_shared || (is_readable && !is_writable)) {
|
||||||
// Create a new region backed by the same VMObject.
|
// Create a new region backed by the same VMObject.
|
||||||
return adopt(*new Region(linearAddress, size, m_vmo.copyRef(), m_offset_in_vmo, String(name), is_readable, is_writable));
|
return adopt(*new Region(linearAddress, size, m_vmo.copyRef(), m_offset_in_vmo, String(name), is_readable, is_writable));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbgprintf("%s<%u> Region::clone(): cowing %s (L%x)\n",
|
||||||
|
current->name().characters(),
|
||||||
|
current->pid(),
|
||||||
|
name.characters(),
|
||||||
|
linearAddress.get());
|
||||||
// Set up a COW region. The parent (this) region becomes COW as well!
|
// Set up a COW region. The parent (this) region becomes COW as well!
|
||||||
for (size_t i = 0; i < page_count(); ++i)
|
for (size_t i = 0; i < page_count(); ++i)
|
||||||
cow_map.set(i, true);
|
cow_map.set(i, true);
|
||||||
|
|
|
@ -117,6 +117,8 @@ public:
|
||||||
const VMObject& vmo() const { return *m_vmo; }
|
const VMObject& vmo() const { return *m_vmo; }
|
||||||
VMObject& vmo() { return *m_vmo; }
|
VMObject& vmo() { return *m_vmo; }
|
||||||
|
|
||||||
|
void set_shared(bool shared) { m_shared = shared; }
|
||||||
|
|
||||||
RetainPtr<Region> clone();
|
RetainPtr<Region> clone();
|
||||||
bool contains(LinearAddress laddr) const
|
bool contains(LinearAddress laddr) const
|
||||||
{
|
{
|
||||||
|
@ -156,6 +158,7 @@ public:
|
||||||
String name;
|
String name;
|
||||||
bool is_readable { true };
|
bool is_readable { true };
|
||||||
bool is_writable { true };
|
bool is_writable { true };
|
||||||
|
bool m_shared { false };
|
||||||
Bitmap cow_map;
|
Bitmap cow_map;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,14 @@ GraphicsBitmap::GraphicsBitmap(Process& process, const Size& size)
|
||||||
size_t size_in_bytes = size.width() * size.height() * sizeof(RGBA32);
|
size_t size_in_bytes = size.width() * size.height() * sizeof(RGBA32);
|
||||||
auto vmo = VMObject::create_anonymous(size_in_bytes);
|
auto vmo = VMObject::create_anonymous(size_in_bytes);
|
||||||
m_client_region = process.allocate_region_with_vmo(LinearAddress(), size_in_bytes, vmo.copyRef(), 0, "GraphicsBitmap (client)", true, true);
|
m_client_region = process.allocate_region_with_vmo(LinearAddress(), size_in_bytes, vmo.copyRef(), 0, "GraphicsBitmap (client)", true, true);
|
||||||
|
m_client_region->set_shared(true);
|
||||||
m_client_region->commit(process);
|
m_client_region->commit(process);
|
||||||
|
|
||||||
{
|
{
|
||||||
auto& server = WSEventLoop::the().server_process();
|
auto& server = WSEventLoop::the().server_process();
|
||||||
InterruptDisabler disabler;
|
InterruptDisabler disabler;
|
||||||
m_server_region = server.allocate_region_with_vmo(LinearAddress(), size_in_bytes, move(vmo), 0, "GraphicsBitmap (server)", true, true);
|
m_server_region = server.allocate_region_with_vmo(LinearAddress(), size_in_bytes, move(vmo), 0, "GraphicsBitmap (server)", true, true);
|
||||||
|
m_server_region->set_shared(true);
|
||||||
}
|
}
|
||||||
m_data = (RGBA32*)m_server_region->linearAddress.asPtr();
|
m_data = (RGBA32*)m_server_region->linearAddress.asPtr();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue