1 /* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 /* 3 Copyright (C) 2009-2015 Red Hat, Inc. 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 This library 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 GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef IMAGE_CACHE_H_ 20 #define IMAGE_CACHE_H_ 21 22 #include <inttypes.h> 23 #include <common/pixman_utils.h> 24 #include <common/canvas_base.h> 25 #include <common/ring.h> 26 27 SPICE_BEGIN_DECLS 28 29 /* FIXME: move back to display-channel.h (once structs are private) */ 30 typedef struct Drawable Drawable; 31 32 typedef struct ImageCacheItem { 33 RingItem lru_link; 34 uint64_t id; 35 #ifdef IMAGE_CACHE_AGE 36 uint32_t age; 37 #endif 38 struct ImageCacheItem *next; 39 pixman_image_t *image; 40 } ImageCacheItem; 41 42 #define IMAGE_CACHE_HASH_SIZE 1024 43 44 typedef struct ImageCache { 45 SpiceImageCache base; 46 ImageCacheItem *hash_table[IMAGE_CACHE_HASH_SIZE]; 47 Ring lru; 48 #ifdef IMAGE_CACHE_AGE 49 uint32_t age; 50 #else 51 uint32_t num_items; 52 #endif 53 } ImageCache; 54 55 void image_cache_init (ImageCache *cache); 56 void image_cache_reset (ImageCache *cache); 57 void image_cache_aging (ImageCache *cache); 58 void image_cache_localize (ImageCache *cache, SpiceImage **image_ptr, 59 SpiceImage *image_store, Drawable *drawable); 60 void image_cache_localize_brush (ImageCache *cache, SpiceBrush *brush, 61 SpiceImage *image_store); 62 void image_cache_localize_mask (ImageCache *cache, SpiceQMask *mask, 63 SpiceImage *image_store); 64 65 SPICE_END_DECLS 66 67 #endif /* IMAGE_CACHE_H_ */ 68