summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-07-24 15:01:30 +0200
committerinfirit <[email protected]>2014-07-24 20:17:46 +0200
commit661dbc7df871f63946cfd67b7458b1228080932c (patch)
tree94c593c6688ff08cdad441d067ed164243b48053 /src
parentde74036cc420a94e5999da54f17ec6572d0a97f1 (diff)
downloadeom-661dbc7df871f63946cfd67b7458b1228080932c.tar.bz2
eom-661dbc7df871f63946cfd67b7458b1228080932c.tar.xz
Store a cairo_surface_t in EomScrollView for the GdkPixbuf to be rendered
Based on eog commit 889f275e38d0a7dcf062f5c63b8efaebaa1ca14f From Claudio Saavedra <[email protected]>
Diffstat (limited to 'src')
-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;