mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Don't load images too often
Factor out image load to find timestamp from loop over dives. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
a0a3c6ec15
commit
98ae7b1f86
2 changed files with 11 additions and 11 deletions
20
dive.c
20
dive.c
|
@ -2885,9 +2885,8 @@ static bool new_picture_for_dive(struct dive *d, char *filename)
|
||||||
// only add pictures that have timestamps between 30 minutes before the dive and
|
// only add pictures that have timestamps between 30 minutes before the dive and
|
||||||
// 30 minutes after the dive ends
|
// 30 minutes after the dive ends
|
||||||
#define D30MIN (30 * 60)
|
#define D30MIN (30 * 60)
|
||||||
bool dive_check_picture_time(struct dive *d, char *filename, int shift_time)
|
bool dive_check_picture_time(struct dive *d, char *filename, int shift_time, timestamp_t timestamp)
|
||||||
{
|
{
|
||||||
timestamp_t timestamp = picture_get_timestamp(filename);
|
|
||||||
offset_t offset;
|
offset_t offset;
|
||||||
if (timestamp) {
|
if (timestamp) {
|
||||||
offset.seconds = timestamp - d->when + shift_time;
|
offset.seconds = timestamp - d->when + shift_time;
|
||||||
|
@ -2901,26 +2900,27 @@ bool dive_check_picture_time(struct dive *d, char *filename, int shift_time)
|
||||||
|
|
||||||
bool picture_check_valid(char *filename, int shift_time)
|
bool picture_check_valid(char *filename, int shift_time)
|
||||||
{
|
{
|
||||||
bool result = false;
|
|
||||||
int i;
|
int i;
|
||||||
struct dive *d;
|
struct dive *dive;
|
||||||
|
|
||||||
for_each_dive (i, d)
|
timestamp_t timestamp = picture_get_timestamp(filename);
|
||||||
if (d->selected)
|
for_each_dive (i, dive)
|
||||||
result = result || dive_check_picture_time(d, filename, shift_time);
|
if (dive->selected && dive_check_picture_time(dive, filename, shift_time, timestamp))
|
||||||
return result;
|
return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dive_create_picture(struct dive *dive, char *filename, int shift_time)
|
void dive_create_picture(struct dive *dive, char *filename, int shift_time)
|
||||||
{
|
{
|
||||||
|
timestamp_t timestamp = picture_get_timestamp(filename);
|
||||||
if (!new_picture_for_dive(dive, filename))
|
if (!new_picture_for_dive(dive, filename))
|
||||||
return;
|
return;
|
||||||
if (!dive_check_picture_time(dive, filename, shift_time))
|
if (!dive_check_picture_time(dive, filename, shift_time, timestamp))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
struct picture *picture = alloc_picture();
|
struct picture *picture = alloc_picture();
|
||||||
picture->filename = filename;
|
picture->filename = filename;
|
||||||
picture->offset.seconds = picture_get_timestamp(filename) - dive->when + shift_time;
|
picture->offset.seconds = timestamp - dive->when + shift_time;
|
||||||
picture_load_exif_data(picture);
|
picture_load_exif_data(picture);
|
||||||
|
|
||||||
dive_add_picture(dive, picture);
|
dive_add_picture(dive, picture);
|
||||||
|
|
2
dive.h
2
dive.h
|
@ -383,7 +383,7 @@ struct picture {
|
||||||
for (struct picture *picture = (_divestruct).picture_list; picture; picture = picture->next)
|
for (struct picture *picture = (_divestruct).picture_list; picture; picture = picture->next)
|
||||||
|
|
||||||
extern struct picture *alloc_picture();
|
extern struct picture *alloc_picture();
|
||||||
extern bool dive_check_picture_time(struct dive *d, char *filename, int shift_time);
|
extern bool dive_check_picture_time(struct dive *d, char *filename, int shift_time, timestamp_t timestamp);
|
||||||
extern void dive_create_picture(struct dive *d, char *filename, int shift_time);
|
extern void dive_create_picture(struct dive *d, char *filename, int shift_time);
|
||||||
extern void dive_add_picture(struct dive *d, struct picture *newpic);
|
extern void dive_add_picture(struct dive *d, struct picture *newpic);
|
||||||
extern void dive_remove_picture(char *filename);
|
extern void dive_remove_picture(char *filename);
|
||||||
|
|
Loading…
Reference in a new issue