[eog] Store a cairo_surface_t in EogScrollView for the GdkPixbuf to be rendered
- From: Claudio Saavedra <csaavedra src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [eog] Store a cairo_surface_t in EogScrollView for the GdkPixbuf to be rendered
- Date: Wed, 8 Sep 2010 16:43:00 +0000 (UTC)
commit 889f275e38d0a7dcf062f5c63b8efaebaa1ca14f
Author: Claudio Saavedra <csaavedra igalia com>
Date: Fri Aug 13 14:23:29 2010 +0300
Store a cairo_surface_t in EogScrollView for the GdkPixbuf to be rendered
Using this later during the rendering should improve performance.
https://bugzilla.gnome.org/show_bug.cgi?id=626795
src/eog-scroll-view.c | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/src/eog-scroll-view.c b/src/eog-scroll-view.c
index e66ba68..2dbd7b2 100644
--- a/src/eog-scroll-view.c
+++ b/src/eog-scroll-view.c
@@ -101,6 +101,7 @@ struct _EogScrollViewPrivate {
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;
@@ -181,6 +182,29 @@ G_DEFINE_TYPE (EogScrollView, eog_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 EogImage and removes references to it */
static void
free_image_resources (EogScrollView *view)
@@ -208,6 +232,11 @@ free_image_resources (EogScrollView *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 */
@@ -1856,6 +1885,10 @@ update_pixbuf (EogScrollView *view, GdkPixbuf *pixbuf)
priv->pixbuf = pixbuf;
+ if (priv->surface) {
+ cairo_surface_destroy (priv->surface);
+ }
+ priv->surface = create_surface_from_pixbuf (priv->pixbuf);
}
static void
@@ -2277,6 +2310,7 @@ eog_scroll_view_init (EogScrollView *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 = EOG_TRANSP_BACKGROUND;
priv->transp_color = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]