[vte/wip/sixels: 25/111] image: Consistently use 8-space indenting




commit 57acf08aef7fb3f96bbce34da490b27b2192813e
Author: Hans Petter Jansson <hpj cl no>
Date:   Sat Aug 8 20:42:48 2020 +0200

    image: Consistently use 8-space indenting

 src/image.cc | 266 +++++++++++++++++++++++++++++------------------------------
 src/image.hh |  54 ++++++------
 2 files changed, 160 insertions(+), 160 deletions(-)
---
diff --git a/src/image.cc b/src/image.cc
index ef0b15a9..05a1912a 100644
--- a/src/image.cc
+++ b/src/image.cc
@@ -30,216 +30,216 @@ Image::Image(cairo_surface_t *surface,
              gint w, gint h,
              _VteStream *stream)
 {
-       m_pixelwidth = pixelwidth;
-       m_pixelheight = pixelheight;
-       m_left = col;
-       m_top = row;
-       m_width = w;
-       m_height = h;
-       m_surface = surface;
-       m_stream = stream;
-
-       g_object_ref(m_stream);
+        m_pixelwidth = pixelwidth;
+        m_pixelheight = pixelheight;
+        m_left = col;
+        m_top = row;
+        m_width = w;
+        m_height = h;
+        m_surface = surface;
+        m_stream = stream;
+
+        g_object_ref(m_stream);
 }
 
 Image::~Image()
 {
-       if(m_surface)
-               cairo_surface_destroy(m_surface);
-       g_object_unref(m_stream);
+        if(m_surface)
+                cairo_surface_destroy(m_surface);
+        g_object_unref(m_stream);
 }
 
 glong
 Image::get_left() const
 {
-       return (glong)m_left;
+        return (glong)m_left;
 }
 
 glong
 Image::get_top() const
 {
-       return (glong)m_top;
+        return (glong)m_top;
 }
 
 glong
 Image::get_bottom() const
 {
-       return (glong)(m_top + m_height - 1);
+        return (glong)(m_top + m_height - 1);
 }
 
 gulong
 Image::get_stream_position() const
 {
-       return m_position;
+        return m_position;
 }
 
 /* Indicate whether the image is serialized to the stream */
 bool
 Image::is_frozen() const
 {
-       return (m_surface == NULL);
+        return (m_surface == NULL);
 }
 
 /* Test whether this image includes given image */
 bool
 Image::includes(const Image *other) const
 {
-       g_assert_true(other != NULL);
+        g_assert_true(other != NULL);
 
-       return other->m_left >= m_left &&
-              other->m_top >= m_top &&
-              other->m_left + other->m_width <= m_left + m_width &&
-              other->m_top + other->m_height <= m_top + m_height;
+        return other->m_left >= m_left &&
+               other->m_top >= m_top &&
+               other->m_left + other->m_width <= m_left + m_width &&
+               other->m_top + other->m_height <= m_top + m_height;
 }
 
 size_t
 Image::resource_size() const
 {
-       size_t result_size;
+        size_t result_size;
 
-       if (is_frozen()) {
-               /* If frozen, return the size sent to VteBoa. */
-               result_size = m_nwrite;
-       } else {
-               /* If not frozen, return the pixel buffer size
+        if (is_frozen()) {
+                /* If frozen, return the size sent to VteBoa. */
+                result_size = m_nwrite;
+        } else {
+                /* If not frozen, return the pixel buffer size
                  * width * height * 4. */
-               result_size = m_pixelwidth * m_pixelheight * 4;
-       }
+                result_size = m_pixelwidth * m_pixelheight * 4;
+        }
 
