draw rect optimization
This commit is contained in:
parent
6df6355ba7
commit
615d90c36f
3 changed files with 113 additions and 30 deletions
|
|
@ -111,10 +111,27 @@ void Window::AddDirtyRect(ScaleData scale) {
|
|||
return;
|
||||
}
|
||||
|
||||
//merging logic should work so that no pixel is drawn twice, and that no pixel not marked dirty is drawn.
|
||||
//so lets say there is already an existing horizontal bar and the new rect is a vertical bar making a cross shape, the center of the cross will currently be drawn twice
|
||||
//so we need to turn it into 3 rects, the top part of the vertical bar, the horizontal bar, and the bottom part of the vertical bar
|
||||
//in this way no pixel is drawn twice and no area not marked dirty is included
|
||||
|
||||
for(ClipRect existing : dirtyRects) {
|
||||
//fully enclosed
|
||||
if(rect.left >= existing.left && rect.right <= existing.right && rect.top >= existing.top && rect.bottom <= existing.bottom) {
|
||||
return;
|
||||
}
|
||||
|
||||
//horizontal line
|
||||
if(rect.top == existing.top && rect.bottom == existing.bottom) {
|
||||
existing.left = std::min(rect.left, existing.left);
|
||||
existing.right = std::max(rect.right, existing.right);
|
||||
return;
|
||||
}
|
||||
|
||||
//vertical line
|
||||
if(rect.left == existing.left && rect.right == existing.right) {
|
||||
existing.top = std::min(rect.top, existing.top);
|
||||
existing.bottom = std::max(rect.bottom, existing.bottom);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//no overlap
|
||||
dirtyRects.push_back(rect);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue