From 15e8f6ad8a3ea7a2e04d8eb70bdaf4aed0b2e3f1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 12 Jun 2019 10:37:20 +0530 Subject: [PATCH] Another fix to the scissor for rendering the cell area With a cyan background it becomes apparent that the width/height are one pixel too small --- kitty/shaders.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/kitty/shaders.c b/kitty/shaders.c index 347998652..acb94b6a8 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -506,14 +506,15 @@ draw_cells(ssize_t vao_idx, ssize_t gvao_idx, GLfloat xstart, GLfloat ystart, GL set_cell_uniforms(current_inactive_text_alpha); GLfloat w = (GLfloat)screen->columns * dx, h = (GLfloat)screen->lines * dy; // The scissor limits below are calculated to ensure that they do not - // overlap with the pixels outside the draw area, see https://github.com/kovidgoyal/kitty/issues/741 - // for a test case (the scissor is also used by draw_cells_interleaved_premult to blit the framebuffer) + // overlap with the pixels outside the draw area, + // for a test case (scissor is also used to blit framebuffer in draw_cells_interleaved_premult) run: + // kitty -o background=cyan -o background_opacity=0.7 -o window_margin_width=40 sh -c "kitty +kitten icat logo/kitty.png; read" #define SCALE(w, x) ((GLfloat)(os_window->viewport_##w) * (GLfloat)(x)) glScissor( - (GLint)(ceilf(SCALE(width, (xstart + 1.0f) / 2.0f))), - (GLint)(ceilf(SCALE(height, ((ystart - h) + 1.0f) / 2.0f))), - (GLsizei)(floorf(SCALE(width, w / 2.0f))-1), - (GLsizei)(floorf(SCALE(height, h / 2.0f))-1) + (GLint)(ceilf(SCALE(width, (xstart + 1.0f) / 2.0f))), // x + (GLint)(ceilf(SCALE(height, ((ystart - h) + 1.0f) / 2.0f))), // y + (GLsizei)(floorf(SCALE(width, w / 2.0f))), // width + (GLsizei)(floorf(SCALE(height, h / 2.0f))) // height ); #undef SCALE if (os_window->is_semi_transparent) {