From b3f6ded68bf84ff865dcdb648b2b84abb2a60ab1 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Tue, 12 May 2009 09:32:22 +0000 Subject: [libview] Get annotations when rendering pages --- (limited to 'libview') diff --git a/libview/ev-jobs.c b/libview/ev-jobs.c index d2f08ef..b5b4282 100644 --- a/libview/ev-jobs.c +++ b/libview/ev-jobs.c @@ -33,6 +33,7 @@ #include "ev-document-security.h" #include "ev-document-find.h" #include "ev-document-layers.h" +#include "ev-document-annotations.h" #include "ev-debug.h" #include @@ -558,6 +559,10 @@ ev_job_render_run (EvJob *job) job_render->image_mapping = ev_document_images_get_image_mapping (EV_DOCUMENT_IMAGES (job->document), job_render->page); + if ((job_render->flags & EV_RENDER_INCLUDE_ANNOTS) && EV_IS_DOCUMENT_ANNOTATIONS (job->document)) + job_render->annots_mapping = + ev_document_annotations_get_annotations (EV_DOCUMENT_ANNOTATIONS (job->document), + job_render->ev_page); g_object_unref (rc); ev_document_doc_mutex_unlock (); diff --git a/libview/ev-jobs.h b/libview/ev-jobs.h index fc577c1..17f1b3c 100644 --- a/libview/ev-jobs.h +++ b/libview/ev-jobs.h @@ -187,7 +187,8 @@ typedef enum { EV_RENDER_INCLUDE_SELECTION = 1 << 2, EV_RENDER_INCLUDE_IMAGES = 1 << 3, EV_RENDER_INCLUDE_FORMS = 1 << 4, - EV_RENDER_INCLUDE_ALL = (1 << 5) - 1 + EV_RENDER_INCLUDE_ANNOTS = 1 << 5, + EV_RENDER_INCLUDE_ALL = (1 << 6) - 1 } EvRenderFlags; struct _EvJobRender @@ -208,6 +209,7 @@ struct _EvJobRender GdkRegion *text_mapping; GList *image_mapping; GList *form_field_mapping; + GList *annots_mapping; cairo_surface_t *selection; GdkRegion *selection_region; diff --git a/libview/ev-pixbuf-cache.c b/libview/ev-pixbuf-cache.c index d7d89f7..b81b7d1 100644 --- a/libview/ev-pixbuf-cache.c +++ b/libview/ev-pixbuf-cache.c @@ -5,8 +5,10 @@ #include "ev-document-images.h" #include "ev-document-forms.h" #include "ev-document-links.h" +#include "ev-document-annotations.h" #include "ev-image.h" #include "ev-form-field.h" +#include "ev-annotation.h" typedef struct _CacheJobInfo { @@ -22,6 +24,7 @@ typedef struct _CacheJobInfo GList *link_mapping; GList *image_mapping; GList *form_field_mapping; + GList *annots_mapping; GdkRegion *text_mapping; /* Selection data. @@ -188,6 +191,10 @@ dispose_cache_job_info (CacheJobInfo *job_info, ev_form_field_mapping_free (job_info->form_field_mapping); job_info->form_field_mapping = NULL; } + if (job_info->annots_mapping) { + ev_annotation_mapping_free (job_info->annots_mapping); + job_info->annots_mapping = NULL; + } if (job_info->text_mapping) { gdk_region_destroy (job_info->text_mapping); job_info->text_mapping = NULL; @@ -373,6 +380,7 @@ move_one_job (CacheJobInfo *job_info, job_info->link_mapping = NULL; job_info->image_mapping = NULL; job_info->form_field_mapping = NULL; + job_info->annots_mapping = NULL; if (new_priority != priority && target_page->job) { ev_job_scheduler_update_job (target_page->job, new_priority); @@ -527,6 +535,12 @@ copy_job_to_job_info (EvJobRender *job_render, job_info->form_field_mapping = job_render->form_field_mapping; } + if (job_render->flags & EV_RENDER_INCLUDE_ANNOTS) { + if (job_info->annots_mapping) + ev_annotation_mapping_free (job_info->annots_mapping); + job_info->annots_mapping = job_render->annots_mapping; + } + if (job_render->flags & EV_RENDER_INCLUDE_TEXT) { if (job_info->text_mapping) gdk_region_destroy (job_info->text_mapping); @@ -633,6 +647,8 @@ add_job (EvPixbufCache *pixbuf_cache, flags |= EV_RENDER_INCLUDE_IMAGES; if (job_info->form_field_mapping == NULL) flags |= EV_RENDER_INCLUDE_FORMS; + if (job_info->annots_mapping == NULL) + flags |= EV_RENDER_INCLUDE_ANNOTS; if (job_info->text_mapping == NULL) flags |= EV_RENDER_INCLUDE_TEXT; @@ -849,6 +865,28 @@ ev_pixbuf_cache_get_form_field_mapping (EvPixbufCache *pixbuf_cache, return job_info->form_field_mapping; } +GList * +ev_pixbuf_cache_get_annots_mapping (EvPixbufCache *pixbuf_cache, + gint page) +{ + CacheJobInfo *job_info; + + if (!EV_IS_DOCUMENT_ANNOTATIONS (pixbuf_cache->document)) + return NULL; + + job_info = find_job_cache (pixbuf_cache, page); + if (job_info == NULL) + return NULL; + + /* We don't need to wait for the idle to handle the callback */ + if (job_info->job && + EV_JOB (job_info->job)->finished) { + copy_job_to_job_info (EV_JOB_RENDER (job_info->job), job_info, pixbuf_cache); + } + + return job_info->annots_mapping; +} + static gboolean new_selection_surface_needed (EvPixbufCache *pixbuf_cache, CacheJobInfo *job_info, diff --git a/libview/ev-pixbuf-cache.h b/libview/ev-pixbuf-cache.h index a22634e..4ab0fce 100644 --- a/libview/ev-pixbuf-cache.h +++ b/libview/ev-pixbuf-cache.h @@ -72,6 +72,8 @@ GdkRegion *ev_pixbuf_cache_get_text_mapping (EvPixbufCache *pixbuf_cache gint page); GList *ev_pixbuf_cache_get_form_field_mapping (EvPixbufCache *pixbuf_cache, gint page); +GList *ev_pixbuf_cache_get_annots_mapping (EvPixbufCache *pixbuf_cache, + gint page); void ev_pixbuf_cache_clear (EvPixbufCache *pixbuf_cache); void ev_pixbuf_cache_style_changed (EvPixbufCache *pixbuf_cache); void ev_pixbuf_cache_reload_page (EvPixbufCache *pixbuf_cache, -- cgit v0.9.1