[evince] libview: Add support for saving media mapping to page cache and showing debug borders
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] libview: Add support for saving media mapping to page cache and showing debug borders
- Date: Wed, 27 May 2015 13:10:11 +0000 (UTC)
commit 4570011b6bc754c15a8bbcbc5fe4f5dbbb7c2b45
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Wed May 27 12:50:48 2015 +0200
libview: Add support for saving media mapping to page cache and showing debug borders
libdocument/ev-debug.c | 1 +
libdocument/ev-debug.h | 5 +++--
libview/ev-jobs.c | 5 +++++
libview/ev-jobs.h | 4 +++-
libview/ev-page-cache.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
libview/ev-page-cache.h | 2 ++
libview/ev-view.c | 15 +++++++++++++++
7 files changed, 71 insertions(+), 4 deletions(-)
---
diff --git a/libdocument/ev-debug.c b/libdocument/ev-debug.c
index 920007d..ea832a3 100644
--- a/libdocument/ev-debug.c
+++ b/libdocument/ev-debug.c
@@ -61,6 +61,7 @@ debug_init (void)
{ "forms", EV_DEBUG_BORDER_FORMS },
{ "annots", EV_DEBUG_BORDER_ANNOTS },
{ "images", EV_DEBUG_BORDER_IMAGES },
+ { "media", EV_DEBUG_BORDER_MEDIA },
{ "selections", EV_DEBUG_BORDER_SELECTIONS }
};
diff --git a/libdocument/ev-debug.h b/libdocument/ev-debug.h
index dff1028..ce0cd8c 100644
--- a/libdocument/ev-debug.h
+++ b/libdocument/ev-debug.h
@@ -83,8 +83,9 @@ typedef enum {
EV_DEBUG_BORDER_FORMS = 1 << 2,
EV_DEBUG_BORDER_ANNOTS = 1 << 3,
EV_DEBUG_BORDER_IMAGES = 1 << 4,
- EV_DEBUG_BORDER_SELECTIONS = 1 << 5,
- EV_DEBUG_BORDER_ALL = (1 << 6) - 1
+ EV_DEBUG_BORDER_MEDIA = 1 << 5,
+ EV_DEBUG_BORDER_SELECTIONS = 1 << 6,
+ EV_DEBUG_BORDER_ALL = (1 << 7) - 1
} EvDebugBorders;
#define DEBUG_JOBS EV_DEBUG_JOBS, __FILE__, __LINE__, G_STRFUNC
diff --git a/libview/ev-jobs.c b/libview/ev-jobs.c
index e118855..3337276 100644
--- a/libview/ev-jobs.c
+++ b/libview/ev-jobs.c
@@ -35,6 +35,7 @@
#include "ev-document-print.h"
#include "ev-document-annotations.h"
#include "ev-document-attachments.h"
+#include "ev-document-media.h"
#include "ev-document-text.h"
#include "ev-debug.h"
@@ -777,6 +778,10 @@ ev_job_page_data_run (EvJob *job)
job_pd->annot_mapping =
ev_document_annotations_get_annotations (EV_DOCUMENT_ANNOTATIONS (job->document),
ev_page);
+ if ((job_pd->flags & EV_PAGE_DATA_INCLUDE_MEDIA) && EV_IS_DOCUMENT_MEDIA (job->document))
+ job_pd->media_mapping =
+ ev_document_media_get_media_mapping (EV_DOCUMENT_MEDIA (job->document),
+ ev_page);
g_object_unref (ev_page);
ev_document_doc_mutex_unlock ();
diff --git a/libview/ev-jobs.h b/libview/ev-jobs.h
index 057bdae..9a197c9 100644
--- a/libview/ev-jobs.h
+++ b/libview/ev-jobs.h
@@ -303,7 +303,8 @@ typedef enum {
EV_PAGE_DATA_INCLUDE_IMAGES = 1 << 6,
EV_PAGE_DATA_INCLUDE_FORMS = 1 << 7,
EV_PAGE_DATA_INCLUDE_ANNOTS = 1 << 8,
- EV_PAGE_DATA_INCLUDE_ALL = (1 << 9) - 1
+ EV_PAGE_DATA_INCLUDE_MEDIA = 1 << 9,
+ EV_PAGE_DATA_INCLUDE_ALL = (1 << 10) - 1
} EvJobPageDataFlags;
struct _EvJobPageData
@@ -317,6 +318,7 @@ struct _EvJobPageData
EvMappingList *image_mapping;
EvMappingList *form_field_mapping;
EvMappingList *annot_mapping;
+ EvMappingList *media_mapping;
cairo_region_t *text_mapping;
gchar *text;
EvRectangle *text_layout;
diff --git a/libview/ev-page-cache.c b/libview/ev-page-cache.c
index eb7f683..3b32393 100644
--- a/libview/ev-page-cache.c
+++ b/libview/ev-page-cache.c
@@ -28,6 +28,7 @@
#include "ev-document-forms.h"
#include "ev-document-images.h"
#include "ev-document-annotations.h"
+#include "ev-document-media.h"
#include "ev-document-text.h"
#include "ev-page-cache.h"
@@ -48,6 +49,7 @@ typedef struct _EvPageCacheData {
EvMappingList *image_mapping;
EvMappingList *form_field_mapping;
EvMappingList *annot_mapping;
+ EvMappingList *media_mapping;
cairo_region_t *text_mapping;
EvRectangle *text_layout;
guint text_layout_length;
@@ -80,7 +82,8 @@ struct _EvPageCacheClass {
EV_PAGE_DATA_INCLUDE_TEXT_MAPPING | \
EV_PAGE_DATA_INCLUDE_IMAGES | \
EV_PAGE_DATA_INCLUDE_FORMS | \
- EV_PAGE_DATA_INCLUDE_ANNOTS)
+ EV_PAGE_DATA_INCLUDE_ANNOTS | \
+ EV_PAGE_DATA_INCLUDE_MEDIA)
#define PRE_CACHE_SIZE 1
@@ -119,6 +122,11 @@ ev_page_cache_data_free (EvPageCacheData *data)
data->annot_mapping = NULL;
}
+ if (data->media_mapping) {
+ ev_mapping_list_unref (data->media_mapping);
+ data->media_mapping = NULL;
+ }
+
if (data->text_mapping) {
cairo_region_destroy (data->text_mapping);
data->text_mapping = NULL;
@@ -239,6 +247,12 @@ ev_page_cache_get_flags_for_data (EvPageCache *cache,
flags | EV_PAGE_DATA_INCLUDE_ANNOTS;
}
+ if (cache->flags & EV_PAGE_DATA_INCLUDE_MEDIA) {
+ flags = (data->media_mapping) ?
+ flags & ~EV_PAGE_DATA_INCLUDE_MEDIA :
+ flags | EV_PAGE_DATA_INCLUDE_MEDIA;
+ }
+
if (cache->flags & EV_PAGE_DATA_INCLUDE_TEXT_MAPPING) {
flags = (data->text_mapping) ?
flags & ~EV_PAGE_DATA_INCLUDE_TEXT_MAPPING :
@@ -305,6 +319,8 @@ job_page_data_finished_cb (EvJob *job,
data->form_field_mapping = job_data->form_field_mapping;
if (job_data->flags & EV_PAGE_DATA_INCLUDE_ANNOTS)
data->annot_mapping = job_data->annot_mapping;
+ if (job_data->flags & EV_PAGE_DATA_INCLUDE_MEDIA)
+ data->media_mapping = job_data->media_mapping;
if (job_data->flags & EV_PAGE_DATA_INCLUDE_TEXT_MAPPING)
data->text_mapping = job_data->text_mapping;
if (job_data->flags & EV_PAGE_DATA_INCLUDE_TEXT_LAYOUT) {
@@ -442,6 +458,9 @@ ev_page_cache_mark_dirty (EvPageCache *cache,
if (flags & EV_PAGE_DATA_INCLUDE_ANNOTS)
g_clear_pointer (&data->annot_mapping, ev_mapping_list_unref);
+ if (flags & EV_PAGE_DATA_INCLUDE_MEDIA)
+ g_clear_pointer (&data->media_mapping, ev_mapping_list_unref);
+
if (flags & EV_PAGE_DATA_INCLUDE_TEXT_MAPPING)
g_clear_pointer (&data->text_mapping, cairo_region_destroy);
@@ -553,6 +572,28 @@ ev_page_cache_get_annot_mapping (EvPageCache *cache,
return data->annot_mapping;
}
+EvMappingList *
+ev_page_cache_get_media_mapping (EvPageCache *cache,
+ gint page)
+{
+ EvPageCacheData *data;
+
+ g_return_val_if_fail (EV_IS_PAGE_CACHE (cache), NULL);
+ g_return_val_if_fail (page >= 0 && page < cache->n_pages, NULL);
+
+ if (!(cache->flags & EV_PAGE_DATA_INCLUDE_MEDIA))
+ return NULL;
+
+ data = &cache->page_list[page];
+ if (data->done)
+ return data->media_mapping;
+
+ if (data->job)
+ return EV_JOB_PAGE_DATA (data->job)->media_mapping;
+
+ return data->media_mapping;
+}
+
cairo_region_t *
ev_page_cache_get_text_mapping (EvPageCache *cache,
gint page)
diff --git a/libview/ev-page-cache.h b/libview/ev-page-cache.h
index 70ee06e..7e5fcce 100644
--- a/libview/ev-page-cache.h
+++ b/libview/ev-page-cache.h
@@ -61,6 +61,8 @@ EvMappingList *ev_page_cache_get_form_field_mapping (EvPageCache *cach
gint page);
EvMappingList *ev_page_cache_get_annot_mapping (EvPageCache *cache,
gint page);
+EvMappingList *ev_page_cache_get_media_mapping (EvPageCache *cache,
+ gint page);
cairo_region_t *ev_page_cache_get_text_mapping (EvPageCache *cache,
gint page);
const gchar *ev_page_cache_get_text (EvPageCache *cache,
diff --git a/libview/ev-view.c b/libview/ev-view.c
index fce092a..64f4027 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -33,6 +33,7 @@
#include "ev-document-images.h"
#include "ev-document-links.h"
#include "ev-document-layers.h"
+#include "ev-document-media.h"
#include "ev-document-misc.h"
#include "ev-pixbuf-cache.h"
#include "ev-page-cache.h"
@@ -4331,6 +4332,18 @@ show_images_border (EvView *view,
}
static void
+show_media_border (EvView *view,
+ cairo_t *cr,
+ gint page,
+ GdkRectangle *clip)
+{
+ cairo_set_source_rgb (cr, 1., 1., 0.);
+ show_mapping_list_border (view, cr, page, clip,
+ ev_page_cache_get_media_mapping (view->page_cache, page));
+}
+
+
+static void
show_selections_border (EvView *view,
cairo_t *cr,
gint page,
@@ -4389,6 +4402,8 @@ draw_debug_borders (EvView *view,
show_annots_border (view, cr, page, clip);
if (borders & EV_DEBUG_BORDER_IMAGES)
show_images_border (view, cr, page, clip);
+ if (borders & EV_DEBUG_BORDER_MEDIA)
+ show_media_border (view, cr, page, clip);
if (borders & EV_DEBUG_BORDER_SELECTIONS)
show_selections_border (view, cr, page, clip);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]