diff options
author | Carlos Garcia Campos <carlosgc@gnome.org> | 2007-06-13 08:54:53 (GMT) |
---|---|---|
committer | Carlos Garcia Campos <carlosgc@src.gnome.org> | 2007-06-13 08:54:53 (GMT) |
commit | 217797d63b2d3b1c9a7a0511af1bbf3d99f0d482 (patch) | |
tree | 7984c3b1bb57f723eb57c81f6ab4121b55e69510 /backend/impress/impress-document.c | |
parent | 83005d76d55eea57772ea2dc7224e45f856725be (diff) |
Use cairo image surfaces instead of GDK pixbufs for drawing pages and
2007-06-13 Carlos Garcia Campos <carlosgc@gnome.org>
* backend/dvi/dvi-document.c: (dvi_document_render),
(dvi_document_render_pixbuf), (dvi_document_document_iface_init):
* backend/impress/impress-document.c:
(imp_render_get_from_drawable), (impress_document_render_pixbuf),
(impress_document_render), (impress_document_document_iface_init),
(impress_document_thumbnails_get_thumbnail):
* backend/djvu/djvu-document-private.h:
* backend/djvu/djvu-document.c: (djvu_document_render),
(djvu_document_finalize), (djvu_document_document_iface_init),
(djvu_document_thumbnails_get_thumbnail), (djvu_document_init):
* backend/tiff/tiff-document.c: (tiff_document_render),
(tiff_document_render_pixbuf),
(tiff_document_document_iface_init):
* backend/pdf/ev-poppler.cc: (pdf_document_render),
(pdf_document_render_pixbuf), (pdf_document_document_iface_init),
(pdf_selection_render_selection):
* backend/comics/comics-document.c:
(comics_document_render_pixbuf), (comics_document_render),
(comics_document_document_iface_init):
* backend/pixbuf/pixbuf-document.c: (pixbuf_document_render),
(pixbuf_document_document_iface_init):
* libdocument/ev-document-misc.[ch]:
(ev_document_misc_surface_from_pixbuf),
(ev_document_misc_surface_rotate_and_scale):
* libdocument/ev-document.[ch]: (ev_document_render):
* libdocument/ev-selection.[ch]: (ev_selection_render_selection):
* shell/ev-pixbuf-cache.[ch]: (dispose_cache_job_info),
(move_one_job), (copy_job_to_job_info), (add_job_if_needed),
(ev_pixbuf_cache_get_surface), (new_selection_surface_needed),
(clear_selection_if_needed), (ev_pixbuf_cache_style_changed),
(ev_pixbuf_cache_get_selection_surface), (clear_job_selection):
* shell/ev-jobs.[ch]: (ev_job_render_dispose),
(render_finished_cb), (ev_job_render_run):
* shell/ev-view.c: (draw_loading_text), (draw_one_page),
(merge_selection_region):
Use cairo image surfaces instead of GDK pixbufs for drawing pages
and selections.
svn path=/trunk/; revision=2499
Diffstat (limited to 'backend/impress/impress-document.c')
-rw-r--r-- | backend/impress/impress-document.c | 62 |
1 files changed, 45 insertions, 17 deletions
diff --git a/backend/impress/impress-document.c b/backend/impress/impress-document.c index 5f5982e..6251fbd 100644 --- a/backend/impress/impress-document.c +++ b/backend/impress/impress-document.c @@ -355,8 +355,10 @@ imp_render_get_from_drawable (ImpressDocument *impress_document) g_return_val_if_fail (page != NULL, FALSE); + ev_document_doc_mutex_lock (); imp_context_set_page (impress_document->ctx, page); imp_render (impress_document->ctx, impress_document); + ev_document_doc_mutex_unlock (); impress_document->pixbuf = gdk_pixbuf_get_from_drawable (NULL, GDK_DRAWABLE (impress_document->pixmap), @@ -370,36 +372,56 @@ imp_render_get_from_drawable (ImpressDocument *impress_document) } static GdkPixbuf * -impress_document_render_pixbuf (EvDocument *document, +impress_document_render_pixbuf (EvDocument *document, EvRenderContext *rc) { ImpressDocument *impress_document = IMPRESS_DOCUMENT (document); - GdkPixbuf *scaled_pixbuf; - - g_return_val_if_fail (IMPRESS_IS_DOCUMENT (document), 0); - g_return_val_if_fail (impress_document->imp != NULL, 0); + GdkPixbuf *pixbuf; + g_return_val_if_fail (IMPRESS_IS_DOCUMENT (document), NULL); + g_return_val_if_fail (impress_document->imp != NULL, NULL); + impress_document->pagenum = rc->page; g_mutex_lock (impress_document->mutex); impress_document->cond = g_cond_new (); ev_document_fc_mutex_unlock (); + ev_document_doc_mutex_unlock (); g_idle_add ((GSourceFunc) imp_render_get_from_drawable, impress_document); g_cond_wait (impress_document->cond, impress_document->mutex); g_cond_free (impress_document->cond); + ev_document_doc_mutex_lock (); ev_document_fc_mutex_lock (); - + g_mutex_unlock (impress_document->mutex); - scaled_pixbuf = gdk_pixbuf_scale_simple (impress_document->pixbuf, - PAGE_WIDTH * rc->scale, - PAGE_HEIGHT * rc->scale, - GDK_INTERP_BILINEAR); - gdk_pixbuf_unref (impress_document->pixbuf); + pixbuf = impress_document->pixbuf; impress_document->pixbuf = NULL; - return scaled_pixbuf; + return pixbuf; +} + +static cairo_surface_t * +impress_document_render (EvDocument *document, + EvRenderContext *rc) +{ + GdkPixbuf *pixbuf; + cairo_surface_t *surface, *scaled_surface; + + pixbuf = impress_document_render_pixbuf (document, rc); + + /* FIXME: impress backend should be ported to cairo */ + surface = ev_document_misc_surface_from_pixbuf (pixbuf); + g_object_unref (pixbuf); + + scaled_surface = ev_document_misc_surface_rotate_and_scale (surface, + (PAGE_WIDTH * rc->scale) + 0.5, + (PAGE_HEIGHT * rc->scale) + 0.5, + rc->rotation); + cairo_surface_destroy (surface); + + return scaled_surface; } static void @@ -461,7 +483,7 @@ impress_document_document_iface_init (EvDocumentIface *iface) iface->can_get_text = impress_document_can_get_text; iface->get_n_pages = impress_document_get_n_pages; iface->get_page_size = impress_document_get_page_size; - iface->render_pixbuf = impress_document_render_pixbuf; + iface->render = impress_document_render; iface->get_info = impress_document_get_info; } @@ -470,20 +492,26 @@ impress_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, EvRenderContext *rc, gboolean border) { - GdkPixbuf *pixbuf = NULL; + GdkPixbuf *pixbuf; + GdkPixbuf *scaled_pixbuf; gdouble w, h; pixbuf = impress_document_render_pixbuf (EV_DOCUMENT (document), rc); + scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf, + (PAGE_WIDTH * rc->scale), + (PAGE_HEIGHT * rc->scale), + GDK_INTERP_BILINEAR); + g_object_unref (pixbuf); if (border) { - GdkPixbuf *tmp_pixbuf = pixbuf; + GdkPixbuf *tmp_pixbuf = scaled_pixbuf; - pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf); + scaled_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf); g_object_unref (tmp_pixbuf); } - return pixbuf; + return scaled_pixbuf; } static void |