-       return result_size;
+        return result_size;
 }
 
 /* Deserialize the cairo image from the temporary file */
 bool
 Image::thaw()
 {
-       if (m_surface)
-               return true;
-       if (m_position < _vte_stream_tail(m_stream))
-               return false;
+        if (m_surface)
+                return true;
+        if (m_position < _vte_stream_tail(m_stream))
+                return false;
 
-       m_nread = 0;
-       m_surface = cairo_image_surface_create_from_png_stream((cairo_read_func_t)read_callback, this);
-       if (!m_surface)
-               return false;
+        m_nread = 0;
+        m_surface = cairo_image_surface_create_from_png_stream((cairo_read_func_t)read_callback, this);
+        if (!m_surface)
+                return false;
 
-       return true;
+        return true;
 }
 
 /* Serialize the image to save RAM */
 void
 Image::freeze()
 {
-       cairo_status_t status;
-       double x_scale, y_scale;
+        cairo_status_t status;
+        double x_scale, y_scale;
 
-       if (!m_surface)
-               return;
+        if (!m_surface)
+                return;
 
-       m_position = _vte_stream_head(m_stream);
-       m_nwrite = 0;
+        m_position = _vte_stream_head(m_stream);
+        m_nwrite = 0;
 
-       cairo_surface_get_device_scale(m_surface, &x_scale, &y_scale);
-       if (!_vte_double_equal(x_scale, 1.0) || !_vte_double_equal(y_scale, 1.0)) {
-               /* If device scale exceeds 1.0, the PNG image created by
+        cairo_surface_get_device_scale(m_surface, &x_scale, &y_scale);
+        if (!_vte_double_equal(x_scale, 1.0) || !_vte_double_equal(y_scale, 1.0)) {
+                /* If device scale exceeds 1.0, the PNG image created by
                  * cairo_surface_write_to_png_stream() may be large. We need to convert
                  * m_surface into a new surface with neutral scale. */
-               cairo_surface_t *image_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 
m_pixelwidth, m_pixelheight);
-               cairo_t *cr = cairo_create(image_surface);
-               paint(cr, 0, 0);
-               cairo_destroy(cr);
-               cairo_surface_destroy(m_surface);
-               m_surface = image_surface;
-       }
-       status = cairo_surface_write_to_png_stream(m_surface, (cairo_write_func_t)write_callback, this);
-       if (status == CAIRO_STATUS_SUCCESS) {
-               cairo_surface_destroy(m_surface);
-               m_surface = NULL;
-       }
+                cairo_surface_t *image_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 
m_pixelwidth, m_pixelheight);
+                cairo_t *cr = cairo_create(image_surface);
+                paint(cr, 0, 0);
+                cairo_destroy(cr);
+                cairo_surface_destroy(m_surface);
+                m_surface = image_surface;
+        }
+        status = cairo_surface_write_to_png_stream(m_surface, (cairo_write_func_t)write_callback, this);
+        if (status == CAIRO_STATUS_SUCCESS) {
+                cairo_surface_destroy(m_surface);
+                m_surface = NULL;
+        }
 }
 
 /* Merge another image into this image */
 bool
 Image::combine(Image *other, gulong char_width, gulong char_height)
 {
-       cairo_t *cr;
+        cairo_t *cr;
 
-       g_assert_true(other != NULL);
+        g_assert_true(other != NULL);
 
-       gulong offsetx = (other->m_left - m_left) * char_width;
-       gulong offsety = (other->m_top - m_top) * char_height;
+        gulong offsetx = (other->m_left - m_left) * char_width;
+        gulong offsety = (other->m_top - m_top) * char_height;
 
-       if (is_frozen())
-               if (!thaw())
-                       return false;
+        if (is_frozen())
+                if (!thaw())
+                        return false;
 
-       if (other->is_frozen())
-               if (!other->thaw())
-                       return false;
+        if (other->is_frozen())
+                if (!other->thaw())
+                        return false;
 
-       cr = cairo_create(m_surface);
-       cairo_rectangle(cr, offsetx, offsety, m_pixelwidth, m_pixelheight);
-       cairo_clip(cr);
-       cairo_set_source_surface(cr, other->m_surface, offsetx, offsety);
-       cairo_paint(cr);
-       cairo_destroy(cr);
+        cr = cairo_create(m_surface);
+        cairo_rectangle(cr, offsetx, offsety, m_pixelwidth, m_pixelheight);
+        cairo_clip(cr);
+        cairo_set_source_surface(cr, other->m_surface, offsetx, offsety);
+        cairo_paint(cr);
+        cairo_destroy(cr);
 
-       return true;
+        return true;
 }
 
 bool
 Image::unite(Image *other, gulong char_width, gulong char_height)
 {
-       if (is_frozen())
-               if (!thaw())
-                       return false;
-
-       gint new_left = std::min(m_left, other->m_left);
-       gint new_top = std::min(m_top, other->m_top);
-       gint new_width = std::max(m_left + m_width, other->m_left + other->m_width) - new_left;
-       gint new_height = std::max(m_top + m_height, other->m_top + other->m_width) - new_top;
-       gint pixelwidth = new_width * char_width;
-       gint pixelheight = new_height * char_height;
-       gint offsetx = (m_left - new_left) * char_width;
-       gint offsety = (m_top - new_top) * char_height;
-
-       cairo_surface_t * new_surface = cairo_surface_create_similar(other->m_surface, 
CAIRO_CONTENT_COLOR_ALPHA, m_pixelwidth, m_pixelheight);
-       cairo_t *cr = cairo_create(new_surface);
-       cairo_rectangle(cr, offsetx, offsety, m_pixelwidth, m_pixelheight);
-       cairo_clip(cr);
-       cairo_set_source_surface(cr, m_surface, offsetx, offsety);
-       cairo_paint(cr);
-       cairo_destroy(cr);
-
-       cairo_surface_destroy(m_surface);
-
-       m_left = new_left;
-       m_top = new_top;
-       m_width = new_width;
-       m_height = new_height;
-       m_pixelwidth = pixelwidth;
-       m_pixelheight = pixelheight;
-       m_surface = new_surface;
-
-       return combine(other, char_width, char_height);
+        if (is_frozen())
+                if (!thaw())
+                        return false;
+
+        gint new_left = std::min(m_left, other->m_left);
+        gint new_top = std::min(m_top, other->m_top);
+        gint new_width = std::max(m_left + m_width, other->m_left + other->m_width) - new_left;
+        gint new_height = std::max(m_top + m_height, other->m_top + other->m_width) - new_top;
+        gint pixelwidth = new_width * char_width;
+        gint pixelheight = new_height * char_height;
+        gint offsetx = (m_left - new_left) * char_width;
+        gint offsety = (m_top - new_top) * char_height;
+
+        cairo_surface_t * new_surface = cairo_surface_create_similar(other->m_surface, 
CAIRO_CONTENT_COLOR_ALPHA, m_pixelwidth, m_pixelheight);
+        cairo_t *cr = cairo_create(new_surface);
+        cairo_rectangle(cr, offsetx, offsety, m_pixelwidth, m_pixelheight);
+        cairo_clip(cr);
+        cairo_set_source_surface(cr, m_surface, offsetx, offsety);
+        cairo_paint(cr);
+        cairo_destroy(cr);
+
+        cairo_surface_destroy(m_surface);
+
+        m_left = new_left;
+        m_top = new_top;
+        m_width = new_width;
+        m_height = new_height;
+        m_pixelwidth = pixelwidth;
+        m_pixelheight = pixelheight;
+        m_surface = new_surface;
+
+        return combine(other, char_width, char_height);
 }
 
 /* Paint the image with provided cairo context */
 bool
 Image::paint(cairo_t *cr, gint offsetx, gint offsety)
 {
-       if (is_frozen())
-               if (!thaw())
-                       return false;
-
-       cairo_save(cr);
-       cairo_rectangle(cr, offsetx, offsety, m_pixelwidth, m_pixelheight);
-       cairo_clip(cr);
-       cairo_set_source_surface(cr, m_surface, offsetx, offsety);
-       cairo_paint(cr);
-       cairo_restore(cr);
-
-       return true;
+        if (is_frozen())
+                if (!thaw())
+                        return false;
+
+        cairo_save(cr);
+        cairo_rectangle(cr, offsetx, offsety, m_pixelwidth, m_pixelheight);
+        cairo_clip(cr);
+        cairo_set_source_surface(cr, m_surface, offsetx, offsety);
+        cairo_paint(cr);
+        cairo_restore(cr);
+
+        return true;
 }
 
 /* Callback routines for stream I/O */
