Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
image_cache.h File Reference
#include "caches/cache.h"
#include "common/image.h"
#include <sqlite3.h>
+ Include dependency graph for image_cache.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dt_image_cache_stats_entry_t
 

Typedefs

typedef struct dt_image_cache_t dt_image_cache_t
 
typedef enum dt_image_cache_write_mode_t dt_image_cache_write_mode_t
 
typedef struct dt_image_cache_stats_entry_t dt_image_cache_stats_entry_t
 

Enumerations

enum  dt_image_cache_write_mode_t {
  DT_IMAGE_CACHE_SAFE = 0 ,
  DT_IMAGE_CACHE_RELAXED = 1 ,
  DT_IMAGE_CACHE_MINIMAL = 2
}
 

Functions

void dt_image_cache_init (const gboolean verbose)
 Initialise the cache.
 
void dt_image_cache_cleanup (void)
 
void dt_image_cache_print (void)
 
gboolean dt_image_cache_is_ready (void)
 Has the image cache been initialised? Callers that run before dt_image_cache_init() or after its cleanup – early startup, late teardown – ask this instead of testing a handle they should not have.
 
void dt_image_cache_get_usage (size_t *current, size_t *max)
 
GArray * dt_image_cache_get_entries_stats (void)
 
dt_image_tdt_image_cache_get (const int32_t imgid, char mode)
 
dt_image_tdt_image_cache_testget (const int32_t imgid, char mode)
 
dt_image_tdt_image_cache_get_existing (const int32_t imgid, char mode)
 
dt_image_tdt_image_cache_get_reload (const int32_t imgid, char mode)
 
int dt_image_cache_seed (const dt_image_t *img)
 
void dt_image_derive_fields (dt_image_t *img)
 Compute the fields the database does not store: rating, monochrome and HDR predicates, makermodel, and the extension cross-check that logs stale stored flags.
 
void dt_image_cache_connect_info_changed_first (const struct dt_control_signal_t *ctlsig)
 
void dt_image_cache_read_release (const dt_image_t *img)
 
void dt_image_cache_write_release (dt_image_t *img, dt_image_cache_write_mode_t mode)
 
void dt_image_cache_remove (const int32_t imgid)
 
void dt_image_cache_set_export_timestamp (const int32_t imgid)
 
void dt_image_cache_set_print_timestamp (const int32_t imgid)
 
int dt_image_invalid (const dt_image_t *img)
 

Typedef Documentation

◆ dt_image_cache_stats_entry_t

◆ dt_image_cache_t

Definition at line 41 of file image_cache.h.

◆ dt_image_cache_write_mode_t

Enumeration Type Documentation

◆ dt_image_cache_write_mode_t

Enumerator
DT_IMAGE_CACHE_SAFE 
DT_IMAGE_CACHE_RELAXED 
DT_IMAGE_CACHE_MINIMAL 

Definition at line 45 of file image_cache.h.

Function Documentation

◆ dt_image_cache_cleanup()

void dt_image_cache_cleanup ( void  )

◆ dt_image_cache_connect_info_changed_first()

void dt_image_cache_connect_info_changed_first ( const struct dt_control_signal_t ctlsig)

◆ dt_image_cache_get()

dt_image_t * dt_image_cache_get ( const int32_t  imgid,
char  mode 
)

Definition at line 337 of file image_cache.c.

References _image_cache, _image_cache_lock_init(), ASAN_UNPOISON_MEMORY_REGION, dt_image_cache_t::cache, dt_image_t::cache_entry, dt_cache_entry_t::data, dt_cache_get, dt_cache_release, and dt_image_invalid().

