[vte/wip/sixels: 50/82] terminal: Clear cell extents before painting for correct overlapping



commit b72b7517e6f774f60bb3f375d504f0c7a61aa49b
Author: Hans Petter Jansson <hpj cl no>
Date:   Fri Jun 12 12:33:28 2020 +0200

    terminal: Clear cell extents before painting for correct overlapping

 src/vte.cc | 62 +++++++++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 39 insertions(+), 23 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index f1ed6836..f3ffbaca 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -8221,29 +8221,38 @@ Terminal::draw_cells(vte::view::DrawingContext::TextRequest* items,
         else
                 rgb_from_index<4, 5, 4>(deco, dc);
 
-        if (clear && (draw_default_bg || back != VTE_DEFAULT_BG)) {
-                /* Paint the background. */
-                i = 0;
-                while (i < n) {
-                        xl = items[i].x;
-                        xr = items[i].x + items[i].columns * column_width;
-                        y = items[i].y;
-                        /* Items are not necessarily contiguous in LTR order.
-                         * Combine as long as they form a single visual run. */
-                        for (i++; i < n && items[i].y == y; i++) {
-                                if (G_LIKELY (items[i].x == xr)) {
-                                        xr += items[i].columns * column_width;  /* extend to the right */
-                                } else if (items[i].x + items[i].columns * column_width == xl) {
-                                        xl = items[i].x;                        /* extend to the left */
-                                } else {
-                                        break;                                  /* break the run */
-                                }
+        /* Paint the background. */
+        i = 0;
+        while (i < n) {
+                xl = items[i].x;
+                xr = items[i].x + items[i].columns * column_width;
+                y = items[i].y;
+                /* Items are not necessarily contiguous in LTR order.
+                 * Combine as long as they form a single visual run. */
+                for (i++; i < n && items[i].y == y; i++) {
+                        if (G_LIKELY (items[i].x == xr)) {
+                                xr += items[i].columns * column_width;  /* extend to the right */
+                        } else if (items[i].x + items[i].columns * column_width == xl) {
+                                xl = items[i].x;                        /* extend to the left */
+                        } else {
+                                break;                                  /* break the run */
                         }
-                       m_draw.fill_rectangle(
-                                                 xl,
-                                                 y,
-                                                 xr - xl, row_height,
-                                                 &bg, VTE_DRAW_OPAQUE);
+                }
+
+                if (back == VTE_DEFAULT_BG) {
+                        /* Clear cells in order to properly overdraw images */
+                        m_draw.clear(xl,
+                                     y,
+                                     xr - xl, row_height,
+                                     get_color(VTE_DEFAULT_BG), m_background_alpha);
+                }
+
+                if (clear && (draw_default_bg || back != VTE_DEFAULT_BG)) {
+                        m_draw.fill_rectangle(
+                                              xl,
+                                              y,
+                                              xr - xl, row_height,
+                                              &bg, VTE_DRAW_OPAQUE);
                 }
         }
 
@@ -9245,7 +9254,8 @@ Terminal::widget_draw(cairo_t *cr)
                                  get_color(VTE_DEFAULT_BG), m_background_alpha);
         }
 
-       /* Draw SIXEL images */
+       /* Draw images */
+
        if (m_sixel_enabled) {
                vte::grid::row_t top_row = first_displayed_row();
                vte::grid::row_t bottom_row = last_displayed_row();
@@ -9260,6 +9270,12 @@ Terminal::widget_draw(cairo_t *cr)
 
                        int x = m_padding.left + image->get_left () * m_cell_width;
                        int y = m_padding.top + (image->get_top () - m_screen->scroll_delta) * m_cell_height;
+
+                        /* Clear cell extent; image may be slightly smaller */
+                        m_draw.clear(x, y, image->get_width() * m_cell_width,
+                                     image->get_height() * m_cell_height,
+                                     get_color(VTE_DEFAULT_BG), m_background_alpha);
+
                        image->paint (cr, x, y, m_cell_width, m_cell_height);
                }
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]