ladybird/SharedGraphics/DisjointRectSet.h
Andreas Kling 98784ad3cb 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.
2019-02-19 14:49:23 +01:00

24 lines
488 B
C++

#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;
};