summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/generators.c16
-rw-r--r--src/generators.h8
-rw-r--r--src/items.c2
-rw-r--r--src/items.h1
-rw-r--r--src/job-manager.c12
5 files changed, 24 insertions, 15 deletions
diff --git a/src/generators.c b/src/generators.c
index f53b826..5e9e64e 100644
--- a/src/generators.c
+++ b/src/generators.c
@@ -109,7 +109,8 @@ generate_image (TGallerySetup *setup,
TIndexItem *item,
unsigned int item_index,
const gchar *dst_dir,
- gboolean update_when_necessary)
+ gboolean update_when_necessary,
+ gboolean *portrait)
{
unsigned long new_w, new_h;
unsigned long thumb_w, thumb_h;
@@ -154,21 +155,21 @@ generate_image (TGallerySetup *setup,
res = (! update_when_necessary) || needs_update (thumb_src_full, thumb_dst) ||
(items->type == GALLERY_TYPE_ALBUM && (needs_update (img_src_full, big_dst) || (orig_dst && needs_update (img_src_full, orig_dst))));
g_free (s1);
-
+
/* Do something when necessary */
if (res) {
get_image_sizes (img_src_full, &new_w, &new_h);
if ((new_w > 0) && (new_h > 0)) {
stats_images_inc ();
- item->gen_portrait = (new_w / new_h) < 1;
+ *portrait = (new_w / new_h) < 1;
/* Generate thumbnail */
g_assert (thumb_src_full != NULL);
get_image_sizes (thumb_src_full, &thumb_w, &thumb_h);
if ((thumb_w > 0) && (thumb_h > 0)) {
- if (! item->gen_portrait)
+ if (! *portrait)
calculate_sizes (setup->thumbnail_landscape_width, setup->thumbnail_landscape_height, &thumb_w, &thumb_h);
else
calculate_sizes (setup->thumbnail_portrait_width, setup->thumbnail_portrait_height, &thumb_w, &thumb_h);
@@ -191,15 +192,12 @@ generate_image (TGallerySetup *setup,
if ((item->width > 0) && (item->height > 0)) {
calculate_sizes (item->width, item->height, &new_w, &new_h);
} else {
- if (! item->gen_portrait)
- {
+ if (! *portrait) {
if ((items->landscape_width > 0) && (items->landscape_height > 0))
calculate_sizes (items->landscape_width, items->landscape_height, &new_w, &new_h);
else
calculate_sizes (setup->preview_landscape_width, setup->preview_landscape_height, &new_w, &new_h);
- }
- else
- {
+ } else {
if ((items->portrait_width > 0) && (items->portrait_height > 0))
calculate_sizes (items->portrait_width, items->portrait_height, &new_w, &new_h);
else
diff --git a/src/generators.h b/src/generators.h
index 3aa9cc2..ae39ed2 100644
--- a/src/generators.h
+++ b/src/generators.h
@@ -23,14 +23,18 @@
/*
- * generate_image: generate needed image sizes
+ * generate_image: generate needed image sizes
+ *
+ * *portrait = indicate image orientation
+ * returns whether item needs to be updated
*/
gboolean generate_image (TGallerySetup *setup,
TAlbum *items,
TIndexItem *item,
unsigned int item_index,
const gchar *dst_dir,
- gboolean update_when_necessary);
+ gboolean update_when_necessary,
+ gboolean *portrait);
/*
* write_html_album: process album and index template files
diff --git a/src/items.c b/src/items.c
index f41e087..c21ce64 100644
--- a/src/items.c
+++ b/src/items.c
@@ -245,8 +245,6 @@ free_album_data (TAlbum *album)
g_free (item->thumbnail);
g_free (item->preview);
g_free (item->border_style);
- g_free (item->gen_img_src);
- g_free (item->gen_thumb);
g_free (item);
}
}
diff --git a/src/items.h b/src/items.h
index de71a71..c972d59 100644
--- a/src/items.h
+++ b/src/items.h
@@ -73,6 +73,7 @@ typedef struct {
gboolean hidden;
/* generated item info */
+ /* !! be careful with writes to this structure during thread work !! */
gboolean gen_portrait;
} TIndexItem;
diff --git a/src/job-manager.c b/src/job-manager.c
index 453bb19..5dd5f8c 100644
--- a/src/job-manager.c
+++ b/src/job-manager.c
@@ -51,6 +51,7 @@ typedef struct {
gboolean gen_done;
int index; /* processed image index */
int real_index; /* absolute index in the list */
+ gboolean gen_portrait;
} TJobItem;
@@ -138,7 +139,7 @@ thread_func (gpointer data)
/* actually do some work */
if (item != NULL && job_item != NULL) {
imgname = g_path_get_basename ((item->path == NULL && item->preview) ? item->preview : item->path);
- updated = generate_image (job->setup, job->items, item, job_item->real_index, job->dst_dir, ! job->force_update);
+ updated = generate_image (job->setup, job->items, item, job_item->real_index, job->dst_dir, ! job->force_update, &job_item->gen_portrait);
if (updated && job->setup->verbose) {
G_LOCK (items_print);
@@ -198,6 +199,7 @@ build_tree (TGallerySetup *setup,
gboolean force_update;
TJobItem *job_item;
GList *job_items;
+ GList *l;
printf ("Processing directory \"%s\"\n", src_tree);
stats_dirs_inc ();
@@ -319,6 +321,7 @@ build_tree (TGallerySetup *setup,
job_item->gen_done = FALSE;
job_item->index = job->total_items;
job_item->real_index = i;
+ job_item->gen_portrait = FALSE;
job_items = g_list_append (job_items, job_item);
}
}
@@ -342,7 +345,6 @@ build_tree (TGallerySetup *setup,
}
/* wait for threads are finished */
- GList *l;
for (l = thread_list; l != NULL; l = l->next) {
g_thread_join (l->data);
}
@@ -354,6 +356,12 @@ build_tree (TGallerySetup *setup,
#endif
g_free (job);
+ /* Copy runtime flags back to items, outside of threading */
+ for (l = job_items; l != NULL; l = l->next) {
+ job_item = l->data;
+ job_item->item->gen_portrait = job_item->gen_portrait;
+ }
+
/* Cleanup generator objects */
g_list_foreach (job_items, (GFunc) g_free, NULL);
g_list_free (job_items);