summaryrefslogtreecommitdiff
path: root/legacy/evas/src/lib
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2008-12-02 02:33:09 +0000
committerCarsten Haitzler <raster@rasterman.com>2008-12-02 02:33:09 +0000
commita2cd677cdc5865e3027c3e3d464859a95919ebc3 (patch)
tree9f86269464d6f742caf2a80571303454d975dd4d /legacy/evas/src/lib
parent72c25fd2fc3f44205f85f77867c77358c7ab57db (diff)
ok - revert scalecache until leak fixed.
SVN revision: 37899
Diffstat (limited to '')
-rw-r--r--legacy/evas/src/lib/cache/evas_cache.h4
-rw-r--r--legacy/evas/src/lib/cache/evas_cache_engine_image.c3
-rw-r--r--legacy/evas/src/lib/cache/evas_cache_image.c132
-rw-r--r--legacy/evas/src/lib/engines/common/evas_image_load.c4
-rw-r--r--legacy/evas/src/lib/engines/common/evas_image_main.c31
-rw-r--r--legacy/evas/src/lib/engines/common/evas_scale_sample.c5
-rw-r--r--legacy/evas/src/lib/include/evas_common.h100
7 files changed, 65 insertions, 214 deletions
diff --git a/legacy/evas/src/lib/cache/evas_cache.h b/legacy/evas/src/lib/cache/evas_cache.h
index 142f3c6b44..f3cee96c27 100644
--- a/legacy/evas/src/lib/cache/evas_cache.h
+++ b/legacy/evas/src/lib/cache/evas_cache.h
@@ -57,9 +57,6 @@ struct _Evas_Cache_Image
57 int usage; 57 int usage;
58 int limit; 58 int limit;
59 int references; 59 int references;
60
61 Eina_List *scaled;
62 int scaledmem;
63}; 60};
64 61
65struct _Evas_Cache_Engine_Image_Func 62struct _Evas_Cache_Engine_Image_Func
@@ -129,7 +126,6 @@ EAPI Image_Entry* evas_cache_image_alone(Image_Entry *im);
129EAPI Image_Entry* evas_cache_image_dirty(Image_Entry *im, int x, int y, int w, int h); 126EAPI Image_Entry* evas_cache_image_dirty(Image_Entry *im, int x, int y, int w, int h);
130EAPI void evas_cache_image_load_data(Image_Entry *im); 127EAPI void evas_cache_image_load_data(Image_Entry *im);
131EAPI void evas_cache_image_surface_alloc(Image_Entry *im, int w, int h); 128EAPI void evas_cache_image_surface_alloc(Image_Entry *im, int w, int h);
132EAPI void evas_cache_image_surface_dealloc(Image_Entry *im);
133EAPI DATA32* evas_cache_image_pixels(Image_Entry *im); 129EAPI DATA32* evas_cache_image_pixels(Image_Entry *im);
134EAPI Image_Entry* evas_cache_image_copied_data(Evas_Cache_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace); 130EAPI Image_Entry* evas_cache_image_copied_data(Evas_Cache_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace);
135EAPI Image_Entry* evas_cache_image_data(Evas_Cache_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace); 131EAPI Image_Entry* evas_cache_image_data(Evas_Cache_Image *cache, int w, int h, DATA32 *image_data, int alpha, int cspace);
diff --git a/legacy/evas/src/lib/cache/evas_cache_engine_image.c b/legacy/evas/src/lib/cache/evas_cache_engine_image.c
index 76b4121c46..d048dc4c82 100644
--- a/legacy/evas/src/lib/cache/evas_cache_engine_image.c
+++ b/legacy/evas/src/lib/cache/evas_cache_engine_image.c
@@ -192,7 +192,7 @@ evas_cache_engine_image_init(const Evas_Cache_Engine_Image_Func *cb, Evas_Cache_
192 parent->references++; 192 parent->references++;
193 193
194 new->brother = NULL; 194 new->brother = NULL;
195 195
196 return new; 196 return new;
197} 197}
198 198
@@ -260,7 +260,6 @@ evas_cache_engine_image_flush(Evas_Cache_Engine_Image *cache)
260 eim = (Engine_Image_Entry *) cache->lru->last; 260 eim = (Engine_Image_Entry *) cache->lru->last;
261 _evas_cache_engine_image_dealloc(cache, eim); 261 _evas_cache_engine_image_dealloc(cache, eim);
262 } 262 }
263 evas_common_image_set_cache(evas_common_image_get_cache());
264} 263}
265 264
266EAPI void 265EAPI void
diff --git a/legacy/evas/src/lib/cache/evas_cache_image.c b/legacy/evas/src/lib/cache/evas_cache_image.c
index 73477d7533..bc9c328ade 100644
--- a/legacy/evas/src/lib/cache/evas_cache_image.c
+++ b/legacy/evas/src/lib/cache/evas_cache_image.c
@@ -45,38 +45,19 @@ static void _evas_cache_image_entry_delete(Evas_Cache_Image *cache, Image_Entry
45 45
46static void 46static void
47_evas_cache_image_make_dirty(Evas_Cache_Image *cache, 47_evas_cache_image_make_dirty(Evas_Cache_Image *cache,
48 Image_Entry *ie) 48 Image_Entry *im)
49{ 49{
50 ie->flags.cached = 1; 50 im->flags.cached = 1;
51 ie->flags.dirty = 1; 51 im->flags.dirty = 1;
52 ie->flags.activ = 0; 52 im->flags.activ = 0;
53 ie->flags.lru_nodata = 0; 53 im->flags.lru_nodata = 0;
54 cache->dirty = eina_inlist_prepend(cache->dirty, EINA_INLIST_GET(ie)); 54 cache->dirty = eina_inlist_prepend(cache->dirty, EINA_INLIST_GET(im));
55 55
56 if (ie->cache_key) 56 if (im->cache_key)
57 { 57 {
58 eina_stringshare_del(ie->cache_key); 58 eina_stringshare_del(im->cache_key);
59 ie->cache_key = NULL; 59 im->cache_key = NULL;
60 } 60 }
61
62 while (ie->scalecache.others)
63 {
64 Image_Entry *ie2;
65
66 ie2 = ie->scalecache.others->data;
67 cache->usage -= cache->func.mem_size_get(ie2);
68 if (ie2->scalecache.usage >= 6)
69 {
70 ie->scalecache.mem -= ie2->scalecache.dst_w * ie2->scalecache.dst_h;
71 ie->cache->scaledmem -= ie2->scalecache.dst_w * ie2->scalecache.dst_h;
72 ie->cache->scaled =
73 eina_list_remove(ie->cache->scaled, ie2);
74 }
75 ie->scalecache.others = eina_list_remove_list(ie->scalecache.others, ie->scalecache.others);
76 ie2->scalecache.parent = NULL;
77 evas_cache_image_drop(ie2);
78 }
79
80} 61}
81 62
82static void 63static void
@@ -111,6 +92,7 @@ _evas_cache_image_make_inactiv(Evas_Cache_Image *cache,
111 im->flags.cached = 1; 92 im->flags.cached = 1;
112 cache->inactiv = evas_hash_direct_add(cache->inactiv, key, im); 93 cache->inactiv = evas_hash_direct_add(cache->inactiv, key, im);
113 cache->lru = eina_inlist_prepend(cache->lru, EINA_INLIST_GET(im)); 94 cache->lru = eina_inlist_prepend(cache->lru, EINA_INLIST_GET(im));
95 cache->usage += cache->func.mem_size_get(im);
114 } 96 }
115 else 97 else
116 { 98 {
@@ -126,6 +108,7 @@ _evas_cache_image_remove_lru_nodata(Evas_Cache_Image *cache,
126 { 108 {
127 im->flags.lru_nodata = 0; 109 im->flags.lru_nodata = 0;
128 cache->lru_nodata = eina_inlist_remove(cache->lru_nodata, EINA_INLIST_GET(im)); 110 cache->lru_nodata = eina_inlist_remove(cache->lru_nodata, EINA_INLIST_GET(im));
111 cache->usage -= cache->func.mem_size_get(im);
129 } 112 }
130} 113}
131 114
@@ -177,24 +160,6 @@ _evas_cache_image_entry_delete(Evas_Cache_Image *cache, Image_Entry *ie)
177 if (cache->func.debug) 160 if (cache->func.debug)
178 cache->func.debug("deleting", ie); 161 cache->func.debug("deleting", ie);
179 162
180 while (ie->scalecache.others)
181 {
182 Image_Entry *ie2;
183
184 ie2 = ie->scalecache.others->data;
185 cache->usage -= cache->func.mem_size_get(ie2);
186 if (ie2->scalecache.usage >= 6)
187 {
188 ie->scalecache.mem -= ie2->scalecache.dst_w * ie2->scalecache.dst_h;
189 ie->cache->scaledmem -= ie2->scalecache.dst_w * ie2->scalecache.dst_h;
190 ie->cache->scaled =
191 eina_list_remove(ie->cache->scaled, ie2);
192 }
193 ie->scalecache.others = eina_list_remove_list(ie->scalecache.others, ie->scalecache.others);
194 ie2->scalecache.parent = NULL;
195 evas_cache_image_drop(ie2);
196 }
197
198 cache->func.destructor(ie); 163 cache->func.destructor(ie);
199 164
200 _evas_cache_image_remove_activ(cache, ie); 165 _evas_cache_image_remove_activ(cache, ie);
@@ -286,7 +251,7 @@ _evas_cache_image_entry_surface_alloc(Evas_Cache_Image *cache,
286 wmin = w > 0 ? w : 1; 251 wmin = w > 0 ? w : 1;
287 hmin = h > 0 ? h : 1; 252 hmin = h > 0 ? h : 1;
288 if (ie->allocated.w == wmin && ie->allocated.h == hmin) 253 if (ie->allocated.w == wmin && ie->allocated.h == hmin)
289 return; 254 return ;
290 255
291#ifdef BUILD_ASYNC_PRELOAD 256#ifdef BUILD_ASYNC_PRELOAD
292 pthread_mutex_lock(&mutex_surface_alloc); 257 pthread_mutex_lock(&mutex_surface_alloc);
@@ -417,9 +382,6 @@ evas_cache_image_init(const Evas_Cache_Image_Func *cb)
417 382
418 new->references = 1; 383 new->references = 1;
419 384
420 new->scaled = NULL;
421 new->scaledmem = 0;
422
423 return new; 385 return new;
424} 386}
425 387
@@ -641,20 +603,6 @@ evas_cache_image_drop(Image_Entry *im)
641 assert(im); 603 assert(im);
642 assert(im->cache); 604 assert(im->cache);
643 605
644 if (im->scalecache.parent)
645 {
646 im->scalecache.parent->cache->usage -= im->scalecache.parent->cache->func.mem_size_get(im);
647 if (im->scalecache.usage >= 6)
648 {
649 im->scalecache.parent->scalecache.mem -= im->scalecache.dst_w * im->scalecache.dst_h;
650 im->scalecache.parent->cache->scaledmem -= im->scalecache.dst_w * im->scalecache.dst_h;
651 im->scalecache.parent->cache->scaled =
652 eina_list_remove(im->scalecache.parent->cache->scaled, im);
653 }
654 im->scalecache.parent->scalecache.others =
655 eina_list_remove(im->scalecache.parent->scalecache.others, im);
656 }
657
658 im->references--; 606 im->references--;
659 cache = im->cache; 607 cache = im->cache;
660 608
@@ -695,31 +643,13 @@ evas_cache_image_data_not_needed(Image_Entry *im)
695EAPI Image_Entry * 643EAPI Image_Entry *
696evas_cache_image_dirty(Image_Entry *im, int x, int y, int w, int h) 644evas_cache_image_dirty(Image_Entry *im, int x, int y, int w, int h)
697{ 645{
698 Image_Entry *im_dirty = im, *ie = im; 646 Image_Entry *im_dirty = im;
699 Evas_Cache_Image *cache; 647 Evas_Cache_Image *cache;
700 648
701 assert(im); 649 assert(im);
702 assert(im->cache); 650 assert(im->cache);
703 651
704 cache = im->cache; 652 cache = im->cache;
705 while (ie->scalecache.others)
706 {
707 Image_Entry *ie2;
708
709 ie2 = ie->scalecache.others->data;
710 cache->usage -= cache->func.mem_size_get(ie2);
711 if (ie2->scalecache.usage >= 6)
712 {
713 ie->scalecache.mem -= ie2->scalecache.dst_w * ie2->scalecache.dst_h;
714 ie->cache->scaledmem -= ie2->scalecache.dst_w * ie2->scalecache.dst_h;
715 ie->cache->scaled =
716 eina_list_remove(ie->cache->scaled, ie2);
717 }
718 ie->scalecache.others = eina_list_remove_list(ie->scalecache.others, ie->scalecache.others);
719 ie2->scalecache.parent = NULL;
720 evas_cache_image_drop(ie2);
721 }
722
723 if (!(im->flags.dirty)) 653 if (!(im->flags.dirty))
724 { 654 {
725 if (im->references == 1) im_dirty = im; 655 if (im->references == 1) im_dirty = im;
@@ -885,41 +815,6 @@ evas_cache_image_surface_alloc(Image_Entry *im, int w, int h)
885 cache->func.debug("surface-alloc", im); 815 cache->func.debug("surface-alloc", im);
886} 816}
887 817
888EAPI void
889evas_cache_image_surface_dealloc(Image_Entry *im)
890{
891 Evas_Cache_Image *cache;
892
893 assert(im);
894 assert(im->cache);
895
896 cache = im->cache;
897
898 if (!((RGBA_Image *)im)->image.data) return;
899 if (!im->info.loader) return;
900 if (!im->info.module) return;
901 if (!im->flags.loaded) return;
902
903 im->flags.loaded = 0;
904
905#ifdef BUILD_ASYNC_PRELOAD
906 pthread_mutex_lock(&mutex_surface_alloc);
907#endif
908
909 printf("-------- actual dealloc %p\n", im);
910 _evas_cache_image_remove_lru_nodata(cache, im);
911 cache->func.surface_delete(im);
912 im->allocated.w = 0;
913 im->allocated.h = 0;
914
915#ifdef BUILD_ASYNC_PRELOAD
916 pthread_mutex_unlock(&mutex_surface_alloc);
917#endif
918
919 if (cache->func.debug)
920 cache->func.debug("surface-dealloc", im);
921}
922
923EAPI Image_Entry * 818EAPI Image_Entry *
924evas_cache_image_size_set(Image_Entry *im, int w, int h) 819evas_cache_image_size_set(Image_Entry *im, int w, int h)
925{ 820{
@@ -995,6 +890,7 @@ evas_cache_image_load_data(Image_Entry *im)
995 { 890 {
996 _evas_cache_image_entry_surface_alloc(cache, im, im->w, im->h); 891 _evas_cache_image_entry_surface_alloc(cache, im, im->w, im->h);
997 im->flags.loaded = 0; 892 im->flags.loaded = 0;
893
998 return ; 894 return ;
999 } 895 }
1000 896
diff --git a/legacy/evas/src/lib/engines/common/evas_image_load.c b/legacy/evas/src/lib/engines/common/evas_image_load.c
index 8d0a94c21b..27b2eef786 100644
--- a/legacy/evas/src/lib/engines/common/evas_image_load.c
+++ b/legacy/evas/src/lib/engines/common/evas_image_load.c
@@ -43,10 +43,6 @@ evas_common_load_rgba_image_module_from_file(Image_Entry *ie)
43 char *dot; 43 char *dot;
44 int i; 44 int i;
45 45
46 if (ie->info.loader)
47 {
48 if (!evas_common_load_rgba_image_data_from_file(ie)) return 0;
49 }
50 dot = strrchr (ie->file, '.'); 46 dot = strrchr (ie->file, '.');
51 if (dot) 47 if (dot)
52 { 48 {
diff --git a/legacy/evas/src/lib/engines/common/evas_image_main.c b/legacy/evas/src/lib/engines/common/evas_image_main.c
index 623aaa04bc..438cfc68b2 100644
--- a/legacy/evas/src/lib/engines/common/evas_image_main.c
+++ b/legacy/evas/src/lib/engines/common/evas_image_main.c
@@ -405,36 +405,7 @@ EAPI void
405evas_common_image_set_cache(int size) 405evas_common_image_set_cache(int size)
406{ 406{
407 if (eci != NULL) 407 if (eci != NULL)
408 { 408 evas_cache_image_set(eci, size);
409 Evas_Cache_Image *cache = eci;
410
411 evas_cache_image_set(eci, size);
412 while (cache->scaledmem > (cache->limit >> 2))
413 {
414 Eina_List *l;
415 Image_Entry *ie;
416
417 l = eina_list_last(cache->scaled);
418 while (l)
419 {
420 ie = l->data;
421 if (ie->scalecache.parent) break;
422 l = l->prev;
423 }
424 if (!l)
425 {
426 break;
427 }
428 ie->scalecache.parent->scalecache.mem -= ie->scalecache.dst_w * ie->scalecache.dst_h;
429 cache->scaledmem -= ie->scalecache.dst_w * ie->scalecache.dst_h;
430 cache->scaled =
431 eina_list_remove_list(cache->scaled, l);
432 ie->scalecache.parent->scalecache.others =
433 eina_list_remove(ie->scalecache.parent->scalecache.others, ie);
434 ie->scalecache.parent = NULL;
435 evas_cache_image_drop(ie);
436 }
437 }
438} 409}
439 410
440EAPI int 411EAPI int
diff --git a/legacy/evas/src/lib/engines/common/evas_scale_sample.c b/legacy/evas/src/lib/engines/common/evas_scale_sample.c
index a1c3d6b022..0d57717760 100644
--- a/legacy/evas/src/lib/engines/common/evas_scale_sample.c
+++ b/legacy/evas/src/lib/engines/common/evas_scale_sample.c
@@ -271,10 +271,9 @@ scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst,
271 /* scale to dst */ 271 /* scale to dst */
272 dptr = dst_ptr; 272 dptr = dst_ptr;
273#ifdef DIRECT_SCALE 273#ifdef DIRECT_SCALE
274 if ((dc->render_op == _EVAS_RENDER_COPY) || 274 if ((!src->cache_entry.flags.alpha) &&
275 ((!src->cache_entry.flags.alpha) &&
276 (!dst->cache_entry.flags.alpha) && 275 (!dst->cache_entry.flags.alpha) &&
277 (!dc->mul.use))) 276 (!dc->mul.use))
278 { 277 {
279 for (y = 0; y < dst_clip_h; y++) 278 for (y = 0; y < dst_clip_h; y++)
280 { 279 {
diff --git a/legacy/evas/src/lib/include/evas_common.h b/legacy/evas/src/lib/include/evas_common.h
index 30ed5f12b8..59f3834d24 100644
--- a/legacy/evas/src/lib/include/evas_common.h
+++ b/legacy/evas/src/lib/include/evas_common.h
@@ -270,70 +270,64 @@ struct _Image_Entry_Flags
270 270
271struct _Image_Entry 271struct _Image_Entry
272{ 272{
273 EINA_INLIST; 273 EINA_INLIST;
274 274
275 Evas_Cache_Image *cache; 275 Evas_Cache_Image *cache;
276 276
277 const char *cache_key; 277 const char *cache_key;
278 278
279 const char *file; 279 const char *file;
280 const char *key; 280 const char *key;
281 281
282 const void *target; 282 const void *target;
283 283
284 time_t timestamp; 284 time_t timestamp;
285 time_t laststat; 285 time_t laststat;
286 286
287 int references; 287 int references;
288 288
289 unsigned char scale; 289 unsigned char scale;
290 290
291 RGBA_Image_Loadopts load_opts; 291 RGBA_Image_Loadopts load_opts;
292 int space; 292 int space;
293 int w; 293 int w;
294 int h; 294 int h;
295 295
296 struct { 296 struct
297 int w; 297 {
298 int h; 298 int w;
299 } allocated; 299 int h;
300 300 } allocated;
301 struct { 301
302 void *module; 302 struct
303 void *loader; 303 {
304 } info; 304 void *module;
305 305 void *loader;
306 Image_Entry_Flags flags; 306 } info;
307 struct { 307
308 int usage; 308 Image_Entry_Flags flags;
309 int mem;
310 int src_x, src_y, src_w, src_h;
311 int dst_w, dst_h;
312 int smooth;
313 Image_Entry *parent;
314 Eina_List *others;
315 } scalecache;
316}; 309};
317 310
318struct _Engine_Image_Entry 311struct _Engine_Image_Entry
319{ 312{
320 EINA_INLIST; 313 EINA_INLIST;
321 314
322 /* Upper Engine data. */ 315 /* Upper Engine data. */
323 Image_Entry *src; 316 Image_Entry *src;
324 317
325 /* Cache stuff. */ 318 /* Cache stuff. */
326 Evas_Cache_Engine_Image *cache; 319 Evas_Cache_Engine_Image *cache;
327 const char *cache_key; 320 const char *cache_key;
328 321
329 struct { 322 struct
330 Evas_Bool cached : 1; 323 {
331 Evas_Bool activ : 1; 324 Evas_Bool cached : 1;
332 Evas_Bool dirty : 1; 325 Evas_Bool activ : 1;
333 Evas_Bool loaded : 1; 326 Evas_Bool dirty : 1;
334 Evas_Bool need_parent : 1; 327 Evas_Bool loaded : 1;
328 Evas_Bool need_parent : 1;
335 } flags; 329 } flags;
336 330
337 int references; 331 int references;
338 int w; 332 int w;
339 int h; 333 int h;