mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:37:35 +00:00
WindowServer: Avoid overdraw by shattering dirty rects into unique shards.
The algorithm I came up with is O(n^2) but given the small numbers of rects we're typically working with, it doesn't really matter. May need to revisit this in the future if we find ourselves with a huge number of rects.
This commit is contained in:
parent
420b7bd55f
commit
98784ad3cb
7 changed files with 127 additions and 21 deletions
23
SharedGraphics/DisjointRectSet.h
Normal file
23
SharedGraphics/DisjointRectSet.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Vector.h>
|
||||
#include <SharedGraphics/Rect.h>
|
||||
|
||||
class DisjointRectSet {
|
||||
public:
|
||||
DisjointRectSet() { }
|
||||
~DisjointRectSet() { }
|
||||
DisjointRectSet(DisjointRectSet&& other) : m_rects(move(other.m_rects)) { }
|
||||
|
||||
void add(const Rect&);
|
||||
|
||||
void clear() { m_rects.clear(); }
|
||||
void clear_with_capacity() { m_rects.clear_with_capacity(); }
|
||||
const Vector<Rect>& rects() const { return m_rects; }
|
||||
|
||||
private:
|
||||
void shatter();
|
||||
|
||||
Vector<Rect> m_rects;
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue