summaryrefslogtreecommitdiff
path: root/src/eom-scroll-view.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/eom-scroll-view.c')
-rw-r--r--src/eom-scroll-view.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/eom-scroll-view.c b/src/eom-scroll-view.c
index c83471c..fcd44ab 100644
--- a/src/eom-scroll-view.c
+++ b/src/eom-scroll-view.c
@@ -94,6 +94,7 @@ struct _EomScrollViewPrivate {
guint image_changed_id;
guint frame_changed_id;
GdkPixbuf *pixbuf;
+ cairo_surface_t *surface;
/* zoom mode, either ZOOM_MODE_FIT or ZOOM_MODE_FREE */
ZoomMode zoom_mode;
@@ -168,6 +169,29 @@ G_DEFINE_TYPE (EomScrollView, eom_scroll_view, GTK_TYPE_TABLE)
util functions
---------------------------------*/
+static cairo_surface_t *
+create_surface_from_pixbuf (GdkPixbuf *pixbuf)
+{
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ cairo_format_t format;
+
+ if (gdk_pixbuf_get_has_alpha (pixbuf))
+ format = CAIRO_FORMAT_ARGB32;
+ else
+ format = CAIRO_FORMAT_RGB24;
+
+ surface = cairo_image_surface_create (format,
+ gdk_pixbuf_get_width (pixbuf),
+ gdk_pixbuf_get_height (pixbuf));
+ cr = cairo_create (surface);
+ gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
+ cairo_paint (cr);
+ cairo_destroy (cr);
+
+ return surface;
+}
+
/* Disconnects from the EomImage and removes references to it */
static void
free_image_resources (EomScrollView *view)
@@ -195,6 +219,11 @@ free_image_resources (EomScrollView *view)
g_object_unref (priv->pixbuf);
priv->pixbuf = NULL;
}
+
+ if (priv->surface !=NULL) {
+ cairo_surface_destroy (priv->surface);
+ priv->surface = NULL;
+ }
}
/* Computes the size in pixels of the scaled image */
@@ -1847,6 +1876,11 @@ update_pixbuf (EomScrollView *view, GdkPixbuf *pixbuf)
}
priv->pixbuf = pixbuf;
+
+ if (priv->surface) {
+ cairo_surface_destroy (priv->surface);
+ }
+ priv->surface = create_surface_from_pixbuf (priv->pixbuf);
}
static void
@@ -2204,6 +2238,7 @@ eom_scroll_view_init (EomScrollView *view)
priv->zoom_multiplier = IMAGE_VIEW_ZOOM_MULTIPLIER;
priv->image = NULL;
priv->pixbuf = NULL;
+ priv->surface = NULL;
priv->progressive_state = PROGRESSIVE_NONE;
priv->transp_style = EOM_TRANSP_BACKGROUND;
priv->transp_color = 0;