surface_cache.h (1490B)
1 #ifndef _LTK_SURFACE_CACHE_H_ 2 #define _LTK_SURFACE_CACHE_H_ 3 4 /* FIXME: It would probably be much better to just have a named cache 5 and then pass a single surface around while drawing other widgets */ 6 /* FIXME: some sort of "locking" for surfaces so they temporarily can't 7 be reassigned? (e.g. when drawing widget hierarchy) */ 8 9 typedef struct ltk_surface_cache ltk_surface_cache; 10 typedef struct ltk_surface_cache_key ltk_surface_cache_key; 11 12 #include "widget.h" 13 #include "ltk.h" 14 #include "graphics.h" 15 16 ltk_surface_cache *ltk_surface_cache_create(ltk_renderdata *renderdata); 17 void ltk_surface_cache_destroy(ltk_surface_cache *cache); 18 ltk_surface_cache_key *ltk_surface_cache_get_named_key(ltk_surface_cache *cache, ltk_widget_type type, int id, int min_w, int min_h); 19 ltk_surface_cache_key *ltk_surface_cache_get_unnamed_key(ltk_surface_cache *cache, int min_w, int min_h); 20 21 /* WARNING: DO NOT RESIZE SURFACES MANUALLY, ALWAYS USE ltk_surface_cache_request_surface_size! */ 22 void ltk_surface_cache_request_surface_size(ltk_surface_cache_key *key, int min_w, int min_h); 23 /* -> just sets to invalid and changes min_* so appropriate size is taken next time */ 24 /* -> cannot assume anything about the contents afterwards! */ 25 26 /* returns 1 if key was valid, i.e. surface was already assigned, 0 otherwise */ 27 int ltk_surface_cache_get_surface(ltk_surface_cache_key *key, ltk_surface **s_ret); 28 29 void ltk_surface_cache_release_key(ltk_surface_cache_key *key); 30 31 #endif /* _LTK_SURFACE_CACHE_H_ */