X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=sidebyside;f=shell%2Fev-pixbuf-cache.c;h=285cae4e2cb366a7eab5f62e26e485b4b6dd45c9;hb=21f638ab8e3ddb81ce7979939defcdb7f49ad376;hp=1d0c528654ed51da163f9a33ddd6dcac39557c16;hpb=9b0445a3b8162f7d36c7407d77d7d410d45ac6e3;p=evince.git diff --git a/shell/ev-pixbuf-cache.c b/shell/ev-pixbuf-cache.c index 1d0c5286..285cae4e 100644 --- a/shell/ev-pixbuf-cache.c +++ b/shell/ev-pixbuf-cache.c @@ -2,6 +2,8 @@ #include "ev-job-queue.h" #include "ev-page-cache.h" #include "ev-selection.h" +#include "ev-document-images.h" +#include "ev-image.h" typedef struct _CacheJobInfo { @@ -11,6 +13,7 @@ typedef struct _CacheJobInfo /* Data we get from rendering */ GdkPixbuf *pixbuf; GList *link_mapping; + GList *image_mapping; GdkRegion *text_mapping; /* Selection data. @@ -152,6 +155,10 @@ dispose_cache_job_info (CacheJobInfo *job_info, ev_link_mapping_free (job_info->link_mapping); job_info->link_mapping = NULL; } + if (job_info->image_mapping) { + ev_image_mapping_free (job_info->image_mapping); + job_info->image_mapping = NULL; + } if (job_info->text_mapping) { gdk_region_destroy (job_info->text_mapping); job_info->text_mapping = NULL; @@ -312,6 +319,7 @@ move_one_job (CacheJobInfo *job_info, job_info->job = NULL; job_info->pixbuf = NULL; job_info->link_mapping = NULL; + job_info->image_mapping = NULL; if (new_priority != priority && target_page->job) { ev_job_queue_update_job (target_page->job, new_priority); @@ -415,15 +423,19 @@ copy_job_to_job_info (EvJobRender *job_render, job_info->link_mapping = job_render->link_mapping; } + if (job_render->include_images) { + if (job_info->image_mapping) + ev_image_mapping_free (job_info->image_mapping); + job_info->image_mapping = job_render->image_mapping; + } + if (job_render->include_text) { if (job_info->text_mapping) gdk_region_destroy (job_info->text_mapping); job_info->text_mapping = job_render->text_mapping; } - if (job_render->include_selection) { - if (job_info->selection) { g_object_unref (G_OBJECT (job_info->selection)); job_info->selection = NULL; @@ -437,6 +449,7 @@ copy_job_to_job_info (EvJobRender *job_render, job_info->selection_region = gdk_region_copy (job_render->selection_region); job_info->selection = g_object_ref (job_render->selection); g_assert (job_info->selection_points.x1 >= 0); + job_info->points_set = TRUE; } if (job_info->job) { @@ -447,10 +460,9 @@ copy_job_to_job_info (EvJobRender *job_render, g_object_unref (G_OBJECT (job_info->job)); job_info->job = NULL; } - } -static CacheJobInfo* +static CacheJobInfo * find_job_cache (EvPixbufCache *pixbuf_cache, int page) { @@ -528,6 +540,7 @@ add_job_if_needed (EvPixbufCache *pixbuf_cache, gboolean include_links = FALSE; gboolean include_text = FALSE; gboolean include_selection = FALSE; + gboolean include_images = FALSE; int width, height; GdkColor *text, *base; @@ -554,6 +567,8 @@ add_job_if_needed (EvPixbufCache *pixbuf_cache, /* Figure out what else we need for this job */ if (job_info->link_mapping == NULL) include_links = TRUE; + if (job_info->image_mapping == NULL) + include_images = TRUE; if (job_info->text_mapping == NULL) include_text = TRUE; if (new_selection_pixbuf_needed (pixbuf_cache, job_info, page, scale)) { @@ -570,6 +585,7 @@ add_job_if_needed (EvPixbufCache *pixbuf_cache, &(job_info->target_points), text, base, include_links, + include_images, include_text, include_selection); ev_job_queue_add_job (job_info->job, priority); @@ -686,10 +702,32 @@ ev_pixbuf_cache_get_link_mapping (EvPixbufCache *pixbuf_cache, EV_JOB (job_info->job)->finished) { copy_job_to_job_info (EV_JOB_RENDER (job_info->job), job_info, pixbuf_cache); } - + return job_info->link_mapping; } +GList * +ev_pixbuf_cache_get_image_mapping (EvPixbufCache *pixbuf_cache, + gint page) +{ + CacheJobInfo *job_info; + + if (!EV_IS_DOCUMENT_IMAGES (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->image_mapping; +} + static gboolean new_selection_pixbuf_needed (EvPixbufCache *pixbuf_cache, CacheJobInfo *job_info, @@ -729,8 +767,8 @@ clear_selection_if_needed (EvPixbufCache *pixbuf_cache, } GdkRegion * -ev_pixbuf_cache_get_text_mapping (EvPixbufCache *pixbuf_cache, - gint page) +ev_pixbuf_cache_get_text_mapping (EvPixbufCache *pixbuf_cache, + gint page) { CacheJobInfo *job_info; @@ -887,6 +925,7 @@ static void clear_job_selection (CacheJobInfo *job_info) { job_info->points_set = FALSE; + job_info->selection_points.x1 = -1; if (job_info->selection) { g_object_unref (job_info->selection);