fixed async preload stall bug! still 1 issue left when caches
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 14 Dec 2010 10:22:06 +0000 (10:22 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 14 Dec 2010 10:22:06 +0000 (10:22 +0000)
(scalecaches) are flushed which can cause a hang until all data is
"loaded back in" again. it's a bit of a doosey actually and so isn't
fixed here.

git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@55551 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/cache/evas_cache_image.c
src/lib/engines/common/evas_image_data.c
src/lib/engines/common/evas_image_main.c
src/lib/engines/common/evas_image_scalecache.c
src/lib/include/evas_common.h

index 81781eb..4d200a7 100644 (file)
@@ -272,6 +272,7 @@ _evas_cache_image_entry_delete(Evas_Cache_Image *cache, Image_Entry *ie)
 
 #ifdef BUILD_ASYNC_PRELOAD
    LKD(ie->lock);
+   LKD(ie->lock_cancel);
 #endif
 #ifdef EVAS_FRAME_QUEUING
    LKD(ie->lock_references);
@@ -336,6 +337,7 @@ _evas_cache_image_entry_new(Evas_Cache_Image *cache,
 
 #ifdef BUILD_ASYNC_PRELOAD
    LKI(ie->lock);
+   LKI(ie->lock_cancel); 
    ie->targets = NULL;
    ie->preload = NULL;
    ie->flags.delete_me = 0;
@@ -431,6 +433,18 @@ _evas_cache_image_async_heavy(void *data)
      }
 
    current->channel = pchannel;
+   
+   // check the unload cancel flag
+   LKL(current->lock_cancel);
+   if (current->unload_cancel)
+     {
+        current->unload_cancel = EINA_FALSE;
+        cache->func.surface_delete(current);
+        current->flags.loaded = 0;
+        current->flags.preload_done = 0;
+     }
+   LKU(current->lock_cancel);
+   
    LKU(current->lock);
 }
 
@@ -1406,7 +1420,15 @@ evas_cache_image_unload_data(Image_Entry *im)
    evas_cache_image_preload_cancel(im, NULL);
 
 #ifdef BUILD_ASYNC_PRELOAD
-   LKL(im->lock);
+   LKL(im->lock_cancel);
+   if (LKT(im->lock) != 0) /* can't get image lock - busy async load */
+     {
+        im->unload_cancel = EINA_TRUE;
+        LKU(im->lock_cancel);
+        return;
+     }
+   LKU(im->lock_cancel);
+//   LKL(im->lock);
 #endif
    if ((!im->flags.loaded) || (!im->file) ||
        (!im->info.module) || (im->flags.dirty))
@@ -1453,17 +1475,22 @@ EAPI void
 evas_cache_image_preload_data(Image_Entry *im, const void *target)
 {
 #ifdef BUILD_ASYNC_PRELOAD
+   RGBA_Image *img = (RGBA_Image *)im;
+   
    assert(im);
    assert(im->cache);
 
-   if (im->flags.loaded)
+   if ((im->flags.loaded) && (img->image.data))
      {
        evas_object_inform_call_image_preloaded((Evas_Object *)target);
        return;
      }
+   im->flags.loaded = 0;
 
    if (!_evas_cache_image_entry_preload_add(im, target))
-     evas_object_inform_call_image_preloaded((Evas_Object *)target);
+     {
+        evas_object_inform_call_image_preloaded((Evas_Object *)target);
+     }
 #else
    evas_cache_image_load_data(im);
    evas_object_inform_call_image_preloaded((Evas_Object *)target);
index 1c17cf7..2213ced 100644 (file)
@@ -102,7 +102,11 @@ evas_common_rgba_image_colorspace_set(Image_Entry* ie_dst, int cspace)
       case EVAS_COLORSPACE_YCBCR422P709_PL:
        if (dst->image.no_free)
          {
-            dst->image.data = NULL;
+             ie_dst->allocated.w = 0;
+             ie_dst->allocated.h = 0;
+             ie_dst->flags.preload_done = 0;
+             ie_dst->flags.loaded = 0;
+             dst->image.data = NULL;
             dst->image.no_free = 0;
              /* FIXME: Must allocate image.data surface cleanly. */
          }
index 0e8d7a3..164e811 100644 (file)
@@ -213,6 +213,8 @@ evas_common_rgba_image_unload(Image_Entry *ie)
         im->image.data = NULL;
         ie->allocated.w = 0;
         ie->allocated.h = 0;
+        ie->flags.preload_done = 0;
+        ie->flags.loaded = 0;
         return;
      }
 #endif   
@@ -222,6 +224,8 @@ evas_common_rgba_image_unload(Image_Entry *ie)
    im->image.data = NULL;
    ie->allocated.w = 0;
    ie->allocated.h = 0;
+   ie->flags.preload_done = 0;
+   ie->flags.loaded = 0;
 }
 
 static int
@@ -284,6 +288,10 @@ _evas_common_rgba_image_surface_delete(Image_Entry *ie)
      evas_cserve_image_free(ie);
 #endif   
    im->image.data = NULL;
+   ie->allocated.w = 0;
+   ie->allocated.h = 0;
+   ie->flags.preload_done = 0;
+   ie->flags.loaded = 0;
    evas_common_rgba_image_scalecache_dirty(&im->cache_entry);
 }
 
index c096119..52a48a4 100644 (file)
@@ -729,19 +729,22 @@ evas_common_rgba_image_scalecache_do(Image_Entry *ie, RGBA_Image *dst,
          * causes only speed-down side-effect and no memory usage gain;
          * it will be loaded again for the very next rendering for this image.
          */
-        if ((dounload) || 
-            ((im->cache_entry.flags.loaded) && 
-             ((!im->cs.no_free) 
+        if (ie->scale_hint != EVAS_IMAGE_SCALE_HINT_DYNAMIC)
+          {
+             if ((dounload) || 
+                 ((im->cache_entry.flags.loaded) && 
+                     ((!im->cs.no_free) 
 #ifdef EVAS_CSERVE             
-             || (ie->data1)
+                      || (ie->data1)
 #endif             
-              )  &&
-             (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)))
-          {
-             if ((dounload) || (im->cache.orig_usage < 
-                                (im->cache.newest_usage / 20)))
+                     )  &&
+                     (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)))
                {
-                  evas_common_rgba_image_unload(&im->cache_entry);
+                  if ((dounload) || (im->cache.orig_usage < 
+                                     (im->cache.newest_usage / 20)))
+                    {
+                       evas_common_rgba_image_unload(&im->cache_entry);
+                    }
                }
           }
 #endif
index 6889c06..9ca90c3 100644 (file)
@@ -598,6 +598,8 @@ struct _Image_Entry
 
 #ifdef BUILD_ASYNC_PRELOAD
    LK(lock);
+   LK(lock_cancel);
+   Eina_Bool unload_cancel : 1;
 #endif
 
    Image_Entry_Flags      flags;