73
74
static void ev_pixbuf_cache_class_init (EvPixbufCacheClass *pixbuf_cache);
74
75
static void ev_pixbuf_cache_finalize (GObject *object);
75
76
static void ev_pixbuf_cache_dispose (GObject *object);
77
static void job_page_ready_cb (EvJob *job,
78
EvPixbufCache *pixbuf_cache);
76
79
static void job_finished_cb (EvJob *job,
77
80
EvPixbufCache *pixbuf_cache);
78
81
static CacheJobInfo *find_job_cache (EvPixbufCache *pixbuf_cache,
80
83
static void copy_job_to_job_info (EvJobRender *job_render,
81
84
CacheJobInfo *job_info,
82
85
EvPixbufCache *pixbuf_cache);
86
static void copy_job_page_and_selection_to_job_info (EvJobRender *job_render,
87
CacheJobInfo *job_info,
88
EvPixbufCache *pixbuf_cache);
83
89
static gboolean new_selection_surface_needed(EvPixbufCache *pixbuf_cache,
84
90
CacheJobInfo *job_info,
152
158
if (job_info->job) {
153
159
g_signal_handlers_disconnect_by_func (job_info->job,
160
G_CALLBACK (job_page_ready_cb),
162
g_signal_handlers_disconnect_by_func (job_info->job,
154
163
G_CALLBACK (job_finished_cb),
156
165
ev_job_queue_remove_job (job_info->job);
245
job_page_ready_cb (EvJob *job,
246
EvPixbufCache *pixbuf_cache)
248
CacheJobInfo *job_info;
249
EvJobRender *job_render = EV_JOB_RENDER (job);
251
/* If the job is outside of our interest, we silently discard it */
252
if ((job_render->rc->page < (pixbuf_cache->start_page - pixbuf_cache->preload_cache_size)) ||
253
(job_render->rc->page > (pixbuf_cache->end_page + pixbuf_cache->preload_cache_size))) {
254
g_object_unref (job);
258
job_info = find_job_cache (pixbuf_cache, job_render->rc->page);
260
copy_job_page_and_selection_to_job_info (job_render, job_info, pixbuf_cache);
261
g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
236
265
job_finished_cb (EvJob *job,
237
266
EvPixbufCache *pixbuf_cache)
245
274
g_object_unref (job);
249
278
job_info = find_job_cache (pixbuf_cache, job_render->rc->page);
251
279
copy_job_to_job_info (job_render, job_info, pixbuf_cache);
252
g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
255
282
/* This checks a job to see if the job would generate the right sized pixbuf
449
copy_job_page_and_selection_to_job_info (EvJobRender *job_render,
450
CacheJobInfo *job_info,
451
EvPixbufCache *pixbuf_cache)
453
if (job_info->surface) {
454
cairo_surface_destroy (job_info->surface);
456
job_info->surface = cairo_surface_reference (job_render->surface);
459
g_object_unref (G_OBJECT (job_info->rc));
461
job_info->rc = g_object_ref (job_render->rc);
463
job_info->points_set = FALSE;
464
if (job_render->include_selection) {
465
if (job_info->selection) {
466
cairo_surface_destroy (job_info->selection);
467
job_info->selection = NULL;
469
if (job_info->selection_region) {
470
gdk_region_destroy (job_info->selection_region);
471
job_info->selection_region = NULL;
474
job_info->selection_points = job_render->selection_points;
475
job_info->selection_region = gdk_region_copy (job_render->selection_region);
476
job_info->selection = cairo_surface_reference (job_render->selection);
477
g_assert (job_info->selection_points.x1 >= 0);
478
job_info->points_set = TRUE;
482
g_signal_handlers_disconnect_by_func (job_info->job,
483
G_CALLBACK (job_page_ready_cb),
487
job_info->page_ready = TRUE;
422
491
copy_job_to_job_info (EvJobRender *job_render,
423
492
CacheJobInfo *job_info,
424
493
EvPixbufCache *pixbuf_cache)
427
job_info->points_set = FALSE;
429
if (job_info->surface) {
430
cairo_surface_destroy (job_info->surface);
432
job_info->surface = cairo_surface_reference (job_render->surface);
435
g_object_unref (G_OBJECT (job_info->rc));
437
job_info->rc = g_object_ref (job_render->rc);
439
495
if (job_render->include_links) {
440
496
if (job_info->link_mapping)
441
497
ev_link_mapping_free (job_info->link_mapping);
460
516
job_info->text_mapping = job_render->text_mapping;
463
if (job_render->include_selection) {
464
if (job_info->selection) {
465
cairo_surface_destroy (job_info->selection);
466
job_info->selection = NULL;
468
if (job_info->selection_region) {
469
gdk_region_destroy (job_info->selection_region);
470
job_info->selection_region = NULL;
473
job_info->selection_points = job_render->selection_points;
474
job_info->selection_region = gdk_region_copy (job_render->selection_region);
475
job_info->selection = cairo_surface_reference (job_render->selection);
476
g_assert (job_info->selection_points.x1 >= 0);
477
job_info->points_set = TRUE;
480
519
if (job_info->job) {
481
520
g_signal_handlers_disconnect_by_func (job_info->job,
482
521
G_CALLBACK (job_finished_cb),
571
610
gboolean include_images = TRUE;
572
611
gboolean include_forms = FALSE;
573
612
GdkColor *text, *base;
614
job_info->page_ready = FALSE;
575
616
if (job_info->rc == NULL) {
576
617
job_info->rc = ev_render_context_new (rotation, page, scale);
613
654
include_selection);
614
655
ev_job_queue_add_job (job_info->job, priority);
615
g_signal_connect (job_info->job, "finished",
656
g_signal_connect (G_OBJECT (job_info->job), "page-ready",
657
G_CALLBACK (job_page_ready_cb),
659
g_signal_connect (G_OBJECT (job_info->job), "finished",
616
660
G_CALLBACK (job_finished_cb),
729
773
if (job_info == NULL)
776
if (job_info->page_ready)
777
return job_info->surface;
732
779
/* We don't need to wait for the idle to handle the callback */
733
780
if (job_info->job &&
734
EV_JOB (job_info->job)->finished) {
735
copy_job_to_job_info (EV_JOB_RENDER (job_info->job), job_info, pixbuf_cache);
781
EV_JOB_RENDER (job_info->job)->page_ready) {
782
copy_job_page_and_selection_to_job_info (EV_JOB_RENDER (job_info->job), job_info, pixbuf_cache);
736
783
g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
753
800
if (job_info->job &&
754
801
EV_JOB (job_info->job)->finished) {
755
802
copy_job_to_job_info (EV_JOB_RENDER (job_info->job), job_info, pixbuf_cache);
756
g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
759
805
return job_info->link_mapping;
776
822
if (job_info->job &&
777
823
EV_JOB (job_info->job)->finished) {
778
824
copy_job_to_job_info (EV_JOB_RENDER (job_info->job), job_info, pixbuf_cache);
779
g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
782
827
return job_info->image_mapping;
799
844
if (job_info->job &&
800
845
EV_JOB (job_info->job)->finished) {
801
846
copy_job_to_job_info (EV_JOB_RENDER(job_info->job), job_info, pixbuf_cache);
802
g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
805
849
return job_info->form_field_mapping;
863
907
if (job_info->job &&
864
908
EV_JOB (job_info->job)->finished) {
865
909
copy_job_to_job_info (EV_JOB_RENDER (job_info->job), job_info, pixbuf_cache);
866
g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
869
912
return job_info->text_mapping;