mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 13:37:22 +00:00
[common] rects: de-dup code and don't needlessly copy rect over itself
This commit is contained in:
parent
f69b869282
commit
2f0b97a487
@ -58,6 +58,21 @@ inline static bool rectContains(const FrameDamageRect * r1,
|
||||
r2->y + r2->height > r1->y + r1->height);
|
||||
}
|
||||
|
||||
inline static int removeRects(FrameDamageRect * rects, int count,
|
||||
bool removed[])
|
||||
{
|
||||
int o = 0;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
if (removed[i] || i == o++)
|
||||
continue;
|
||||
|
||||
rects[o-1] = rects[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cornerCompare(const void * a_, const void * b_)
|
||||
{
|
||||
const struct Corner * a = a_;
|
||||
@ -260,12 +275,7 @@ int rectsMergeOverlapping(FrameDamageRect * rects, int count)
|
||||
}
|
||||
while (changed);
|
||||
|
||||
int o = 0;
|
||||
for (int i = 0; i < count; ++i)
|
||||
if (!removed[i])
|
||||
rects[o++] = rects[i];
|
||||
|
||||
return o;
|
||||
return removeRects(rects, count, removed);
|
||||
}
|
||||
|
||||
int rectsRejectContained(FrameDamageRect * rects, int count)
|
||||
@ -287,10 +297,5 @@ int rectsRejectContained(FrameDamageRect * rects, int count)
|
||||
}
|
||||
}
|
||||
|
||||
int o = 0;
|
||||
for (int i = 0; i < count; ++i)
|
||||
if (!removed[i])
|
||||
rects[o++] = rects[i];
|
||||
|
||||
return o;
|
||||
return removeRects(rects, count, removed);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user