[eog/wip/baedert/gtkimageview: 72/75] eog-image: Set the interp type



commit 023a0b9f9bd1ea55a8ec5cb26cda9cc2f2a627cc
Author: Timm Bäder <mail baedert org>
Date:   Sat Mar 19 15:46:19 2016 +0100

    eog-image: Set the interp type

 src/eog-image-private.h |    2 +-
 src/eog-image.c         |    9 +++++++++
 src/eog-image.h         |    2 ++
 src/eog-scroll-view.c   |   32 +++++++++++++++++---------------
 src/eog-window.c        |    2 --
 5 files changed, 29 insertions(+), 18 deletions(-)
---
diff --git a/src/eog-image-private.h b/src/eog-image-private.h
index 0833e44..f48386c 100644
--- a/src/eog-image-private.h
+++ b/src/eog-image-private.h
@@ -48,8 +48,8 @@ struct _EogImagePrivate {
 
        cairo_surface_t *surface;
        guint timeout_id;
-
        double view_scale;
+       cairo_filter_t interp_type;
 
 #ifdef HAVE_RSVG
        RsvgHandle       *svg;
diff --git a/src/eog-image.c b/src/eog-image.c
index c9c7097..88dad02 100644
--- a/src/eog-image.c
+++ b/src/eog-image.c
@@ -214,6 +214,8 @@ __draw (GtkAbstractImage *_image, cairo_t *ct)
 
        if (priv->svg)
                cairo_scale (ct, 1.0 / priv->view_scale, 1.0 / priv->view_scale);
+       else
+               cairo_pattern_set_filter (cairo_get_source (ct), priv->interp_type);
 
        cairo_set_source_surface (ct, priv->surface, 0, 0);
 }
@@ -400,6 +402,7 @@ eog_image_init (EogImage *img)
        img->priv->image = NULL;
        img->priv->anim = NULL;
        img->priv->anim_iter = NULL;
+       img->priv->interp_type = CAIRO_FILTER_GOOD;
        img->priv->timeout_id = 0;
        img->priv->thumbnail = NULL;
        img->priv->width = -1;
@@ -2596,3 +2599,9 @@ eog_image_set_view_scale (EogImage *img, double scale)
                g_signal_emit_by_name (G_OBJECT (img), "changed", 0);
        }
 }
+
+void
+eog_image_set_interp_type (EogImage *img, cairo_filter_t interp_type)
+{
+       img->priv->interp_type = interp_type;
+}
diff --git a/src/eog-image.h b/src/eog-image.h
index 729f41f..9f7d3fe 100644
--- a/src/eog-image.h
+++ b/src/eog-image.h
@@ -218,6 +218,8 @@ gboolean          eog_image_has_alpha                (EogImage *img);
 
 void              eog_image_set_view_scale           (EogImage *img, double view_scale);
 
+void              eog_image_set_interp_type          (EogImage *img, cairo_filter_t interp_type);
+
 G_END_DECLS
 
 #endif /* __EOG_IMAGE_H__ */
diff --git a/src/eog-scroll-view.c b/src/eog-scroll-view.c
index 18a9324..caf31b1 100644
--- a/src/eog-scroll-view.c
+++ b/src/eog-scroll-view.c
@@ -269,24 +269,22 @@ eog_scroll_view_set_cursor (EogScrollView *view, EogScrollViewCursor new_cursor)
 #define DOUBLE_EQUAL_MAX_DIFF 1e-6
 #define DOUBLE_EQUAL(a,b) (fabs (a - b) < DOUBLE_EQUAL_MAX_DIFF)
 
-/* Returns whether the image is zoomed in */
-static gboolean
+static inline gboolean
 is_zoomed_in (EogScrollView *view)
 {
-       EogScrollViewPrivate *priv;
+       EogScrollViewPrivate *priv = view->priv;
+       double scale = gtk_image_view_get_scale (GTK_IMAGE_VIEW (priv->display));
 
-       priv = view->priv;
-       return priv->zoom - 1.0 > DOUBLE_EQUAL_MAX_DIFF;
+       return scale - 1.0 > DOUBLE_EQUAL_MAX_DIFF;
 }
 
-/* Returns whether the image is zoomed out */
-static gboolean
+static inline gboolean
 is_zoomed_out (EogScrollView *view)
 {
-       EogScrollViewPrivate *priv;
+       EogScrollViewPrivate *priv = view->priv;
+       double scale = gtk_image_view_get_scale (GTK_IMAGE_VIEW (priv->display));
 
-       priv = view->priv;
-       return DOUBLE_EQUAL_MAX_DIFF + priv->zoom - 1.0 < 0.0;
+       return DOUBLE_EQUAL_MAX_DIFF + scale - 1.0 < 0.0;
 }
 
 /* Returns wether the image is movable, that means if it is larger then
@@ -486,7 +484,7 @@ set_minimum_zoom_factor (EogScrollView *view)
  **/
 static void
 set_zoom (EogScrollView *view, double zoom,
-         gboolean have_anchor, int anchorx, int anchory)
+          gboolean have_anchor, int anchorx, int anchory)
 {
        EogScrollViewPrivate *priv = view->priv;
 
@@ -1431,13 +1429,17 @@ display_scale_changed_cb (GtkImageView *display,
                           GParamSpec   *param_spec,
                           gpointer      user_data)
 {
+       EogScrollView *view = user_data;
+       EogScrollViewPrivate *priv = view->priv;
        double scale = gtk_image_view_get_scale (display);
 
+       eog_image_set_view_scale (priv->image, scale);
 
-       /* Will recalculate the surface */
-       eog_image_set_view_scale (EOG_SCROLL_VIEW (user_data)->priv->image, scale);
-
-       /*gtk_image_view_set_scale (GTK_IMAGE_VIEW (EOG_SCROLL_VIEW (user_data)->priv->display), 1.0);*/
+       if (is_zoomed_in (view)) {
+               eog_image_set_interp_type (priv->image, priv->interp_type_in);
+       } else if (is_zoomed_out (view)) {
+               eog_image_set_interp_type (priv->image, priv->interp_type_out);
+       }
 }
 
 static void
diff --git a/src/eog-window.c b/src/eog-window.c
index 4e2b2ab..5c73e58 100644
--- a/src/eog-window.c
+++ b/src/eog-window.c
@@ -1024,8 +1024,6 @@ eog_window_action_open_with (GSimpleAction *action,
        window = EOG_WINDOW (user_data);
 
        index = g_variant_get_uint32 (parameter);
-       if (index < 0)
-               return;
 
        app = g_ptr_array_index (window->priv->appinfo, index);
        if (!app)


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