summaryrefslogtreecommitdiff
path: root/legacy/evas/src/lib/cache/evas_cache.h
blob: 142f3c6b44e27bed1ab99ba13fe1a0bb2bfe6472 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#ifndef _EVAS_CACHE_H
#define _EVAS_CACHE_H


typedef struct _Evas_Cache_Image                Evas_Cache_Image;
typedef struct _Evas_Cache_Image_Func           Evas_Cache_Image_Func;
typedef struct _Evas_Cache_Engine_Image         Evas_Cache_Engine_Image;
typedef struct _Evas_Cache_Engine_Image_Func    Evas_Cache_Engine_Image_Func;


struct _Evas_Cache_Image_Func
{
   Image_Entry *(*alloc)(void);
   void         (*dealloc)(Image_Entry *im);

   /* The cache provide some helpers for surface manipulation. */
   int          (*surface_alloc)(Image_Entry *im, int w, int h);
   void         (*surface_delete)(Image_Entry *im);
   DATA32      *(*surface_pixels)(Image_Entry *im);

   /* The cache is doing the allocation and deallocation, you must just do the rest. */
   int          (*constructor)(Image_Entry *im);
   void         (*destructor)(Image_Entry *im);

   void         (*dirty_region)(Image_Entry *im, int x, int y, int w, int h);
   /* Only called when references > 0. Need to provide a fresh copie of im. */
   /* The destination surface does have a surface, but no allocated pixel data. */
   int          (*dirty)(Image_Entry *dst, const Image_Entry *src);
   /* Only called when references == 1. We will call drop on `im'. */
   /* The destination surface does not have any surface. */
   int          (*size_set)(Image_Entry *dst, const Image_Entry *src, int w, int h);

   /* The destination surface does not have any surface. */
   int          (*copied_data)(Image_Entry *dst, int w, int h, DATA32 *image_data, int alpha, int cspace);
   /* The destination surface does not have any surface. */
   int          (*data)(Image_Entry *dst, int w, int h, DATA32 *image_data, int alpha, int cspace);
   int          (*color_space)(Image_Entry *dst, int cspace);

   /* This function need to update im->w and im->h. */
   int          (*load)(Image_Entry *im);
   int          (*mem_size_get)(Image_Entry *im);
   void         (*debug)(const char *context, Image_Entry *im);
};

struct _Evas_Cache_Image
{
   Evas_Cache_Image_Func         func;

   Eina_Inlist                  *dirty;

   Eina_Inlist                  *lru;
   Eina_Inlist                  *lru_nodata;
   Evas_Hash                    *inactiv;
   Evas_Hash                    *activ;
   void                         *data;

   int                           usage;
   int                           limit;
   int                           references;
   
   Eina_List                    *scaled;
   int                           scaledmem;
};

struct _Evas_Cache_Engine_Image_Func
{
   /* Must return a char* allocated with eina_stringshare_add. */
   char*                (*key)(Image_Entry *im, const char *file, const char *key, RGBA_Image_Loadopts *lo, int *error);

   Engine_Image_Entry*  (*alloc)(void);
   void                 (*dealloc)(Engine_Image_Entry *eim);

   int                  (*constructor)(Engine_Image_Entry *eim, void* data);
   void                 (*destructor)(Engine_Image_Entry *eim);

   void                 (*dirty_region)(Engine_Image_Entry *eim, int x, int y, int w, int h);
   /* Only called when references > 0. Need to provide a fresh copie of im. */
   int                  (*dirty)(Engine_Image_Entry *dst, const Engine_Image_Entry *src);
   /* Only called when references == 1. We will call drop on `im'. */
   int                  (*size_set)(Engine_Image_Entry *dst, const Engine_Image_Entry *src);

   int                  (*update_data)(Engine_Image_Entry* dst, void* data);

   void                 (*load)(Engine_Image_Entry *eim, const Image_Entry* im);
   int                  (*mem_size_get)(Engine_Image_Entry *eim);
   void                 (*debug)(const char* context, Engine_Image_Entry *eim);
};

struct _Evas_Cache_Engine_Image
{
   Evas_Cache_Engine_Image_Func func;

