Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
mipmap_cache.h File Reference
#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

voiddt_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)
 

Macro Definition Documentation

◆ dt_mipmap_cache_get

#define dt_mipmap_cache_get (   B,
  C,
  D,
  E,
 
)    dt_mipmap_cache_get_with_caller(B,C,D,E,F,__FILE__,__LINE__)

Definition at line 166 of file mipmap_cache.h.

◆ dt_mipmap_cache_get_with_shutdown

#define dt_mipmap_cache_get_with_shutdown (   B,
  C,
  D,
  E,
  F,
 
)     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.

◆ dt_mipmap_cache_release

#define dt_mipmap_cache_release (   B)    dt_mipmap_cache_release_with_caller(B, __FILE__, __LINE__)

Definition at line 198 of file mipmap_cache.h.

◆ dt_mipmap_cache_write_get

#define dt_mipmap_cache_write_get (   B,
  C,
 
)    dt_mipmap_cache_write_get_with_caller(B,C,D,__FILE__,__LINE__)

Definition at line 189 of file mipmap_cache.h.

Typedef Documentation

◆ dt_mipmap_buffer_t

◆ dt_mipmap_cache_one_t

Definition at line 81 of file mipmap_cache.h.

◆ 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.

◆ dt_mipmap_cache_stats_entry_t

◆ dt_mipmap_cache_t

Definition at line 86 of file mipmap_cache.h.

◆ dt_mipmap_get_flags_t

◆ dt_mipmap_size_t

Enumeration Type Documentation

◆ dt_mipmap_get_flags_t

Enumerator
DT_MIPMAP_BLOCKING 
DT_MIPMAP_TESTLOCK 

Definition at line 59 of file mipmap_cache.h.

◆ 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.

Function Documentation

◆ dt_mimap_cache_evict()

void dt_mimap_cache_evict ( const int32_t  imgid)

◆ dt_mipmap_cache_alloc()

◆ dt_mipmap_cache_cleanup()

◆ dt_mipmap_cache_copy_thumbnails()

void dt_mipmap_cache_copy_thumbnails ( const uint32_t  dst_imgid,
const uint32_t  src_imgid 
)

◆ dt_mipmap_cache_get_entries_stats()

◆ dt_mipmap_cache_get_fitting_size()

dt_mipmap_size_t dt_mipmap_cache_get_fitting_size ( const int32_t  width,
const int32_t  height,
const uint32_t  imgid 
)

◆ dt_mipmap_cache_get_matching_size()

dt_mipmap_size_t dt_mipmap_cache_get_matching_size ( const int32_t  width,
const int32_t  height,
const uint32_t  imgid 
)

◆ dt_mipmap_cache_get_settings()

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.

◆ dt_mipmap_cache_get_usage()

void dt_mipmap_cache_get_usage ( size_t *  current,
size_t *  max 
)

◆ dt_mipmap_cache_get_with_caller()

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 
)

◆ dt_mipmap_cache_get_with_caller_and_shutdown()

◆ dt_mipmap_cache_init()

void dt_mipmap_cache_init ( const dt_mipmap_cache_settings_t settings,
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.
settingsthe 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().

◆ dt_mipmap_cache_print()

◆ dt_mipmap_cache_release_with_caller()

◆ dt_mipmap_cache_remove()

◆ 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().

◆ dt_mipmap_cache_remove_at_size()

◆ dt_mipmap_cache_set_settings()

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.

Parameters
settingsthe 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().

◆ dt_mipmap_cache_swap_at_size()

◆ dt_mipmap_cache_write_get_with_caller()

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().

◆ dt_mipmap_get_cache_dir()

void dt_mipmap_get_cache_dir ( char  path[DT_PATH_MAX],
dt_mipmap_size_t  mip 
)

◆ dt_mipmap_get_cache_filename()