Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
thumbtable_info.c
Go to the documentation of this file.
1/*
2 This file is part of the Ansel project.
3 Copyright (C) 2026 Aurélien PIERRE.
4
5 Ansel is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Ansel is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Ansel. If not, see <http://www.gnu.org/licenses/>.
17*/
18
20
21#include "common/image.h"
22#include "caches/image_cache.h"
23#include "system/macros.h"
24
25#include <glib.h>
26#include <glib/gi18n.h>
27#include <string.h>
28
29void dt_thumbtable_copy_image(dt_image_t *info, const dt_image_t *const img)
30{
31 if(IS_NULL_PTR(info) || IS_NULL_PTR(img)) return;
32
33 memcpy(info, img, sizeof(dt_image_t));
34}
35
37{
38 if(IS_NULL_PTR(info) || info->id <= 0) return;
39
40 if(!dt_image_cache_is_ready()) return;
41
43}
44
45
46#ifndef NDEBUG
47static gboolean _thumbtable_float_equal(const float a, const float b)
48{
49 return (isnan(a) && isnan(b)) || a == b;
50}
51
52static gboolean _thumbtable_double_equal(const double a, const double b)
53{
54 return (isnan(a) && isnan(b)) || a == b;
55}
56
58{
59 if(IS_NULL_PTR(sql_info) || sql_info->id <= 0) return;
60
61 const dt_image_t *img = dt_image_cache_get(sql_info->id, 'r');
62 if(IS_NULL_PTR(img)) return;
63
64 dt_image_t cache_info = {0};
65 dt_thumbtable_copy_image(&cache_info, img);
67
68 g_assert_cmpint(sql_info->id, ==, cache_info.id);
69 g_assert_cmpint(sql_info->film_id, ==, cache_info.film_id);
70 g_assert_cmpint(sql_info->group_id, ==, cache_info.group_id);
71 g_assert_cmpint(sql_info->group_members, ==, cache_info.group_members);
72 g_assert_cmpint(sql_info->history_items, ==, cache_info.history_items);
73 g_assert_cmpint(sql_info->version, ==, cache_info.version);
74 g_assert_cmpint(sql_info->width, ==, cache_info.width);
75 g_assert_cmpint(sql_info->height, ==, cache_info.height);
76 g_assert_cmpint(sql_info->orientation, ==, cache_info.orientation);
77 g_assert_cmpint(sql_info->p_width, ==, cache_info.p_width);
78 g_assert_cmpint(sql_info->p_height, ==, cache_info.p_height);
79 g_assert_cmpint(sql_info->flags, ==, cache_info.flags);
80 g_assert_cmpint(sql_info->loader, ==, cache_info.loader);
81 g_assert_cmpint(sql_info->rating, ==, cache_info.rating);
82 g_assert_cmpint(sql_info->color_labels, ==, cache_info.color_labels);
83 g_assert(sql_info->has_localcopy == cache_info.has_localcopy);
84 g_assert(sql_info->has_audio == cache_info.has_audio);
85 g_assert(sql_info->is_bw == cache_info.is_bw);
86 g_assert(sql_info->is_bw_flow == cache_info.is_bw_flow);
87 g_assert(sql_info->is_hdr == cache_info.is_hdr);
88 g_assert((int64_t)sql_info->import_timestamp == (int64_t)cache_info.import_timestamp);
89 g_assert((int64_t)sql_info->change_timestamp == (int64_t)cache_info.change_timestamp);
90 g_assert((int64_t)sql_info->export_timestamp == (int64_t)cache_info.export_timestamp);
91 g_assert((int64_t)sql_info->print_timestamp == (int64_t)cache_info.print_timestamp);
92 g_assert(_thumbtable_float_equal(sql_info->exif_exposure, cache_info.exif_exposure));
93 g_assert(_thumbtable_float_equal(sql_info->exif_exposure_bias, cache_info.exif_exposure_bias));
94 g_assert(_thumbtable_float_equal(sql_info->exif_aperture, cache_info.exif_aperture));
95 g_assert(_thumbtable_float_equal(sql_info->exif_iso, cache_info.exif_iso));
96 g_assert(_thumbtable_float_equal(sql_info->exif_focal_length, cache_info.exif_focal_length));
98 g_assert((int64_t)sql_info->exif_datetime_taken == (int64_t)cache_info.exif_datetime_taken);
99 g_assert(_thumbtable_double_equal(sql_info->geoloc.latitude, cache_info.geoloc.latitude));
100 g_assert(_thumbtable_double_equal(sql_info->geoloc.longitude, cache_info.geoloc.longitude));
101 g_assert(_thumbtable_double_equal(sql_info->geoloc.elevation, cache_info.geoloc.elevation));
102 g_assert_cmpstr(sql_info->filename, ==, cache_info.filename);
103 g_assert_cmpstr(sql_info->fullpath, ==, cache_info.fullpath);
104 g_assert_cmpstr(sql_info->local_copy_path, ==, cache_info.local_copy_path);
105 g_assert_cmpstr(sql_info->local_copy_legacy_path, ==, cache_info.local_copy_legacy_path);
106 g_assert_cmpstr(sql_info->filmroll, ==, cache_info.filmroll);
107 g_assert_cmpstr(sql_info->folder, ==, cache_info.folder);
108 g_assert_cmpstr(sql_info->datetime, ==, cache_info.datetime);
109 g_assert_cmpstr(sql_info->camera_makermodel, ==, cache_info.camera_makermodel);
110 g_assert_cmpstr(sql_info->exif_maker, ==, cache_info.exif_maker);
111 g_assert_cmpstr(sql_info->exif_model, ==, cache_info.exif_model);
112 g_assert_cmpstr(sql_info->exif_lens, ==, cache_info.exif_lens);
113}
114#endif
115
116// clang-format off
117// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
118// vim: shiftwidth=2 expandtab tabstop=2 cindent
119// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
120// clang-format on
gboolean dt_image_cache_is_ready(void)
Has the image cache been initialised? Callers that run before dt_image_cache_init() or after its clea...
Definition image_cache.c:83
dt_image_t * dt_image_cache_get(const int32_t imgid, char mode)
int dt_image_cache_seed(const dt_image_t *img)
void dt_image_cache_read_release(const dt_image_t *img)
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
Definition macros.h:96
double latitude
Definition image.h:332
double elevation
Definition image.h:332
double longitude
Definition image.h:332
gboolean has_audio
Definition image.h:476
gboolean is_hdr
Definition image.h:479
float exif_exposure
Definition image.h:367
int32_t height
Definition image.h:397
GTimeSpan export_timestamp
Definition image.h:415
float exif_focus_distance
Definition image.h:372
GTimeSpan import_timestamp
Definition image.h:415
gboolean is_bw
Definition image.h:477
int32_t group_id
Definition image.h:401
char camera_makermodel[128]
Definition image.h:382
float exif_exposure_bias
Definition image.h:368
float exif_iso
Definition image.h:370
dt_image_loader_t loader
Definition image.h:417
float exif_aperture
Definition image.h:369
char local_copy_path[DT_PATH_MAX]
Definition image.h:388
int32_t version
Definition image.h:401
dt_image_geoloc_t geoloc
Definition image.h:434
int32_t flags
Definition image.h:401
dt_image_orientation_t orientation
Definition image.h:366
int32_t width
Definition image.h:397
float exif_focal_length
Definition image.h:371
char exif_maker[64]
Definition image.h:374
GTimeSpan change_timestamp
Definition image.h:415
uint32_t history_items
Definition image.h:403
int rating
Definition image.h:473
gboolean has_localcopy
Definition image.h:475
char exif_lens[128]
Definition image.h:376
GTimeSpan print_timestamp
Definition image.h:415
int32_t film_id
Definition image.h:401
char folder[DT_PATH_MAX]
Definition image.h:390
GTimeSpan exif_datetime_taken
Definition image.h:377
int color_labels
Definition image.h:472
int32_t p_height
Definition image.h:397
int32_t p_width
Definition image.h:397
char filmroll[DT_PATH_MAX]
Definition image.h:391
char exif_model[64]
Definition image.h:375
char datetime[200]
Definition image.h:392
uint32_t group_members
Definition image.h:402
char local_copy_legacy_path[DT_PATH_MAX]
Definition image.h:389
char filename[DT_MAX_FILENAME_LEN]
Definition image.h:386
int32_t id
Definition image.h:401
char fullpath[DT_PATH_MAX]
Definition image.h:387
gboolean is_bw_flow
Definition image.h:478
void dt_thumbtable_copy_image(dt_image_t *info, const dt_image_t *const img)
static gboolean _thumbtable_double_equal(const double a, const double b)
void dt_thumbtable_info_debug_assert_matches_cache(const dt_image_t *sql_info)
void dt_thumbtable_info_seed_image_cache(const dt_image_t *info)
static gboolean _thumbtable_float_equal(const float a, const float b)