mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
Add a Vector::clear_with_capacity() that doesn't release the backing store.
Use this for WindowManager's dirty rects to avoid kmalloc traffic.
This commit is contained in:
parent
b7d83e3265
commit
8068b8e09e
Notes:
sideshowbarker
2024-07-19 16:04:18 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/8068b8e09e1
@ -100,6 +100,15 @@ public:
|
||||
m_impl = nullptr;
|
||||
}
|
||||
|
||||
void clear_with_capacity()
|
||||
{
|
||||
if (!m_impl)
|
||||
return;
|
||||
for (size_t i = 0; i < size(); ++i)
|
||||
at(i).~T();
|
||||
m_impl->m_size = 0;
|
||||
}
|
||||
|
||||
bool contains_slow(const T& value) const
|
||||
{
|
||||
for (size_t i = 0; i < size(); ++i) {
|
||||
|
@ -223,6 +223,9 @@ void WindowManager::processMouseEvent(MouseEvent& event)
|
||||
void WindowManager::compose()
|
||||
{
|
||||
printf("[WM] compose #%u (%u rects)\n", ++m_recompose_count, m_invalidated_rects.size());
|
||||
|
||||
dbgprintf("kmalloc stats: alloc:%u free:%u eternal:%u\n", sum_alloc, sum_free, kmalloc_sum_eternal);
|
||||
|
||||
auto any_window_contains_rect = [this] (const Rect& r) {
|
||||
for (auto* window = m_windows_in_order.head(); window; window = window->next()) {
|
||||
if (outerRectForWindow(window->rect()).contains(r))
|
||||
@ -235,7 +238,7 @@ void WindowManager::compose()
|
||||
for (auto& r : m_invalidated_rects) {
|
||||
if (any_window_contains_rect(r))
|
||||
continue;
|
||||
dbgprintf("Repaint root %d,%d %dx%d\n", r.x(), r.y(), r.width(), r.height());
|
||||
//dbgprintf("Repaint root %d,%d %dx%d\n", r.x(), r.y(), r.width(), r.height());
|
||||
painter.fillRect(r, Color(0, 72, 96));
|
||||
}
|
||||
}
|
||||
@ -249,7 +252,7 @@ void WindowManager::compose()
|
||||
for (auto& r : m_invalidated_rects) {
|
||||
flush(r);
|
||||
}
|
||||
m_invalidated_rects.clear();
|
||||
m_invalidated_rects.clear_with_capacity();
|
||||
}
|
||||
|
||||
void WindowManager::redraw_cursor()
|
||||
@ -311,7 +314,7 @@ bool WindowManager::isVisible(Window& window) const
|
||||
|
||||
void WindowManager::invalidate()
|
||||
{
|
||||
m_invalidated_rects.clear();
|
||||
m_invalidated_rects.clear_with_capacity();
|
||||
m_invalidated_rects.append(AbstractScreen::the().rect());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user