   Eina_Inlist*            dirty;

   Evas_Hash*                   activ;
   Evas_Hash*                   inactiv;
   Eina_Inlist*            lru;

   Evas_Cache_Image*            parent;
   Evas_Cache_Engine_Image*     brother;

   int                          usage;
   int                          limit;

   int                          references;
};


#ifdef __cplusplus
extern "C" {
#endif


EAPI Evas_Cache_Image*        evas_cache_image_init(const Evas_Cache_Image_Func *cb);
EAPI void                     evas_cache_image_shutdown(Evas_Cache_Image *cache);
EAPI Image_Entry*             evas_cache_image_request(Evas_Cache_Image *cache, const char *file, const char *key, RGBA_Image_Loadopts *lo, int *error);
EAPI void                     evas_cache_image_drop(Image_Entry *im);
EAPI void                     evas_cache_image_data_not_needed(Image_Entry *im);
EAPI int                      evas_cache_image_flush(Evas_Cache_Image *cache);
EAPI void                     evas_cache_private_set(Evas_Cache_Image *cache, const void *data);
EAPI void*                    evas_cache_private_get(Evas_Cache_Image *cache);
EAPI void*                    evas_cache_private_from_image_entry_get(Image_Entry *im);

EAPI int                      evas_cache_image_usage_get(Evas_Cache_Image *cache);
EAPI int                      evas_cache_image_get(Evas_Cache_Image *cache);
EAPI void                     evas_cache_image_set(Evas_Cache_Image *cache, int size);

EAPI Image_Entry*             evas_cache_image_alone(Image_Entry *im);
EAPI Image_Entry*             evas_cache_image_dirty(Image_Entry *im, int x, int y, int w, int h);
EAPI void                     evas_cache_image_load_data(Image_Entry *im);
EAPI void                     evas_cache_image_surface_alloc(Image_Entry *im, int w, int h);
EAPI void                     evas_cache_image_surface_dealloc(Image_Entry *im);
EAPI DATA32*                  evas_cache_image_pixels(Image_Entry *im);
EAPI Image_Entry*             evas_cache_image_copied_data(Evas_Cache_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace);
EAPI Image_Entry*             evas_cache_image_data(Evas_Cache_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace);
EAPI void                     evas_cache_image_colorspace(Image_Entry *im, int cspace);
EAPI Image_Entry*             evas_cache_image_empty(Evas_Cache_Image *cache);
EAPI Image_Entry*             evas_cache_image_size_set(Image_Entry *im, int w, int h);

EAPI Evas_Cache_Engine_Image* evas_cache_engine_image_init(const Evas_Cache_Engine_Image_Func *cb, Evas_Cache_Image *parent);
EAPI void                     evas_cache_engine_image_shutdown(Evas_Cache_Engine_Image *cache);

EAPI int                      evas_cache_engine_image_usage_get(Evas_Cache_Engine_Image *cache);
EAPI int                      evas_cache_engine_image_get(Evas_Cache_Engine_Image *cache);
EAPI void                     evas_cache_engine_image_set(Evas_Cache_Engine_Image *cache, int limit);

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);
EAPI void                     evas_cache_engine_parent_not_needed(Engine_Image_Entry *eim);
EAPI Engine_Image_Entry*      evas_cache_engine_image_engine(Evas_Cache_Engine_Image *cache, void *engine_data);
EAPI void                     evas_cache_engine_image_drop(Engine_Image_Entry *eim);
EAPI Engine_Image_Entry*      evas_cache_engine_image_alone(Engine_Image_Entry *eim, void *data);
EAPI Engine_Image_Entry*      evas_cache_engine_image_dirty(Engine_Image_Entry *eim, int x, int y, int w, int h);
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);
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);
EAPI void                     evas_cache_engine_image_colorspace(Engine_Image_Entry *eim, int cspace, void *engine_data);
EAPI Engine_Image_Entry*      evas_cache_engine_image_size_set(Engine_Image_Entry *eim, int w, int h);

EAPI void                     evas_cache_engine_image_load_data(Engine_Image_Entry *eim);


#ifdef __cplusplus
}
#endif


#endif /* _EVAS_CACHE_H */