[gnome-photos] image-view: Use the correct stride value
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] image-view: Use the correct stride value
- Date: Thu, 28 Jun 2018 19:29:14 +0000 (UTC)
commit 15542a14daf17a28f83b75cf02acd2bc2db4d38d
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Jun 26 16:48:33 2018 +0200
image-view: Use the correct stride value
Multiplying the bytes per pixel of the Babl format with the requested
width is the same as GEGL_AUTO_ROWSTRIDE. Therefore, it makes no sense
to pass an explicit stride if that's just the same thing as
GEGL_AUTO_ROWSTRIDE.
The correct value would be the one specified by the Cairo surface
because ultimately the size of the allocated memory is defined by the
product of the stride and height. Any mismatch between Cairo and
GEGL_AUTO_ROWSTRIDE, due to extra padding at the end of each row to
satisfy alignment requirements, etc., would affect performance.
It's hard to know the performance impact of the current code, and
a CAIRO_ARGB32 pixel has a nicely rounded length of 32 bits, which
makes a mismatch unlikely. Still, it is wise to make this change
because the Cairo documentation recommends this. For what it's worth,
GIMP also uses the Cairo stride value when copying pixels out of a
GeglBuffer into a Cairo surface.
src/photos-image-view.c | 3 ---
1 file changed, 3 deletions(-)
---
diff --git a/src/photos-image-view.c b/src/photos-image-view.c
index b6a664a0..af2847fb 100644
--- a/src/photos-image-view.c
+++ b/src/photos-image-view.c
@@ -533,7 +533,6 @@ photos_image_view_draw_node (PhotosImageView *self, cairo_t *cr, GdkRectangle *r
GeglRectangle roi;
cairo_surface_t *surface = NULL;
g_autofree guchar *buf = NULL;
- gint bpp;
gint scale_factor;
gint stride;
gint64 end;
@@ -556,8 +555,6 @@ photos_image_view_draw_node (PhotosImageView *self, cairo_t *cr, GdkRectangle *r
start = g_get_monotonic_time ();
- bpp = babl_format_get_bytes_per_pixel (format);
- stride = bpp * roi.width;
gegl_buffer_get (self->buffer,
&roi,
self->zoom_visible_scaled,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]