cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=3aa63faa1087aafa7fe1f7d4a778536dbd4de53f

commit 3aa63faa1087aafa7fe1f7d4a778536dbd4de53f
Author: Cedric BAIL <ced...@osg.samsung.com>
Date:   Tue Dec 6 11:44:05 2016 -0800

    evas: add possibility for image loader to know if what they are working is 
still useful.
---
 src/lib/evas/cache/evas_cache_image.c | 11 +++++++++++
 src/lib/evas/cache/evas_preload.c     |  1 +
 2 files changed, 12 insertions(+)

diff --git a/src/lib/evas/cache/evas_cache_image.c 
b/src/lib/evas/cache/evas_cache_image.c
index 7dba180..152cea6 100644
--- a/src/lib/evas/cache/evas_cache_image.c
+++ b/src/lib/evas/cache/evas_cache_image.c
@@ -324,6 +324,14 @@ _evas_cache_image_entry_surface_alloc(Evas_Cache_Image 
*cache,
    SLKU(engine_lock);
 }
 
+static Eina_Bool
+evas_cache_image_cancelled(void *data)
+{
+   Image_Entry *current = data;
+
+   return evas_preload_thread_cancelled_is(current->preload);
+}
+
 static void
 _evas_cache_image_async_heavy(void *data)
 {
@@ -343,7 +351,10 @@ _evas_cache_image_async_heavy(void *data)
    if ((!current->flags.loaded) &&
        current->info.loader->threadable)
      {
+        evas_module_task_register(evas_cache_image_cancelled, current);
         error = cache->func.load(current);
+        evas_module_task_unregister();
+
         if (cache->func.debug) cache->func.debug("load", current);
         current->load_error = error;
         if (error != EVAS_LOAD_ERROR_NONE)
diff --git a/src/lib/evas/cache/evas_preload.c 
b/src/lib/evas/cache/evas_preload.c
index f18d5b6..9ad2f35 100644
--- a/src/lib/evas/cache/evas_preload.c
+++ b/src/lib/evas/cache/evas_preload.c
@@ -135,5 +135,6 @@ evas_preload_thread_cancel(Evas_Preload_Pthread *work)
 Eina_Bool
 evas_preload_thread_cancelled_is(Evas_Preload_Pthread *work)
 {
+   if (!work) return EINA_FALSE;
    return ecore_thread_check(work->thread);
 }

-- 


Reply via email to