Minor cleanups
This commit is contained in:
@@ -103,17 +103,18 @@ vec4 vec4_premul(vec4 rgba) {
|
|||||||
#ifdef NEEDS_FOREGROUND
|
#ifdef NEEDS_FOREGROUND
|
||||||
// sRGB luminance values
|
// sRGB luminance values
|
||||||
const vec3 Y = vec3(0.2126, 0.7152, 0.0722);
|
const vec3 Y = vec3(0.2126, 0.7152, 0.0722);
|
||||||
|
const float gamma_factor = 2.2;
|
||||||
// Scaling factor for the extra text-alpha adjustment for luminance-difference.
|
// Scaling factor for the extra text-alpha adjustment for luminance-difference.
|
||||||
const float text_gamma_scaling = 0.5;
|
const float text_gamma_scaling = 0.5;
|
||||||
|
|
||||||
float linear2srgb(float x) {
|
float linear2srgb(float x) {
|
||||||
// Approximation of linear-to-sRGB conversion
|
// Approximation of linear-to-sRGB conversion
|
||||||
return pow(x, 1.0 / 2.2);
|
return pow(x, 1.0 / gamma_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
float srgb2linear(float x) {
|
float srgb2linear(float x) {
|
||||||
// Approximation of sRGB-to-linear conversion
|
// Approximation of sRGB-to-linear conversion
|
||||||
return pow(x, 2.2);
|
return pow(x, gamma_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
float clamp_to_unit_float(float x) {
|
float clamp_to_unit_float(float x) {
|
||||||
|
|||||||
@@ -236,8 +236,8 @@ the curl will peak once per character, with dense twice.
|
|||||||
opt('text_old_gamma', 'no',
|
opt('text_old_gamma', 'no',
|
||||||
option_type='to_bool', ctype='bool',
|
option_type='to_bool', ctype='bool',
|
||||||
long_text='''
|
long_text='''
|
||||||
If to simulate the old gamma-incorrect blending for the text alpha-channel, this
|
Revert to using the old (pre 0.28) gamma correction algorithm when rendering text.
|
||||||
will make some text appear like the strokes are uneven. Dark text on bright backgrounds
|
This will make some text appear like the strokes are uneven. Dark text on bright backgrounds
|
||||||
will also look thicker while lighter text on darker backgrounds will look thinner.
|
will also look thicker while lighter text on darker backgrounds will look thinner.
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
@@ -245,26 +245,22 @@ will also look thicker while lighter text on darker backgrounds will look thinne
|
|||||||
opt('text_gamma_adjustment', '1.0',
|
opt('text_gamma_adjustment', '1.0',
|
||||||
option_type='positive_float', ctype='float',
|
option_type='positive_float', ctype='float',
|
||||||
long_text='''
|
long_text='''
|
||||||
This setting adjusts the thickness of darker text on lighter backgrounds. Increasing the value
|
Adjust the thickness of darker text on lighter backgrounds. Increasing the value
|
||||||
setting will make the text appear thicker while decreasing the value will make it thinner. It
|
setting will make the text appear thicker while decreasing the value will make it thinner. It
|
||||||
can compensate for some fonts looking too-thin when using the gamma-correct alpha blending.
|
can compensate for some fonts looking too-thin when using the gamma-correct alpha blending.
|
||||||
|
|
||||||
The result is scaled based on the luminance difference between the background and the foreground.
|
The result is scaled based on the luminance difference between the background and the foreground.
|
||||||
Dark text on light backgrounds receive the full impact of the curve while light text on dark
|
Dark text on light backgrounds receive the full impact of the curve while light text on dark
|
||||||
backgrounds are affected very little.
|
backgrounds are affected very little. Valid values are 0.01 and above. For macOS like text rendering,
|
||||||
|
a value of ~1.7 usually works well.
|
||||||
Range: >=0.01
|
|
||||||
MacOS: 1.7
|
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
opt('text_contrast', '0',
|
opt('text_contrast', '0',
|
||||||
option_type='positive_float', ctype='float',
|
option_type='positive_float', ctype='float',
|
||||||
long_text='''
|
long_text='''
|
||||||
Additional multiplicative text contrast as a percentage, will saturate and cause jagged edges if set too high.
|
Increase text contrast further. This will cause jagged edges due to over saturation if set too high.
|
||||||
|
The value is a percentage from 0 to 100. For macOS like text rendering, a value of 30 usually works well.
|
||||||
Range: >=0.0
|
|
||||||
MacOS: 30
|
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
egr() # }}}
|
egr() # }}}
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ typedef struct {
|
|||||||
static const SpriteMap NEW_SPRITE_MAP = { .xnum = 1, .ynum = 1, .last_num_of_layers = 1, .last_ynum = -1 };
|
static const SpriteMap NEW_SPRITE_MAP = { .xnum = 1, .ynum = 1, .last_num_of_layers = 1, .last_ynum = -1 };
|
||||||
static GLint max_texture_size = 0, max_array_texture_layers = 0;
|
static GLint max_texture_size = 0, max_array_texture_layers = 0;
|
||||||
|
|
||||||
GLfloat
|
static GLfloat
|
||||||
srgb_color(uint8_t color) {
|
srgb_color(uint8_t color) {
|
||||||
return srgb_lut[color];
|
return srgb_lut[color];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
color_vec3(GLint location, color_type color) {
|
color_vec3(GLint location, color_type color) {
|
||||||
glUniform3f(location, srgb_lut[(color >> 16) & 0xFF], srgb_lut[(color >> 8) & 0xFF], srgb_lut[color & 0xFF]);
|
glUniform3f(location, srgb_lut[(color >> 16) & 0xFF], srgb_lut[(color >> 8) & 0xFF], srgb_lut[color & 0xFF]);
|
||||||
}
|
}
|
||||||
@@ -234,7 +234,7 @@ init_cell_program(void) {
|
|||||||
#define CELL_BUFFERS enum { cell_data_buffer, selection_buffer, uniform_buffer };
|
#define CELL_BUFFERS enum { cell_data_buffer, selection_buffer, uniform_buffer };
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
create_cell_vao() {
|
create_cell_vao(void) {
|
||||||
ssize_t vao_idx = create_vao();
|
ssize_t vao_idx = create_vao();
|
||||||
#define A(name, size, dtype, offset, stride) \
|
#define A(name, size, dtype, offset, stride) \
|
||||||
add_attribute_to_vao(CELL_PROGRAM, vao_idx, #name, \
|
add_attribute_to_vao(CELL_PROGRAM, vao_idx, #name, \
|
||||||
@@ -257,7 +257,7 @@ create_cell_vao() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
create_graphics_vao() {
|
create_graphics_vao(void) {
|
||||||
ssize_t vao_idx = create_vao();
|
ssize_t vao_idx = create_vao();
|
||||||
add_buffer_to_vao(vao_idx, GL_ARRAY_BUFFER);
|
add_buffer_to_vao(vao_idx, GL_ARRAY_BUFFER);
|
||||||
add_attribute_to_vao(GRAPHICS_PROGRAM, vao_idx, "src", 4, GL_FLOAT, 0, NULL, 0);
|
add_attribute_to_vao(GRAPHICS_PROGRAM, vao_idx, "src", 4, GL_FLOAT, 0, NULL, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user