[vte/wip/sixels: 19/82] image: Eliminate GLib integer types
- From: Hans Petter Jansson <hansp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/wip/sixels: 19/82] image: Eliminate GLib integer types
- Date: Fri, 26 Jun 2020 00:44:41 +0000 (UTC)
commit 656a1a100999131f5aff6ba642660b5fd874cbf7
Author: Hans Petter Jansson <hpj cl no>
Date: Mon Jun 1 00:22:45 2020 +0200
image: Eliminate GLib integer types
src/image.cc | 46 +++++++++++++++++++++++-----------------------
src/image.hh | 30 ++++++++++++++++--------------
2 files changed, 39 insertions(+), 37 deletions(-)
---
diff --git a/src/image.cc b/src/image.cc
index b28df3bf..79c08e20 100644
--- a/src/image.cc
+++ b/src/image.cc
@@ -27,9 +27,9 @@ namespace vte {
namespace image {
Image::Image(cairo_surface_t *surface,
- gint pixelwidth, gint pixelheight,
- gint col, gint row,
- gint w, gint h,
+ int pixelwidth, int pixelheight,
+ int col, int row,
+ int w, int h,
_VteStream *stream)
{
m_pixelwidth = pixelwidth;
@@ -51,25 +51,25 @@ Image::~Image()
g_object_unref(m_stream);
}
-glong
+long
Image::get_left() const
{
- return (glong)m_left;
+ return (long)m_left;
}
-glong
+long
Image::get_top() const
{
- return (glong)m_top;
+ return (long)m_top;
}
-glong
+long
Image::get_bottom() const
{
- return (glong)(m_top + m_height - 1);
+ return (long)(m_top + m_height - 1);
}
-gulong
+unsigned long
Image::get_stream_position() const
{
return m_position;
@@ -162,14 +162,14 @@ Image::freeze()
/* Merge another image into this image */
bool
-Image::combine(Image *other, gulong char_width, gulong char_height)
+Image::combine(Image *other, unsigned long char_width, unsigned long char_height)
{
cairo_t *cr;
assert(other != nullptr);
- gulong offsetx = (other->m_left - m_left) * char_width;
- gulong offsety = (other->m_top - m_top) * char_height;
+ unsigned long offsetx = (other->m_left - m_left) * char_width;
+ unsigned long offsety = (other->m_top - m_top) * char_height;
if (is_frozen())
if (!thaw())
@@ -190,20 +190,20 @@ Image::combine(Image *other, gulong char_width, gulong char_height)
}
bool
-Image::unite(Image *other, gulong char_width, gulong char_height)
+Image::unite(Image *other, unsigned long char_width, unsigned long 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;
+ int new_left = std::min(m_left, other->m_left);
+ int new_top = std::min(m_top, other->m_top);
+ int new_width = std::max(m_left + m_width, other->m_left + other->m_width) - new_left;
+ int new_height = std::max(m_top + m_height, other->m_top + other->m_width) - new_top;
+ int pixelwidth = new_width * char_width;
+ int pixelheight = new_height * char_height;
+ int offsetx = (m_left - new_left) * char_width;
+ int 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);
@@ -228,7 +228,7 @@ Image::unite(Image *other, gulong char_width, gulong char_height)
/* Paint the image with provided cairo context */
bool
-Image::paint(cairo_t *cr, gint offsetx, gint offsety)
+Image::paint(cairo_t *cr, int offsetx, int offsety)
{
if (is_frozen())
if (!thaw())
diff --git a/src/image.hh b/src/image.hh
index 37039f88..600e6935 100644
--- a/src/image.hh
+++ b/src/image.hh
@@ -27,25 +27,25 @@ namespace image {
struct Image {
private:
- gint m_pixelwidth; /* Image width in pixels */
- gint m_pixelheight; /* Image height in pixels */
- gint m_left; /* Left position in cell units */
- gint m_top; /* Top position in cell units */
- gint m_width; /* Width in cell units */
- gint m_height; /* Height in cell units */
+ int m_pixelwidth; /* Image width in pixels */
+ int m_pixelheight; /* Image height in pixels */
+ int m_left; /* Left position in cell units */
+ int m_top; /* Top position in cell units */
+ int m_width; /* Width in cell units */
+ int m_height; /* Height in cell units */
VteStream *m_stream; /* For serialization */
- gulong m_position; /* Indicates the position at the stream if it's serialized */
+ unsigned long 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);
+ explicit Image(cairo_surface_t *surface, int pixelwidth, int pixelheight,
+ int col, int row, int w, int h, _VteStream *stream);
~Image();
- glong get_left() const;
- glong get_top() const;
- glong get_bottom() const;
- gulong get_stream_position() const;
+ long get_left() const;
+ long get_top() const;
+ long get_bottom() const;
+ unsigned long get_stream_position() const;
bool is_frozen() const;
bool includes(const Image *rhs) const;
size_t resource_size() const;
@@ -54,7 +54,9 @@ public:
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:
+
+ /* Callbacks */
+
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);
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]