summaryrefslogtreecommitdiff
path: root/legacy/evas/src
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
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
-rw-r--r--legacy/evas/src/modules/engines/software_generic/evas_engine.c243
8 files changed, 76 insertions, 446 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;
diff --git a/legacy/evas/src/modules/engines/software_generic/evas_engine.c b/legacy/evas/src/modules/engines/software_generic/evas_engine.c
index ddd277da7c..1435b3146a 100644
--- a/legacy/evas/src/modules/engines/software_generic/evas_engine.c
+++ b/legacy/evas/src/modules/engines/software_generic/evas_engine.c
@@ -731,175 +731,6 @@ eng_image_data_preload_cancel(void *data, void *image)
731 evas_cache_image_preload_cancel(&im->cache_entry); 731 evas_cache_image_preload_cancel(&im->cache_entry);
732} 732}
733 733
734#define SCALECACHE 1
735
736#ifdef SCALECACHE
737static Image_Entry *
738_sc_find(Image_Entry *im, int src_x, int src_y, int src_w, int src_h, int dst_w, int dst_h, int smooth)
739{
740 Eina_List *l;
741 Image_Entry *ie = NULL;
742
743 for (l = im->scalecache.others; l; l = l->next)
744 {
745 ie = l->data;
746 if ((ie->scalecache.dst_w == dst_w) &&
747 (ie->scalecache.dst_h == dst_h) &&
748 (ie->scalecache.src_w == src_w) &&
749 (ie->scalecache.src_h == src_h) &&
750 (ie->scalecache.src_x == src_x) &&
751 (ie->scalecache.src_y == src_y) &&
752 (ie->scalecache.smooth == smooth))
753 {
754 if (l != ie->scalecache.others)
755 {
756 im->scalecache.others = eina_list_remove_list(im->scalecache.others, l);
757 im->scalecache.others = eina_list_prepend(im->scalecache.others, ie);
758 }
759 ie->scalecache.usage++;
760 return ie;
761 }
762 }
763 return NULL;
764}
765
766static void
767_sc_clean(Image_Entry *im)
768{
769 while ((im->scalecache.mem > (im->cache->limit >> 2)) ||
770 (eina_list_count(im->scalecache.others) > 40))
771 {
772 Eina_List *l;
773 Image_Entry *ie;
774
775 printf("clean %i > %i\n", im->cache->scaledmem, im->cache->limit >> 2);
776 l = eina_list_last(im->scalecache.others);
777 ie = l->data;
778 if (ie->scalecache.usage >= 6)
779 {
780 im->scalecache.mem -= ie->scalecache.dst_w * ie->scalecache.dst_h;
781 im->cache->scaledmem -= ie->scalecache.dst_w * ie->scalecache.dst_h;
782 im->cache->scaled =
783 eina_list_remove(im->cache->scaled, ie);
784 }
785 im->scalecache.others = eina_list_remove_list(im->scalecache.others, l);
786 ie->scalecache.parent = NULL;
787 evas_cache_image_drop(ie);
788 }
789}
790
791static Image_Entry *
792_sc_new(Image_Entry *im, int src_x, int src_y, int src_w, int src_h, int dst_w, int dst_h, int smooth)
793{
794 Image_Entry *ie;
795
796 ie = evas_cache_image_empty(im->cache);
797 evas_cache_image_colorspace(ie, EVAS_COLORSPACE_ARGB8888);
798 im->scalecache.usage++;
799 im->scalecache.others = eina_list_prepend(im->scalecache.others, ie);
800 ie->scalecache.src_x = src_x;
801 ie->scalecache.src_y = src_y;
802 ie->scalecache.src_w = src_w;
803 ie->scalecache.src_h = src_h;
804 ie->scalecache.dst_w = dst_w;
805 ie->scalecache.dst_h = dst_h;
806 ie->scalecache.smooth = smooth;
807 ie->scalecache.parent = im;
808 return ie;
809}
810
811static int
812_sc_fill(Image_Entry *im, Image_Entry *ie)
813{
814 RGBA_Draw_Context *tctx;
815
816 ie->scalecache.usage++;
817 if (ie->scalecache.usage < 5) return 0;
818 if (ie->scalecache.usage >= 6)
819 {
820 ie->scalecache.parent->scalecache.usage--;
821 if (ie->scalecache.parent->scalecache.usage <= 0)
822 {
823 ie->scalecache.parent->scalecache.usage = 0;
824 if ((im->info.loader) &&
825 (im->flags.loaded) &&
826 (im->info.module) &&
827 (im->file) &&
828 (((RGBA_Image*)im)->image.data));
829 {
830 evas_cache_image_surface_dealloc(im);
831 }
832 }
833 im->cache->scaled =
834 eina_list_remove(im->cache->scaled, ie);
835 im->cache->scaled =
836 eina_list_prepend(im->cache->scaled, ie);
837 return 1;
838 }
839 im->scalecache.usage += 10;
840 im->cache->func.load(im);
841 ie->scalecache.usage = 6;
842 im->scalecache.mem += ie->scalecache.dst_w * ie->scalecache.dst_h;
843 im->cache->scaledmem += ie->scalecache.dst_w * ie->scalecache.dst_h;
844 im->cache->scaled =
845 eina_list_prepend(im->cache->scaled, ie);
846 ie->flags.alpha = im->flags.alpha;
847 ie->w = ie->scalecache.dst_w;
848 ie->h = ie->scalecache.dst_h;
849 evas_cache_image_surface_alloc(ie, ie->w, ie->h);
850 tctx = evas_common_draw_context_new();
851 evas_common_draw_context_set_render_op(tctx, _EVAS_RENDER_COPY);
852 if (ie->scalecache.smooth)
853 evas_common_scale_rgba_in_to_out_clip_smooth
854 ((RGBA_Image *)im, (RGBA_Image *)ie, tctx,
855 ie->scalecache.src_x, ie->scalecache.src_y,
856 ie->scalecache.src_w, ie->scalecache.src_h,
857 0, 0,
858 ie->scalecache.dst_w, ie->scalecache.dst_h);
859 else
860 evas_common_scale_rgba_in_to_out_clip_sample
861 ((RGBA_Image *)im, (RGBA_Image *)ie, tctx,
862 ie->scalecache.src_x, ie->scalecache.src_y,
863 ie->scalecache.src_w, ie->scalecache.src_h,
864 0, 0,
865 ie->scalecache.dst_w, ie->scalecache.dst_h);
866 evas_common_draw_context_free(tctx);
867 return 1;
868}
869
870static void
871_sc_flush(Evas_Cache_Image *cache)
872{
873 while (cache->scaledmem > (cache->limit >> 2))
874 {
875 Eina_List *l;
876 Image_Entry *ie;
877
878 printf("flush %i > %i\n", cache->scaledmem, cache->limit >> 2);
879 l = eina_list_last(cache->scaled);
880 while (l)
881 {
882 ie = l->data;
883 if (ie->scalecache.parent) break;
884 l = l->prev;
885 }
886 if (!l)
887 {
888 break;
889 }
890 ie->scalecache.parent->scalecache.mem -= ie->scalecache.dst_w * ie->scalecache.dst_h;
891 cache->scaledmem -= ie->scalecache.dst_w * ie->scalecache.dst_h;
892 cache->scaled =
893 eina_list_remove_list(cache->scaled, l);
894 ie->scalecache.parent->scalecache.others =
895 eina_list_remove(ie->scalecache.parent->scalecache.others, ie);
896 ie->scalecache.parent = NULL;
897 evas_cache_image_drop(ie);
898 }
899}
900
901#endif
902
903static void 734static void
904eng_image_draw(void *data, void *context, void *surface, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth) 735eng_image_draw(void *data, void *context, void *surface, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth)
905{ 736{
@@ -912,72 +743,20 @@ eng_image_draw(void *data, void *context, void *surface, void *image, int src_x,
912 evas_common_image_colorspace_normalize(im); 743 evas_common_image_colorspace_normalize(im);
913#ifdef BUILD_PTHREAD 744#ifdef BUILD_PTHREAD
914 if (cpunum > 1) 745 if (cpunum > 1)
915 { 746 evas_common_pipe_image_draw(im, surface, context, smooth,
916 if (im->image.data) 747 src_x, src_y, src_w, src_h,
917 { 748 dst_x, dst_y, dst_w, dst_h);
918 evas_common_pipe_image_draw(im, surface,
919 context, smooth,
920 src_x, src_y, src_w, src_h,
921 dst_x, dst_y, dst_w, dst_h);
922 }
923 }
924 else 749 else
925#endif 750#endif
926 { 751 {
927#ifdef SCALECACHE 752 if (smooth)
928 Image_Entry *ie, *ie2; 753 evas_common_scale_rgba_in_to_out_clip_smooth(im, surface, context,
929 int ok; 754 src_x, src_y, src_w, src_h,
930 755 dst_x, dst_y, dst_w, dst_h);
931 ie = (Image_Entry *)im; 756 else
932 if ((src_w == dst_w) && (src_h == dst_h)) 757 evas_common_scale_rgba_in_to_out_clip_sample(im, surface, context,
933 { 758 src_x, src_y, src_w, src_h,
934 ie->scalecache.usage++; 759 dst_x, dst_y, dst_w, dst_h);
935 if (smooth)
936 evas_common_scale_rgba_in_to_out_clip_smooth(im, surface, context,
937 src_x, src_y, src_w, src_h,
938 dst_x, dst_y, dst_w, dst_h);
939 else
940 evas_common_scale_rgba_in_to_out_clip_sample(im, surface, context,
941 src_x, src_y, src_w, src_h,
942 dst_x, dst_y, dst_w, dst_h);
943 }
944 else
945 {
946 ok = 0;
947 _sc_clean(ie);
948 ie2 = _sc_find(ie, src_x, src_y, src_w, src_h, dst_w, dst_h, smooth);
949 if (ie2) ok = _sc_fill(ie, ie2);
950 else
951 {
952 ie2 = _sc_new(ie, src_x, src_y, src_w, src_h, dst_w, dst_h, smooth);
953 if (ie2) ok = _sc_fill(ie, ie2);
954 }
955 if ((ie2) && (ok))
956 evas_common_scale_rgba_in_to_out_clip_sample((RGBA_Image *)ie2,
957 surface, context,
958 0, 0, dst_w, dst_h,
959 dst_x, dst_y, dst_w, dst_h);
960 else
961 {
962 ie->scalecache.usage++;
963 evas_cache_image_load_data(ie);
964#endif
965 if (im->image.data)
966 {
967 if (smooth)
968 evas_common_scale_rgba_in_to_out_clip_smooth(im, surface, context,
969 src_x, src_y, src_w, src_h,
970 dst_x, dst_y, dst_w, dst_h);
971 else
972 evas_common_scale_rgba_in_to_out_clip_sample(im, surface, context,
973 src_x, src_y, src_w, src_h,
974 dst_x, dst_y, dst_w, dst_h);
975 }
976#ifdef SCALECACHE
977 }
978 }
979 _sc_flush(ie->cache);
980#endif
981 evas_common_cpu_end_opt(); 760 evas_common_cpu_end_opt();
982 } 761 }
983} 762}