]> www.fi.muni.cz Git - evince.git/commitdiff
[libview] Remove ev_page_cache_get_size() from EvPageCache
authorCarlos Garcia Campos <carlosgc@gnome.org>
Thu, 20 Aug 2009 16:30:46 +0000 (18:30 +0200)
committerCarlos Garcia Campos <carlosgc@gnome.org>
Tue, 15 Sep 2009 13:56:02 +0000 (15:56 +0200)
libview/ev-page-cache.c
libview/ev-page-cache.h
libview/ev-pixbuf-cache.c
libview/ev-view-private.h
libview/ev-view.c

index 1bf689eea0b5838803f8b4a838a6c55801e5b9c0..8fba8c6ad775bc2b4ea7272ef0f0e512e4b4b5e9 100644 (file)
@@ -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 *
index f3888b40902b84a8ca774470583ae44a83284a80..82e2791dff795ddf16f1e9d23cbfc4388c4b037f 100644 (file)
@@ -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,
index 763ec047365d271698b62bc13ddeb325ce2d2779..0ebfeaef75f084fc5b2be634de7d3e9481011688 100644 (file)
@@ -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);
index d0519d7ac219231fe5ee519c34f499dc7b659366..abef629074cd6b098f99a2f0461338d08470c2e5 100644 (file)
@@ -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__ */
 
index 497da18710ef7c7a3986d4ec3de70a97e9610e4e..f9d8ae8af28a6bee341df7a8fd313af1e17e6be3 100644 (file)
@@ -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);