[evince] [presentation] Fix rendering of documents with non uniform page size
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] [presentation] Fix rendering of documents with non uniform page size
- Date: Sat, 13 Mar 2010 13:54:08 +0000 (UTC)
commit 7a6187803fffe561099ea780692ab5b959093220
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Sat Mar 13 14:42:37 2010 +0100
[presentation] Fix rendering of documents with non uniform page size
libview/ev-view-presentation.c | 49 +++++++++++++++++----------------------
1 files changed, 21 insertions(+), 28 deletions(-)
---
diff --git a/libview/ev-view-presentation.c b/libview/ev-view-presentation.c
index 5074e4e..7d72541 100644
--- a/libview/ev-view-presentation.c
+++ b/libview/ev-view-presentation.c
@@ -164,23 +164,16 @@ static gdouble
ev_view_presentation_get_scale_for_page (EvViewPresentation *pview,
guint page)
{
- gdouble width, height;
+ if (!ev_document_is_page_size_uniform (pview->document) || pview->scale == 0) {
+ gdouble width, height;
- ev_document_get_page_size (pview->document, page, &width, &height);
-
- if (pview->rotation == 90 || pview->rotation == 270)
- return pview->monitor_height / width;
- else
- return pview->monitor_height / height;
-}
-
-static void
-ev_view_presentation_update_scale (EvViewPresentation *pview)
-{
- if (ev_document_is_page_size_uniform (pview->document) && pview->scale != 0)
- return;
+ ev_document_get_page_size (pview->document, page, &width, &height);
+ pview->scale = (pview->rotation == 90 || pview->rotation == 270) ?
+ pview->monitor_height / width :
+ pview->monitor_height / height;
+ }
- pview->scale = ev_view_presentation_get_scale_for_page (pview, pview->current_page);
+ return pview->scale;
}
static void
@@ -190,17 +183,19 @@ ev_view_presentation_get_page_area (EvViewPresentation *pview,
GtkWidget *widget = GTK_WIDGET (pview);
gdouble doc_width, doc_height;
gint view_width, view_height;
+ gdouble scale;
ev_document_get_page_size (pview->document,
pview->current_page,
&doc_width, &doc_height);
+ scale = ev_view_presentation_get_scale_for_page (pview, pview->current_page);
if (pview->rotation == 90 || pview->rotation == 270) {
- view_width = (gint)((doc_height * pview->scale) + 0.5);
- view_height = (gint)((doc_width * pview->scale) + 0.5);
+ view_width = (gint)((doc_height * scale) + 0.5);
+ view_height = (gint)((doc_width * scale) + 0.5);
} else {
- view_width = (gint)((doc_width * pview->scale) + 0.5);
- view_height = (gint)((doc_height * pview->scale) + 0.5);
+ view_width = (gint)((doc_width * scale) + 0.5);
+ view_height = (gint)((doc_height * scale) + 0.5);
}
area->x = (MAX (0, widget->allocation.width - view_width)) / 2;
@@ -345,11 +340,8 @@ ev_view_presentation_schedule_new_job (EvViewPresentation *pview,
if (page < 0 || page >= ev_document_get_n_pages (pview->document))
return NULL;
- if (ev_document_is_page_size_uniform (pview->document))
- scale = pview->scale;
- else
- scale = ev_view_presentation_get_scale_for_page (pview, page);
- job = ev_job_render_new (pview->document, page, pview->rotation, pview->scale, 0, 0);
+ scale = ev_view_presentation_get_scale_for_page (pview, page);
+ job = ev_job_render_new (pview->document, page, pview->rotation, scale, 0, 0);
g_signal_connect (job, "finished",
G_CALLBACK (job_finished_cb),
pview);
@@ -459,7 +451,7 @@ ev_view_presentation_update_current_page (EvViewPresentation *pview,
}
pview->current_page = page;
- ev_view_presentation_update_scale (pview);
+
if (pview->page_cache)
ev_page_cache_set_page_range (pview->page_cache, page, page);
@@ -749,14 +741,16 @@ ev_view_presentation_get_link_at_location (EvViewPresentation *pview,
EvLink *link;
gdouble width, height;
gdouble new_x, new_y;
+ gdouble scale;
if (!pview->page_cache)
return NULL;
ev_document_get_page_size (pview->document, pview->current_page, &width, &height);
ev_view_presentation_get_page_area (pview, &page_area);
- x = (x - page_area.x) / pview->scale;
- y = (y - page_area.y) / pview->scale;
+ scale = ev_view_presentation_get_scale_for_page (pview, pview->current_page);
+ x = (x - page_area.x) / scale;
+ y = (y - page_area.y) / scale;
switch (pview->rotation) {
case 0:
case 360:
@@ -1203,7 +1197,6 @@ init_presentation (GtkWidget *widget)
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
pview->monitor_height = monitor.height;
- ev_view_presentation_update_scale (pview);
ev_view_presentation_update_current_page (pview, pview->current_page);
ev_view_presentation_hide_cursor_timeout_start (pview);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]