Referenced by _add_thumbnail_at_rowid(), _build_embedded_profile(), _colorlabels_execute(), _deflicker_prepare_histogram(), _dt_dev_refresh_image_storage(), _ensure_has_txt_flag(), _exif_xmp_append_history_hash(), _expand_image_and_version(), _generate_blocking(), _get_image_copy(), _history_load_and_apply_apply(), _history_snapshot_undo_restore(), _hold_entry(), _image_duplicate_with_version(), _image_has_txt_flag(), _image_import_internal(), _image_remove(), _image_set_monochrome_flag(), _init_8(), _init_expansion(), _init_f(), _jump_to(), _own_gainmaps(), _pop_undo_execute(), _print_button_clicked(), _ratings_apply_to_image(), _refresh_selected_images_datetime(), _remove_preset_flag(), _set_datetime(), _set_location(), _setup_selected_images_list(), _view_image_get_surface_internal(), _write_history_from_state(), _write_mipmap_to_disk(), check_gain_maps(), dt_colorspaces_get_input_profile_from_image(), dt_control_export_job_run(), dt_control_gpx_apply_job_run(), dt_control_merge_hdr_process(), dt_control_refresh_exif_run(), dt_dev_history_commit_item_now(), dt_dev_load_image(), dt_dev_merge_history_into_image(), dt_dev_read_history_ext(), dt_exif_read_blob(), dt_focus_draw_clusters(), dt_grouping_add_grouped_images(), dt_grouping_add_to_group(), dt_grouping_change_representative(), dt_grouping_get_group_images(), dt_grouping_get_image_group(), dt_grouping_remove_from_group(), dt_image_cache_get_existing(), dt_image_cache_set_export_timestamp(), dt_image_cache_set_print_timestamp(), dt_image_find_best_color_profile(), dt_image_full_path(), dt_image_get_datetime(), dt_image_get_location(), dt_image_get_orientation(), dt_image_local_copy_reset(), dt_image_local_copy_set(), dt_image_read_duplicates(), dt_image_rename(), dt_image_resolve_usercrop(), dt_image_write_sidecar_file(), dt_image_write_sidecar_file_forced(), dt_mipmap_cache_allocate_dynamic(), dt_preview_window_spawn(), dt_ratings_get(), dt_thumbtable_info_debug_assert_matches_cache(), finalize_store(), gui_changed(), image_set_rawcrops(), load_xmp_callback(), main(), test_cached_entry_overwrites_a_row_written_behind_it(), test_crawl_corrects_an_entry_the_row_already_agrees_with(), test_crawl_keeps_a_cached_entry_in_step(), test_crawl_waits_for_a_held_entry(), test_editing_the_entry_survives_the_next_rating(), try_enter(), update_preview_cb(), update_profile_list(), and write_image().

◆ dt_image_cache_get_entries_stats()

◆ dt_image_cache_get_existing()

dt_image_t * dt_image_cache_get_existing ( const int32_t  imgid,
char  mode 
)

Definition at line 379 of file image_cache.c.

References _image_cache, dt_image_cache_t::cache, dt_cache_contains(), and dt_image_cache_get().

Referenced by _crawl_image().

◆ dt_image_cache_get_reload()

◆ dt_image_cache_get_usage()

void dt_image_cache_get_usage ( size_t *  current,
size_t *  max 
)

◆ dt_image_cache_init()

void dt_image_cache_init ( const gboolean  verbose)

Initialise the cache.

Parameters
verbosewhether this cache traces to the log. Read ONCE, here, from the session's debug flags by the orchestrator – the cache does not consult them itself, so it neither depends on the debug machinery at runtime nor changes behaviour halfway through a session. -d cache still works: darktable.c turns it into this argument.
Todo:
: actually an independent conf var?

Definition at line 257 of file image_cache.c.

References _cache_print, _image_cache, _verbose, dt_image_cache_t::cache, dt_cache_init(), dt_cache_set_allocate_callback(), dt_cache_set_cleanup_callback(), DT_DEBUG_CACHE, dt_image_cache_allocate(), dt_image_cache_deallocate(), IS_NULL_PTR, and size.

Referenced by cache_setup(), and dt_init().

◆ dt_image_cache_is_ready()

gboolean dt_image_cache_is_ready ( void  )

Has the image cache been initialised? Callers that run before dt_image_cache_init() or after its cleanup – early startup, late teardown – ask this instead of testing a handle they should not have.

Definition at line 83 of file image_cache.c.

References _image_cache, and IS_NULL_PTR.

