]> www.fi.muni.cz Git - evince.git/commitdiff
bypass GDKSplashOutputDev and just use a normal SplashOutputDev. Speeds
authorJonathan Blandford <jrb@redhat.com>
Wed, 5 Jan 2005 20:47:12 +0000 (20:47 +0000)
committerJonathan Blandford <jrb@src.gnome.org>
Wed, 5 Jan 2005 20:47:12 +0000 (20:47 +0000)
Wed Jan  5 15:38:28 2005  Jonathan Blandford  <jrb@redhat.com>

        * pdf/xpdf/pdf-document.cc (bitmap_to_pixbuf): bypass
        GDKSplashOutputDev and just use a normal SplashOutputDev.  Speeds
        things up a bit.

        * shell/ev-sidebar-thumbnail.c: start of some profiling code.

ChangeLog
pdf/xpdf/pdf-document.cc
shell/ev-sidebar-bookmarks.c
shell/ev-sidebar-thumbnails.c

index 03faeb41816899d2d51dccf8a0c6b0fc11159dd7..cb614d473d06163494dffac15de96f326986329b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Wed Jan  5 15:38:28 2005  Jonathan Blandford  <jrb@redhat.com>
+
+       * pdf/xpdf/pdf-document.cc (bitmap_to_pixbuf): bypass
+       GDKSplashOutputDev and just use a normal SplashOutputDev.  Speeds
+       things up a bit.
+
+       * shell/ev-sidebar-thumbnail.c: start of some profiling code.
+
 2005-01-05  Martin Kretzschmar  <martink@gnome.org>
 
        * pdf/xpdf/GlobalParams.cc (displayFontTabFc): match only outline
index 2293841fd2e6709433f906311eb27126c5400687..d3f4ea68375ef4df60af99837c0c2a28f6e02261 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "GlobalParams.h"
 #include "GDKSplashOutputDev.h"
+#include "SplashBitmap.h"
 #include "PDFDoc.h"
 #include "Outline.h"
 #include "UnicodeMap.h"
@@ -1053,6 +1054,60 @@ pdf_document_document_bookmarks_iface_init (EvDocumentBookmarksIface *iface)
 }
 
 /* Thumbnails */
