From 2aed60400916afc5c0ec8fb84ee2423002ff29a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Aliste?= Date: Mon, 8 Sep 2014 23:17:59 -0300 Subject: [PATCH 2/2] glib: add poppler_page_render_annot poppler_page_render_annot is a fast method to render an annotation. With this method we can animate annotations while being created (for highlight annotations and other annotations that need a "DRAG Mode" to add them) --- glib/poppler-page.cc | 34 ++++++++++++++++++++++++++++++++++ glib/poppler-page.h | 3 +++ 2 files changed, 37 insertions(+) diff --git a/glib/poppler-page.cc b/glib/poppler-page.cc index 6e2e7f8..6a332e0 100644 --- a/glib/poppler-page.cc +++ b/glib/poppler-page.cc @@ -386,6 +386,40 @@ poppler_page_render (PopplerPage *page, } /** + * poppler_page_render_annot: + * @page: the page in which the annot is + * @cairo: cairo context to render to + * @poppler_annot: annot to render + * + * Render the annot (which belongs to page) to the given cairo context. + **/ +void +poppler_page_render_annot (PopplerPage *page, + PopplerAnnot *poppler_annot, + cairo_t *cairo) +{ + CairoOutputDev *output_dev; + + g_return_if_fail (POPPLER_IS_PAGE (page)); + + output_dev = page->document->output_dev; + output_dev->setCairo (cairo); + + /* NOTE: instead of passing -1 we should/could use cairo_clip_extents() + * to get a bounding box */ + cairo_save (cairo); + page->page->displayAnnot(poppler_annot->annot, output_dev, + 72.0, 72.0, 0, + gFalse, /* useMediaBox */ + gTrue, /* Crop */ + -1, -1, + -1, -1, + NULL, NULL); + cairo_restore (cairo); + output_dev->setCairo (NULL); +} + +/** * poppler_page_render_for_printing_with_options: * @page: the page to render from * @cairo: cairo context to render to diff --git a/glib/poppler-page.h b/glib/poppler-page.h index 63fe362..44667df 100644 --- a/glib/poppler-page.h +++ b/glib/poppler-page.h @@ -34,6 +34,9 @@ G_BEGIN_DECLS GType poppler_page_get_type (void) G_GNUC_CONST; +void poppler_page_render_annot (PopplerPage *page, + PopplerAnnot *poppler_annot, + cairo_t *cairo); void poppler_page_render (PopplerPage *page, cairo_t *cairo); void poppler_page_render_for_printing (PopplerPage *page, -- 1.9.3