mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-08-09 20:24:14 +00:00
[client] util: replace util_mergeOverlappingRects with common version
This commit is contained in:
@@ -219,48 +219,6 @@ bool util_hasGLExt(const char * exts, const char * ext)
|
||||
return str_containsValue(exts, ' ', ext);
|
||||
}
|
||||
|
||||
static bool rectIntersects(const FrameDamageRect * r1, const FrameDamageRect * r2)
|
||||
{
|
||||
return r1->x < r2->x + r2->width &&
|
||||
r1->x + r1->width > r2->x &&
|
||||
r1->y < r2->y + r2->height &&
|
||||
r2->y + r1->height > r2->y;
|
||||
}
|
||||
|
||||
int util_mergeOverlappingRects(FrameDamageRect * rects, int count)
|
||||
{
|
||||
bool removed[count];
|
||||
bool changed;
|
||||
|
||||
memset(removed, 0, sizeof(removed));
|
||||
|
||||
do
|
||||
{
|
||||
changed = false;
|
||||
for (int i = 0; i < count; ++i)
|
||||
if (!removed[i])
|
||||
for (int j = i + 1; j < count; ++j)
|
||||
if (!removed[j] && rectIntersects(rects + i, rects + j))
|
||||
{
|
||||
uint32_t x2 = max(rects[i].x + rects[i].width, rects[j].x + rects[j].width);
|
||||
uint32_t y2 = max(rects[i].y + rects[i].height, rects[j].y + rects[j].height);
|
||||
rects[i].x = min(rects[i].x, rects[j].x);
|
||||
rects[i].y = min(rects[i].y, rects[j].y);
|
||||
rects[i].width = x2 - rects[i].x;
|
||||
rects[i].height = y2 - rects[i].y;
|
||||
removed[j] = true;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
while (changed);
|
||||
|
||||
int o = 0;
|
||||
for (int i = 0; i < count; ++i)
|
||||
if (!removed[i])
|
||||
rects[o++] = rects[i];
|
||||
return o;
|
||||
}
|
||||
|
||||
bool util_initUIFonts(void)
|
||||
{
|
||||
if (FontConfig)
|
||||
|
Reference in New Issue
Block a user