annotate src/image-load.h @ 1015:2cdcf67e9300

run image loader in separate thread this feature is disabled by default for now, it must be enabled by configure --enable-threads
author nadvornik
date Sat, 30 Aug 2008 20:15:47 +0000
parents 4d3c98219246
children 988995f6b1cf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1 /*
196
f6e307c7bad6 rename GQview -> Geeqie over the code
nadvornik
parents: 138
diff changeset
2 * Geeqie
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3 * (C) 2004 John Ellis
475
48c8e49b571c updated copyright in source files
nadvornik
parents: 446
diff changeset
4 * Copyright (C) 2008 The Geeqie Team
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 * This software comes with no warranty of any kind, use at your own risk!
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
11 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
13
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14 #ifndef IMAGE_LOAD_H
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15 #define IMAGE_LOAD_H
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16
1012
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
17 #define TYPE_IMAGE_LOADER (image_loader_get_type())
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
18
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
19 //typedef struct _ImageLoader ImageLoader;
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
20 typedef struct _ImageLoaderClass ImageLoaderClass;
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
21
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
22 struct _ImageLoader
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
23 {
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
24 GObject parent;
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
25
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
26 /*< private >*/
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
27 GdkPixbuf *pixbuf;
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
28 FileData *fd;
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
29 gchar *path;
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
30
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
31 gint bytes_read;
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
32 gint bytes_total;
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
33
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
34 gint preview;
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
35
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
36 gint requested_width;
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
37 gint requested_height;
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
38 gint shrunk;
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
39
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
40 gint done;
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
41 gint idle_id;
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
42 gint idle_priority;
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
43
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
44 GdkPixbufLoader *loader;
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
45
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
46 gint idle_done_id;
1014
4d3c98219246 prepared image loader code for threads
nadvornik
parents: 1012
diff changeset
47 GList *area_param_list;
1015
2cdcf67e9300 run image loader in separate thread
nadvornik
parents: 1014
diff changeset
48
2cdcf67e9300 run image loader in separate thread
nadvornik
parents: 1014
diff changeset
49 GThread *thread;
2cdcf67e9300 run image loader in separate thread
nadvornik
parents: 1014
diff changeset
50 GMutex *data_mutex;
2cdcf67e9300 run image loader in separate thread
nadvornik
parents: 1014
diff changeset
51 gint stopping;
1012
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
52
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
53 guchar *mapped_file;
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
54 gint read_buffer_size;
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
55 gint idle_read_loop_count;
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
56 };
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
57
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
58 struct _ImageLoaderClass {
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
59 GObjectClass parent;
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
60
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
61 /* class members */
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
62 void (*area_ready)(ImageLoader *, guint x, guint y, guint w, guint h, gpointer);
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
63 void (*error)(ImageLoader *, gpointer);
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
64 void (*done)(ImageLoader *, gpointer);
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
65 void (*percent)(ImageLoader *, gdouble, gpointer);
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
66 };
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
67
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
68 GType image_loader_get_type(void);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 9
diff changeset
70 ImageLoader *image_loader_new(FileData *fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 9
diff changeset
71
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72 void image_loader_free(ImageLoader *il);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 /* Speed up loading when you only need at most width x height size image,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 * only the jpeg GdkPixbuf loader benefits from it - so there is no
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77 * guarantee that the image will scale down to the requested size..
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 void image_loader_set_requested_size(ImageLoader *il, gint width, gint height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 void image_loader_set_buffer_size(ImageLoader *il, guint size);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 /* this only has effect if used before image_loader_start()
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84 * default is G_PRIORITY_DEFAULT_IDLE
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86 void image_loader_set_priority(ImageLoader *il, gint priority);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87
1012
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
88 gint image_loader_start(ImageLoader *il);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 GdkPixbuf *image_loader_get_pixbuf(ImageLoader *il);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 gchar *image_loader_get_format(ImageLoader *il);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 gdouble image_loader_get_percent(ImageLoader *il);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94 gint image_loader_get_is_done(ImageLoader *il);
1011
616b14da08c2 do not access image_loader directly
nadvornik
parents: 1009
diff changeset
95 FileData *image_loader_get_fd(ImageLoader *il);
616b14da08c2 do not access image_loader directly
nadvornik
parents: 1009
diff changeset
96 gint image_loader_get_shrunk(ImageLoader *il);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 9
diff changeset
98 gint image_load_dimensions(FileData *fd, gint *width, gint *height);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100 #endif