diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-01-12 07:22:25 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-01-12 07:22:25 +0100 |
commit | 8068b8e09e1f7790f7e11b3b6fb6ccd932b48670 (patch) | |
tree | de1ba1c71410e6d8bde97269efa043c9e617bc67 | |
parent | b7d83e3265c03cef385cd5feb9a9ec80551a6d66 (diff) | |
download | serenity-8068b8e09e1f7790f7e11b3b6fb6ccd932b48670.zip |
Add a Vector::clear_with_capacity() that doesn't release the backing store.
Use this for WindowManager's dirty rects to avoid kmalloc traffic.
-rw-r--r-- | AK/Vector.h | 9 | ||||
-rw-r--r-- | Widgets/WindowManager.cpp | 9 |
2 files changed, 15 insertions, 3 deletions
diff --git a/AK/Vector.h b/AK/Vector.h index 00b134551d..984573ec7e 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -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) { diff --git a/Widgets/WindowManager.cpp b/Widgets/WindowManager.cpp index 1b2a5fd4c1..a45f3483f2 100644 --- a/Widgets/WindowManager.cpp +++ b/Widgets/WindowManager.cpp @@ -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()); } |