build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Failing after 27s
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Failing after 28s
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Failing after 28s
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Failing after 21s
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Failing after 20s
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Failing after 21s
build / module (push) Failing after 16s
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Failing after 19s
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Failing after 20s
build / host-linux (push) Failing after 19s
build / host-windows-cross (push) Failing after 17s
build / obs (clang) (push) Failing after 18s
build / docs (push) Failing after 7s
build / obs (gcc) (push) Failing after 20s
build / host-windows-native (push) Canceled after 0s
build / idd (push) Canceled after 0s
Capture every guest display into a single frame and compose it back into the guest's desktop on the client, so one Looking Glass session can carry a multi-monitor guest instead of one instance per display. KVMFR gains a per-frame display layout (version 24). A frame with displayCount == 0 is a conventional single-display frame and behaves exactly as before, so existing capture backends are unaffected. - common: shared display layout and a shelf packer that minimises atlas area, plus atlas/desktop coordinate mapping helpers and unit tests - host: capture interface and host app carry the layout; a layout change invalidates the format so clients re-read it - host/XCB: enumerate RandR monitors and repack the root window into the atlas directly in shared memory - client/EGL: compose the atlas into the presented view as its own pass, leaving post processing, HDR, cursor and damage handling unchanged Also fixes the XCB backend writing a single row per frame instead of the whole image.
153 lines
5.4 KiB
C
153 lines
5.4 KiB
C
#include "common/displays.h"
|
|
#include "common/debug.h"
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <inttypes.h>
|
|
|
|
static int failures = 0;
|
|
|
|
static void check(bool cond, const char * what)
|
|
{
|
|
printf(" [%s] %s\n", cond ? "PASS" : "FAIL", what);
|
|
if (!cond)
|
|
++failures;
|
|
}
|
|
|
|
/* verify no two displays overlap in the atlas and all are in bounds */
|
|
static bool validate(const KVMFRDisplay * d, unsigned count,
|
|
unsigned aw, unsigned ah)
|
|
{
|
|
for(unsigned i = 0; i < count; ++i)
|
|
{
|
|
if (d[i].atlasX + d[i].atlasWidth > aw) return false;
|
|
if (d[i].atlasY + d[i].atlasHeight > ah) return false;
|
|
if (d[i].atlasWidth != d[i].desktopWidth) return false;
|
|
if (d[i].atlasHeight != d[i].desktopHeight) return false;
|
|
for(unsigned j = i + 1; j < count; ++j)
|
|
{
|
|
const bool disjoint =
|
|
d[i].atlasX + d[i].atlasWidth <= d[j].atlasX ||
|
|
d[j].atlasX + d[j].atlasWidth <= d[i].atlasX ||
|
|
d[i].atlasY + d[i].atlasHeight <= d[j].atlasY ||
|
|
d[j].atlasY + d[j].atlasHeight <= d[i].atlasY;
|
|
if (!disjoint)
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
static void run(const char * title, const LGDisplayInfo * in, unsigned count)
|
|
{
|
|
KVMFRDisplay out[KVMFR_MAX_DISPLAYS];
|
|
unsigned aw, ah, dw, dh;
|
|
|
|
printf("\n== %s ==\n", title);
|
|
if (!lgDisplaysPack(in, count, 1, out, &aw, &ah, &dw, &dh))
|
|
{
|
|
printf(" [FAIL] pack returned false\n");
|
|
++failures;
|
|
return;
|
|
}
|
|
|
|
uint64_t used = 0;
|
|
for(unsigned i = 0; i < count; ++i)
|
|
used += (uint64_t)in[i].width * in[i].height;
|
|
|
|
printf(" atlas %ux%u (%.1f MP), desktop %ux%u, waste %.1f%%\n",
|
|
aw, ah, (aw * (double)ah) / 1e6, dw, dh,
|
|
100.0 * (1.0 - used / (aw * (double)ah)));
|
|
for(unsigned i = 0; i < count; ++i)
|
|
printf(" %-8s atlas +%u+%u %ux%u desktop +%d+%d\n",
|
|
out[i].name, out[i].atlasX, out[i].atlasY,
|
|
out[i].atlasWidth, out[i].atlasHeight,
|
|
out[i].desktopX, out[i].desktopY);
|
|
|
|
check(validate(out, count, aw, ah), "layout is non-overlapping and in bounds");
|
|
check((uint64_t)aw * ah >= used, "atlas is at least the sum of display areas");
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
debug_init();
|
|
|
|
/* the real geometry of the development machine */
|
|
const LGDisplayInfo real[3] = {
|
|
{ .id = 0, .name = "DP-2", .x = 2160, .y = 2880, .width = 5120, .height = 2880 },
|
|
{ .id = 1, .name = "DP-1", .x = 0, .y = 896, .width = 2160, .height = 3840 },
|
|
{ .id = 2, .name = "DP-3", .x = 2160, .y = 0, .width = 5120, .height = 2880,
|
|
.primary = true },
|
|
};
|
|
run("3 mixed displays (this machine)", real, 3);
|
|
|
|
const LGDisplayInfo triple[3] = {
|
|
{ .id = 0, .name = "A", .x = 0, .y = 0, .width = 1920, .height = 1080 },
|
|
{ .id = 1, .name = "B", .x = 1920, .y = 0, .width = 1920, .height = 1080 },
|
|
{ .id = 2, .name = "C", .x = 3840, .y = 0, .width = 1920, .height = 1080 },
|
|
};
|
|
run("3 identical 1080p displays", triple, 3);
|
|
|
|
const LGDisplayInfo single[1] = {
|
|
{ .id = 0, .name = "only", .x = 0, .y = 0, .width = 2560, .height = 1440 },
|
|
};
|
|
run("single display", single, 1);
|
|
|
|
const LGDisplayInfo negative[2] = {
|
|
{ .id = 0, .name = "left", .x = -1920, .y = -100, .width = 1920, .height = 1080 },
|
|
{ .id = 1, .name = "right", .x = 0, .y = 0, .width = 2560, .height = 1440 },
|
|
};
|
|
run("negative desktop coordinates", negative, 2);
|
|
|
|
printf("\n== edge cases ==\n");
|
|
KVMFRDisplay out[KVMFR_MAX_DISPLAYS];
|
|
unsigned aw, ah, dw, dh;
|
|
check(!lgDisplaysPack(real, 0, 1, out, &aw, &ah, &dw, &dh),
|
|
"zero displays rejected");
|
|
check(!lgDisplaysPack(real, KVMFR_MAX_DISPLAYS + 1, 1, out, &aw, &ah, &dw, &dh),
|
|
"too many displays rejected");
|
|
|
|
const LGDisplayInfo zero[1] = {
|
|
{ .id = 0, .name = "bad", .x = 0, .y = 0, .width = 0, .height = 1080 } };
|
|
check(!lgDisplaysPack(zero, 1, 1, out, &aw, &ah, &dw, &dh),
|
|
"zero-width display rejected");
|
|
|
|
const LGDisplayInfo huge[2] = {
|
|
{ .id = 0, .name = "h1", .x = 0, .y = 0, .width = 16384, .height = 16384 },
|
|
{ .id = 1, .name = "h2", .x = 0, .y = 0, .width = 16384, .height = 16384 } };
|
|
check(!lgDisplaysPack(huge, 2, 1, out, &aw, &ah, &dw, &dh),
|
|
"oversized set rejected rather than silently truncated");
|
|
|
|
/* alignment */
|
|
const LGDisplayInfo odd[1] = {
|
|
{ .id = 0, .name = "odd", .x = 0, .y = 0, .width = 1234, .height = 1000 } };
|
|
if (lgDisplaysPack(odd, 1, 64, out, &aw, &ah, &dw, &dh))
|
|
check(aw % 64 == 0, "atlas width honours 64px alignment");
|
|
else
|
|
check(false, "alignment case packed");
|
|
|
|
/* desktop normalisation */
|
|
if (lgDisplaysPack(negative, 2, 1, out, &aw, &ah, &dw, &dh))
|
|
{
|
|
check(out[0].desktopX == 0 && out[1].desktopX == 1920,
|
|
"negative coordinates normalised to origin");
|
|
check(dw == 4480 && dh == 1540, "virtual desktop bounds computed");
|
|
}
|
|
|
|
/* atlas <-> desktop round trip */
|
|
if (lgDisplaysPack(real, 3, 1, out, &aw, &ah, &dw, &dh))
|
|
{
|
|
int32_t ax, ay, dx, dy;
|
|
bool ok = lgDisplaysDesktopToAtlas(out, 3, 2160 + 10, 2880 + 20, &ax, &ay) &&
|
|
lgDisplaysAtlasToDesktop(out, 3, ax, ay, &dx, &dy);
|
|
check(ok && dx == 2170 && dy == 2900, "desktop->atlas->desktop round trips");
|
|
check(lgDisplaysFindAtPoint(out, 3, 0, 0) == -1,
|
|
"point in a desktop gap reports no display");
|
|
check(lgDisplaysFindAtPoint(out, 3, 2160, 0) == 2,
|
|
"point inside DP-3 finds DP-3");
|
|
}
|
|
|
|
printf("\n%s (%d failure%s)\n", failures ? "FAILED" : "ALL PASSED",
|
|
failures, failures == 1 ? "" : "s");
|
|
return failures != 0;
|
|
}
|