mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-01-08 21:33:57 +00:00
[common] rects: de-dup code and don't needlessly copy rect over itself
This commit is contained in:
parent
f69b869282
commit
2f0b97a487
1 changed files with 17 additions and 12 deletions
|
@ -58,6 +58,21 @@ inline static bool rectContains(const FrameDamageRect * r1,
|
||||||
r2->y + r2->height > r1->y + r1->height);
|
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_)
|
static int cornerCompare(const void * a_, const void * b_)
|
||||||
{
|
{
|
||||||
const struct Corner * a = a_;
|
const struct Corner * a = a_;
|
||||||
|
@ -260,12 +275,7 @@ int rectsMergeOverlapping(FrameDamageRect * rects, int count)
|
||||||
}
|
}
|
||||||
while (changed);
|
while (changed);
|
||||||
|
|
||||||
int o = 0;
|
return removeRects(rects, count, removed);
|
||||||
for (int i = 0; i < count; ++i)
|
|
||||||
if (!removed[i])
|
|
||||||
rects[o++] = rects[i];
|
|
||||||
|
|
||||||
return o;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int rectsRejectContained(FrameDamageRect * rects, int count)
|
int rectsRejectContained(FrameDamageRect * rects, int count)
|
||||||
|
@ -287,10 +297,5 @@ int rectsRejectContained(FrameDamageRect * rects, int count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int o = 0;
|
return removeRects(rects, count, removed);
|
||||||
for (int i = 0; i < count; ++i)
|
|
||||||
if (!removed[i])
|
|
||||||
rects[o++] = rects[i];
|
|
||||||
|
|
||||||
return o;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue