Add scale support
This commit is contained in:
@@ -56,12 +56,13 @@ int main(int argc, char **argv)
|
||||
{
|
||||
if (argc < 2 || argc > 4) {
|
||||
fprintf(stderr,
|
||||
"usage: %s /path/to/obs-webkit-renderer [opaque | opaque-url URL]\n",
|
||||
"usage: %s /path/to/obs-webkit-renderer [opaque | zoom | opaque-url URL]\n",
|
||||
argv[0]);
|
||||
return 2;
|
||||
}
|
||||
bool external_url = argc == 4 && strcmp(argv[2], "opaque-url") == 0;
|
||||
bool opaque = external_url || (argc == 3 && strcmp(argv[2], "opaque") == 0);
|
||||
bool zoom = argc == 3 && strcmp(argv[2], "zoom") == 0;
|
||||
bool opaque = external_url || zoom || (argc == 3 && strcmp(argv[2], "opaque") == 0);
|
||||
int control[2];
|
||||
int frames[2];
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, control) || pipe(frames)) {
|
||||
@@ -108,14 +109,18 @@ int main(int argc, char **argv)
|
||||
const char opaque_css[] = "html,body{margin:0;background:rgb(7,19,31)!important}"
|
||||
"#box{position:fixed;left:16px;top:16px;width:32px;height:32px;"
|
||||
"background:rgb(241,23,17);transform:translateZ(0);filter:blur(.1px)}";
|
||||
const char zoom_css[] = "html,body{margin:0;background:rgb(7,19,31)!important}"
|
||||
"#box{position:fixed;left:0;top:0;width:10px;height:10px;"
|
||||
"background:rgb(241,23,17)}";
|
||||
const char *url = external_url ? argv[3] : internal_url;
|
||||
const char *css = external_url ? "" : opaque ? opaque_css : transparent_css;
|
||||
const char *css = external_url ? "" : zoom ? zoom_css : opaque ? opaque_css : transparent_css;
|
||||
struct owb_config_header config = {
|
||||
.magic = OWB_CONFIG_MAGIC,
|
||||
.version = OWB_PROTOCOL_VERSION,
|
||||
.width = width,
|
||||
.height = height,
|
||||
.fps = 10,
|
||||
.zoom_percent = zoom ? 200 : 100,
|
||||
.transparent = opaque ? 0 : 1,
|
||||
/* GPU rendering must still produce an invisible captured frame. */
|
||||
.hardware_acceleration = 1,
|
||||
@@ -158,10 +163,17 @@ int main(int argc, char **argv)
|
||||
nonuniform ? "content" : "uniform");
|
||||
continue;
|
||||
}
|
||||
size_t center = ((size_t)(height / 2) * width + width / 2) * 4;
|
||||
size_t center = zoom ? ((size_t)5 * width + 15) * 4
|
||||
: ((size_t)(height / 2) * width + width / 2) * 4;
|
||||
memcpy(last_bgra, frame + center, sizeof(last_bgra));
|
||||
memcpy(last_corner_bgra, frame, sizeof(last_corner_bgra));
|
||||
bool expected = opaque
|
||||
size_t corner = zoom ? ((size_t)5 * width + 25) * 4 : 0;
|
||||
memcpy(last_corner_bgra, frame + corner, sizeof(last_corner_bgra));
|
||||
bool expected = zoom
|
||||
? last_bgra[0] < 32 && last_bgra[1] < 40 && last_bgra[2] > 210 &&
|
||||
last_bgra[3] == 255 && last_corner_bgra[0] > 20 &&
|
||||
last_corner_bgra[1] < 32 && last_corner_bgra[2] < 32 &&
|
||||
last_corner_bgra[3] == 255
|
||||
: opaque
|
||||
? last_bgra[0] < 32 && last_bgra[1] < 40 && last_bgra[2] > 210 &&
|
||||
last_bgra[3] == 255
|
||||
: last_bgra[0] < 8 && last_bgra[1] < 8 && last_bgra[2] > 248 &&
|
||||
@@ -192,7 +204,8 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr,
|
||||
"renderer did not produce the expected %s red BGRA frame "
|
||||
"(center BGRA=%u,%u,%u,%u; corner BGRA=%u,%u,%u,%u)\n",
|
||||
opaque ? "opaque" : "transparent", last_bgra[0], last_bgra[1],
|
||||
zoom ? "200%-zoomed" : opaque ? "opaque" : "transparent",
|
||||
last_bgra[0], last_bgra[1],
|
||||
last_bgra[2], last_bgra[3], last_corner_bgra[0], last_corner_bgra[1],
|
||||
last_corner_bgra[2], last_corner_bgra[3]);
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user