@@ -247,27 +247,27 @@ Image::paint(cairo_t *cr, gint offsetx, gint offsety)
 cairo_status_t
 Image::read_callback(void *closure, char *data, unsigned int length)
 {
-       Image *image = (Image *)closure;
+        Image *image = (Image *)closure;
 
-       g_assert_true(image != NULL);
+        g_assert_true(image != NULL);
 
-       _vte_stream_read(image->m_stream, image->m_position + image->m_nread, data, length);
-       image->m_nread += length;
+        _vte_stream_read(image->m_stream, image->m_position + image->m_nread, data, length);
+        image->m_nread += length;
 
-       return CAIRO_STATUS_SUCCESS;
+        return CAIRO_STATUS_SUCCESS;
 }
 
 cairo_status_t
 Image::write_callback(void *closure, const char *data, unsigned int length)
 {
-       Image *image = (Image *)closure;
+        Image *image = (Image *)closure;
 
-       g_assert_true (image != NULL);
+        g_assert_true (image != NULL);
 
-       _vte_stream_append(image->m_stream, data, length);
-       image->m_nwrite += length;
+        _vte_stream_append(image->m_stream, data, length);
+        image->m_nwrite += length;
 
-       return CAIRO_STATUS_SUCCESS;
+        return CAIRO_STATUS_SUCCESS;
 }
 
 } // namespace image
