Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
image_cache.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2009-2021 darktable developers.
4
5 darktable 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 darktable 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 darktable. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#pragma once
20
21#include "common/cache.h"
22#include "common/image.h"
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28typedef struct dt_image_cache_t
29{
31}
33
34// what to do if an image struct is
35// released after writing.
37{
38 // always write to database and xmp
40 // only write to db and do xmp only during shutdown
44
48
49// blocks until it gets the image struct with this id for reading.
50// also does the sql query if the image is not in cache atm.
51// if id < 0, a newly wiped image struct shall be returned (for import).
52// this will silently start the garbage collector and free long-unused
53// cachelines to free up space if necessary.
54// if an entry is swapped out like this in the background, this is the latest
55// point where sql and xmp can be synched (unsafe setting).
56dt_image_t *dt_image_cache_get(dt_image_cache_t *cache, const int32_t imgid, char mode);
57
58// same as read_get, but doesn't block and returns NULL if the image
59// is currently unavailable.
60dt_image_t *dt_image_cache_testget(dt_image_cache_t *cache, const int32_t imgid, char mode);
61
62// drops the read lock on an image struct
64
65// drops the write privileges on an image struct.
66// this triggers a write-through to sql, and if the setting
67// is present, also to xmp sidecar files (safe setting).
69
70// remove the image from the cache
71void dt_image_cache_remove(dt_image_cache_t *cache, const int32_t imgid);
72
73// register timestamps in cache
74void dt_image_cache_set_change_timestamp(dt_image_cache_t *cache, const int32_t imgid);
75void dt_image_cache_set_change_timestamp_from_image(dt_image_cache_t *cache, const int32_t imgid, const int32_t sourceid);
76void dt_image_cache_unset_change_timestamp(dt_image_cache_t *cache, const int32_t imgid);
77void dt_image_cache_set_export_timestamp(dt_image_cache_t *cache, const int32_t imgid);
78void dt_image_cache_set_print_timestamp(dt_image_cache_t *cache, const int32_t imgid);
79
80#ifdef __cplusplus
81}
82#endif
83
84// clang-format off
85// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
86// vim: shiftwidth=2 expandtab tabstop=2 cindent
87// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
88// clang-format on
89
void dt_image_cache_cleanup(dt_image_cache_t *cache)
Definition image_cache.c:205
void dt_image_cache_init(dt_image_cache_t *cache)
Definition image_cache.c:187
void dt_image_cache_read_release(dt_image_cache_t *cache, const dt_image_t *img)
Definition image_cache.c:239
void dt_image_cache_set_change_timestamp_from_image(dt_image_cache_t *cache, const int32_t imgid, const int32_t sourceid)
Definition image_cache.c:347
void dt_image_cache_set_change_timestamp(dt_image_cache_t *cache, const int32_t imgid)
Definition image_cache.c:335
dt_image_cache_write_mode_t
Definition image_cache.h:37
@ DT_IMAGE_CACHE_RELAXED
Definition image_cache.h:41
@ DT_IMAGE_CACHE_SAFE
Definition image_cache.h:39
void dt_image_cache_unset_change_timestamp(dt_image_cache_t *cache, const int32_t imgid)
Definition image_cache.c:365
dt_image_t * dt_image_cache_get(dt_image_cache_t *cache, const int32_t imgid, char mode)
Definition image_cache.c:217
void dt_image_cache_set_export_timestamp(dt_image_cache_t *cache, const int32_t imgid)
Definition image_cache.c:377
void dt_image_cache_write_release(dt_image_cache_t *cache, dt_image_t *img, dt_image_cache_write_mode_t mode)
Definition image_cache.c:249
void dt_image_cache_remove(dt_image_cache_t *cache, const int32_t imgid)
Definition image_cache.c:329
dt_image_t * dt_image_cache_testget(dt_image_cache_t *cache, const int32_t imgid, char mode)
Definition image_cache.c:227
void dt_image_cache_set_print_timestamp(dt_image_cache_t *cache, const int32_t imgid)
Definition image_cache.c:389
void dt_image_cache_print(dt_image_cache_t *cache)
Definition image_cache.c:210
Definition cache.h:42
Definition image_cache.h:29
dt_cache_t cache
Definition image_cache.h:30
Definition common/image.h:195