+
+static GdkPixbuf *
+bitmap_to_pixbuf (SplashBitmap *bitmap,
+                 GdkPixbuf    *target,
+                 gint          x_offset,
+                 gint          y_offset)
+{
+       gint width;
+       gint height;
+       SplashColorPtr dataPtr;
+       int x, y;
+
+       gboolean target_has_alpha;
+       gint target_rowstride;
+       guchar *target_data;
+
+       width = bitmap->getWidth ();
+       height = bitmap->getHeight ();
+
+       if (width + x_offset > gdk_pixbuf_get_width (target))
+               width = gdk_pixbuf_get_width (target) - x_offset;
+       if (height + y_offset > gdk_pixbuf_get_height (target))
+               height = gdk_pixbuf_get_height (target) - x_offset;
+
+       target_has_alpha = gdk_pixbuf_get_has_alpha (target);
+       target_rowstride = gdk_pixbuf_get_rowstride (target);
+       target_data = gdk_pixbuf_get_pixels (target);
+
+       dataPtr = bitmap->getDataPtr ();
+
+       for (y = 0; y < height; y++) {
+               SplashRGB8 *p;
+               SplashRGB8 rgb;
+               guchar *q;
+
+               p = dataPtr.rgb8 + y * width;
+               q = target_data + ((y + y_offset) * target_rowstride + 
+                                  x_offset * (target_has_alpha?4:3));
+               for (x = 0; x < width; x++) {
+                       rgb = *p++;
+
+                       *q++ = splashRGB8R (rgb);
+                       *q++ = splashRGB8G (rgb);
+                       *q++ = splashRGB8B (rgb);
+
+                       if (target_has_alpha)
+                               q++;
+               }
+       }
+
+       return target;
+}
+
+
 static GdkPixbuf *
 pdf_document_thumbnails_get_page_pixbuf (PdfDocument *pdf_document,
                                         gdouble      scale_factor,
@@ -1060,39 +1115,27 @@ pdf_document_thumbnails_get_page_pixbuf (PdfDocument *pdf_document,
                                         gint         width,
                                         gint         height)
 {
-       GdkPixmap *pixmap;
-       GDKSplashOutputDev *output;
+       SplashOutputDev *output;
        GdkPixbuf *pixbuf;
-       GdkPixbuf *shadow;
+       SplashColor color;
 
-       pixmap = gdk_pixmap_new (pdf_document->target,
-                                width, height, -1);
+       color.rgb8 = splashMakeRGB8 (255, 255, 255);
 
-       output = new GDKSplashOutputDev (gdk_drawable_get_screen (pdf_document->target),
-                                        NULL, NULL);
+       output = new SplashOutputDev (splashModeRGB8, gFalse, color);
        output->startDoc (pdf_document->doc->getXRef());
        pdf_document->doc->displayPage (output,
                                        page_num + 1,
                                        72*scale_factor,
                                        72*scale_factor,
                                        0, gTrue, gFalse);
-       output->redraw (0, 0,
-                       pixmap,
-                       0, 0,
-                       width, height);
-       pixbuf = gdk_pixbuf_get_from_drawable (NULL,
-                                              pixmap,
-                                              NULL,
-                                              0, 0,
-                                              0, 0,
-                                              width, height);
-       gdk_drawable_unref (pixmap);
-       delete output;
 
-       shadow = ev_document_misc_get_thumbnail_frame (-1, -1, pixbuf);
-       g_object_unref (pixbuf);
+       pixbuf = ev_document_misc_get_thumbnail_frame (output->getBitmap()->getWidth(),
+                                                      output->getBitmap()->getHeight(),
+                                                      NULL);
+       bitmap_to_pixbuf (output->getBitmap(), pixbuf, 1, 1);
+       delete output;
 
-       return shadow;
+       return pixbuf;
 }
 
 static GdkPixbuf *
index b215e1ed62debc091fa13ff58673c999da0a58ac..a81759c4eac1d42814cb906598674af6b733452d 100644 (file)
@@ -203,6 +203,7 @@ stack_data_free (IdleStackData       *stack_data,
        g_free (stack_data);
 }
 
+#if 0
 static gboolean
 do_one_iteration (EvSidebarBookmarks *ev_sidebar_bookmarks)
 {
@@ -298,7 +299,7 @@ populate_bookmarks_idle (gpointer data)
 #endif
        return TRUE;
 }
-
+#endif
 void
 ev_sidebar_bookmarks_clear_document (EvSidebarBookmarks *sidebar_bookmarks)
 {
@@ -349,7 +350,7 @@ ev_sidebar_bookmarks_set_document (EvSidebarBookmarks *sidebar_bookmarks,
                stack_data->tree_iter = NULL;
 
                priv->idle_stack = g_list_prepend (priv->idle_stack, stack_data);
-               priv->idle_id = g_idle_add (populate_bookmarks_idle, sidebar_bookmarks);
+               //priv->idle_id = g_idle_add (populate_bookmarks_idle, sidebar_bookmarks);
        }
 }
 
index 4154be3c56ec3f55763e4108266fd022426d28fb..573af69510946ec0f272a308994e26ab9b625117 100644 (file)
@@ -173,14 +173,33 @@ static gboolean
 populate_thumbnails_idle (gpointer data)
 {
        GTimer *timer;
-       gint i;
-       gulong microseconds = 0;
+       int i;
+       gdouble time_elapsed = 0;
 
        EvSidebarThumbnails *ev_sidebar_thumbnails = EV_SIDEBAR_THUMBNAILS (data);
        EvSidebarThumbnailsPrivate *priv = ev_sidebar_thumbnails->priv;
 
+
+#if PROFILE_THUMB == 1
+       static GTimer *total_timer;
+       static gboolean first_time = TRUE;
+
+       if (first_time) {
+               total_timer = g_timer_new ();
+               first_time = FALSE;
+               g_timer_start (total_timer);
+       }
+#endif
+
        if (priv->current_page == priv->n_pages) {
                priv->idle_id = 0;
+#if PROFILE_THUMB == 1
+               time_elapsed = g_timer_elapsed (total_timer, NULL);
+               g_timer_destroy (total_timer);
+               g_print ("%d rows done in %f seconds\n",
+                        gtk_tree_model_iter_n_children (GTK_TREE_MODEL (priv->list_store), NULL),
+                        time_elapsed);
+#endif
                return FALSE;
        }
 
@@ -189,13 +208,13 @@ populate_thumbnails_idle (gpointer data)
        g_timer_start (timer);
        while (do_one_iteration (ev_sidebar_thumbnails)) {
                i++;
-               g_timer_elapsed (timer, &microseconds);
-               if (microseconds > IDLE_WORK_LENGTH)
+               time_elapsed = g_timer_elapsed (timer, NULL);
+               if (time_elapsed > IDLE_WORK_LENGTH/1000000)
                        break;
        }
        g_timer_destroy (timer);
-#if 0
-       g_print ("%d rows done this idle in %d\n", i, (int)microseconds);
+#if PROFILE_THUMB == 2
+       g_print ("%d rows done this idle in %f seconds\n", i, time_elapsed);
 #endif
 
        return TRUE;