mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-04 13:42:33 +02:00
Get rid of transparency specialisation in cell shader
It's not a significant optimisation anymore as it only elides call to adjust_alpha_for_incorrect_blending_by_compositor, which will probably not be needed anymore anyway.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
#define HAS_TRANSPARENCY {TRANSPARENT}
|
||||
#define DO_FG_OVERRIDE {DO_FG_OVERRIDE}
|
||||
#define FG_OVERRIDE_THRESHOLD {FG_OVERRIDE_THRESHOLD}
|
||||
#define FG_OVERRIDE_ALGO {FG_OVERRIDE_ALGO}
|
||||
@@ -13,9 +12,5 @@
|
||||
#define USE_SELECTION_FG
|
||||
#define NUM_COLORS 256
|
||||
|
||||
#if (HAS_TRANSPARENCY == 1)
|
||||
#define TRANSPARENT
|
||||
#endif
|
||||
|
||||
// sRGB luminance values
|
||||
const vec3 Y = vec3(0.2126, 0.7152, 0.0722);
|
||||
|
||||
@@ -112,11 +112,7 @@ void main() {
|
||||
vec4 text_fg = load_text_foreground_color();
|
||||
text_fg = adjust_foreground_contrast_with_background(text_fg, background);
|
||||
vec4 text_fg_premul = calculate_premul_foreground_from_sprites(text_fg);
|
||||
#ifdef TRANSPARENT
|
||||
final_color = alpha_blend_premul(text_fg_premul, vec4_premul(background, bg_alpha));
|
||||
final_color.a = adjust_alpha_for_incorrect_blending_by_compositor(text_fg_premul.a, final_color.a);
|
||||
#else
|
||||
final_color = alpha_blend_premul(text_fg_premul, background);
|
||||
#endif
|
||||
output_color = final_color;
|
||||
}
|
||||
|
||||
@@ -604,7 +604,7 @@ def create_os_window(
|
||||
wm_class_name: str,
|
||||
wm_class_class: str,
|
||||
window_state: Optional[int] = WINDOW_NORMAL,
|
||||
load_programs: Optional[Callable[[bool], None]] = None,
|
||||
load_programs: Optional[Callable[[], None]] = None,
|
||||
x: Optional[int] = None,
|
||||
y: Optional[int] = None,
|
||||
disallow_override_title: bool = False,
|
||||
|
||||
@@ -1487,7 +1487,7 @@ create_os_window(PyObject UNUSED *self, PyObject *args, PyObject *kw) {
|
||||
}
|
||||
}
|
||||
if (is_first_window) {
|
||||
PyObject *ret = PyObject_CallFunction(load_programs, "O", is_semi_transparent ? Py_True : Py_False);
|
||||
PyObject *ret = PyObject_CallNoArgs(load_programs);
|
||||
if (ret == NULL) return NULL;
|
||||
Py_DECREF(ret);
|
||||
get_platform_dependent_config_values(glfw_window);
|
||||
@@ -1495,7 +1495,6 @@ create_os_window(PyObject UNUSED *self, PyObject *args, PyObject *kw) {
|
||||
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK_LEFT, GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, &encoding);
|
||||
if (encoding != GL_SRGB) log_error("The output buffer does not support sRGB color encoding, colors will be incorrect.");
|
||||
is_first_window = false;
|
||||
|
||||
}
|
||||
OSWindow *w = add_os_window();
|
||||
w->handle = glfw_window;
|
||||
|
||||
@@ -86,9 +86,9 @@ def set_custom_ibeam_cursor() -> None:
|
||||
log_error(f'Failed to set custom beam cursor with error: {e}')
|
||||
|
||||
|
||||
def load_all_shaders(semi_transparent: bool = False) -> None:
|
||||
def load_all_shaders() -> None:
|
||||
try:
|
||||
load_shader_programs(semi_transparent)
|
||||
load_shader_programs()
|
||||
load_borders_program()
|
||||
except CompileError as err:
|
||||
raise SystemExit(err)
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
/*
|
||||
* TODO: for shader refactoring
|
||||
* Get rid of TRANSPARENT define and always use premul colors
|
||||
* Change rendering of cursor -- should now be rendered with full blending as a layer between bg and fg layers
|
||||
* Check that rendering of special cells aka selections still works
|
||||
* Check color fringing issues and background lightness isssues are properly fixed
|
||||
* Port graphics rendering to start use a dummy 1 pixel empty texture then possibly replace with defines so that the most
|
||||
* common use case of no graphics has zero performance overhead.
|
||||
* Convert all images loaded to GPU to linear space for correct blending or alternately do conversion to linear space in
|
||||
|
||||
@@ -136,7 +136,6 @@ class TextFgOverrideThreshold(NamedTuple):
|
||||
class LoadShaderPrograms:
|
||||
text_fg_override_threshold: TextFgOverrideThreshold = TextFgOverrideThreshold()
|
||||
text_old_gamma: bool = False
|
||||
semi_transparent: bool = False
|
||||
cell_program_replacer: MultiReplacer = null_replacer
|
||||
|
||||
@property
|
||||
@@ -149,10 +148,9 @@ class LoadShaderPrograms:
|
||||
|
||||
def recompile_if_needed(self) -> None:
|
||||
if self.needs_recompile:
|
||||
self(self.semi_transparent, allow_recompile=True)
|
||||
self(allow_recompile=True)
|
||||
|
||||
def __call__(self, semi_transparent: bool = False, allow_recompile: bool = False) -> None:
|
||||
self.semi_transparent = semi_transparent
|
||||
def __call__(self, allow_recompile: bool = False) -> None:
|
||||
opts = get_options()
|
||||
self.text_old_gamma = opts.text_composition_strategy == 'legacy'
|
||||
|
||||
@@ -179,7 +177,6 @@ class LoadShaderPrograms:
|
||||
|
||||
def resolve_cell_defines(src: str) -> str:
|
||||
r = self.cell_program_replacer.replacements
|
||||
r['TRANSPARENT'] = '1' if semi_transparent else '0'
|
||||
r['DO_FG_OVERRIDE'] = '1' if self.text_fg_override_threshold.scaled_value else '0'
|
||||
r['FG_OVERRIDE_ALGO'] = '1' if self.text_fg_override_threshold.unit == '%' else '2'
|
||||
r['FG_OVERRIDE_THRESHOLD'] = str(self.text_fg_override_threshold.scaled_value)
|
||||
|
||||
Reference in New Issue
Block a user