Ensure cell start position is clamped to a pixel

This commit is contained in:
Kovid Goyal 2021-12-05 18:26:25 +05:30
parent b4024bf7f2
commit 11badac95d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 14 additions and 2 deletions

View File

@ -138,6 +138,18 @@ clamp_position_to_nearest_pixel(float pos, const unsigned int viewport_size) {
return -1.f + num_of_pixels * px;
}
static inline float
gl_pos_x(const unsigned int px_from_left_margin, const unsigned int viewport_size) {
const float px = 2.f / viewport_size;
return -1.f + px_from_left_margin * px;
}
static inline float
gl_pos_y(const unsigned int px_from_top_margin, const unsigned int viewport_size) {
const float px = 2.f / viewport_size;
return 1.f - px_from_top_margin * px;
}
GraphicsManager* grman_alloc(void);
void grman_clear(GraphicsManager*, bool, CellPixelSize fg);

View File

@ -709,8 +709,8 @@ static void
init_screen_render_data(OSWindow *osw, const WindowGeometry *g, ScreenRenderData *d) {
d->dx = gl_size(osw->fonts_data->cell_width, osw->viewport_width);
d->dy = gl_size(osw->fonts_data->cell_height, osw->viewport_height);
d->xstart = -1.f + gl_size(g->left, osw->viewport_width);
d->ystart = 1.f - gl_size(g->top, osw->viewport_height);
d->xstart = gl_pos_x(g->left, osw->viewport_width);
d->ystart = gl_pos_y(g->top, osw->viewport_height);
}
PYWRAP1(set_tab_bar_render_data) {