[client] util: replace util_mergeOverlappingRects with common version

This commit is contained in:
Quantum 2021-08-11 02:42:31 -04:00 committed by Geoffrey McRae
parent 604b44d6d8
commit 7e982a6658
3 changed files with 2 additions and 44 deletions

View File

@ -40,7 +40,6 @@ bool util_guestCurToLocal(struct DoublePoint *local);
void util_localCurToGuest(struct DoublePoint *guest);
void util_rotatePoint(struct DoublePoint *point);
bool util_hasGLExt(const char * exts, const char * ext);
int util_mergeOverlappingRects(FrameDamageRect * rects, int count);
static inline double util_clamp(double x, double min, double max)
{

View File

@ -24,6 +24,7 @@
#include "common/KVMFR.h"
#include "common/option.h"
#include "common/sysinfo.h"
#include "common/rects.h"
#include "common/time.h"
#include "common/locking.h"
#include "app.h"
@ -955,7 +956,7 @@ static bool egl_render(LG_Renderer * renderer, LG_RendererRotate rotate,
);
}
accumulated->count = util_mergeOverlappingRects(accumulated->rects, accumulated->count);
accumulated->count = rectsMergeOverlapping(accumulated->rects, accumulated->count);
}
++this->overlayHistoryIdx;

View File

@ -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)