comparison src/image.c @ 1032:7c87b324b9bb

dropped IMAGE_THROTTLE_LARGER_IMAGES code
author nadvornik
date Wed, 03 Sep 2008 19:58:21 +0000
parents 999919edcb7b
children 5fc64d6252e7
comparison
equal deleted inserted replaced
1031:999919edcb7b 1032:7c87b324b9bb
30 #include "filedata.h" 30 #include "filedata.h"
31 #include "filecache.h" 31 #include "filecache.h"
32 32
33 #include <math.h> 33 #include <math.h>
34 34
35
36 /* size of the image loader buffer (512 bytes x defined number) */
37 #define IMAGE_LOAD_BUFFER_COUNT 8
38
39 /* define this so that more bytes are read per idle loop on larger images (> 1MB) */
40 #define IMAGE_THROTTLE_LARGER_IMAGES 1
41
42 /* throttle factor to increase read bytes by (2 is double, 3 is triple, etc.) */
43 #define IMAGE_THROTTLE_FACTOR 32
44
45 /* the file size at which throttling take place */
46 #define IMAGE_THROTTLE_THRESHOLD 1048576
47
48 static GList *image_list = NULL; 35 static GList *image_list = NULL;
49
50 36
51 static void image_update_title(ImageWindow *imd); 37 static void image_update_title(ImageWindow *imd);
52 static void image_read_ahead_start(ImageWindow *imd); 38 static void image_read_ahead_start(ImageWindow *imd);
53 static void image_cache_set(ImageWindow *imd, FileData *fd); 39 static void image_cache_set(ImageWindow *imd, FileData *fd);
54 40
591 * since we have a pixbuf with _something_ */ 577 * since we have a pixbuf with _something_ */
592 578
593 image_load_done_cb(il, data); 579 image_load_done_cb(il, data);
594 } 580 }
595 581
596 #ifdef IMAGE_THROTTLE_LARGER_IMAGES
597 static void image_load_buffer_throttle(ImageLoader *il)
598 {
599 if (!il || il->bytes_total < IMAGE_THROTTLE_THRESHOLD) return;
600
601 /* Larger image files usually have larger chunks of data per pixel...
602 * So increase the buffer read size so that the rendering chunks called
603 * are also larger.
604 */
605
606 image_loader_set_buffer_size(il, IMAGE_LOAD_BUFFER_COUNT * IMAGE_THROTTLE_FACTOR);
607 }
608 #endif
609
610 /* this read ahead is located here merely for the callbacks, above */ 582 /* this read ahead is located here merely for the callbacks, above */
611 583
612 static gint image_read_ahead_check(ImageWindow *imd) 584 static gint image_read_ahead_check(ImageWindow *imd)
613 { 585 {
614 if (!imd->read_ahead_fd) return FALSE; 586 if (!imd->read_ahead_fd) return FALSE;
628 /* override the old signals */ 600 /* override the old signals */
629 g_signal_handlers_disconnect_matched(G_OBJECT(imd->il), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, imd); 601 g_signal_handlers_disconnect_matched(G_OBJECT(imd->il), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, imd);
630 g_signal_connect (G_OBJECT(imd->il), "area_ready", (GCallback)image_load_area_cb, imd); 602 g_signal_connect (G_OBJECT(imd->il), "area_ready", (GCallback)image_load_area_cb, imd);
631 g_signal_connect (G_OBJECT(imd->il), "error", (GCallback)image_load_error_cb, imd); 603 g_signal_connect (G_OBJECT(imd->il), "error", (GCallback)image_load_error_cb, imd);
632 g_signal_connect (G_OBJECT(imd->il), "done", (GCallback)image_load_done_cb, imd); 604 g_signal_connect (G_OBJECT(imd->il), "done", (GCallback)image_load_done_cb, imd);
633 image_loader_set_buffer_size(imd->il, IMAGE_LOAD_BUFFER_COUNT);
634
635 #ifdef IMAGE_THROTTLE_LARGER_IMAGES
636 image_load_buffer_throttle(imd->il);
637 #endif
638 605
639 g_object_set(G_OBJECT(imd->pr), "loading", TRUE, NULL); 606 g_object_set(G_OBJECT(imd->pr), "loading", TRUE, NULL);
640 image_state_set(imd, IMAGE_STATE_LOADING); 607 image_state_set(imd, IMAGE_STATE_LOADING);
641 608
642 if (!imd->delay_flip) 609 if (!imd->delay_flip)
698 imd->il = image_loader_new(fd); 665 imd->il = image_loader_new(fd);
699 666
700 g_signal_connect (G_OBJECT(imd->il), "area_ready", (GCallback)image_load_area_cb, imd); 667 g_signal_connect (G_OBJECT(imd->il), "area_ready", (GCallback)image_load_area_cb, imd);
701 g_signal_connect (G_OBJECT(imd->il), "error", (GCallback)image_load_error_cb, imd); 668 g_signal_connect (G_OBJECT(imd->il), "error", (GCallback)image_load_error_cb, imd);
702 g_signal_connect (G_OBJECT(imd->il), "done", (GCallback)image_load_done_cb, imd); 669 g_signal_connect (G_OBJECT(imd->il), "done", (GCallback)image_load_done_cb, imd);
703 image_loader_set_buffer_size(imd->il, IMAGE_LOAD_BUFFER_COUNT);
704 670
705 if (!image_loader_start(imd->il)) 671 if (!image_loader_start(imd->il))
706 { 672 {
707 DEBUG_1("image start error"); 673 DEBUG_1("image start error");
708 674
715 681
716 return FALSE; 682 return FALSE;
717 } 683 }
718 684
719 image_state_set(imd, IMAGE_STATE_LOADING); 685 image_state_set(imd, IMAGE_STATE_LOADING);
720
721 #ifdef IMAGE_THROTTLE_LARGER_IMAGES
722 image_load_buffer_throttle(imd->il);
723 #endif
724 686
725 if (!imd->delay_flip && !image_get_pixbuf(imd)) image_load_pixbuf_ready(imd); 687 if (!imd->delay_flip && !image_get_pixbuf(imd)) image_load_pixbuf_ready(imd);
726 688
727 return TRUE; 689 return TRUE;
728 } 690 }