[gthumb] cairo scale: use a generic value for the max scale factor to use



commit 8243dcd17000123d65cba42e8ec446a73eb7b650
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Wed Aug 22 08:44:10 2012 +0200

    cairo scale: use a generic value for the max scale factor to use

 gthumb/cairo-scale.c       |   11 +++++------
 gthumb/cairo-scale.h       |    3 +++
 gthumb/gth-image-dragger.c |    2 +-
 3 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/gthumb/cairo-scale.c b/gthumb/cairo-scale.c
index 602a437..125433e 100644
--- a/gthumb/cairo-scale.c
+++ b/gthumb/cairo-scale.c
@@ -742,7 +742,6 @@ _cairo_image_surface_scale_bilinear_2x2 (cairo_surface_t *image,
 }
 
 
-
 cairo_surface_t *
 _cairo_image_surface_scale_bilinear (cairo_surface_t *image,
 				     int              new_width,
@@ -757,9 +756,9 @@ _cairo_image_surface_scale_bilinear (cairo_surface_t *image,
 	scale = (double) new_width / cairo_image_surface_get_width (image);
 	last_scale = 1.0;
 	s = scale;
-	while (s < 0.5) {
-		s *= 2;
-		last_scale /= 2;
+	while (s < 1.0 / _CAIRO_MAX_SCALE_FACTOR) {
+		s *= _CAIRO_MAX_SCALE_FACTOR;
+		last_scale /= _CAIRO_MAX_SCALE_FACTOR;
 		iterations++;
 	}
 	last_scale = last_scale / scale;
@@ -769,8 +768,8 @@ _cairo_image_surface_scale_bilinear (cairo_surface_t *image,
 	h = cairo_image_surface_get_height (tmp);
 
 	while (iterations-- > 0) {
-		w /= 2.0;
-		h /= 2.0;
+		w /= _CAIRO_MAX_SCALE_FACTOR;
+		h /= _CAIRO_MAX_SCALE_FACTOR;
 		tmp2 = _cairo_image_surface_scale_bilinear_2x2 (tmp, round (w), round (h));
 		cairo_surface_destroy (tmp);
 		tmp = tmp2;
diff --git a/gthumb/cairo-scale.h b/gthumb/cairo-scale.h
index dcd957e..bad01a8 100644
--- a/gthumb/cairo-scale.h
+++ b/gthumb/cairo-scale.h
@@ -28,6 +28,9 @@
 G_BEGIN_DECLS
 
 
+#define _CAIRO_MAX_SCALE_FACTOR 2.0
+
+
 typedef enum /*< skip >*/ {
 	SCALE_FILTER_POINT = 0,
 	SCALE_FILTER_BOX,
diff --git a/gthumb/gth-image-dragger.c b/gthumb/gth-image-dragger.c
index a4d9ef6..5053ea4 100644
--- a/gthumb/gth-image-dragger.c
+++ b/gthumb/gth-image-dragger.c
@@ -319,7 +319,7 @@ _gth_image_dragger_update_scaled_image (GthImageDragger *self)
 		return;
 
 	zoom = gth_image_viewer_get_zoom (self->priv->viewer);
-	if (zoom >= 0.5)
+	if (zoom >= 1.0 / _CAIRO_MAX_SCALE_FACTOR)
 		return;
 
 	self->priv->scaled = _cairo_image_surface_scale_bilinear (image,



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