[vte] draw: Move drawing images after translating the cairo context



commit 39f353a9c511d11056cdb4355dc1f719391c1595
Author: Christian Persch <chpe src gnome org>
Date:   Mon Oct 19 21:14:43 2020 +0200

    draw: Move drawing images after translating the cairo context
    
    This avoids having to offset the images manually.

 src/vte.cc | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 0e4ba382..f02e4891 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -9186,6 +9186,17 @@ Terminal::widget_draw(cairo_t *cr)
                                  get_color(VTE_DEFAULT_BG), m_background_alpha);
         }
 
+        /* Clip vertically, for the sake of smooth scrolling. We want the top and bottom paddings to be 
unused.
+         * Don't clip horizontally so that antialiasing can legally overflow to the right padding. */
+        cairo_save(cr);
+        cairo_rectangle(cr, 0, m_padding.top, allocated_width, allocated_height - m_padding.top - 
m_padding.bottom);
+        cairo_clip(cr);
+
+        cairo_translate(cr, m_padding.left, m_padding.top);
+
+        /* Transform to view coordinates */
+        cairo_region_translate(region, -m_padding.left, -m_padding.top);
+
 #ifdef WITH_SIXEL
        /* Draw images */
        if (m_images_enabled) {
@@ -9196,34 +9207,23 @@ Terminal::widget_draw(cairo_t *cr)
                for (; it != image_map->end (); ++it) {
                        vte::image::Image *image = it->second;
 
-                        if (image->get_bottom() < top_row
-                            || image->get_top() > bottom_row)
+                        if (image->get_bottom() < top_row ||
+                            image->get_top() > bottom_row)
                                continue;
 
-                       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;
+                       auto const x = image->get_left () * m_cell_width;
+                       auto const y = (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);
+                       image->paint(cr, x, y, m_cell_width, m_cell_height);
                }
        }
 #endif /* WITH_SIXEL */
 
-        /* Clip vertically, for the sake of smooth scrolling. We want the top and bottom paddings to be 
unused.
-         * Don't clip horizontally so that antialiasing can legally overflow to the right padding. */
-        cairo_save(cr);
-        cairo_rectangle(cr, 0, m_padding.top, allocated_width, allocated_height - m_padding.top - 
m_padding.bottom);
-        cairo_clip(cr);
-
-        cairo_translate(cr, m_padding.left, m_padding.top);
-
-        /* Transform to view coordinates */
-        cairo_region_translate(region, -m_padding.left, -m_padding.top);
-
         /* Whether blinking text should be visible now */
         m_text_blink_state = true;
         text_blink_enabled_now = (unsigned)m_text_blink_mode & (unsigned)(m_has_focus ? 
TextBlinkMode::eFOCUSED : TextBlinkMode::eUNFOCUSED);


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