2
This file is part of darktable,
3
copyright (c) 2009--2010 johannes hanika.
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.
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.
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/>.
18
#ifndef DT_IMAGE_CACHE_H
19
#define DT_IMAGE_CACHE_H
21
#include "common/image.h"
22
#include "common/dtpthread.h"
27
* image cache to hold temporary representations
29
* fast access by img->id via sorted index,
30
* which is updated each time a new image is alloc'ed or
31
* an old image is kicked.
32
* lru list maintained via linked list for fast updates.
35
typedef struct dt_image_cache_line_t
41
dt_image_cache_line_t;
43
typedef struct dt_image_cache_t
45
dt_pthread_mutex_t mutex;
47
dt_image_cache_line_t *line;
53
void dt_image_cache_init(dt_image_cache_t *cache, int32_t entries, const int32_t load_cached);
54
void dt_image_cache_cleanup(dt_image_cache_t *cache);
55
/** print some debug info. */
56
void dt_image_cache_print(dt_image_cache_t *cache);
58
/** returns alloc'ed image (newly or from cache) or NULL on failure.
59
* lru is freed instead. there is no explicit interface for free.
60
* result will have users lock incremented.
61
* init image from db if it was not already loaded. */
62
dt_image_t *dt_image_cache_get(int32_t id, const char mode);
63
/** only use for import. */
64
dt_image_t *dt_image_cache_get_uninited(int32_t id, const char mode);
65
/** decrements users lock. */
66
void dt_image_cache_release(dt_image_t *img, const char mode);
67
/** synches this image and the db entry. */
68
void dt_image_cache_flush(dt_image_t *img);
69
/** same as above, but doesn't write the redundant sidecar files. */
70
void dt_image_cache_flush_no_sidecars(dt_image_t *img);
71
/** invalidates resources occupied by this image. */
72
void dt_image_cache_clear(int32_t id);