[gnome-photos] image-view: Use double instead of float internally
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] image-view: Use double instead of float internally
- Date: Thu, 6 Apr 2017 11:21:08 +0000 (UTC)
commit 80e128415abbe05fffccd63a26824c2fd4b6e4cd
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Mar 30 10:04:42 2017 +0200
image-view: Use double instead of float internally
Even though we don't need the extra accuracy of double-precision
floating-point numbers, it doesn't cost us that much either because we
are not going to have hundreds of PhotosImageView instances. On the
other hand it does give us consistency with the Cairo and GVariant
APIs, and the future GtkImageView API that's in the works.
src/photos-image-view.c | 40 ++++++++++++++++++++--------------------
1 files changed, 20 insertions(+), 20 deletions(-)
---
diff --git a/src/photos-image-view.c b/src/photos-image-view.c
index 8405758..f7e4f27 100644
--- a/src/photos-image-view.c
+++ b/src/photos-image-view.c
@@ -38,12 +38,12 @@ struct _PhotosImageView
GeglNode *node;
cairo_region_t *bbox_region;
cairo_region_t *region;
- gfloat x;
- gfloat x_scaled;
- gfloat y;
- gfloat y_scaled;
- gfloat zoom;
- gfloat zoom_scaled;
+ gdouble x;
+ gdouble x_scaled;
+ gdouble y;
+ gdouble y_scaled;
+ gdouble zoom;
+ gdouble zoom_scaled;
};
enum
@@ -115,7 +115,7 @@ photos_image_view_update (PhotosImageView *self)
{
GdkRectangle viewport;
GeglRectangle bbox;
- float zoom_scaled = 1.0;
+ gdouble zoom_scaled = 1.0;
gint scale_factor;
gint viewport_height_real;
gint viewport_width_real;
@@ -140,9 +140,9 @@ photos_image_view_update (PhotosImageView *self)
if (bbox.height > viewport_height_real || bbox.width > viewport_width_real)
{
- gfloat height_ratio = bbox.height / (gfloat) viewport_height_real;
- gfloat width_ratio = bbox.width / (gfloat) viewport_width_real;
- gfloat max_ratio = MAX (height_ratio, width_ratio);
+ gdouble height_ratio = bbox.height / (gdouble) viewport_height_real;
+ gdouble width_ratio = bbox.width / (gdouble) viewport_width_real;
+ gdouble max_ratio = MAX (height_ratio, width_ratio);
zoom_scaled = 1.0 / max_ratio;
@@ -153,14 +153,14 @@ photos_image_view_update (PhotosImageView *self)
}
self->zoom_scaled = zoom_scaled;
- self->zoom = self->zoom_scaled / (gfloat) scale_factor;
+ self->zoom = self->zoom_scaled / (gdouble) scale_factor;
/* At this point, viewport is definitely bigger than bbox. */
self->x_scaled = (bbox.width - viewport_width_real) / 2.0 + bbox.x;
self->y_scaled = (bbox.height - viewport_height_real) / 2.0 + bbox.y;
- self->x = self->x_scaled / (gfloat) scale_factor;
- self->y = self->y_scaled / (gfloat) scale_factor;
+ self->x = self->x_scaled / (gdouble) scale_factor;
+ self->y = self->y_scaled / (gdouble) scale_factor;
}
@@ -240,7 +240,7 @@ photos_image_view_draw_node (PhotosImageView *self, cairo_t *cr, GdkRectangle *r
stride = bpp * roi.width;
gegl_buffer_get (self->buffer,
&roi,
- (gdouble) self->zoom_scaled,
+ self->zoom_scaled,
format,
buf,
stride,
@@ -335,15 +335,15 @@ photos_image_view_get_property (GObject *object, guint prop_id, GValue *value, G
break;
case PROP_X:
- g_value_set_float (value, self->x);
+ g_value_set_float (value, (gfloat) self->x);
break;
case PROP_Y:
- g_value_set_float (value, self->y);
+ g_value_set_float (value, (gfloat) self->y);
break;
case PROP_ZOOM:
- g_value_set_float (value, self->zoom);
+ g_value_set_float (value, (gfloat) self->zoom);
break;
default:
@@ -496,7 +496,7 @@ gfloat
photos_image_view_get_x (PhotosImageView *self)
{
g_return_val_if_fail (PHOTOS_IS_IMAGE_VIEW (self), 0.0);
- return self->x;
+ return (gfloat) self->x;
}
@@ -504,7 +504,7 @@ gfloat
photos_image_view_get_y (PhotosImageView *self)
{
g_return_val_if_fail (PHOTOS_IS_IMAGE_VIEW (self), 0.0);
- return self->y;
+ return (gfloat) self->y;
}
@@ -512,7 +512,7 @@ gfloat
photos_image_view_get_zoom (PhotosImageView *self)
{
g_return_val_if_fail (PHOTOS_IS_IMAGE_VIEW (self), 0.0);
- return self->zoom;
+ return (gfloat) self->zoom;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]