Referenced by dt_dev_ensure_image_storage(), dt_image_resolve_usercrop(), dt_ioppr_get_iop_order_list(), dt_ioppr_get_iop_order_version(), and dt_thumbtable_info_seed_image_cache().

◆ dt_image_cache_print()

void dt_image_cache_print ( void  )

◆ dt_image_cache_read_release()

void dt_image_cache_read_release ( const dt_image_t img)

Definition at line 474 of file image_cache.c.

References _image_cache, _image_cache_self_hash(), dt_image_cache_t::cache, dt_image_t::cache_entry, dt_cache_release, dt_image_invalid(), dt_image_t::id, IS_NULL_PTR, and dt_image_t::self_hash.

Referenced by _add_thumbnail_at_rowid(), _colorlabels_execute(), _deflicker_prepare_histogram(), _dt_dev_refresh_image_storage(), _dt_image_info_changed_callback(), _exif_xmp_append_history_hash(), _expand_image_and_version(), _get_image_copy(), _image_cache_info_changed_reload_callback(), _image_duplicate_with_version(), _image_has_txt_flag(), _image_remove(), _image_set_monochrome_flag(), _init_8(), _init_expansion(), _init_f(), _jump_to(), _own_gainmaps(), _print_button_clicked(), _refresh_selected_images_datetime(), _setup_selected_images_list(), _view_image_get_surface_internal(), _write_mipmap_to_disk(), check_gain_maps(), dt_colorspaces_get_input_profile_from_image(), dt_control_export_job_run(), dt_control_gpx_apply_job_run(), dt_control_merge_hdr_process(), dt_dev_read_history_ext(), dt_exif_read_blob(), dt_focus_draw_clusters(), dt_grouping_add_grouped_images(), dt_grouping_change_representative(), dt_grouping_get_group_images(), dt_grouping_get_image_group(), dt_grouping_remove_from_group(), dt_image_full_path(), dt_image_get_datetime(), dt_image_get_location(), dt_image_get_orientation(), dt_image_local_copy_reset(), dt_image_local_copy_set(), dt_image_read_duplicates(), dt_image_rename(), dt_image_resolve_usercrop(), dt_ioppr_get_iop_order_list(), dt_ioppr_get_iop_order_version(), dt_mipmap_cache_allocate_dynamic(), dt_preview_window_spawn(), dt_ratings_get(), dt_thumbtable_info_debug_assert_matches_cache(), finalize_store(), image_set_rawcrops(), load_xmp_callback(), main(), test_cached_entry_overwrites_a_row_written_behind_it(), test_crawl_corrects_an_entry_the_row_already_agrees_with(), test_crawl_keeps_a_cached_entry_in_step(), test_crawl_waits_for_a_held_entry(), test_editing_the_entry_survives_the_next_rating(), try_enter(), update_preview_cb(), and update_profile_list().

◆ dt_image_cache_remove()

void dt_image_cache_remove ( const int32_t  imgid)

Definition at line 589 of file image_cache.c.

References _image_cache, dt_image_cache_t::cache, and dt_cache_remove().

Referenced by _image_remove(), and dt_film_remove().

◆ dt_image_cache_seed()

◆ dt_image_cache_set_export_timestamp()

void dt_image_cache_set_export_timestamp ( const int32_t  imgid)

◆ dt_image_cache_set_print_timestamp()

void dt_image_cache_set_print_timestamp ( const int32_t  imgid)

◆ dt_image_cache_testget()

◆ dt_image_cache_write_release()

void dt_image_cache_write_release ( dt_image_t img,
dt_image_cache_write_mode_t  mode 
)
Todo:
: that a memory leak ?

Definition at line 499 of file image_cache.c.

