[client] egl: add option to set initial scale algorithm

The option is egl:scale. The scale algorithm number is displayed on the
alert to make it easier to specify the number for the option.
This commit is contained in:
Quantum 2021-02-22 00:03:50 -05:00 committed by Geoffrey McRae
parent 0512c88ea8
commit 30b5287c38
3 changed files with 26 additions and 4 deletions

View File

@ -142,9 +142,10 @@ bool egl_desktop_init(EGL_Desktop ** desktop, EGLDisplay * display)
app_registerKeybind(KEY_N, egl_desktop_toggle_nv, *desktop, "Toggle night vision mode"); app_registerKeybind(KEY_N, egl_desktop_toggle_nv, *desktop, "Toggle night vision mode");
app_registerKeybind(KEY_S, egl_desktop_toggle_scale_algo, *desktop, "Toggle scale algorithm"); app_registerKeybind(KEY_S, egl_desktop_toggle_scale_algo, *desktop, "Toggle scale algorithm");
(*desktop)->nvMax = option_get_int("egl", "nvGainMax"); (*desktop)->nvMax = option_get_int("egl", "nvGainMax");
(*desktop)->nvGain = option_get_int("egl", "nvGain" ); (*desktop)->nvGain = option_get_int("egl", "nvGain" );
(*desktop)->cbMode = option_get_int("egl", "cbMode" ); (*desktop)->cbMode = option_get_int("egl", "cbMode" );
(*desktop)->scaleAlgo = option_get_int("egl", "scale" );
return true; return true;
} }
@ -175,13 +176,23 @@ static const char * egl_desktop_scale_algo_name(int algorithm)
} }
} }
bool egl_desktop_scale_validate(struct Option * opt, const char ** error)
{
if (opt->value.x_int >= 0 && opt->value.x_int < EGL_SCALE_MAX)
return true;
*error = "Invalid scale algorithm number";
return false;
}
void egl_desktop_toggle_scale_algo(int key, void * opaque) void egl_desktop_toggle_scale_algo(int key, void * opaque)
{ {
EGL_Desktop * desktop = (EGL_Desktop *)opaque; EGL_Desktop * desktop = (EGL_Desktop *)opaque;
if (++desktop->scaleAlgo == EGL_SCALE_MAX) if (++desktop->scaleAlgo == EGL_SCALE_MAX)
desktop->scaleAlgo = 0; desktop->scaleAlgo = 0;
app_alert(LG_ALERT_INFO, "Scale Algorithm: %s", egl_desktop_scale_algo_name(desktop->scaleAlgo)); app_alert(LG_ALERT_INFO, "Scale Algorithm %d: %s", desktop->scaleAlgo,
egl_desktop_scale_algo_name(desktop->scaleAlgo));
} }
void egl_desktop_free(EGL_Desktop ** desktop) void egl_desktop_free(EGL_Desktop ** desktop)

View File

@ -32,6 +32,9 @@ enum EGL_DesktopScaleType
EGL_DESKTOP_DOWNSCALE, EGL_DESKTOP_DOWNSCALE,
}; };
struct Option;
bool egl_desktop_scale_validate(struct Option * opt, const char ** error);
bool egl_desktop_init(EGL_Desktop ** desktop, EGLDisplay * display); bool egl_desktop_init(EGL_Desktop ** desktop, EGLDisplay * display);
void egl_desktop_free(EGL_Desktop ** desktop); void egl_desktop_free(EGL_Desktop ** desktop);

View File

@ -152,6 +152,14 @@ static struct Option egl_options[] =
.type = OPTION_TYPE_INT, .type = OPTION_TYPE_INT,
.value.x_int = 0 .value.x_int = 0
}, },
{
.module = "egl",
.name = "scale",
.description = "Set the scale algorithm (0 = auto, 1 = nearest, 2 = linear)",
.type = OPTION_TYPE_INT,
.validator = egl_desktop_scale_validate,
.value.x_int = 0
},
{0} {0}
}; };