~ubuntu-branches/ubuntu/hardy/evince/hardy

« back to all changes in this revision

Viewing changes to backend/pdf/ev-poppler.cc

  • Committer: Bazaar Package Importer
  • Author(s): Aron Sisak
  • Date: 2007-06-19 13:49:52 UTC
  • mfrom: (1.1.15 upstream)
  • Revision ID: james.westby@ubuntu.com-20070619134952-k1hur43gw2120n72
Tags: 0.9.1-0ubuntu1
* New upstream release:
  - New Features and UI Improvements:
    * Cairo-based renderer for pages and selections of PDF, DVJU and DVI documents
    * PDF exporter for printing DVI documents
    * Zoom icon artwork
  * Patch to avoid frequent process wakeup for metadata handling
  * Bumped poppler requirements to 0.5.9
  * Changed sidebar ordering
  * Removed extra locking of a main loop to speed up rendering 
  - Bug fixes:
    * Print job is released quickly
    * Update a cursor and tooltips after scrolling
  * More safe mkdir_with_parents
  * Safe saving of a document copy to a remote location
  * Build fix without libgnome
  * Selections don't disappear after zoom
  * Preview button added to the print dialog
  - Translations:
  * sv, en_GB, ta, nb, ca, gl, et, es, dz, th, he
* debian/control.in
  - changed gs / gs-esp / gs-esp-x dependency to ghostscript-x
  - changed libpoppler dependecy (>= 0.5.9)

Show diffs side-by-side

added added

removed removed

Lines of Context:
426
426
        return g_list_reverse (retval);
427
427
}
428
428
 
429
 
static GdkPixbuf *
430
 
pdf_document_render_pixbuf (EvDocument   *document,
431
 
                            EvRenderContext *rc)
 
429
static cairo_surface_t *
 
430
pdf_document_render (EvDocument      *document,
 
431
                     EvRenderContext *rc)
432
432
{
433
433
        PdfDocument *pdf_document;
434
 
        GdkPixbuf *pixbuf;
 
434
        cairo_surface_t *surface;
435
435
        double width_points, height_points;
436
436
        gint width, height;
437
437
 
448
448
                width = (int) ((width_points * rc->scale) + 0.5);
449
449
                height = (int) ((height_points * rc->scale) + 0.5);
450
450
        }
451
 
 
 
451
        
 
452
#ifdef HAVE_POPPLER_PAGE_RENDER
 
453
        cairo_t *cr;
 
454
        
 
455
        surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
 
456
                                              width, height);
 
457
        memset (cairo_image_surface_get_data (surface), 0xff,
 
458
                cairo_image_surface_get_height (surface) *
 
459
                cairo_image_surface_get_stride (surface));
 
460
        
 
461
        cr = cairo_create (surface);
 
462
        switch (rc->rotation) {
 
463
                case 90:
 
464
                        cairo_translate (cr, width, 0);
 
465
                        break;
 
466
                case 180:
 
467
                        cairo_translate (cr, width, height);
 
468
                        break;
 
469
                case 270:
 
470
                        cairo_translate (cr, 0, height);
 
471
                        break;
 
472
                default:
 
473
                        cairo_translate (cr, 0, 0);
 
474
        }
 
475
        cairo_scale (cr, rc->scale, rc->scale);
 
476
        cairo_rotate (cr, rc->rotation * G_PI / 180.0);
 
477
        poppler_page_render (POPPLER_PAGE (rc->data), cr);
 
478
        cairo_destroy (cr);
 
479
#else /* HAVE_POPPLER_PAGE_RENDER */
 
480
        GdkPixbuf *pixbuf;
 
481
        
452
482
        pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
453
483
                                 FALSE, 8,
454
484
                                 width, height);
459
489
                                       rc->scale,
460
490
                                       rc->rotation,
461
491
                                       pixbuf);
462
 
        
463
 
        
464
 
        return pixbuf;
 
492
        surface = ev_document_misc_surface_from_pixbuf (pixbuf);
 
493
        g_object_unref (pixbuf);
 
494
#endif /* HAVE_POPPLER_PAGE_RENDER */
 
495
 
 
496
        return surface;
465
497
}
466
498
 
467
499
/* EvDocumentSecurity */
671
703
        iface->get_page_label = pdf_document_get_page_label;
672
704
        iface->has_attachments = pdf_document_has_attachments;
673
705
        iface->get_attachments = pdf_document_get_attachments;
674
 
        iface->render_pixbuf = pdf_document_render_pixbuf;
 
706
        iface->render = pdf_document_render;
675
707
        iface->get_text = pdf_document_get_text;
676
708
        iface->can_get_text = pdf_document_can_get_text;
677
709
        iface->get_info = pdf_document_get_info;
1135
1167
                                gint              page)
1136
1168
{
1137
1169
        GList *retval = NULL;
1138
 
#ifdef HAVE_POPPLER_PAGE_GET_IMAGE_MAPPING
1139
1170
        PdfDocument *pdf_document;
1140
1171
        PopplerPage *poppler_page;
1141
1172
        GList *mapping_list;
1164
1195
 
1165
1196
        poppler_page_free_image_mapping (mapping_list);
1166
1197
        g_object_unref (poppler_page);
1167
 
#endif /* HAVE_POPPLER_PAGE_GET_IMAGE_MAPPING */
 
1198
 
1168
1199
        return retval;
1169
1200
}
1170
1201
 