diff --git a/src/image.hh b/src/image.hh
index b28b558b..bc13e764 100644
--- a/src/image.hh
+++ b/src/image.hh
@@ -25,35 +25,35 @@ namespace image {
 
 struct Image {
 private:
-       gint m_left;                /* left position in cell unit at the vte virtual screen */
-       gint m_width;               /* width in cell unit */
-       gint m_top;                 /* top position in cell unit at the vte virtual screen */
-       gint m_height;              /* height in cell unit */
-       VteStream *m_stream;        /* NULL if it's serialized */
-       gint m_pixelwidth;          /* image width in pixels */
-       gint m_pixelheight;         /* image hieght in pixels */
-       gulong m_position;          /* indicates the position at the stream if it's serialized */
-       size_t m_nread;             /* private use: for read callback */
-       size_t m_nwrite;            /* private use: for write callback */
-       cairo_surface_t *m_surface; /* internal cairo image */
+        gint m_left;                /* left position in cell unit at the vte virtual screen */
+        gint m_width;               /* width in cell unit */
+        gint m_top;                 /* top position in cell unit at the vte virtual screen */
+        gint m_height;              /* height in cell unit */
+        VteStream *m_stream;        /* NULL if it's serialized */
+        gint m_pixelwidth;          /* image width in pixels */
+        gint m_pixelheight;         /* image hieght in pixels */
+        gulong m_position;          /* indicates the position at the stream if it's serialized */
+        size_t m_nread;             /* private use: for read callback */
+        size_t m_nwrite;            /* private use: for write callback */
+        cairo_surface_t *m_surface; /* internal cairo image */
 public:
-       explicit Image(cairo_surface_t *surface, gint pixelwidth, gint pixelheight, gint col, gint row, gint 
w, gint h, _VteStream *stream);
-       ~Image();
-       glong get_left() const;
-       glong get_top() const;
-       glong get_bottom() const;
-       gulong get_stream_position() const;
-       bool is_frozen() const;
-       bool includes(const Image *rhs) const;
-       size_t resource_size() const;
-       void freeze();
-       bool thaw();
-       bool combine(Image *rhs, gulong char_width, gulong char_height);
-       bool unite(Image *rhs, gulong char_width, gulong char_height);
-       bool paint(cairo_t *cr, gint offsetx, gint offsety);
+        explicit Image(cairo_surface_t *surface, gint pixelwidth, gint pixelheight, gint col, gint row, gint 
w, gint h, _VteStream *stream);
+        ~Image();
+        glong get_left() const;
+        glong get_top() const;
+        glong get_bottom() const;
+        gulong get_stream_position() const;
+        bool is_frozen() const;
+        bool includes(const Image *rhs) const;
+        size_t resource_size() const;
+        void freeze();
+        bool thaw();
+        bool combine(Image *rhs, gulong char_width, gulong char_height);
+        bool unite(Image *rhs, gulong char_width, gulong char_height);
+        bool paint(cairo_t *cr, gint offsetx, gint offsety);
 public:
-       static cairo_status_t read_callback(void *closure, char *data, unsigned int length);
-       static cairo_status_t write_callback(void *closure, const char *data, unsigned int length);
+        static cairo_status_t read_callback(void *closure, char *data, unsigned int length);
+        static cairo_status_t write_callback(void *closure, const char *data, unsigned int length);
 };
 
 } // namespace image


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