Changeset 151

Show
Ignore:
Timestamp:
05/07/06 09:30:06 (2 years ago)
Author:
jordi
Message:

Instead of setting a new "Loading..." empty page each time the page is resizing, the PagePter? class instructs the IPageView to resize the current page image to the new page width and height using a faster, yet uglier, algorithm.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/IPageView.h

    r150 r151  
    107107            /// @return The position of the vertical scroll bar. 
    108108            virtual gdouble getVerticalScroll (void) = 0; 
     109 
     110            /// 
     111            /// @brief Resize the current page. 
     112            /// 
     113            /// When the document's scale is changed the view is instructed 
     114            /// to resize the current page when the cached page image is 
     115            /// not ready yet. The view should resize the current image using 
     116            /// a fast algorithm, without caring too much about the final 
     117            /// result. 
     118            /// 
     119            /// @param width The new width of the page. 
     120            /// @param height The new height of the page. 
     121            /// 
     122            virtual void resizePage (gint width, gint height) = 0; 
    109123             
    110124            /// 
  • trunk/src/PDFDocument.cxx

    r149 r151  
    395395    poppler_page_render_to_pixbuf (page, 0, 0, width, height, getZoom (), 
    396396                                   getRotation (), pixbuf); 
    397     gdk_pixbuf_unref (pixbuf); 
     397    g_object_unref (pixbuf); 
    398398    setLinks (renderedPage, page); 
    399399    g_object_unref (G_OBJECT (page)); 
  • trunk/src/PagePter.cxx

    r150 r151  
    193193{ 
    194194    g_WaitingForPage = FALSE; 
    195     refreshPage (PAGE_SCROLL_START); 
     195    refreshPage (PAGE_SCROLL_START, FALSE); 
    196196} 
    197197 
     
    200200{ 
    201201    g_WaitingForPage = FALSE; 
    202     refreshPage (m_NextPageScroll); 
     202    refreshPage (m_NextPageScroll, FALSE); 
    203203} 
    204204 
     
    207207{ 
    208208    g_WaitingForPage = FALSE; 
    209     refreshPage (PAGE_SCROLL_START); 
     209    refreshPage (PAGE_SCROLL_START, FALSE); 
    210210} 
    211211 
     
    214214{ 
    215215    g_WaitingForPage = FALSE; 
    216     refreshPage (PAGE_SCROLL_NONE); 
     216    refreshPage (PAGE_SCROLL_NONE, TRUE); 
    217217} 
    218218 
     
    221221{ 
    222222    g_WaitingForPage = FALSE; 
    223     refreshPage (PAGE_SCROLL_NONE); 
     223    refreshPage (PAGE_SCROLL_NONE, FALSE); 
    224224} 
    225225 
     
    232232    if ( g_WaitingForPage ) 
    233233    { 
    234         data->pter->refreshPage (data->scroll); 
     234        data->pter->refreshPage (data->scroll, FALSE); 
    235235        return TRUE; 
    236236    } 
     
    248248/// @param pageScroll This will be passed to the main view to let it know how 
    249249///                   to show the scroll this new page. 
    250 /// 
    251 void 
    252 PagePter::refreshPage (PageScroll pageScroll) 
     250/// @param wasZoomed If this is set to TRUE then it means that the page 
     251///                  has been refreshed because its scaled has changed. 
     252/// 
     253void 
     254PagePter::refreshPage (PageScroll pageScroll, gboolean wasZoomed) 
    253255{ 
    254256    g_assert (NULL != m_Document &&  
     
    269271            { 
    270272                documentPage = m_Document->getEmptyPage (); 
    271                 view.showPage (documentPage, pageScroll); 
    272                 delete documentPage; 
    273                 view.showText (_("Loading...")); 
     273                if ( wasZoomed ) 
     274                { 
     275                    view.resizePage (documentPage->getWidth (), 
     276                                     documentPage->getHeight ()); 
     277                } 
     278                else 
     279                { 
     280                    view.showPage (documentPage, pageScroll); 
     281                    delete documentPage; 
     282                    view.showText (_("Loading...")); 
     283                } 
    274284 
    275285                g_WaitingForPage = TRUE; 
  • trunk/src/PagePter.h

    r148 r151  
    6262            IPageView *m_PageView; 
    6363             
    64             void refreshPage (PageScroll pageScroll); 
     64            void refreshPage (PageScroll pageScroll, gboolean wasZoomed); 
    6565    }; 
    6666} 
  • trunk/src/gtk/PageView.cxx

    r150 r151  
    106106 
    107107void 
     108PageView::resizePage (gint width, gint height) 
     109{ 
     110    GdkPixbuf *originalPage = gtk_image_get_pixbuf (GTK_IMAGE (m_PageImage)); 
     111    if ( NULL != originalPage ) 
     112    { 
     113        GdkPixbuf *scaledPage = gdk_pixbuf_scale_simple (originalPage, 
     114                                                         width, height, 
     115                                                         GDK_INTERP_NEAREST); 
     116        if ( NULL != scaledPage ) 
     117        { 
     118            gtk_image_set_from_pixbuf (GTK_IMAGE (m_PageImage), scaledPage); 
     119            g_object_unref (scaledPage); 
     120        } 
     121    } 
     122} 
     123 
     124void 
    108125PageView::setCursor (PageCursor cursorType) 
    109126{ 
     
    188205    GdkPixbuf *pixbuf = getPixbufFromPage (page); 
    189206    gtk_image_set_from_pixbuf (GTK_IMAGE (m_PageImage), pixbuf); 
    190     gdk_pixbuf_unref (pixbuf); 
     207    g_object_unref (pixbuf); 
    191208    // Set the vertical scroll to the specified. 
    192209    if ( PAGE_SCROLL_NONE != scroll ) 
     
    274291         
    275292        gtk_image_set_from_pixbuf (GTK_IMAGE (m_PageImage), modifiedPage); 
    276         gdk_pixbuf_unref (modifiedPage); 
     293        g_object_unref (modifiedPage); 
    277294    }  
    278295} 
     
    311328            page->getRowStride (), NULL, NULL); 
    312329    GdkPixbuf *finalPixbuf = gdk_pixbuf_copy (pixbuf); 
    313     gdk_pixbuf_unref (pixbuf); 
     330    g_object_unref (pixbuf); 
    314331 
    315332    return finalPixbuf; 
  • trunk/src/gtk/PageView.h

    r150 r151  
    3333            void getSize (gint *width, gint *height); 
    3434            gdouble getVerticalScroll (void); 
     35            void resizePage (gint width, gint height); 
    3536            void scrollPage (gdouble scrollX, gdouble scrollY, 
    3637                             gint dx, gint dy); 
  • trunk/tests/DumbDocumentObserver.cxx

    r136 r151  
    8686DumbDocumentObserver::notifyReload (void) 
    8787{ 
    88     m_NotifiedReload
     88    m_NotifiedReload = TRUE
    8989} 
    9090 
  • trunk/tests/DumbPageView.cxx

    r150 r151  
    5252 
    5353void 
     54DumbPageView::resizePage (gint width, gint height) 
     55{ 
     56} 
     57 
     58void 
    5459DumbPageView::scrollPage (gdouble scrollX, gdouble scrollY, gint dx, gint dy) 
    5560{ 
  • trunk/tests/DumbPageView.h

    r150 r151  
    3030            void getSize (gint *width, gint *height); 
    3131            gdouble getVerticalScroll (void); 
     32            void resizePage (gint width, gint height); 
    3233            void scrollPage (gdouble scrollX, gdouble scrollY, 
    3334                             gint dx, gint dy);