Clamp positions of window numbers/titles to nearest pixel

Avoids jaggies in rendering
This commit is contained in:
Kovid Goyal 2021-12-26 11:05:16 +05:30
parent 93abedd93f
commit f6b748712c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -577,7 +577,10 @@ render_window_title(OSWindow *os_window, Screen *screen UNUSED, GLfloat xstart,
window->title_bar_data.last_drawn_title_object_id = window->title;
}
static ImageRenderData data = {.group_count=1};
gpu_data_for_image(&data, xstart, ystart, xstart + width, ystart - 2.f * (bar_height / (float)os_window->viewport_height));
gpu_data_for_image(&data,
clamp_position_to_nearest_pixel(xstart, os_window->viewport_width),
clamp_position_to_nearest_pixel(ystart, os_window->viewport_height),
xstart + width, ystart - 2.f * (bar_height / (float)os_window->viewport_height));
if (!data.texture_id) { glGenTextures(1, &data.texture_id); }
glBindTexture(GL_TEXTURE_2D, data.texture_id);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
@ -653,7 +656,11 @@ draw_window_number(OSWindow *os_window, Screen *screen, const CellRenderData *cr
bind_program(GRAPHICS_ALPHA_MASK_PROGRAM);
ImageRenderData *ird = load_alpha_mask_texture(lr.width_px, lr.height_px, lr.canvas);
#undef lr
gpu_data_for_image(ird, left, top, right, bottom);
gpu_data_for_image(ird,
clamp_position_to_nearest_pixel(left, os_window->viewport_width),
clamp_position_to_nearest_pixel(top, os_window->viewport_height),
right, bottom
);
glEnable(GL_BLEND);
BLEND_PREMULT;
glUniform1i(cell_uniform_data.amask_image_loc, GRAPHICS_UNIT);