![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
#include "system/atomic.h"#include "common/paths.h"#include "caches/cache.h"#include "colorprofiles/profile_types.h"#include "common/image.h"
Include dependency graph for mipmap_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_mipmap_buffer_t |
| struct | dt_mipmap_cache_settings_t |
| Everything about the mipmap cache that the USER decides. More... | |
| struct | dt_mipmap_cache_stats_entry_t |
Macros | |
| #define | dt_mipmap_cache_get(B, C, D, E, F) dt_mipmap_cache_get_with_caller(B,C,D,E,F,__FILE__,__LINE__) |
| #define | dt_mipmap_cache_get_with_shutdown(B, C, D, E, F, G) dt_mipmap_cache_get_with_caller_and_shutdown(B,C,D,E,F,G,__FILE__,__LINE__) |
| #define | dt_mipmap_cache_write_get(B, C, D) dt_mipmap_cache_write_get_with_caller(B,C,D,__FILE__,__LINE__) |
| #define | dt_mipmap_cache_release(B) dt_mipmap_cache_release_with_caller(B, __FILE__, __LINE__) |
Typedefs | |
| typedef enum dt_mipmap_size_t | dt_mipmap_size_t |
| typedef enum dt_mipmap_get_flags_t | dt_mipmap_get_flags_t |
| typedef struct dt_mipmap_buffer_t | dt_mipmap_buffer_t |
| typedef struct dt_mipmap_cache_one_t | dt_mipmap_cache_one_t |
| typedef struct dt_mipmap_cache_t | dt_mipmap_cache_t |
| typedef struct dt_mipmap_cache_settings_t | dt_mipmap_cache_settings_t |
| Everything about the mipmap cache that the USER decides. | |
| typedef struct dt_mipmap_cache_stats_entry_t | dt_mipmap_cache_stats_entry_t |
Enumerations | |
| enum | dt_mipmap_size_t { DT_MIPMAP_0 , DT_MIPMAP_1 , DT_MIPMAP_2 , DT_MIPMAP_3 , DT_MIPMAP_4 , DT_MIPMAP_5 , DT_MIPMAP_6 , DT_MIPMAP_7 , DT_MIPMAP_8 , DT_MIPMAP_F , DT_MIPMAP_FULL , DT_MIPMAP_NONE } |
| enum | dt_mipmap_get_flags_t { DT_MIPMAP_BLOCKING = 0 , DT_MIPMAP_TESTLOCK = 1 } |
Functions | |
| void * | dt_mipmap_cache_alloc (dt_mipmap_buffer_t *buf, const dt_image_t *img) |
| void | dt_mipmap_cache_set_settings (const dt_mipmap_cache_settings_t *settings) |
| Apply new settings to a running cache. | |
| void | dt_mipmap_cache_get_settings (dt_mipmap_cache_settings_t *settings) |
| Read back the settings in force. Snapshot, taken under the same lock the setter takes, so the four fields are always consistent with each other. | |
| void | dt_mipmap_cache_init (const dt_mipmap_cache_settings_t *settings, const gboolean verbose) |
| Initialise the cache. | |
| void | dt_mipmap_cache_cleanup (void) |
| void | dt_mipmap_cache_print (void) |
| void | dt_mipmap_cache_get_usage (size_t *current, size_t *max) |
| GArray * | dt_mipmap_cache_get_entries_stats (void) |
| void | dt_mipmap_cache_get_with_caller (dt_mipmap_buffer_t *buf, const int32_t imgid, const dt_mipmap_size_t mip, const dt_mipmap_get_flags_t flags, const char mode, const char *file, int line) |
| void | dt_mipmap_cache_get_with_caller_and_shutdown (dt_mipmap_buffer_t *buf, const int32_t imgid, const dt_mipmap_size_t mip, const dt_mipmap_get_flags_t flags, const char mode, dt_atomic_int *shutdown, const char *file, int line) |
| void | dt_mipmap_cache_write_get_with_caller (dt_mipmap_buffer_t *buf, const int32_t imgid, const int mip, const char *file, int line) |
| void | dt_mipmap_cache_release_with_caller (dt_mipmap_buffer_t *buf, const char *file, int line) |
| void | dt_mipmap_cache_remove (const int32_t imgid, const gboolean flush_disk) |
| void | dt_mipmap_cache_remove_at_size (const int32_t imgid, const dt_mipmap_size_t mip, const gboolean flush_disk) |
| void | dt_mipmap_cache_remove_all_sizes (const int32_t imgid, const gboolean flush_disk) |
| void | dt_mimap_cache_evict (const int32_t imgid) |
| dt_mipmap_size_t | dt_mipmap_cache_get_matching_size (const int32_t width, const int32_t height, const uint32_t imgid) |
| dt_mipmap_size_t | dt_mipmap_cache_get_fitting_size (const int32_t width, const int32_t height, const uint32_t imgid) |
| void | dt_mipmap_cache_swap_at_size (const int32_t imgid, const dt_mipmap_size_t mip, const uint8_t *const buffer, const int32_t width, const int32_t height, dt_colorspaces_color_profile_type_t profile) |
| void | dt_mipmap_cache_copy_thumbnails (const uint32_t dst_imgid, const uint32_t src_imgid) |
| void | dt_mipmap_get_cache_filename (char path[DT_PATH_MAX], dt_mipmap_size_t mip, const int32_t imgid) |
| void | dt_mipmap_get_cache_dir (char path[DT_PATH_MAX], dt_mipmap_size_t mip) |
| #define dt_mipmap_cache_get | ( | B, | |
| C, | |||
| D, | |||
| E, | |||
| F | |||
| ) | dt_mipmap_cache_get_with_caller(B,C,D,E,F,__FILE__,__LINE__) |
Definition at line 166 of file mipmap_cache.h.
| #define dt_mipmap_cache_get_with_shutdown | ( | B, | |
| C, | |||
| D, | |||
| E, | |||
| F, | |||
| G | |||
| ) | dt_mipmap_cache_get_with_caller_and_shutdown(B,C,D,E,F,G,__FILE__,__LINE__) |
Definition at line 176 of file mipmap_cache.h.
| #define dt_mipmap_cache_release | ( | B | ) | dt_mipmap_cache_release_with_caller(B, __FILE__, __LINE__) |
Definition at line 198 of file mipmap_cache.h.
| #define dt_mipmap_cache_write_get | ( | B, | |
| C, | |||
| D | |||
| ) | dt_mipmap_cache_write_get_with_caller(B,C,D,__FILE__,__LINE__) |
Definition at line 189 of file mipmap_cache.h.
| typedef struct dt_mipmap_buffer_t dt_mipmap_buffer_t |
| typedef struct dt_mipmap_cache_one_t dt_mipmap_cache_one_t |
Definition at line 81 of file mipmap_cache.h.
| typedef struct dt_mipmap_cache_settings_t dt_mipmap_cache_settings_t |
Everything about the mipmap cache that the USER decides.
These four were read from conf at the point of use, so the cache depended on the configuration system and its behaviour could change under it mid-decode. They cross the boundary as one value now: the application reads conf, the cache is told. That also makes the lifecycle visible – set once at startup, set again when the user changes a preference, and never anywhere else.
| typedef struct dt_mipmap_cache_stats_entry_t dt_mipmap_cache_stats_entry_t |
| typedef struct dt_mipmap_cache_t dt_mipmap_cache_t |
Definition at line 86 of file mipmap_cache.h.
| typedef enum dt_mipmap_get_flags_t dt_mipmap_get_flags_t |
| typedef enum dt_mipmap_size_t dt_mipmap_size_t |
| Enumerator | |
|---|---|
| DT_MIPMAP_BLOCKING | |
| DT_MIPMAP_TESTLOCK | |
Definition at line 59 of file mipmap_cache.h.
| enum dt_mipmap_size_t |
| Enumerator | |
|---|---|
| DT_MIPMAP_0 | |
| DT_MIPMAP_1 | |
| DT_MIPMAP_2 | |
| DT_MIPMAP_3 | |
| DT_MIPMAP_4 | |
| DT_MIPMAP_5 | |
| DT_MIPMAP_6 | |
| DT_MIPMAP_7 | |
| DT_MIPMAP_8 | |
| DT_MIPMAP_F | |
| DT_MIPMAP_FULL | |
| DT_MIPMAP_NONE | |
Definition at line 43 of file mipmap_cache.h.
| void dt_mimap_cache_evict | ( | const int32_t | imgid | ) |
Definition at line 1359 of file mipmap_cache.c.
References _get_cache(), _mipmap_cache, dt_cache_remove(), DT_MIPMAP_0, DT_MIPMAP_F, get_key(), and k.
Referenced by _generate_one(), _prerender_job(), and preload_image_cache().
| void * dt_mipmap_cache_alloc | ( | dt_mipmap_buffer_t * | buf, |
| const dt_image_t * | img | ||
| ) |
Definition at line 512 of file mipmap_cache.c.
References _get_buffer_from_dsc(), _get_entry_size(), ASAN_POISON_MEMORY_REGION, ASAN_UNPOISON_MEMORY_REGION, bpp, dt_iop_buffer_dsc_t::bpp, dt_mipmap_buffer_t::buf, dt_mipmap_buffer_t::cache_entry, dt_cache_entry_t::data, dt_cache_entry_t::data_size, dt_image_t::dsc, dt_alloc_align(), dt_free_align, dt_mipmap_cache_update_buffer_addresses(), DT_MIPMAP_FULL, dt_image_t::filename, dt_image_t::height, IS_NULL_PTR, MAX, dt_mipmap_buffer_dsc::size, dt_mipmap_buffer_t::size, and dt_image_t::width.
Referenced by dt_imageio_open_avif(), dt_imageio_open_exr(), dt_imageio_open_heif(), dt_imageio_open_j2k(), dt_imageio_open_jpeg(), dt_imageio_open_pfm(), dt_imageio_open_png(), dt_imageio_open_pnm(), dt_imageio_open_rawspeed(), dt_imageio_open_rawspeed_sraw(), dt_imageio_open_rgbe(), dt_imageio_open_tiff(), and dt_imageio_open_webp().
Definition at line 878 of file mipmap_cache.c.
References _mipmap_cache, dt_mipmap_cache_one_t::cache, dt_cache_cleanup(), dt_free, dt_mipmap_cache_print(), IS_NULL_PTR, dt_mipmap_cache_t::mip_f, dt_mipmap_cache_t::mip_full, and dt_mipmap_cache_t::mip_thumbs.
Referenced by dt_cleanup().
| void dt_mipmap_cache_copy_thumbnails | ( | const uint32_t | dst_imgid, |
| const uint32_t | src_imgid | ||
| ) |
Definition at line 1696 of file mipmap_cache.c.
References _mipmap_cache, _write_mipmap_to_disk(), dt_mipmap_cache_t::cachedir, DT_MIPMAP_0, DT_MIPMAP_F, dt_mipmap_get_cache_filename(), and DT_PATH_MAX.
Referenced by dt_image_copy_rename().
| GArray * dt_mipmap_cache_get_entries_stats | ( | void | ) |
Definition at line 977 of file mipmap_cache.c.
References _mipmap_cache, _mipmap_subcache_collect(), dt_mipmap_cache_one_t::cache, FALSE, IS_NULL_PTR, dt_mipmap_cache_t::mip_f, dt_mipmap_cache_t::mip_full, dt_mipmap_cache_t::mip_thumbs, and out.
Referenced by _rebuild_memory(), and dt_mipmap_cache_get_usage().
| dt_mipmap_size_t dt_mipmap_cache_get_fitting_size | ( | const int32_t | width, |
| const int32_t | height, | ||
| const uint32_t | imgid | ||
| ) |
Definition at line 1251 of file mipmap_cache.c.
References _cache_print, _mipmap_cache, DT_DEBUG_CACHE, DT_MIPMAP_0, DT_MIPMAP_F, height, k, dt_mipmap_cache_t::max_height, dt_mipmap_cache_t::max_width, and width.
Referenced by _preview_pipe_finished(), and dt_dev_resync_mipmap_cache().
| dt_mipmap_size_t dt_mipmap_cache_get_matching_size | ( | const int32_t | width, |
| const int32_t | height, | ||
| const uint32_t | imgid | ||
| ) |
Definition at line 1234 of file mipmap_cache.c.
References _cache_print, _mipmap_cache, DT_DEBUG_CACHE, DT_MIPMAP_0, DT_MIPMAP_F, height, k, dt_mipmap_cache_t::max_height, dt_mipmap_cache_t::max_width, and width.
Referenced by _view_image_get_surface_internal(), and preload_auto_callback().
| void dt_mipmap_cache_get_settings | ( | dt_mipmap_cache_settings_t * | settings | ) |
Read back the settings in force. Snapshot, taken under the same lock the setter takes, so the four fields are always consistent with each other.
Definition at line 160 of file mipmap_cache.c.
References _settings_get(), and IS_NULL_PTR.
| void dt_mipmap_cache_get_usage | ( | size_t * | current, |
| size_t * | max | ||
| ) |
Definition at line 959 of file mipmap_cache.c.
References _mipmap_cache, _settings_get(), dt_mipmap_cache_get_entries_stats(), entries, i, IS_NULL_PTR, max, dt_mipmap_cache_settings_t::max_memory, and TRUE.
Referenced by _rebuild_memory().
| void dt_mipmap_cache_get_with_caller | ( | dt_mipmap_buffer_t * | buf, |
| const int32_t | imgid, | ||
| const dt_mipmap_size_t | mip, | ||
| const dt_mipmap_get_flags_t | flags, | ||
| const char | mode, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Definition at line 1149 of file mipmap_cache.c.
References dt_mipmap_cache_get_with_caller_and_shutdown(), and flags.
Referenced by dt_mipmap_cache_write_get_with_caller().
| void dt_mipmap_cache_get_with_caller_and_shutdown | ( | dt_mipmap_buffer_t * | buf, |
| const int32_t | imgid, | ||
| const dt_mipmap_size_t | mip, | ||
| const dt_mipmap_get_flags_t | flags, | ||
| const char | mode, | ||
| dt_atomic_int * | shutdown, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Definition at line 1156 of file mipmap_cache.c.
References _generate_blocking(), _get_cache(), _get_dsc_from_entry(), _invalidate_buffer(), dt_cache_entry_t::_lock_demoting, _mipmap_cache, _validate_buffer(), dt_mipmap_buffer_t::cache_entry, dt_cache_get, dt_cache_get_with_caller(), dt_cache_release, dt_cache_testget(), DT_MIPMAP_0, DT_MIPMAP_BLOCKING, DT_MIPMAP_TESTLOCK, flags, get_key(), dt_mipmap_buffer_t::imgid, key, and dt_mipmap_buffer_t::size.
Referenced by dt_mipmap_cache_get_with_caller().
| void dt_mipmap_cache_init | ( | const dt_mipmap_cache_settings_t * | settings, |
| const gboolean | verbose | ||
| ) |
Initialise the cache.
| verbose | whether 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. |
| settings | the user's choices; see dt_mipmap_cache_settings_t. NULL uses zeroes, which is only sensible in a test. |
Definition at line 809 of file mipmap_cache.c.
References _get_entry_size(), _mipmap_cache, _settings_get(), _verbose, dt_mipmap_cache_t::buffer_size, dt_mipmap_cache_one_t::cache, dt_mipmap_cache_t::cachedir, dt_cache_init(), dt_cache_set_allocate_callback(), dt_cache_set_cleanup_callback(), DT_CTL_WORKER_RESERVED, DT_MIPMAP_2, dt_mipmap_cache_allocate_dynamic(), dt_mipmap_cache_deallocate_dynamic(), dt_mipmap_cache_get_filename(), dt_mipmap_cache_set_settings(), DT_MIPMAP_F, DT_MIPMAP_FULL, dt_worker_threads(), IS_NULL_PTR, k, dt_mipmap_cache_t::max_height, dt_mipmap_cache_t::max_width, dt_mipmap_cache_t::mip_f, dt_mipmap_cache_t::mip_full, dt_mipmap_cache_t::mip_thumbs, dt_mipmap_cache_one_t::stats_fetches, dt_mipmap_cache_one_t::stats_misses, dt_mipmap_cache_one_t::stats_near_match, dt_mipmap_cache_one_t::stats_requests, and dt_mipmap_cache_one_t::stats_standin.
Referenced by dt_init().
Definition at line 891 of file mipmap_cache.c.
References _cache_print, _mipmap_cache, dt_mipmap_cache_one_t::cache, dt_cache_t::cost, dt_cache_t::cost_quota, DT_DEBUG_CACHE, dt_mipmap_cache_t::mip_f, dt_mipmap_cache_t::mip_full, dt_mipmap_cache_t::mip_thumbs, dt_mipmap_cache_one_t::stats_fetches, dt_mipmap_cache_one_t::stats_misses, dt_mipmap_cache_one_t::stats_near_match, dt_mipmap_cache_one_t::stats_requests, and dt_mipmap_cache_one_t::stats_standin.
Referenced by dt_mipmap_cache_cleanup().
| void dt_mipmap_cache_release_with_caller | ( | dt_mipmap_buffer_t * | buf, |
| const char * | file, | ||
| int | line | ||
| ) |
Definition at line 1218 of file mipmap_cache.c.
References _get_cache(), _mipmap_cache, dt_mipmap_buffer_t::buf, dt_mipmap_cache_one_t::cache, dt_mipmap_buffer_t::cache_entry, dt_cache_release_with_caller(), DT_MIPMAP_0, DT_MIPMAP_NONE, dt_mipmap_buffer_t::imgid, IS_NULL_PTR, and dt_mipmap_buffer_t::size.
| void dt_mipmap_cache_remove | ( | const int32_t | imgid, |
| const gboolean | flush_disk | ||
| ) |
Definition at line 1326 of file mipmap_cache.c.
References DT_MIPMAP_0, dt_mipmap_cache_remove_at_size(), DT_MIPMAP_F, and k.
Referenced by _image_import_internal(), _jpg_combobox_changed(), clear_image_cache(), dt_film_remove(), dt_history_delete_on_image_ext(), dt_image_history_changed(), and dt_mipmap_cache_remove_all_sizes().
| void dt_mipmap_cache_remove_all_sizes | ( | const int32_t | imgid, |
| const gboolean | flush_disk | ||
| ) |
Definition at line 1351 of file mipmap_cache.c.
References _remove_one_size(), dt_mipmap_cache_remove(), DT_MIPMAP_F, and DT_MIPMAP_FULL.
Referenced by _image_remove().
| void dt_mipmap_cache_remove_at_size | ( | const int32_t | imgid, |
| const dt_mipmap_size_t | mip, | ||
| const gboolean | flush_disk | ||
| ) |
Definition at line 1302 of file mipmap_cache.c.
References _get_cache(), _get_dsc_from_entry(), _mipmap_cache, ASAN_UNPOISON_MEMORY_REGION, dt_cache_release, dt_cache_remove(), dt_cache_testget(), DT_MIPMAP_0, DT_MIPMAP_BUFFER_DSC_FLAG_INVALIDATE, dt_mipmap_cache_unlink_ondisk_thumbnail(), DT_MIPMAP_F, dt_mipmap_buffer_dsc::flags, get_key(), and key.
Referenced by dt_mipmap_cache_remove().
| void dt_mipmap_cache_set_settings | ( | const dt_mipmap_cache_settings_t * | settings | ) |
Apply new settings to a running cache.
Every field takes effect immediately, including ::max_memory – the LRU quota is soft, so lowering it makes the next insertions evict harder rather than freeing anything synchronously. Call it whenever the user changes one of the four; the application does that from its DT_SIGNAL_PREFERENCES_CHANGE handler.
| settings | the new values. NULL is a no-op. |
Definition at line 165 of file mipmap_cache.c.
References _mipmap_cache, _settings, _settings_lock, _settings_lock_ensure(), dt_mipmap_cache_one_t::cache, dt_cache_t::cost_quota, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), IS_NULL_PTR, dt_mipmap_cache_settings_t::max_memory, and dt_mipmap_cache_t::mip_thumbs.
Referenced by _preferences_changed(), and dt_mipmap_cache_init().
| void dt_mipmap_cache_swap_at_size | ( | const int32_t | imgid, |
| const dt_mipmap_size_t | mip, | ||
| const uint8_t *const | buffer, | ||
| const int32_t | width, | ||
| const int32_t | height, | ||
| dt_colorspaces_color_profile_type_t | profile | ||
| ) |
Definition at line 1266 of file mipmap_cache.c.
References _cache_print, _get_buffer_from_dsc(), _get_cache(), _get_dsc_from_entry(), _mipmap_cache, ASAN_UNPOISON_MEMORY_REGION, dt_mipmap_buffer_dsc::color_space, dt_cache_get_with_caller(), dt_cache_release, dt_colorprofiles_bgra8_to_adobergb_rgba8(), DT_COLORSPACE_ADOBERGB, DT_DEBUG_CACHE, dt_iop_flip_and_zoom_8(), DT_MIPMAP_0, DT_MIPMAP_F, dt_mipmap_buffer_dsc::flags, get_key(), height, dt_mipmap_buffer_dsc::height, dt_mipmap_buffer_dsc::iscale, key, ORIENTATION_NONE, dt_mipmap_buffer_dsc::size, width, and dt_mipmap_buffer_dsc::width.
Referenced by dt_dev_resync_mipmap_cache().
| void dt_mipmap_cache_write_get_with_caller | ( | dt_mipmap_buffer_t * | buf, |
| const int32_t | imgid, | ||
| const int | mip, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Definition at line 1213 of file mipmap_cache.c.
References DT_MIPMAP_BLOCKING, and dt_mipmap_cache_get_with_caller().
| void dt_mipmap_get_cache_dir | ( | char | path[DT_PATH_MAX], |
| dt_mipmap_size_t | mip | ||
| ) |
Definition at line 272 of file mipmap_cache.c.
References _mipmap_cache, dt_mipmap_cache_t::cachedir, and DT_PATH_MAX.
Referenced by dt_mipmap_cache_deallocate_dynamic(), dt_mipmap_get_cache_filename(), and generate_thumbnail_cache().
| void dt_mipmap_get_cache_filename | ( | char | path[DT_PATH_MAX], |
| dt_mipmap_size_t | mip, | ||
| const int32_t | imgid | ||
| ) |
Definition at line 279 of file mipmap_cache.c.
References dt_concat_path_file(), dt_free, dt_mipmap_get_cache_dir(), and DT_PATH_MAX.
Referenced by _generate_one(), _prerender_job(), dt_mipmap_cache_allocate_dynamic(), dt_mipmap_cache_copy_thumbnails(), dt_mipmap_cache_deallocate_dynamic(), dt_mipmap_cache_unlink_ondisk_thumbnail(), and preload_image_cache().