-static GdkPixbuf *
-make_thumbnail_for_page (PopplerPage *poppler_page,
- EvRenderContext *rc,
- gint width,
- gint height)
-{
- GdkPixbuf *pixbuf;
-
-#ifdef POPPLER_WITH_GDK
- pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8,
- width, height);
- gdk_pixbuf_fill (pixbuf, 0xffffffff);
-
- ev_document_fc_mutex_lock ();
- poppler_page_render_to_pixbuf (poppler_page, 0, 0,
- width, height,
- rc->scale, rc->rotation, pixbuf);
- ev_document_fc_mutex_unlock ();
-#else
- cairo_surface_t *surface;
-
- ev_document_fc_mutex_lock ();
- surface = pdf_page_render (poppler_page, width, height, rc);
- ev_document_fc_mutex_unlock ();
-
- pixbuf = ev_document_misc_pixbuf_from_surface (surface);
- cairo_surface_destroy (surface);
-#endif /* POPPLER_WITH_GDK */
-
- return pixbuf;
-}
-
-static GdkPixbuf *
-pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails,
- EvRenderContext *rc,
- gboolean border)
-{
- PdfDocument *pdf_document = PDF_DOCUMENT (document_thumbnails);
- PopplerPage *poppler_page;
- GdkPixbuf *pixbuf = NULL;
- GdkPixbuf *border_pixbuf;
- double page_width, page_height;
- gint width, height;
-
- poppler_page = POPPLER_PAGE (rc->page->backend_page);
-
- poppler_page_get_size (poppler_page,
- &page_width, &page_height);
-
- width = MAX ((gint)(page_width * rc->scale + 0.5), 1);
- height = MAX ((gint)(page_height * rc->scale + 0.5), 1);
-
- if (rc->rotation == 90 || rc->rotation == 270) {
- gint temp;
-
- temp = width;
- width = height;
- height = temp;
- }
-
-#ifdef POPPLER_WITH_GDK
- pixbuf = poppler_page_get_thumbnail_pixbuf (poppler_page);
-#else
- cairo_surface_t *surface;
-
- surface = poppler_page_get_thumbnail (poppler_page);
- if (surface) {
- pixbuf = ev_document_misc_pixbuf_from_surface (surface);
- cairo_surface_destroy (surface);
- }
-#endif /* POPPLER_WITH_GDK */
-
- if (pixbuf != NULL) {
- int thumb_width = (rc->rotation == 90 || rc->rotation == 270) ?
- gdk_pixbuf_get_height (pixbuf) :
- gdk_pixbuf_get_width (pixbuf);
-
- if (thumb_width == width) {
- GdkPixbuf *rotated_pixbuf;
-
- rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf,
- (GdkPixbufRotation) (360 - rc->rotation));
- g_object_unref (pixbuf);
- pixbuf = rotated_pixbuf;
- } else {
- /* The provided thumbnail has a different size */
- g_object_unref (pixbuf);
- pixbuf = make_thumbnail_for_page (poppler_page, rc, width, height);
- }
- } else {
- /* There is no provided thumbnail. We need to make one. */
- pixbuf = make_thumbnail_for_page (poppler_page, rc, width, height);
- }
-
- if (border && pixbuf) {
- border_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, pixbuf);
- g_object_unref (pixbuf);
- pixbuf = border_pixbuf;
- }
-
- return pixbuf;
-}
-
-static void
-pdf_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface)
-{
- iface->get_thumbnail = pdf_document_thumbnails_get_thumbnail;
-}
-
-