mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00: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
2 changed files with 15 additions and 3 deletions
|
@ -100,6 +100,15 @@ public:
|
||||||
m_impl = nullptr;
|
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
|
bool contains_slow(const T& value) const
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < size(); ++i) {
|
for (size_t i = 0; i < size(); ++i) {
|
||||||
|
|
|
@ -223,6 +223,9 @@ void WindowManager::processMouseEvent(MouseEvent& event)
|
||||||
void WindowManager::compose()
|
void WindowManager::compose()
|
||||||
{
|
{
|
||||||
printf("[WM] compose #%u (%u rects)\n", ++m_recompose_count, m_invalidated_rects.size());
|
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) {
|
auto any_window_contains_rect = [this] (const Rect& r) {
|
||||||
for (auto* window = m_windows_in_order.head(); window; window = window->next()) {
|
for (auto* window = m_windows_in_order.head(); window; window = window->next()) {
|
||||||
if (outerRectForWindow(window->rect()).contains(r))
|
if (outerRectForWindow(window->rect()).contains(r))
|
||||||
|
@ -235,7 +238,7 @@ void WindowManager::compose()
|
||||||
for (auto& r : m_invalidated_rects) {
|
for (auto& r : m_invalidated_rects) {
|
||||||
if (any_window_contains_rect(r))
|
if (any_window_contains_rect(r))
|
||||||
continue;
|
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));
|
painter.fillRect(r, Color(0, 72, 96));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,7 +252,7 @@ void WindowManager::compose()
|
||||||
for (auto& r : m_invalidated_rects) {
|
for (auto& r : m_invalidated_rects) {
|
||||||
flush(r);
|
flush(r);
|
||||||
}
|
}
|
||||||
m_invalidated_rects.clear();
|
m_invalidated_rects.clear_with_capacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::redraw_cursor()
|
void WindowManager::redraw_cursor()
|
||||||
|
@ -311,7 +314,7 @@ bool WindowManager::isVisible(Window& window) const
|
||||||
|
|
||||||
void WindowManager::invalidate()
|
void WindowManager::invalidate()
|
||||||
{
|
{
|
||||||
m_invalidated_rects.clear();
|
m_invalidated_rects.clear_with_capacity();
|
||||||
m_invalidated_rects.append(AbstractScreen::the().rect());
|
m_invalidated_rects.append(AbstractScreen::the().rect());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue