~ubuntu-branches/ubuntu/oneiric/evince/oneiric-updates

« back to all changes in this revision

Viewing changes to shell/ev-pixbuf-cache.c

  • Committer: Bazaar Package Importer
  • Author(s): Josselin Mouette, Josselin Mouette, Marc 'HE' Brockschmidt
  • Date: 2008-12-31 16:41:58 UTC
  • mfrom: (1.1.36 upstream)
  • mto: (1.5.1 sid)
  • mto: This revision was merged to the branch mainline in revision 109.
  • Revision ID: james.westby@ubuntu.com-20081231164158-xnobl1sokvvc6ho8
Tags: 2.24.2-1
[ Josselin Mouette ]
* README.Debian: document that you need to install poppler-data.
  Closes: #506836.

[ Marc 'HE' Brockschmidt ]
* debian/control: Make the Gnome team maintainer. I'm not doing the job
   anyway.

[ Josselin Mouette ]
* New upstream release.
* Require nautilus 2.22 to build the extension for the correct 
  version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include <config.h>
2
2
#include "ev-pixbuf-cache.h"
3
 
#include "ev-job-queue.h"
 
3
#include "ev-job-scheduler.h"
4
4
#include "ev-page-cache.h"
5
5
#include "ev-document-images.h"
6
6
#include "ev-document-forms.h"
163
163
                g_signal_handlers_disconnect_by_func (job_info->job,
164
164
                                                      G_CALLBACK (job_finished_cb),
165
165
                                                      data);
166
 
                ev_job_queue_remove_job (job_info->job);
167
 
                g_object_unref (G_OBJECT (job_info->job));
 
166
                ev_job_cancel (job_info->job);
 
167
                g_object_unref (job_info->job);
168
168
                job_info->job = NULL;
169
169
        }
170
170
        if (job_info->surface) {
250
250
        EvJobRender *job_render = EV_JOB_RENDER (job);
251
251
 
252
252
        /* If the job is outside of our interest, we silently discard it */
253
 
        if ((job_render->rc->page < (pixbuf_cache->start_page - pixbuf_cache->preload_cache_size)) ||
254
 
            (job_render->rc->page > (pixbuf_cache->end_page + pixbuf_cache->preload_cache_size))) {
 
253
        if ((job_render->page < (pixbuf_cache->start_page - pixbuf_cache->preload_cache_size)) ||
 
254
            (job_render->page > (pixbuf_cache->end_page + pixbuf_cache->preload_cache_size))) {
255
255
                g_object_unref (job);
256
256
                return;
257
257
        }
258
258
 
259
 
        job_info = find_job_cache (pixbuf_cache, job_render->rc->page);
 
259
        job_info = find_job_cache (pixbuf_cache, job_render->page);
260
260
 
261
261
        copy_job_page_and_selection_to_job_info (job_render, job_info, pixbuf_cache);
262
262
        g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
270
270
        EvJobRender *job_render = EV_JOB_RENDER (job);
271
271
 
272
272
        /* If the job is outside of our interest, we silently discard it */
273
 
        if ((job_render->rc->page < (pixbuf_cache->start_page - pixbuf_cache->preload_cache_size)) ||
274
 
            (job_render->rc->page > (pixbuf_cache->end_page + pixbuf_cache->preload_cache_size))) {
 
273
        if ((job_render->page < (pixbuf_cache->start_page - pixbuf_cache->preload_cache_size)) ||
 
274
            (job_render->page > (pixbuf_cache->end_page + pixbuf_cache->preload_cache_size))) {
275
275
                g_object_unref (job);
276
276
                return;
277
277
        }
278
278
 
279
 
        job_info = find_job_cache (pixbuf_cache, job_render->rc->page);
 
279
        job_info = find_job_cache (pixbuf_cache, job_render->page);
280
280
        copy_job_to_job_info (job_render, job_info, pixbuf_cache);
281
281
}
282
282
 
298
298
                return;
299
299
 
300
300
        ev_page_cache_get_size (page_cache,
301
 
                                EV_JOB_RENDER (job_info->job)->rc->page,
302
 
                                EV_JOB_RENDER (job_info->job)->rc->rotation,
 
301
                                EV_JOB_RENDER (job_info->job)->page,
 
302
                                EV_JOB_RENDER (job_info->job)->rotation,
303
303
                                scale,
304
304
                                &width, &height);
305
305
                                
313
313
        g_signal_handlers_disconnect_by_func (job_info->job,
314
314
                                              G_CALLBACK (job_finished_cb),
315
315
                                              pixbuf_cache);
316
 
        ev_job_queue_remove_job (job_info->job);
 
316
        ev_job_cancel (job_info->job);
317
317
        g_object_unref (job_info->job);
318
318
        job_info->job = NULL;
319
319
}
330
330
              CacheJobInfo  *new_next_job,
331
331
              int            start_page,
332
332
              int            end_page,
333
 
              EvJobPriority  priority)
 
333
              gint           priority)
334
334
{
335
335
        CacheJobInfo *target_page = NULL;
336
336
        int page_offset;
337
 
        EvJobPriority new_priority;
 
337
        gint new_priority;
338
338
 
339
339
        if (page < (start_page - pixbuf_cache->preload_cache_size) ||
340
340
            page > (end_page + pixbuf_cache->preload_cache_size)) {
361
361
                page_offset = page - start_page;
362
362
                g_assert (page_offset >= 0 &&
363
363
                          page_offset <= ((end_page - start_page) + 1));
364
 
                new_priority = EV_JOB_PRIORITY_HIGH;
 
364
                new_priority = EV_JOB_PRIORITY_URGENT;
365
365
                target_page = new_job_list + page_offset;
366
366
        }
367
367
 
374
374
        job_info->form_field_mapping = NULL;
375
375
 
376
376
        if (new_priority != priority && target_page->job) {
377
 
                ev_job_queue_update_job (target_page->job, new_priority);
 
377
                ev_job_scheduler_update_job (target_page->job, new_priority);
378
378
        }
379
379
}
380
380
 
421
421
                move_one_job (pixbuf_cache->job_list + i,
422
422
                              pixbuf_cache, page,
423
423
                              new_job_list, new_prev_job, new_next_job,
424
 
                              start_page, end_page, EV_JOB_PRIORITY_HIGH);
 
424
                              start_page, end_page, EV_JOB_PRIORITY_URGENT);
425
425
                page ++;
426
426
        }
427
427
 
454
454
                                         CacheJobInfo  *job_info,
455
455
                                         EvPixbufCache *pixbuf_cache)
456
456
{
 
457
        if (job_info->rc == NULL) {
 
458
                job_info->rc = ev_render_context_new (job_render->ev_page,
 
459
                                                      job_render->rotation,
 
460
                                                      job_render->scale);
 
461
        } else {
 
462
                ev_render_context_set_page (job_info->rc, job_render->ev_page);
 
463
                ev_render_context_set_rotation (job_info->rc, job_render->rotation);
 
464
                ev_render_context_set_scale (job_info->rc, job_render->scale);
 
465
        }
 
466
        
457
467
        if (job_info->surface) {
458
468
                cairo_surface_destroy (job_info->surface);
459
469
        }
460
470
        job_info->surface = cairo_surface_reference (job_render->surface);
461
471
 
462
 
        if (job_info->rc) {
463
 
                g_object_unref (G_OBJECT (job_info->rc));
464
 
        }
465
 
        job_info->rc = g_object_ref (job_render->rc);
466
 
 
467
472
        job_info->points_set = FALSE;
468
 
        if (job_render->include_selection) {
 
473
        if (job_render->flags & EV_RENDER_INCLUDE_SELECTION) {
469
474
                if (job_info->selection) {
470
475
                        cairo_surface_destroy (job_info->selection);
471
476
                        job_info->selection = NULL;
496
501
                      CacheJobInfo  *job_info,
497
502
                      EvPixbufCache *pixbuf_cache)
498
503
{
499
 
        if (job_render->include_links) {
 
504
        if (!job_info->page_ready) {
 
505
                g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
 
506
                copy_job_page_and_selection_to_job_info (job_render,
 
507
                                                         job_info,
 
508
                                                         pixbuf_cache);
 
509
        }
 
510
        
 
511
        if (job_render->flags & EV_RENDER_INCLUDE_LINKS) {
500
512
                if (job_info->link_mapping)
501
513
                        ev_link_mapping_free (job_info->link_mapping);
502
514
                job_info->link_mapping = job_render->link_mapping;
503
515
        }
504
516
 
505
 
        if (job_render->include_images) {
 
517
        if (job_render->flags & EV_RENDER_INCLUDE_IMAGES) {
506
518
                if (job_info->image_mapping)
507
519
                        ev_image_mapping_free (job_info->image_mapping);
508
520
                job_info->image_mapping = job_render->image_mapping;
509
521
        }
510
522
 
511
 
        if (job_render->include_forms) {
 
523
        if (job_render->flags & EV_RENDER_INCLUDE_FORMS) {
512
524
                if (job_info->form_field_mapping)
513
525
                        ev_form_field_mapping_free (job_info->form_field_mapping);
514
526
                job_info->form_field_mapping = job_render->form_field_mapping;
515
527
        }
516
528
 
517
 
        if (job_render->include_text) {
 
529
        if (job_render->flags & EV_RENDER_INCLUDE_TEXT) {
518
530
                if (job_info->text_mapping)
519
531
                        gdk_region_destroy (job_info->text_mapping);
520
532
                job_info->text_mapping = job_render->text_mapping;
524
536
                g_signal_handlers_disconnect_by_func (job_info->job,
525
537
                                                      G_CALLBACK (job_finished_cb),
526
538
                                                      pixbuf_cache);
527
 
                ev_job_queue_remove_job (job_info->job);
528
 
                g_object_unref (G_OBJECT (job_info->job));
 
539
                ev_job_cancel (job_info->job);
 
540
                g_object_unref (job_info->job);
529
541
                job_info->job = NULL;
530
542
        }
531
543
}
608
620
         gfloat         scale,
609
621
         EvJobPriority  priority)
610
622
{
611
 
        gboolean include_links = FALSE;
612
 
        gboolean include_text = FALSE;
613
 
        gboolean include_selection = FALSE;
614
 
        gboolean include_images = FALSE;
615
 
        gboolean include_forms = FALSE;
616
 
        GdkColor *text, *base;
 
623
        EvRenderFlags flags = 0;
617
624
 
618
625
        job_info->page_ready = FALSE;
619
626
        
620
 
        if (job_info->rc == NULL) {
621
 
                job_info->rc = ev_render_context_new (rotation, page, scale);
622
 
        } else {
623
 
                ev_render_context_set_rotation (job_info->rc, rotation);
624
 
                ev_render_context_set_page (job_info->rc, page);
625
 
                ev_render_context_set_scale (job_info->rc, scale);
626
 
        }
627
 
 
628
627
        if (job_info->region)
629
628
                gdk_region_destroy (job_info->region);
630
629
        job_info->region = region ? gdk_region_copy (region) : NULL;
631
630
 
632
631
        /* Figure out what else we need for this job */
633
632
        if (job_info->link_mapping == NULL)
634
 
                include_links = TRUE;
 
633
                flags |= EV_RENDER_INCLUDE_LINKS;
635
634
        if (job_info->image_mapping == NULL)
636
 
                include_images = TRUE;
 
635
                flags |= EV_RENDER_INCLUDE_IMAGES;
637
636
        if (job_info->form_field_mapping == NULL)
638
 
                include_forms = TRUE;
 
637
                flags |= EV_RENDER_INCLUDE_FORMS;
639
638
        if (job_info->text_mapping == NULL)
640
 
                include_text = TRUE;
641
 
        if (new_selection_surface_needed (pixbuf_cache, job_info, page, scale)) {
642
 
                include_selection = TRUE;
643
 
        }
644
 
 
645
 
        gtk_widget_ensure_style (pixbuf_cache->view);
646
 
 
647
 
        get_selection_colors (pixbuf_cache->view, &text, &base);
 
639
                flags |= EV_RENDER_INCLUDE_TEXT;
648
640
 
649
641
        job_info->job = ev_job_render_new (pixbuf_cache->document,
650
 
                                           job_info->rc,
 
642
                                           page, rotation, scale,
651
643
                                           width, height,
652
 
                                           &(job_info->target_points),
653
 
                                           job_info->selection_style,
654
 
                                           text, base,
655
 
                                           include_forms,
656
 
                                           include_links,
657
 
                                           include_images,
658
 
                                           include_text,
659
 
                                           include_selection);
660
 
        ev_job_queue_add_job (job_info->job, priority);
 
644
                                           flags);
 
645
        
 
646
        if (new_selection_surface_needed (pixbuf_cache, job_info, page, scale)) {
 
647
                GdkColor *text, *base;
 
648
 
 
649
                gtk_widget_ensure_style (pixbuf_cache->view);
 
650
                get_selection_colors (pixbuf_cache->view, &text, &base);
 
651
                ev_job_render_set_selection_info (EV_JOB_RENDER (job_info->job), 
 
652
                                                  &(job_info->target_points),
 
653
                                                  job_info->selection_style,
 
654
                                                  text, base);
 
655
        }
 
656
 
661
657
        g_signal_connect (G_OBJECT (job_info->job), "page-ready",
662
658
                          G_CALLBACK (job_page_ready_cb),
663
659
                          pixbuf_cache);
664
660
        g_signal_connect (G_OBJECT (job_info->job), "finished",
665
661
                          G_CALLBACK (job_finished_cb),
666
662
                          pixbuf_cache);
 
663
        ev_job_scheduler_push_job (job_info->job, priority);
667
664
}
668
665
 
669
666
static void
711
708
 
712
709
                add_job_if_needed (pixbuf_cache, job_info,
713
710
                                   page_cache, page, rotation, scale,
714
 
                                   EV_JOB_PRIORITY_HIGH);
 
711
                                   EV_JOB_PRIORITY_URGENT);
715
712
        }
716
713
 
717
714
        for (i = FIRST_VISABLE_PREV(pixbuf_cache); i < pixbuf_cache->preload_cache_size; i++) {
856
853
 
857
854
static gboolean
858
855
new_selection_surface_needed (EvPixbufCache *pixbuf_cache,
859
 
                             CacheJobInfo  *job_info,
860
 
                             gint           page,
861
 
                             gfloat         scale)
 
856
                              CacheJobInfo  *job_info,
 
857
                              gint           page,
 
858
                              gfloat         scale)
862
859
{
863
860
        EvPageCache *page_cache;
864
861
 
995
992
        /* If we have a running job, we just return what we have under the
996
993
         * assumption that it'll be updated later and we can scale it as need
997
994
         * be */
998
 
        if (job_info->job && EV_JOB_RENDER (job_info->job)->include_selection)
 
995
        if (job_info->job && (EV_JOB_RENDER (job_info->job)->flags & EV_RENDER_INCLUDE_SELECTION))
999
996
                return job_info->selection;
1000
997
 
1001
998
        /* Now, lets see if we need to resize the image.  If we do, we clear the
1245
1242
 
1246
1243
        add_job (pixbuf_cache, job_info, page_cache, region,
1247
1244
                 width, height, page, rotation, scale,
1248
 
                 EV_JOB_PRIORITY_HIGH);
 
1245
                 EV_JOB_PRIORITY_URGENT);
1249
1246
}
1250
1247
 
1251
1248