[vte/wip/sixels: 48/82] image: Take cell width/height for painting in case it changed



commit fd4d625d4c3d98c66e4c69698fb568b3c49eafc0
Author: Hans Petter Jansson <hpj cl no>
Date:   Fri Jun 12 12:30:35 2020 +0200

    image: Take cell width/height for painting in case it changed
    
    This will allow us to scale the image proportionally to the change
    in cell size.

 src/image.cc | 4 +++-
 src/image.hh | 2 +-
 src/vte.cc   | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/src/image.cc b/src/image.cc
index 86012a8e..c9ff5bd7 100644
--- a/src/image.cc
+++ b/src/image.cc
@@ -39,8 +39,10 @@ Image::contains(const Image &other) const noexcept
 
 /* Paint the image with provided cairo context */
 void
-Image::paint(cairo_t *cr, int offset_x, int offset_y) const noexcept
+Image::paint(cairo_t *cr, int offset_x, int offset_y, int cell_width, int cell_height) const noexcept
 {
+        /* FIXME-hpj: Scale the image if cell width/height is different */
+
         cairo_save(cr);
         cairo_rectangle(cr, offset_x, offset_y, m_width_pixels, m_height_pixels);
         cairo_clip(cr);
diff --git a/src/image.hh b/src/image.hh
index 2c9a172b..b79a71a6 100644
--- a/src/image.hh
+++ b/src/image.hh
@@ -74,7 +74,7 @@ public:
                 return m_width_pixels * m_height_pixels * 4;
         }
         bool contains(const Image &other) const noexcept;
-        void paint(cairo_t *cr, gint offset_x, gint offset_y) const noexcept;
+        void paint(cairo_t *cr, gint offset_x, gint offset_y, int cell_width, int cell_height) const 
noexcept;
 };
 
 } // namespace image
diff --git a/src/vte.cc b/src/vte.cc
index 67bc051a..f1ed6836 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -9260,7 +9260,7 @@ 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;
-                       image->paint (cr, x, y);
+                       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]