comparison src/image.c @ 495:c7a2471e5c4e

Introduce macros to display debug messages. if (debug) printf(...) is now replaced by variadic macros: DEBUG_1() And for higher debugging levels: DEBUG_2() DEBUG_3() DEBUG_4()
author zas_
date Wed, 23 Apr 2008 20:47:19 +0000
parents 805c3258d228
children fc9c8a3e1a8b
comparison
equal deleted inserted replaced
494:3bb9a8df6ee9 495:c7a2471e5c4e
119 119
120 static void image_complete_util(ImageWindow *imd, gint preload) 120 static void image_complete_util(ImageWindow *imd, gint preload)
121 { 121 {
122 if (imd->il && image_get_pixbuf(imd) != image_loader_get_pixbuf(imd->il)) return; 122 if (imd->il && image_get_pixbuf(imd) != image_loader_get_pixbuf(imd->il)) return;
123 123
124 if (debug) printf("%s image load completed \"%s\" (%s)\n", get_exec_time(), 124 DEBUG_1("%s image load completed \"%s\" (%s)\n", get_exec_time(),
125 (preload) ? (imd->read_ahead_fd ? imd->read_ahead_fd->path : "null") : 125 (preload) ? (imd->read_ahead_fd ? imd->read_ahead_fd->path : "null") :
126 (imd->image_fd ? imd->image_fd->path : "null"), 126 (imd->image_fd ? imd->image_fd->path : "null"),
127 (preload) ? "preload" : "current"); 127 (preload) ? "preload" : "current");
128 128
129 if (!preload) imd->completed = TRUE; 129 if (!preload) imd->completed = TRUE;
295 0.50, 0.50); 295 0.50, 0.50);
296 } 296 }
297 297
298 if (exif_rotate) image_state_set(imd, IMAGE_STATE_ROTATE_AUTO); 298 if (exif_rotate) image_state_set(imd, IMAGE_STATE_ROTATE_AUTO);
299 layout_image_overlay_update(layout_find_by_image(imd)); 299 layout_image_overlay_update(layout_find_by_image(imd));
300 if (debug) printf("%s image postprocess done: %s\n", get_exec_time(), imd->image_fd->name); 300 DEBUG_1("%s image postprocess done: %s\n", get_exec_time(), imd->image_fd->name);
301 } 301 }
302 302
303 static void image_post_process_alter(ImageWindow *imd, gint clamp) 303 static void image_post_process_alter(ImageWindow *imd, gint clamp)
304 { 304 {
305 if (imd->delay_alter_type != ALTER_NONE) 305 if (imd->delay_alter_type != ALTER_NONE)
320 return; 320 return;
321 } 321 }
322 322
323 imd->cm = NULL; 323 imd->cm = NULL;
324 image_state_set(imd, IMAGE_STATE_COLOR_ADJ); 324 image_state_set(imd, IMAGE_STATE_COLOR_ADJ);
325 if (debug) printf("%s image postprocess cm done: %s\n", get_exec_time(), imd->image_fd->name); 325 DEBUG_1("%s image postprocess cm done: %s\n", get_exec_time(), imd->image_fd->name);
326 326
327 image_post_process_alter(imd, FALSE); 327 image_post_process_alter(imd, FALSE);
328 328
329 image_read_ahead_start(imd); 329 image_read_ahead_start(imd);
330 } 330 }
397 { 397 {
398 input_type = COLOR_PROFILE_SRGB; 398 input_type = COLOR_PROFILE_SRGB;
399 input_file = NULL; 399 input_file = NULL;
400 imd->color_profile_from_image = COLOR_PROFILE_SRGB; 400 imd->color_profile_from_image = COLOR_PROFILE_SRGB;
401 401
402 if (debug) printf("Found EXIF ColorSpace of sRGB\n"); 402 DEBUG_1("Found EXIF ColorSpace of sRGB\n");
403 } 403 }
404 if (cs == 2 || (interop_index && !strcmp(interop_index, "R03"))) 404 if (cs == 2 || (interop_index && !strcmp(interop_index, "R03")))
405 { 405 {
406 input_type = COLOR_PROFILE_ADOBERGB; 406 input_type = COLOR_PROFILE_ADOBERGB;
407 input_file = NULL; 407 input_file = NULL;
408 imd->color_profile_from_image = COLOR_PROFILE_ADOBERGB; 408 imd->color_profile_from_image = COLOR_PROFILE_ADOBERGB;
409 409
410 if (debug) printf("Found EXIF ColorSpace of AdobeRGB\n"); 410 DEBUG_1("Found EXIF ColorSpace of AdobeRGB\n");
411 } 411 }
412 412
413 g_free(interop_index); 413 g_free(interop_index);
414 } 414 }
415 } 415 }
416 416
417 if (profile) 417 if (profile)
418 { 418 {
419 if (debug) printf("Found embedded color profile\n"); 419 DEBUG_1("Found embedded color profile\n");
420 imd->color_profile_from_image = COLOR_PROFILE_MEM; 420 imd->color_profile_from_image = COLOR_PROFILE_MEM;
421 421
422 cm = color_man_new_embedded(run_in_bg ? imd : NULL, NULL, 422 cm = color_man_new_embedded(run_in_bg ? imd : NULL, NULL,
423 profile, profile_len, 423 profile, profile_len,
424 screen_type, screen_file); 424 screen_type, screen_file);
454 #if 0 454 #if 0
455 ExifData *exif = NULL; 455 ExifData *exif = NULL;
456 456
457 if (!image_get_pixbuf(imd)) return; 457 if (!image_get_pixbuf(imd)) return;
458 458
459 if (debug) printf("%s image postprocess: %s\n", get_exec_time(), imd->image_fd->name); 459 DEBUG_1("%s image postprocess: %s\n", get_exec_time(), imd->image_fd->name);
460 460
461 if (options->image.exif_rotate_enable || 461 if (options->image.exif_rotate_enable ||
462 (imd->color_profile_enable && imd->color_profile_use_image) ) 462 (imd->color_profile_enable && imd->color_profile_use_image) )
463 { 463 {
464 exif = exif_read_fd(imd->image_fd); 464 exif = exif_read_fd(imd->image_fd);
615 *------------------------------------------------------------------- 615 *-------------------------------------------------------------------
616 */ 616 */
617 617
618 static void image_read_ahead_cancel(ImageWindow *imd) 618 static void image_read_ahead_cancel(ImageWindow *imd)
619 { 619 {
620 if (debug) printf("%s read ahead cancelled for :%s\n", get_exec_time(), imd->read_ahead_fd ? imd->read_ahead_fd->path : "null"); 620 DEBUG_1("%s read ahead cancelled for :%s\n", get_exec_time(), imd->read_ahead_fd ? imd->read_ahead_fd->path : "null");
621 621
622 image_loader_free(imd->read_ahead_il); 622 image_loader_free(imd->read_ahead_il);
623 imd->read_ahead_il = NULL; 623 imd->read_ahead_il = NULL;
624 624
625 if (imd->read_ahead_pixbuf) g_object_unref(imd->read_ahead_pixbuf); 625 if (imd->read_ahead_pixbuf) g_object_unref(imd->read_ahead_pixbuf);
631 631
632 static void image_read_ahead_done_cb(ImageLoader *il, gpointer data) 632 static void image_read_ahead_done_cb(ImageLoader *il, gpointer data)
633 { 633 {
634 ImageWindow *imd = data; 634 ImageWindow *imd = data;
635 635
636 if (debug) printf("%s read ahead done for :%s\n", get_exec_time(), imd->read_ahead_fd->path); 636 DEBUG_1("%s read ahead done for :%s\n", get_exec_time(), imd->read_ahead_fd->path);
637 637
638 imd->read_ahead_pixbuf = image_loader_get_pixbuf(imd->read_ahead_il); 638 imd->read_ahead_pixbuf = image_loader_get_pixbuf(imd->read_ahead_il);
639 if (imd->read_ahead_pixbuf) 639 if (imd->read_ahead_pixbuf)
640 { 640 {
641 g_object_ref(imd->read_ahead_pixbuf); 641 g_object_ref(imd->read_ahead_pixbuf);
662 if (!imd->read_ahead_fd || imd->read_ahead_il || imd->read_ahead_pixbuf) return; 662 if (!imd->read_ahead_fd || imd->read_ahead_il || imd->read_ahead_pixbuf) return;
663 663
664 /* still loading ?, do later */ 664 /* still loading ?, do later */
665 if (imd->il /*|| imd->cm*/) return; 665 if (imd->il /*|| imd->cm*/) return;
666 666
667 if (debug) printf("%s read ahead started for :%s\n", get_exec_time(), imd->read_ahead_fd->path); 667 DEBUG_1("%s read ahead started for :%s\n", get_exec_time(), imd->read_ahead_fd->path);
668 668
669 imd->read_ahead_il = image_loader_new(imd->read_ahead_fd); 669 imd->read_ahead_il = image_loader_new(imd->read_ahead_fd);
670 670
671 image_loader_set_error_func(imd->read_ahead_il, image_read_ahead_error_cb, imd); 671 image_loader_set_error_func(imd->read_ahead_il, image_read_ahead_error_cb, imd);
672 if (!image_loader_start(imd->read_ahead_il, image_read_ahead_done_cb, imd)) 672 if (!image_loader_start(imd->read_ahead_il, image_read_ahead_done_cb, imd))
682 682
683 image_read_ahead_cancel(imd); 683 image_read_ahead_cancel(imd);
684 684
685 imd->read_ahead_fd = file_data_ref(fd); 685 imd->read_ahead_fd = file_data_ref(fd);
686 686
687 if (debug) printf("read ahead set to :%s\n", imd->read_ahead_fd->path); 687 DEBUG_1("read ahead set to :%s\n", imd->read_ahead_fd->path);
688 688
689 image_read_ahead_start(imd); 689 image_read_ahead_start(imd);
690 } 690 }
691 691
692 /* 692 /*
713 imd->prev_fd = NULL; 713 imd->prev_fd = NULL;
714 imd->prev_pixbuf = NULL; 714 imd->prev_pixbuf = NULL;
715 imd->prev_color_row = -1; 715 imd->prev_color_row = -1;
716 } 716 }
717 717
718 if (debug) printf("%s post buffer set: %s\n", get_exec_time(), fd ? fd->path : "null"); 718 DEBUG_1("%s post buffer set: %s\n", get_exec_time(), fd ? fd->path : "null");
719 } 719 }
720 720
721 static gint image_post_buffer_get(ImageWindow *imd) 721 static gint image_post_buffer_get(ImageWindow *imd)
722 { 722 {
723 gint success; 723 gint success;
783 783
784 static void image_load_done_cb(ImageLoader *il, gpointer data) 784 static void image_load_done_cb(ImageLoader *il, gpointer data)
785 { 785 {
786 ImageWindow *imd = data; 786 ImageWindow *imd = data;
787 787
788 if (debug) printf ("%s image done\n", get_exec_time()); 788 DEBUG_1 ("%s image done\n", get_exec_time());
789 789
790 g_object_set(G_OBJECT(imd->pr), "loading", FALSE, NULL); 790 g_object_set(G_OBJECT(imd->pr), "loading", FALSE, NULL);
791 image_state_unset(imd, IMAGE_STATE_LOADING); 791 image_state_unset(imd, IMAGE_STATE_LOADING);
792 792
793 if (imd->delay_flip && 793 if (imd->delay_flip &&
805 image_read_ahead_start(imd); 805 image_read_ahead_start(imd);
806 } 806 }
807 807
808 static void image_load_error_cb(ImageLoader *il, gpointer data) 808 static void image_load_error_cb(ImageLoader *il, gpointer data)
809 { 809 {
810 if (debug) printf ("%s image error\n", get_exec_time()); 810 DEBUG_1 ("%s image error\n", get_exec_time());
811 811
812 /* even on error handle it like it was done, 812 /* even on error handle it like it was done,
813 * since we have a pixbuf with _something_ */ 813 * since we have a pixbuf with _something_ */
814 814
815 image_load_done_cb(il, data); 815 image_load_done_cb(il, data);
886 return FALSE; 886 return FALSE;
887 } 887 }
888 888
889 static gint image_load_begin(ImageWindow *imd, FileData *fd) 889 static gint image_load_begin(ImageWindow *imd, FileData *fd)
890 { 890 {
891 if (debug) printf ("%s image begin \n", get_exec_time()); 891 DEBUG_1 ("%s image begin \n", get_exec_time());
892 892
893 if (imd->il) return FALSE; 893 if (imd->il) return FALSE;
894 894
895 imd->completed = FALSE; 895 imd->completed = FALSE;
896 g_object_set(G_OBJECT(imd->pr), "complete", FALSE, NULL); 896 g_object_set(G_OBJECT(imd->pr), "complete", FALSE, NULL);
897 897
898 if (image_post_buffer_get(imd)) 898 if (image_post_buffer_get(imd))
899 { 899 {
900 if (debug) printf("from post buffer: %s\n", imd->image_fd->path); 900 DEBUG_1("from post buffer: %s\n", imd->image_fd->path);
901 return TRUE; 901 return TRUE;
902 } 902 }
903 903
904 if (image_read_ahead_check(imd)) 904 if (image_read_ahead_check(imd))
905 { 905 {
906 if (debug) printf("from read ahead buffer: %s\n", imd->image_fd->path); 906 DEBUG_1("from read ahead buffer: %s\n", imd->image_fd->path);
907 return TRUE; 907 return TRUE;
908 } 908 }
909 909
910 if (!imd->delay_flip && image_get_pixbuf(imd)) 910 if (!imd->delay_flip && image_get_pixbuf(imd))
911 { 911 {
924 image_loader_set_error_func(imd->il, image_load_error_cb, imd); 924 image_loader_set_error_func(imd->il, image_load_error_cb, imd);
925 image_loader_set_buffer_size(imd->il, IMAGE_LOAD_BUFFER_COUNT); 925 image_loader_set_buffer_size(imd->il, IMAGE_LOAD_BUFFER_COUNT);
926 926
927 if (!image_loader_start(imd->il, image_load_done_cb, imd)) 927 if (!image_loader_start(imd->il, image_load_done_cb, imd))
928 { 928 {
929 if (debug) printf("image start error\n"); 929 DEBUG_1("image start error\n");
930 930
931 g_object_set(G_OBJECT(imd->pr), "loading", FALSE, NULL); 931 g_object_set(G_OBJECT(imd->pr), "loading", FALSE, NULL);
932 932
933 image_loader_free(imd->il); 933 image_loader_free(imd->il);
934 imd->il = NULL; 934 imd->il = NULL;
951 951
952 static void image_reset(ImageWindow *imd) 952 static void image_reset(ImageWindow *imd)
953 { 953 {
954 /* stops anything currently being done */ 954 /* stops anything currently being done */
955 955
956 if (debug) printf("%s image reset\n", get_exec_time()); 956 DEBUG_1("%s image reset\n", get_exec_time());
957 957
958 g_object_set(G_OBJECT(imd->pr), "loading", FALSE, NULL); 958 g_object_set(G_OBJECT(imd->pr), "loading", FALSE, NULL);
959 959
960 image_loader_free(imd->il); 960 image_loader_free(imd->il);
961 imd->il = NULL; 961 imd->il = NULL;