Remove a bunch of option processing code and directly define the threshold in the shader
This commit is contained in:
parent
c3242453bd
commit
d3fc8a2897
7 changed files with 4 additions and 29 deletions
|
|
@ -134,7 +134,7 @@ vec3 fg_override(float under_luminance, float over_lumininace, vec3 over) {
|
|||
// If the difference in luminance is too small,
|
||||
// force the foreground color to be black or white.
|
||||
float diff_luminance = abs(under_luminance - over_lumininace);
|
||||
float override_level = (1.f - colored_sprite) * step(diff_luminance, text_fg_override_threshold);
|
||||
float override_level = (1.f - colored_sprite) * step(diff_luminance, FG_OVERRIDE);
|
||||
float original_level = 1.f - override_level;
|
||||
return original_level * over + override_level * vec3(step(under_luminance, 0.5f));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@
|
|||
and adjust the first parameter until the perceived thickness matches the dark theme.
|
||||
''')
|
||||
|
||||
opt('text_fg_override_threshold', 0, option_type='float', ctype='percent', long_text='''
|
||||
opt('text_fg_override_threshold', 0, option_type='float', long_text='''
|
||||
The minimum accepted difference in luminance between the foreground and background
|
||||
color, below which kitty will override the foreground color. It is percentage
|
||||
ranging from :code:`0` to :code:`100`. If the difference in luminance of the
|
||||
|
|
|
|||
15
kitty/options/to-c-generated.h
generated
15
kitty/options/to-c-generated.h
generated
|
|
@ -70,19 +70,6 @@ convert_from_opts_text_composition_strategy(PyObject *py_opts, Options *opts) {
|
|||
Py_DECREF(ret);
|
||||
}
|
||||
|
||||
static void
|
||||
convert_from_python_text_fg_override_threshold(PyObject *val, Options *opts) {
|
||||
opts->text_fg_override_threshold = percent(val);
|
||||
}
|
||||
|
||||
static void
|
||||
convert_from_opts_text_fg_override_threshold(PyObject *py_opts, Options *opts) {
|
||||
PyObject *ret = PyObject_GetAttrString(py_opts, "text_fg_override_threshold");
|
||||
if (ret == NULL) return;
|
||||
convert_from_python_text_fg_override_threshold(ret, opts);
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
|
||||
static void
|
||||
convert_from_python_cursor_shape(PyObject *val, Options *opts) {
|
||||
opts->cursor_shape = PyLong_AsLong(val);
|
||||
|
|
@ -1083,8 +1070,6 @@ convert_opts_from_python_opts(PyObject *py_opts, Options *opts) {
|
|||
if (PyErr_Occurred()) return false;
|
||||
convert_from_opts_text_composition_strategy(py_opts, opts);
|
||||
if (PyErr_Occurred()) return false;
|
||||
convert_from_opts_text_fg_override_threshold(py_opts, opts);
|
||||
if (PyErr_Occurred()) return false;
|
||||
convert_from_opts_cursor_shape(py_opts, opts);
|
||||
if (PyErr_Occurred()) return false;
|
||||
convert_from_opts_cursor_beam_thickness(py_opts, opts);
|
||||
|
|
|
|||
|
|
@ -14,13 +14,6 @@ PyFloat_AsFloat(PyObject *o) {
|
|||
return (float)PyFloat_AsDouble(o);
|
||||
}
|
||||
|
||||
static inline float
|
||||
percent(PyObject *o) {
|
||||
float ans = PyFloat_AsFloat(o);
|
||||
return MAX(0.f, MIN(ans, 100.f)) * 0.01f;
|
||||
}
|
||||
|
||||
|
||||
static inline color_type
|
||||
color_as_int(PyObject *color) {
|
||||
if (!PyObject_TypeCheck(color, &Color_Type)) { PyErr_SetString(PyExc_TypeError, "Not a Color object"); return 0; }
|
||||
|
|
|
|||
|
|
@ -574,8 +574,6 @@ set_cell_uniforms(float current_inactive_text_alpha, bool force) {
|
|||
S(CELL_PROGRAM, text_contrast, text_contrast, 1f); S(CELL_FG_PROGRAM, text_contrast, text_contrast, 1f);
|
||||
float text_gamma_adjustment = OPT(text_gamma_adjustment) < 0.01f ? 1.0f : 1.0f / OPT(text_gamma_adjustment);
|
||||
S(CELL_PROGRAM, text_gamma_adjustment, text_gamma_adjustment, 1f); S(CELL_FG_PROGRAM, text_gamma_adjustment, text_gamma_adjustment, 1f);
|
||||
S(CELL_PROGRAM, text_fg_override_threshold, OPT(text_fg_override_threshold), 1f);
|
||||
S(CELL_FG_PROGRAM, text_fg_override_threshold, OPT(text_fg_override_threshold), 1f);
|
||||
#undef S
|
||||
#define SV(prog, name, num, val, type) { bind_program(prog); glUniform##type(glGetUniformLocation(program_id(prog), #name), num, val); }
|
||||
SV(CELL_PROGRAM, gamma_lut, 256, srgb_lut, 1fv); SV(CELL_FG_PROGRAM, gamma_lut, 256, srgb_lut, 1fv);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ typedef struct {
|
|||
char *bell_path, *bell_theme;
|
||||
float background_opacity, dim_opacity;
|
||||
float text_contrast, text_gamma_adjustment;
|
||||
float text_fg_override_threshold;
|
||||
bool text_old_gamma;
|
||||
|
||||
char *background_image, *default_window_logo;
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ def __call__(self, semi_transparent: bool = False, allow_recompile: bool = False
|
|||
self.semi_transparent = semi_transparent
|
||||
opts = get_options()
|
||||
self.text_old_gamma = opts.text_composition_strategy == 'legacy'
|
||||
self.text_fg_override_threshold = opts.text_fg_override_threshold
|
||||
self.text_fg_override_threshold = max(0, min(opts.text_fg_override_threshold, 100)) * 0.01
|
||||
compile_program(BLIT_PROGRAM, *load_shaders('blit'), allow_recompile)
|
||||
v, f = load_shaders('cell')
|
||||
|
||||
|
|
@ -415,7 +415,7 @@ def __call__(self, semi_transparent: bool = False, allow_recompile: bool = False
|
|||
STRIKE_SPRITE_INDEX=NUM_UNDERLINE_STYLES + 1,
|
||||
)
|
||||
if self.text_fg_override_threshold != 0.:
|
||||
ff = ff.replace('#define NO_FG_OVERRIDE', '#define FG_OVERRIDE')
|
||||
ff = ff.replace('#define NO_FG_OVERRIDE', f'#define FG_OVERRIDE {self.text_fg_override_threshold}')
|
||||
if self.text_old_gamma:
|
||||
ff = ff.replace('#define TEXT_NEW_GAMMA', '#define TEXT_OLD_GAMMA')
|
||||
if semi_transparent:
|
||||
|
|
|
|||
Loading…
Reference in a new issue