Commit 6965a51a authored by Carlos Garcia Campos's avatar Carlos Garcia Campos

[libview] Remove ev_page_cache_get_size() from EvPageCache

parent af6e8468
......@@ -149,32 +149,6 @@ ev_page_cache_set_page_label (EvPageCache *page_cache,
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 *
......
......@@ -35,12 +35,6 @@ G_BEGIN_DECLS
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,
......
......@@ -6,6 +6,7 @@
#include "ev-document-forms.h"
#include "ev-document-images.h"
#include "ev-document-annotations.h"
#include "ev-view-private.h"
typedef struct _CacheJobInfo
{
......@@ -294,20 +295,18 @@ check_job_size_and_unref (EvPixbufCache *pixbuf_cache,
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;
......@@ -684,8 +683,9 @@ add_job_if_needed (EvPixbufCache *pixbuf_cache,
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 &&
......@@ -882,16 +882,13 @@ new_selection_surface_needed (EvPixbufCache *pixbuf_cache,
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);
......@@ -1261,10 +1258,9 @@ ev_pixbuf_cache_reload_page (EvPixbufCache *pixbuf_cache,
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);
......
......@@ -227,5 +227,12 @@ struct _EvViewClass {
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__ */
......@@ -904,6 +904,42 @@ compute_border (EvView *view, int width, int height, GtkBorder *border)
}
}
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,
......@@ -959,10 +995,7 @@ get_page_extents (EvView *view,
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;
......@@ -1005,11 +1038,8 @@ get_page_extents (EvView *view,
/* 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)
......@@ -2691,18 +2721,14 @@ ev_view_size_request_dual_page (EvView *view,
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;
......@@ -2730,11 +2756,7 @@ ev_view_size_request_single_page (EvView *view,
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);
......@@ -4309,10 +4331,7 @@ draw_one_page (EvView *view,
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment