[vte/wip/sixels: 51/111] image: Fix resource calculation for non-image surfaces
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/wip/sixels: 51/111] image: Fix resource calculation for non-image surfaces
- Date: Sat, 8 Aug 2020 18:43:01 +0000 (UTC)
commit 70951b841b2c463b4626249bd94a5e925ffedb82
Author: Hans Petter Jansson <hpj cl no>
Date: Sat Aug 8 20:42:48 2020 +0200
image: Fix resource calculation for non-image surfaces
src/image.hh | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/src/image.hh b/src/image.hh
index 01fec072..ad411656 100644
--- a/src/image.hh
+++ b/src/image.hh
@@ -65,7 +65,11 @@ public:
inline constexpr auto get_top() const noexcept { return m_top_cells; }
inline constexpr auto get_bottom() const noexcept { return m_top_cells + m_height_cells - 1; }
inline auto resource_size() const noexcept {
- return cairo_image_surface_get_stride(m_surface.get()) * m_height_pixels;
+ if (cairo_image_surface_get_stride(m_surface.get()) != 0)
+ return cairo_image_surface_get_stride(m_surface.get()) * m_height_pixels;
+
+ /* Not an image surface: Only the device knows for sure, so we guess */
+ 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]