mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:57:35 +00:00
GraphicsBitmap: munmap() pixels on destruction of self-allocating bitmaps.
This commit is contained in:
parent
d93c278d29
commit
e90b501b31
2 changed files with 7 additions and 0 deletions
|
@ -21,6 +21,7 @@ GraphicsBitmap::GraphicsBitmap(Format format, const Size& size)
|
||||||
m_data = (RGBA32*)mmap(nullptr, size_in_bytes, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
|
m_data = (RGBA32*)mmap(nullptr, size_in_bytes, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
|
||||||
ASSERT(m_data && m_data != (void*)-1);
|
ASSERT(m_data && m_data != (void*)-1);
|
||||||
set_mmap_name(m_data, size_in_bytes, String::format("GraphicsBitmap [%dx%d]", width(), height()).characters());
|
set_mmap_name(m_data, size_in_bytes, String::format("GraphicsBitmap [%dx%d]", width(), height()).characters());
|
||||||
|
m_needs_munmap = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Retained<GraphicsBitmap> GraphicsBitmap::create_wrapper(Format format, const Size& size, RGBA32* data)
|
Retained<GraphicsBitmap> GraphicsBitmap::create_wrapper(Format format, const Size& size, RGBA32* data)
|
||||||
|
@ -74,6 +75,11 @@ GraphicsBitmap::GraphicsBitmap(Format format, Retained<SharedBuffer>&& shared_bu
|
||||||
|
|
||||||
GraphicsBitmap::~GraphicsBitmap()
|
GraphicsBitmap::~GraphicsBitmap()
|
||||||
{
|
{
|
||||||
|
if (m_needs_munmap) {
|
||||||
|
size_t size_in_bytes = m_size.area() * sizeof(RGBA32);
|
||||||
|
int rc = munmap(m_data, size_in_bytes);
|
||||||
|
ASSERT(rc == 0);
|
||||||
|
}
|
||||||
m_data = nullptr;
|
m_data = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ private:
|
||||||
RGBA32* m_data { nullptr };
|
RGBA32* m_data { nullptr };
|
||||||
size_t m_pitch { 0 };
|
size_t m_pitch { 0 };
|
||||||
Format m_format { Format::Invalid };
|
Format m_format { Format::Invalid };
|
||||||
|
bool m_needs_munmap { false };
|
||||||
MappedFile m_mapped_file;
|
MappedFile m_mapped_file;
|
||||||
RetainPtr<SharedBuffer> m_shared_buffer;
|
RetainPtr<SharedBuffer> m_shared_buffer;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue