return FALSE;
}
-void
-ev_page_cache_get_size (EvPageCache *page_cache,
- gint page,
- gint rotation,
- gfloat scale,
- gint *width,
- gint *height)
-{
- double w, h;
-
- g_return_if_fail (EV_IS_PAGE_CACHE (page_cache));
-
- ev_document_get_page_size (page_cache->document, page, &w, &h);
-
- w = w * scale + 0.5;
- h = h * scale + 0.5;
-
- if (rotation == 0 || rotation == 180) {
- if (width) *width = (int)w;
- if (height) *height = (int)h;
- } else {
- if (width) *width = (int)h;
- if (height) *height = (int)w;
- }
-}
-
#define PAGE_CACHE_STRING "ev-page-cache"
EvPageCache *
GType ev_page_cache_get_type (void) G_GNUC_CONST;
-void ev_page_cache_get_size (EvPageCache *page_cache,
- gint page,
- gint rotation,
- gfloat scale,
- gint *width,
- gint *height);
/* Navigation */
gint ev_page_cache_get_current_page (EvPageCache *page_cache);
void ev_page_cache_set_current_page (EvPageCache *page_cache,
#include "ev-document-forms.h"
#include "ev-document-images.h"
#include "ev-document-annotations.h"
+#include "ev-view-private.h"
typedef struct _CacheJobInfo
{
EvPageCache *page_cache,
gfloat scale)
{
- gint width;
- gint height;
+ gint width, height;
g_assert (job_info);
if (job_info->job == NULL)
return;
- ev_page_cache_get_size (page_cache,
- EV_JOB_RENDER (job_info->job)->page,
- EV_JOB_RENDER (job_info->job)->rotation,
- scale,
- &width, &height);
-
+ _get_page_size_for_scale_and_rotation (job_info->job->document,
+ EV_JOB_RENDER (job_info->job)->page,
+ scale,
+ EV_JOB_RENDER (job_info->job)->rotation,
+ &width, &height);
if (width == EV_JOB_RENDER (job_info->job)->target_width &&
height == EV_JOB_RENDER (job_info->job)->target_height)
return;
if (job_info->job)
return;
- ev_page_cache_get_size (page_cache, page, rotation,
- scale, &width, &height);
+ _get_page_size_for_scale_and_rotation (pixbuf_cache->document,
+ page, scale, rotation,
+ &width, &height);
if (job_info->surface &&
cairo_image_surface_get_width (job_info->surface) == width &&
gint page,
gfloat scale)
{
- EvPageCache *page_cache;
-
if (job_info->selection && job_info->rc) {
gint width, height;
gint selection_width, selection_height;
-
- page_cache = ev_page_cache_get (pixbuf_cache->document);
- ev_page_cache_get_size (page_cache, page,
- job_info->rc->rotation,
- scale, &width, &height);
+
+ _get_page_size_for_scale_and_rotation (pixbuf_cache->document,
+ page, scale, job_info->rc->rotation,
+ &width, &height);
selection_width = cairo_image_surface_get_width (job_info->selection);
selection_height = cairo_image_surface_get_height (job_info->selection);
if (job_info == NULL)
return;
- ev_page_cache_get_size (ev_page_cache_get (pixbuf_cache->document),
- page, rotation, scale,
- &width, &height);
-
+ _get_page_size_for_scale_and_rotation (pixbuf_cache->document,
+ page, scale, rotation,
+ &width, &height);
add_job (pixbuf_cache, job_info, region,
width, height, page, rotation, scale,
EV_JOB_PRIORITY_URGENT);
EvLink *link);
};
+void _get_page_size_for_scale_and_rotation (EvDocument *document,
+ gint page,
+ gdouble scale,
+ gint rotation,
+ gint *page_width,
+ gint *page_height);
+
#endif /* __EV_VIEW_PRIVATE_H__ */
}
}
+void
+_get_page_size_for_scale_and_rotation (EvDocument *document,
+ gint page,
+ gdouble scale,
+ gint rotation,
+ gint *page_width,
+ gint *page_height)
+{
+ gdouble w, h;
+ gint width, height;
+
+ ev_document_get_page_size (document, page, &w, &h);
+
+ width = (gint)(w * scale + 0.5);
+ height = (gint)(h * scale + 0.5);
+
+ if (page_width)
+ *page_width = (rotation == 0 || rotation == 180) ? width : height;
+ if (page_height)
+ *page_height = (rotation == 0 || rotation == 180) ? height : width;
+}
+
+static void
+ev_view_get_page_size (EvView *view,
+ gint page,
+ gint *page_width,
+ gint *page_height)
+{
+ _get_page_size_for_scale_and_rotation (view->document,
+ page,
+ view->scale,
+ view->rotation,
+ page_width,
+ page_height);
+}
+
static void
ev_view_get_max_page_size (EvView *view,
gint *max_width,
widget = GTK_WIDGET (view);
/* Get the size of the page */
- ev_page_cache_get_size (view->page_cache, page,
- view->rotation,
- view->scale,
- &width, &height);
+ ev_view_get_page_size (view, page, &width, &height);
compute_border (view, width, height, border);
page_area->width = width + border->left + border->right;
page_area->height = height + border->top + border->bottom;
/* First, we get the bounding box of the two pages */
if (other_page < ev_document_get_n_pages (view->document)
&& (0 <= other_page)) {
- ev_page_cache_get_size (view->page_cache,
- other_page,
- view->rotation,
- view->scale,
- &width_2, &height_2);
+ ev_view_get_page_size (view, other_page,
+ &width_2, &height_2);
if (width_2 > width)
max_width = width_2;
if (height_2 > height)
gint width, height;
/* Find the largest of the two. */
- ev_page_cache_get_size (view->page_cache,
- view->current_page,
- view->rotation,
- view->scale,
- &width, &height);
+ ev_view_get_page_size (view,
+ view->current_page,
+ &width, &height);
if (view->current_page + 1 < ev_document_get_n_pages (view->document)) {
gint width_2, height_2;
- ev_page_cache_get_size (view->page_cache,
- view->current_page + 1,
- view->rotation,
- view->scale,
- &width_2, &height_2);
+ ev_view_get_page_size (view,
+ view->current_page + 1,
+ &width_2, &height_2);
if (width_2 > width) {
width = width_2;
height = height_2;
GtkBorder border;
gint width, height;
- ev_page_cache_get_size (view->page_cache,
- view->current_page,
- view->rotation,
- view->scale,
- &width, &height);
+ ev_view_get_page_size (view, view->current_page, &width, &height);
compute_border (view, width, height, &border);
requisition->width = width + border.left + border.right + (2 * view->spacing);
return;
}
- ev_page_cache_get_size (view->page_cache,
- page, view->rotation,
- view->scale,
- &width, &height);
+ ev_view_get_page_size (view, page, &width, &height);
page_width = cairo_image_surface_get_width (page_surface);
page_height = cairo_image_surface_get_height (page_surface);