mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-25 17:52:02 +02:00
Remove a switch in the cell vertex shader
This commit is contained in:
@@ -76,21 +76,17 @@ vec3 color_to_vec(uint c) {
|
|||||||
return vec3(gamma_lut[r], gamma_lut[g], gamma_lut[b]);
|
return vec3(gamma_lut[r], gamma_lut[g], gamma_lut[b]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float one_if_equal_zero_otherwise(int a, int b) {
|
||||||
|
return 1.0f - clamp(abs(float(a) - float(b)), 0.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
uint resolve_color(uint c, uint defval) {
|
uint resolve_color(uint c, uint defval) {
|
||||||
// Convert a cell color to an actual color based on the color table
|
// Convert a cell color to an actual color based on the color table
|
||||||
int t = int(c & BYTE_MASK);
|
int t = int(c & BYTE_MASK);
|
||||||
uint r;
|
uint is_one = uint(one_if_equal_zero_otherwise(t, 1));
|
||||||
switch(t) {
|
uint is_two = uint(one_if_equal_zero_otherwise(t, 2));
|
||||||
case 1:
|
uint is_neither_one_nor_two = 1u - is_one - is_two;
|
||||||
r = color_table[(c >> 8) & BYTE_MASK];
|
return is_one * color_table[(c >> 8) & BYTE_MASK] + is_two * (c >> 8) + is_neither_one_nor_two * defval;
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
r = c >> 8;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
r = defval;
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 to_color(uint c, uint defval) {
|
vec3 to_color(uint c, uint defval) {
|
||||||
|
|||||||
Reference in New Issue
Block a user