Add option --no-mipmaps

Add an option to disable trilinear filtering even if mipmapping is
available.
This commit is contained in:
Romain Vimont 2020-04-11 23:55:29 +02:00
parent bea7658807
commit 11a61b2cb3
6 changed files with 31 additions and 11 deletions

View file

@ -74,6 +74,10 @@ Disable device control (mirror the device in read\-only).
.B \-N, \-\-no\-display .B \-N, \-\-no\-display
Do not display device (only when screen recording is enabled). Do not display device (only when screen recording is enabled).
.TP
.B \-\-no\-mipmaps
If the renderer is OpenGL 3.0+ or OpenGL ES 2.0+, then mipmaps are automatically generated to improve downscaling quality. This option disables the generation of mipmaps.
.TP .TP
.BI "\-p, \-\-port " port[:port] .BI "\-p, \-\-port " port[:port]
Set the TCP port (range) used by the client to listen. Set the TCP port (range) used by the client to listen.

View file

@ -75,6 +75,11 @@ scrcpy_print_usage(const char *arg0) {
" Do not display device (only when screen recording is\n" " Do not display device (only when screen recording is\n"
" enabled).\n" " enabled).\n"
"\n" "\n"
" --no-mipmaps\n"
" If the renderer is OpenGL 3.0+ or OpenGL ES 2.0+, then\n"
" mipmaps are automatically generated to improve downscaling\n"
" quality. This option disables the generation of mipmaps.\n"
"\n"
" -p, --port port[:port]\n" " -p, --port port[:port]\n"
" Set the TCP port (range) used by the client to listen.\n" " Set the TCP port (range) used by the client to listen.\n"
" Default is %d:%d.\n" " Default is %d:%d.\n"
@ -462,6 +467,7 @@ guess_record_format(const char *filename) {
#define OPT_DISPLAY_ID 1014 #define OPT_DISPLAY_ID 1014
#define OPT_ROTATION 1015 #define OPT_ROTATION 1015
#define OPT_RENDER_DRIVER 1016 #define OPT_RENDER_DRIVER 1016
#define OPT_NO_MIPMAPS 1017
bool bool
scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) { scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
@ -478,6 +484,7 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
{"max-size", required_argument, NULL, 'm'}, {"max-size", required_argument, NULL, 'm'},
{"no-control", no_argument, NULL, 'n'}, {"no-control", no_argument, NULL, 'n'},
{"no-display", no_argument, NULL, 'N'}, {"no-display", no_argument, NULL, 'N'},
{"no-mipmaps", no_argument, NULL, OPT_NO_MIPMAPS},
{"port", required_argument, NULL, 'p'}, {"port", required_argument, NULL, 'p'},
{"push-target", required_argument, NULL, OPT_PUSH_TARGET}, {"push-target", required_argument, NULL, OPT_PUSH_TARGET},
{"record", required_argument, NULL, 'r'}, {"record", required_argument, NULL, 'r'},
@ -629,6 +636,9 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
case OPT_RENDER_DRIVER: case OPT_RENDER_DRIVER:
opts->render_driver = optarg; opts->render_driver = optarg;
break; break;
case OPT_NO_MIPMAPS:
opts->mipmaps = false;
break;
default: default:
// getopt prints the error message on stderr // getopt prints the error message on stderr
return false; return false;

View file

@ -401,7 +401,7 @@ scrcpy(const struct scrcpy_options *options) {
options->window_y, options->window_width, options->window_y, options->window_width,
options->window_height, options->window_height,
options->window_borderless, options->window_borderless,
options->rotation)) { options->rotation, options-> mipmaps)) {
goto end; goto end;
} }

View file

@ -37,6 +37,7 @@ struct scrcpy_options {
bool render_expired_frames; bool render_expired_frames;
bool prefer_text; bool prefer_text;
bool window_borderless; bool window_borderless;
bool mipmaps;
}; };
#define SCRCPY_OPTIONS_DEFAULT { \ #define SCRCPY_OPTIONS_DEFAULT { \
@ -70,6 +71,7 @@ struct scrcpy_options {
.render_expired_frames = false, \ .render_expired_frames = false, \
.prefer_text = false, \ .prefer_text = false, \
.window_borderless = false, \ .window_borderless = false, \
.mipmaps = true, \
} }
bool bool

View file

@ -199,7 +199,7 @@ screen_init_rendering(struct screen *screen, const char *window_title,
struct size frame_size, bool always_on_top, struct size frame_size, bool always_on_top,
int16_t window_x, int16_t window_y, uint16_t window_width, int16_t window_x, int16_t window_y, uint16_t window_width,
uint16_t window_height, bool window_borderless, uint16_t window_height, bool window_borderless,
uint8_t rotation) { uint8_t rotation, bool mipmaps) {
screen->frame_size = frame_size; screen->frame_size = frame_size;
screen->rotation = rotation; screen->rotation = rotation;
if (rotation) { if (rotation) {
@ -266,6 +266,7 @@ screen_init_rendering(struct screen *screen, const char *window_title,
LOGI("OpenGL version: %s", gl->version); LOGI("OpenGL version: %s", gl->version);
if (mipmaps) {
bool supports_mipmaps = bool supports_mipmaps =
sc_opengl_version_at_least(gl, 3, 0, /* OpenGL 3.0+ */ sc_opengl_version_at_least(gl, 3, 0, /* OpenGL 3.0+ */
2, 0 /* OpenGL ES 2.0+ */); 2, 0 /* OpenGL ES 2.0+ */);
@ -276,6 +277,9 @@ screen_init_rendering(struct screen *screen, const char *window_title,
LOGW("Trilinear filtering disabled " LOGW("Trilinear filtering disabled "
"(OpenGL 3.0+ or ES 2.0+ required)"); "(OpenGL 3.0+ or ES 2.0+ required)");
} }
} else {
LOGI("Trilinear filtering disabled");
}
} else { } else {
LOGW("Trilinear filtering disabled (not an OpenGL renderer)"); LOGW("Trilinear filtering disabled (not an OpenGL renderer)");
} }

View file

@ -76,7 +76,7 @@ screen_init_rendering(struct screen *screen, const char *window_title,
struct size frame_size, bool always_on_top, struct size frame_size, bool always_on_top,
int16_t window_x, int16_t window_y, uint16_t window_width, int16_t window_x, int16_t window_y, uint16_t window_width,
uint16_t window_height, bool window_borderless, uint16_t window_height, bool window_borderless,
uint8_t rotation); uint8_t rotation, bool mipmaps);
// show the window // show the window
void void