References _image_cache, _image_cache_self_hash(), dt_image_cache_t::cache, dt_image_t::cache_entry, dt_image_t::change_timestamp, dt_image_t::datetime, dt_cache_release, dt_control_save_xmp(), dt_control_signal_get_global(), dt_datetime_gtimespan_to_local(), dt_datetime_now_to_gtimespan(), DT_DEBUG_CONTROL_SIGNAL_RAISE, dt_free, DT_IMAGE_CACHE_MINIMAL, DT_IMAGE_CACHE_SAFE, dt_image_film_roll_name(), dt_image_get_xmp_mode(), dt_image_get_xmp_rating_from_flags(), DT_IMAGE_HAS_WAV, dt_image_invalid(), dt_image_is_hdr(), DT_IMAGE_LOCAL_COPY, dt_image_local_copy_paths_from_fullpath(), dt_image_monochrome_flags(), dt_image_repository_store(), dt_image_use_monochrome_workflow(), DT_PATH_MAX, DT_SIGNAL_IMAGE_INFO_CHANGED, DT_VIEW_REJECT, dt_image_t::exif_datetime_taken, FALSE, dt_image_t::filename, dt_image_t::film_id, dt_image_t::filmroll, dt_image_t::flags, dt_image_t::folder, folder, dt_image_t::fullpath, dt_image_t::has_audio, dt_image_t::has_localcopy, dt_image_t::id, dt_image_t::is_bw, dt_image_t::is_bw_flow, dt_image_t::is_hdr, IS_NULL_PTR, dt_image_t::local_copy_legacy_path, dt_image_t::local_copy_path, dt_image_t::rating, and dt_image_t::self_hash.

Referenced by _build_embedded_profile(), _colorlabels_execute(), _crawl_image(), _ensure_has_txt_flag(), _generate_blocking(), _history_load_and_apply_apply(), _history_snapshot_undo_restore(), _hold_entry(), _image_import_internal(), _image_set_monochrome_flag(), _pop_undo_execute(), _ratings_apply_to_image(), _remove_preset_flag(), _set_datetime(), _set_location(), _write_history_from_state(), dt_control_refresh_exif_run(), dt_dev_history_commit_item_now(), dt_dev_load_image(), dt_dev_merge_history_into_image(), dt_grouping_add_to_group(), dt_grouping_change_representative(), dt_grouping_remove_from_group(), dt_image_cache_set_export_timestamp(), dt_image_cache_set_print_timestamp(), dt_image_find_best_color_profile(), dt_image_history_changed(), dt_image_local_copy_reset(), dt_image_local_copy_set(), dt_image_read_duplicates(), dt_image_rename(), dt_image_resolve_usercrop(), dt_image_write_sidecar_file(), dt_image_write_sidecar_file_forced(), gui_changed(), image_set_rawcrops(), main(), test_cached_entry_overwrites_a_row_written_behind_it(), test_crawl_corrects_an_entry_the_row_already_agrees_with(), test_crawl_keeps_a_cached_entry_in_step(), test_editing_the_entry_survives_the_next_rating(), and write_image().

◆ dt_image_derive_fields()

void dt_image_derive_fields ( dt_image_t img)

Compute the fields the database does not store: rating, monochrome and HDR predicates, makermodel, and the extension cross-check that logs stale stored flags.

Call this on any dt_image_t freshly filled from a database row – dt_image_repository_load() does it for its own callers, and gui/dtgtk/thumbtable.c must do it after dt_image_from_stmt() on each row of its bulk query. Skipping it leaves rating, is_bw, is_hdr and exif_makermodel stale from whatever the struct held before.

Parameters
imgimage to complete, in place. NULL is a no-op.

Definition at line 180 of file image_cache.c.

References _cache_print, DT_DEBUG_IMAGEIO, dt_image_flags_from_extension(), dt_image_get_xmp_rating_from_flags(), DT_IMAGE_HAS_WAV, DT_IMAGE_HDR, dt_image_is_hdr(), DT_IMAGE_LDR, DT_IMAGE_LOCAL_COPY, dt_image_monochrome_flags(), DT_IMAGE_RAW, dt_image_refresh_makermodel(), dt_image_use_monochrome_workflow(), DT_VIEW_REJECT, dt_image_t::filename, dt_image_t::flags, dt_image_t::has_audio, dt_image_t::has_localcopy, dt_image_t::id, dt_image_t::is_bw, dt_image_t::is_bw_flow, dt_image_t::is_hdr, IS_NULL_PTR, and dt_image_t::rating.

Referenced by _collection_lut_row(), and _image_cache_reload_from_db().

◆ dt_image_invalid()