1601
1632
static void
1602
1633
pdf_selection_render_selection (EvSelection      *selection,
1603
1634
                                EvRenderContext  *rc,
1604
 
                                GdkPixbuf       **pixbuf,
 
1635
                                cairo_surface_t **surface,
1605
1636
                                EvRectangle      *points,
1606
1637
                                EvRectangle      *old_points,
1607
 
                                GdkColor        *text,
1608
 
                                GdkColor        *base)
 
1638
                                GdkColor         *text,
 
1639
                                GdkColor         *base)
1609
1640
{
1610
1641
        PdfDocument *pdf_document;
1611
1642
        double width_points, height_points;
1614
1645
        pdf_document = PDF_DOCUMENT (selection);
1615
1646
        set_rc_data (pdf_document, rc);
1616
1647
 
1617
 
        poppler_page_get_size (POPPLER_PAGE (rc->data), &width_points, &height_points);
 
1648
        poppler_page_get_size (POPPLER_PAGE (rc->data),
 
1649
                               &width_points, &height_points);
1618
1650
        width = (int) ((width_points * rc->scale) + 0.5);
1619
1651
        height = (int) ((height_points * rc->scale) + 0.5);
1620
1652
 
1621
 
        if (*pixbuf == NULL) {
1622
 
                * pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
1623
 
                                           TRUE, 8,
1624
 
                                           width, height);
 
1653
 
 
1654
#ifdef HAVE_POPPLER_PAGE_RENDER
 
1655
        cairo_t *cr;
 
1656
 
 
1657
        if (*surface == NULL) {
 
1658
                *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
 
1659
                                                       width, height);
 
1660
                
1625
1661
        }
1626
 
        
 
1662
 
 
1663
        cr = cairo_create (*surface);
 
1664
        cairo_scale (cr, rc->scale, rc->scale);
 
1665
        cairo_surface_set_device_offset (*surface, 0, 0);
 
1666
        memset (cairo_image_surface_get_data (*surface), 0x00,
 
1667
                cairo_image_surface_get_height (*surface) *
 
1668
                cairo_image_surface_get_stride (*surface));
1627
1669
        poppler_page_render_selection (POPPLER_PAGE (rc->data),
1628
 
                                       rc->scale, rc->rotation, *pixbuf,
 
1670
                                       cr,
1629
1671
                                       (PopplerRectangle *)points,
1630
1672
                                       (PopplerRectangle *)old_points,
 
1673
                                       POPPLER_SELECTION_NORMAL, /* SelectionStyle */
1631
1674
                                       text,
1632
1675
                                       base);
 
1676
        cairo_destroy (cr);
 
1677
#else /* HAVE_POPPLER_PAGE_RENDER */
 
1678
        GdkPixbuf *pixbuf;
 
1679
        
 
1680
        pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
 
1681
                                 TRUE, 8,
 
1682
                                 width, height);
 
1683
 
 
1684
        poppler_page_render_selection_to_pixbuf (POPPLER_PAGE (rc->data),
 
1685
                                                 rc->scale, rc->rotation, pixbuf,
 
1686
                                                 (PopplerRectangle *)points,
 
1687
                                                 (PopplerRectangle *)old_points,
 
1688
                                                 POPPLER_SELECTION_NORMAL, /* SelectionStyle */
 
1689
                                                 text,
 
1690
                                                 base);
 
1691
        if (*surface)
 
1692
                cairo_surface_destroy (*surface);
 
1693
        *surface = ev_document_misc_surface_from_pixbuf (pixbuf);
 
1694
        g_object_unref (pixbuf);
 
1695
#endif /* HAVE_POPPLER_PAGE_RENDER */
1633
1696
}
1634
1697
 
1635
1698
 
1645
1708
 
1646
1709
        set_rc_data (pdf_document, rc);
1647
1710
 
1648
 
        retval = poppler_page_get_selection_region ((PopplerPage *)rc->data, rc->scale, (PopplerRectangle *) points);
1649
 
 
 
1711
        retval = poppler_page_get_selection_region ((PopplerPage *)rc->data,
 
1712
                                                    rc->scale,
 
1713
                                                    (PopplerRectangle *) points);
1650
1714
        return retval;
1651
1715
}
1652
1716
 
1685
1749
pdf_document_get_page_duration (EvDocumentTransition *trans,
1686
1750
                                gint                  page)
1687
1751
{
1688
 
#ifdef HAVE_POPPLER_PAGE_GET_DURATION   
1689
1752
        PdfDocument *pdf_document;
1690
1753
        PopplerPage *poppler_page;
1691
1754
        gdouble      duration = -1;
1699
1762
        g_object_unref (poppler_page);
1700
1763
 
1701
1764
        return duration;
1702
 
#else
1703
 
        return -1;
1704
 
#endif /* HAVE_POPPLER_PAGE_GET_DURATION */
1705
1765
}
1706
1766
 
1707
1767
static void