move around - flatter.
[profile/ivi/evas.git] / src / lib / cache / evas_cache.h
1 #ifndef _EVAS_CACHE_H
2 #define _EVAS_CACHE_H
3
4
5 typedef struct _Evas_Cache_Image                Evas_Cache_Image;
6 typedef struct _Evas_Cache_Image_Func           Evas_Cache_Image_Func;
7 typedef struct _Evas_Cache_Engine_Image         Evas_Cache_Engine_Image;
8 typedef struct _Evas_Cache_Engine_Image_Func    Evas_Cache_Engine_Image_Func;
9
10
11 struct _Evas_Cache_Image_Func
12 {
13    Image_Entry *(*alloc)(void);
14    void         (*dealloc)(Image_Entry *im);
15
16    /* The cache provide some helpers for surface manipulation. */
17    int          (*surface_alloc)(Image_Entry *im, int w, int h);
18    void         (*surface_delete)(Image_Entry *im);
19    DATA32      *(*surface_pixels)(Image_Entry *im);
20
21    /* The cache is doing the allocation and deallocation, you must just do the rest. */
22    int          (*constructor)(Image_Entry *im);
23    void         (*destructor)(Image_Entry *im);
24
25    void         (*dirty_region)(Image_Entry *im, int x, int y, int w, int h);
26    /* Only called when references > 0. Need to provide a fresh copie of im. */
27    /* The destination surface does have a surface, but no allocated pixel data. */
28    int          (*dirty)(Image_Entry *dst, const Image_Entry *src);
29    /* Only called when references == 1. We will call drop on `im'. */
30    /* The destination surface does not have any surface. */
31    int          (*size_set)(Image_Entry *dst, const Image_Entry *src, int w, int h);
32
33    /* The destination surface does not have any surface. */
34    int          (*copied_data)(Image_Entry *dst, int w, int h, DATA32 *image_data, int alpha, int cspace);
35    /* The destination surface does not have any surface. */
36    int          (*data)(Image_Entry *dst, int w, int h, DATA32 *image_data, int alpha, int cspace);
37    int          (*color_space)(Image_Entry *dst, int cspace);
38
39    /* This function need to update im->w and im->h. */
40    int          (*load)(Image_Entry *im);
41    int          (*mem_size_get)(Image_Entry *im);
42    void         (*debug)(const char *context, Image_Entry *im);
43 };
44
45 struct _Evas_Cache_Image
46 {
47    Evas_Cache_Image_Func         func;
48
49    Evas_Object_List             *dirty;
50
51    Evas_Object_List             *lru;
52    Evas_Object_List             *lru_nodata;
53    Evas_Hash                    *inactiv;
54    Evas_Hash                    *activ;
55    void                         *data;
56
57    int                           usage;
58    int                           limit;
59    int                           references;
60 };
61
62 struct _Evas_Cache_Engine_Image_Func
63 {
64    /* Must return a char* allocated with evas_stringshare_add. */
65    char*                (*key)(Image_Entry *im, const char *file, const char *key, RGBA_Image_Loadopts *lo, int *error);
66
67    Engine_Image_Entry*  (*alloc)(void);
68    void                 (*dealloc)(Engine_Image_Entry *eim);
69
70    int                  (*constructor)(Engine_Image_Entry *eim, void* data);
71    void                 (*destructor)(Engine_Image_Entry *eim);
72
73    void                 (*dirty_region)(Engine_Image_Entry *eim, int x, int y, int w, int h);
74    /* Only called when references > 0. Need to provide a fresh copie of im. */
75    int                  (*dirty)(Engine_Image_Entry *dst, const Engine_Image_Entry *src);
76    /* Only called when references == 1. We will call drop on `im'. */
77    int                  (*size_set)(Engine_Image_Entry *dst, const Engine_Image_Entry *src);
78
79    int                  (*update_data)(Engine_Image_Entry* dst, void* data);
80
81    void                 (*load)(Engine_Image_Entry *eim, const Image_Entry* im);
82    int                  (*mem_size_get)(Engine_Image_Entry *eim);
83    void                 (*debug)(const char* context, Engine_Image_Entry *eim);
84 };
85
86 struct _Evas_Cache_Engine_Image
87 {
88    Evas_Cache_Engine_Image_Func func;
89
90    Evas_Object_List*            dirty;
91
92    Evas_Hash*                   activ;
93    Evas_Hash*                   inactiv;
94    Evas_Object_List*            lru;
95
96    Evas_Cache_Image*            parent;
97    Evas_Cache_Engine_Image*     brother;
98
99    int                          usage;
100    int                          limit;
101
102    int                          references;
103 };
104
105
106 #ifdef __cplusplus
107 extern "C" {
108 #endif
109
110
111 EAPI Evas_Cache_Image*        evas_cache_image_init(const Evas_Cache_Image_Func *cb);
112 EAPI void                     evas_cache_image_shutdown(Evas_Cache_Image *cache);
113 EAPI Image_Entry*             evas_cache_image_request(Evas_Cache_Image *cache, const char *file, const char *key, RGBA_Image_Loadopts *lo, int *error);
114 EAPI void                     evas_cache_image_drop(Image_Entry *im);
115 EAPI void                     evas_cache_image_data_not_needed(Image_Entry *im);
116 EAPI int                      evas_cache_image_flush(Evas_Cache_Image *cache);
117 EAPI void                     evas_cache_private_set(Evas_Cache_Image *cache, const void *data);
118 EAPI void*                    evas_cache_private_get(Evas_Cache_Image *cache);
119 EAPI void*                    evas_cache_private_from_image_entry_get(Image_Entry *im);
120
121 EAPI int                      evas_cache_image_usage_get(Evas_Cache_Image *cache);
122 EAPI int                      evas_cache_image_get(Evas_Cache_Image *cache);
123 EAPI void                     evas_cache_image_set(Evas_Cache_Image *cache, int size);
124
125 EAPI Image_Entry*             evas_cache_image_alone(Image_Entry *im);
126 EAPI Image_Entry*             evas_cache_image_dirty(Image_Entry *im, int x, int y, int w, int h);
127 EAPI void                     evas_cache_image_load_data(Image_Entry *im);
128 EAPI void                     evas_cache_image_surface_alloc(Image_Entry *im, int w, int h);
129 EAPI DATA32*                  evas_cache_image_pixels(Image_Entry *im);
130 EAPI Image_Entry*             evas_cache_image_copied_data(Evas_Cache_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace);
131 EAPI Image_Entry*             evas_cache_image_data(Evas_Cache_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace);
132 EAPI void                     evas_cache_image_colorspace(Image_Entry *im, int cspace);
133 EAPI Image_Entry*             evas_cache_image_empty(Evas_Cache_Image *cache);
134 EAPI Image_Entry*             evas_cache_image_size_set(Image_Entry *im, int w, int h);
135
136 EAPI Evas_Cache_Engine_Image* evas_cache_engine_image_init(const Evas_Cache_Engine_Image_Func *cb, Evas_Cache_Image *parent);
137 EAPI void                     evas_cache_engine_image_shutdown(Evas_Cache_Engine_Image *cache);
138
139 EAPI void                     evas_cache_engine_image_shutdown(Evas_Cache_Engine_Image *cache);
140 EAPI int                      evas_cache_engine_image_usage_get(Evas_Cache_Engine_Image *cache);
141 EAPI int                      evas_cache_engine_image_get(Evas_Cache_Engine_Image *cache);
142 EAPI void                     evas_cache_engine_image_set(Evas_Cache_Engine_Image *cache, int limit);
143
144 EAPI Engine_Image_Entry*      evas_cache_engine_image_request(Evas_Cache_Engine_Image *cache, const char *file, const char *key, RGBA_Image_Loadopts *lo, void *engine_data, int *error);
145 EAPI void                     evas_cache_engine_parent_not_needed(Engine_Image_Entry *eim);
146 EAPI Engine_Image_Entry*      evas_cache_engine_image_engine(Evas_Cache_Engine_Image *cache, void *engine_data);
147 EAPI void                     evas_cache_engine_image_drop(Engine_Image_Entry *eim);
148 EAPI Engine_Image_Entry*      evas_cache_engine_image_alone(Engine_Image_Entry *eim, void *data);
149 EAPI Engine_Image_Entry*      evas_cache_engine_image_dirty(Engine_Image_Entry *eim, int x, int y, int w, int h);
150 EAPI Engine_Image_Entry*      evas_cache_engine_image_copied_data(Evas_Cache_Engine_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace, void *engine_data);
151 EAPI Engine_Image_Entry*      evas_cache_engine_image_data(Evas_Cache_Engine_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace, void *engine_data);
152 EAPI void                     evas_cache_engine_image_colorspace(Engine_Image_Entry *eim, int cspace, void *engine_data);
153 EAPI Engine_Image_Entry*      evas_cache_engine_image_size_set(Engine_Image_Entry *eim, int w, int h);
154
155 EAPI void                     evas_cache_engine_image_load_data(Engine_Image_Entry *eim);
156
157
158 #ifdef __cplusplus
159 }
160 #endif
161
162
163 #endif /* _EVAS_CACHE_H */