[EGIT] [core/efl] master 01/02: epp - document that fallthrough is intended

2016-09-08 Thread Carsten Haitzler
raster pushed a commit to branch master.

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

commit f37a0398c3906551a94a119b5e8b5b729644edd1
Author: Carsten Haitzler (Rasterman) 
Date:   Thu Sep 8 11:16:14 2016 +0900

epp - document that fallthrough is intended
---
 src/bin/edje/epp/cpplib.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/bin/edje/epp/cpplib.c b/src/bin/edje/epp/cpplib.c
index 5fb7375..1e9802f 100644
--- a/src/bin/edje/epp/cpplib.c
+++ b/src/bin/edje/epp/cpplib.c
@@ -4298,6 +4298,7 @@ skip_if_group(cpp_reader * pfile, int any)
  validate_else(pfile,
kt->type ==
T_ELSE ? "#else" : "#endif");
+   /* this fall through is intened */
case T_ELIF:
   if (pfile->if_stack == CPP_BUFFER(pfile)->if_stack)
 {

-- 




[EGIT] [core/efl] master 02/02: efl ui image - fix janky blocking async image preload thread handling

2016-09-08 Thread Carsten Haitzler
raster pushed a commit to branch master.

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

commit be29f3f4ecfda76de98963b5f2d04c0ccc672590
Author: Carsten Haitzler (Rasterman) 
Date:   Thu Sep 8 15:00:22 2016 +0900

efl ui image - fix janky blocking async image preload thread handling

fix the elm image threaded image preload to be far simpler and
actually threadsafe without blocking the mainloop at all even on
object deletion. this also ensures ar least the first 512M of any
async precached file are loaded in so the preload doesnt stall on
headers that are outside maybe the first 4k of the file. i saw this
happening all over the place in the test i created.

@optimize
---
 src/lib/elementary/efl_ui_image.c| 334 ---
 src/lib/elementary/efl_ui_widget_image.h |   6 +-
 2 files changed, 132 insertions(+), 208 deletions(-)

diff --git a/src/lib/elementary/efl_ui_image.c 
b/src/lib/elementary/efl_ui_image.c
index 0ddab23..b1ddcc5 100644
--- a/src/lib/elementary/efl_ui_image.c
+++ b/src/lib/elementary/efl_ui_image.c
@@ -44,12 +44,15 @@ static const Elm_Action key_actions[] = {
{NULL, NULL}
 };
 
-struct _Async_Open_Data {
+typedef struct _Async_Open_Data Async_Open_Data;
+
+struct _Async_Open_Data
+{
+   Eo   *obj;
Eina_Stringshare *file, *key;
-   Eina_File *f_set, *f_open;
-   void *map;
-   Eina_Bool cancel;
-   Eina_Bool failed;
+   Eina_File*f_set, *f_open;
+   void *map;
+   unsigned char sum;
 };
 
 static void
@@ -241,243 +244,186 @@ _async_open_data_free(Async_Open_Data *data)
 }
 
 static void
-_efl_ui_image_async_open_do(void *data, Ecore_Thread *thread EINA_UNUSED)
+_efl_ui_image_async_open_do(void *data, Ecore_Thread *thread)
 {
-   Efl_Ui_Image_Data * sd = data;
+   Async_Open_Data *todo = data;
Eina_File *f;
-   Async_Open_Data *todo, *done;
void *map = NULL;
-   unsigned int buf;
+   unsigned char *p, sum = 0;
+   size_t i, size;
 
-   eina_spinlock_take(&sd->async.lck);
-   todo = sd->async.todo;
-   done = sd->async.done;
-   sd->async.todo = NULL;
-   sd->async.done = NULL;
-
-   if (done) _async_open_data_free(done);
-   if (!todo)
- {
-eina_spinlock_release(&sd->async.lck);
-return;
- }
+   if (ecore_thread_check(thread)) return;
 
-begin:
-   if (todo->f_set)
- f = todo->f_set;
+   if (todo->f_set) f = todo->f_set;
else if (todo->file)
  {
 // blocking
 f = eina_file_open(todo->file, EINA_FALSE);
-if (!f)
-  {
- todo->failed = EINA_TRUE;
- sd->async.done = todo;
- eina_spinlock_release(&sd->async.lck);
- return;
-  }
+if (!f) return;
  }
else
  {
 CRI("Async open has no input file!");
-eina_spinlock_release(&sd->async.lck);
 return;
  }
-
-   if (ecore_thread_check(sd->async.th))
+   if (ecore_thread_check(thread))
  {
 if (!todo->f_set) eina_file_close(f);
-_async_open_data_free(todo);
-eina_spinlock_release(&sd->async.lck);
 return;
  }
 
// Read just enough data for map to actually do something.
-   map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
-   if (map && (eina_file_size_get(f) >= sizeof(buf)))
- memcpy(&buf, map, sizeof(buf));
+   p = map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
+   size = eina_file_size_get(f);
+   // Read and ensure all pages are in memory for sure first just
+   // 1 byte per page will do. also keep a limit on how much we will
+   // blindly load in here to let's say 512M
+   if (size > (512 * 1024 * 1024)) size = 512 * 1024 * 1024;
+   for (i = 0; i < size; i += 4096)
+ {
+if (ecore_thread_check(thread)) break;
+sum += p[i];
+ }
 
-   if (ecore_thread_check(sd->async.th))
+   if (ecore_thread_check(thread))
  {
 if (map) eina_file_map_free(f, map);
 if (!todo->f_set) eina_file_close(f);
-_async_open_data_free(todo);
-eina_spinlock_release(&sd->async.lck);
 return;
  }
+   todo->f_open = f;
+   todo->map = map;
+   todo->sum = sum;
+}
 
-   done = todo;
-   todo = NULL;
-   done->cancel = EINA_FALSE;
-   done->failed = EINA_FALSE;
-   done->f_set = NULL;
-   done->f_open = f;
-   done->map = map;
-
-   todo = sd->async.todo;
+static void
+_async_clear(Efl_Ui_Image_Data *sd)
+{
+   sd->async.th = NULL;
sd->async.todo = NULL;
-   if (!todo) sd->async.done = done;
+   eina_stringshare_del(sd->async.file);
+   eina_stringshare_del(sd->async.key);
+   sd->async.file = NULL;
+   sd->async.key = NULL;
+}
 
-   if (todo)
+static void
+_async_cancel(Efl_Ui_Image_Data *sd)
+{
+   if (sd->async.th)
  {
-DBG("Async open got a new command before finishing");
-_async_open_data_free(done);
-goto begin;
+ecore_thread_cancel(sd->async.th);
+((Async_Open_Data *)(sd->a

[EGIT] [core/efl] master 01/01: eo domain tests - make a start on them with some basic ones

2016-09-08 Thread Carsten Haitzler
raster pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=150cc62a0d151e6477a191ec5e97299b01f14fc2

commit 150cc62a0d151e6477a191ec5e97299b01f14fc2
Author: Carsten Haitzler (Rasterman) 
Date:   Thu Sep 8 18:39:38 2016 +0900

eo domain tests - make a start on them with some basic ones

this adds tests for some of the basic domain tests. doing the
inter-thread ones is going to be much more fun.
---
 src/Makefile_Eo.am   |  2 +
 src/tests/eo/suite/eo_test_domain.c  | 89 
 src/tests/eo/suite/eo_test_domain.h  | 19 
 src/tests/eo/suite/eo_test_general.c | 67 +++
 4 files changed, 177 insertions(+)

diff --git a/src/Makefile_Eo.am b/src/Makefile_Eo.am
index f41c09f..bd5dcba 100644
--- a/src/Makefile_Eo.am
+++ b/src/Makefile_Eo.am
@@ -119,6 +119,8 @@ tests/eo/suite/eo_test_class_simple.c \
 tests/eo/suite/eo_test_class_simple.h \
 tests/eo/suite/eo_test_class_singleton.c \
 tests/eo/suite/eo_test_class_singleton.h \
+tests/eo/suite/eo_test_domain.c \
+tests/eo/suite/eo_test_domain.h \
 tests/eo/suite/eo_suite.c \
 tests/eo/suite/eo_suite.h \
 tests/eo/suite/eo_error_msgs.h \
diff --git a/src/tests/eo/suite/eo_test_domain.c 
b/src/tests/eo/suite/eo_test_domain.c
new file mode 100644
index 000..9ed5f9a
--- /dev/null
+++ b/src/tests/eo/suite/eo_test_domain.c
@@ -0,0 +1,89 @@
+#ifdef HAVE_CONFIG_H
+# include 
+#endif
+
+#include "Eina.h"
+#include "Eo.h"
+#include "eo_test_domain.h"
+
+#define MY_CLASS DOMAIN_CLASS
+
+EAPI const Efl_Event_Description _EV_DOMAIN_A_CHANGED =
+EFL_EVENT_DESCRIPTION("domain,a,changed");
+
+static void
+_a_set(Eo *obj EINA_UNUSED, void *class_data, int a)
+{
+   Domain_Public_Data *pd = class_data;
+   printf("Set Begin\n");
+   pd->a = a;
+   sleep(1);
+   printf("Set End\n");
+   printf("Call Events\n");
+   efl_event_callback_legacy_call(obj, EV_DOMAIN_A_CHANGED, &pd->a);
+   printf("Call Events End\n");
+}
+
+static int
+_a_get(Eo *obj EINA_UNUSED, void *class_data)
+{
+   Domain_Public_Data *pd = class_data;
+   printf("Get Begin\n");
+   return pd->a;
+}
+
+//return obj = efl_add(DOMAIN_CLASS, NULL);
+
+EFL_VOID_FUNC_BODYV(domain_recursive, EFL_FUNC_CALL(n), int n);
+
+static void
+_recursive(Eo *obj, void *class_data EINA_UNUSED, int n)
+{
+   static int count = 0;
+
+   if (count < n)
+ {
+count++;
+domain_recursive(obj, n);
+ }
+   else
+ count = 0;
+}
+
+static void
+_dbg_info_get(Eo *eo_obj, void *_pd EINA_UNUSED, Efl_Dbg_Info *root)
+{
+   efl_dbg_info_get(efl_super(eo_obj, MY_CLASS), root);
+   Efl_Dbg_Info *group = EFL_DBG_INFO_LIST_APPEND(root, "Test list");
+   EFL_DBG_INFO_APPEND(group, "Test", EINA_VALUE_TYPE_INT, 8);
+}
+
+EFL_VOID_FUNC_BODYV(domain_a_set, EFL_FUNC_CALL(a), int a);
+EFL_FUNC_BODY(domain_a_get, int, 0);
+EFL_FUNC_BODY(domain_a_print, Eina_Bool, EINA_FALSE);
+EFL_FUNC_BODY_CONST(domain_class_hi_print, Eina_Bool, EINA_FALSE);
+EFL_VOID_FUNC_BODY(domain_pure_virtual);
+EFL_VOID_FUNC_BODY(domain_no_implementation);
+
+static Eina_Bool
+_class_initializer(Efl_Class *klass)
+{
+   EFL_OPS_DEFINE(ops,
+ EFL_OBJECT_OP_FUNC(domain_a_set, _a_set),
+ EFL_OBJECT_OP_FUNC(domain_a_get, _a_get),
+ EFL_OBJECT_OP_FUNC(domain_recursive, _recursive)
+   );
+   return efl_class_functions_set(klass, &ops);
+}
+
+static const Efl_Class_Description class_desc = {
+ EO_VERSION,
+ "Domain",
+ EFL_CLASS_TYPE_REGULAR,
+ sizeof(Domain_Public_Data),
+ _class_initializer,
+ NULL,
+ NULL
+};
+
+EFL_DEFINE_CLASS(domain_class_get, &class_desc, EO_CLASS, NULL)
diff --git a/src/tests/eo/suite/eo_test_domain.h 
b/src/tests/eo/suite/eo_test_domain.h
new file mode 100644
index 000..ac74285
--- /dev/null
+++ b/src/tests/eo/suite/eo_test_domain.h
@@ -0,0 +1,19 @@
+#ifndef DOMAIN_H
+#define DOMAIN_H
+
+typedef struct
+{
+   int a;
+} Domain_Public_Data;
+
+EAPI void domain_a_set(Eo *obj, int a);
+EAPI int  domain_a_get(Eo *obj);
+EAPI void domain_recursive(Eo *obj, int n);
+
+extern const Efl_Event_Description _EV_DOMAIN_A_CHANGED;
+#define EV_DOMAIN_A_CHANGED (&(_EV_DOMAIN_A_CHANGED))
+
+#define DOMAIN_CLASS domain_class_get()
+const Efl_Class *domain_class_get(void);
+
+#endif
diff --git a/src/tests/eo/suite/eo_test_general.c 
b/src/tests/eo/suite/eo_test_general.c
index 95ab0b7..9be6de5 100644
--- a/src/tests/eo/suite/eo_test_general.c
+++ b/src/tests/eo/suite/eo_test_general.c
@@ -9,6 +9,7 @@
 #include "eo_suite.h"
 #include "eo_test_class_simple.h"
 #include "eo_test_class_singleton.h"
+#include "eo_test_domain.h"
 
 /* Loading this internal header for testing purposes. */
 #include "eo_ptr_indirection.h"
@@ -1354,6 +1355,71 @@ START_TEST(eo_rec_interface)
 }
 END_TEST
 
+START_TEST(eo_domain)
+{
+   Eo *obj, *objs;
+
+   printf("\n");
+   efl_object_init();
+
+   fail_if(efl_domain_get() != EFL_ID_DOM

Re: [E-devel] [EGIT] [core/efl] master 01/01: eo - make eo id table TLS private data for thread safety and speed

2016-09-08 Thread Tom Hacohen
On 07/09/16 12:35, Carsten Haitzler (The Rasterman) wrote:
> On Wed, 7 Sep 2016 10:44:33 +0100 Tom Hacohen  said:
>
>> Hey,
>>
>> Good job doing it, but I have to say, I'm quite disappointed you decided
>> to push it in.
>>
>> No tests... Eo is a core piece of infrastructure. I kept it stable and
>
> jp was pestering me because there is a patch in phab that fixes something i
> already had fixed as part of this patchset that fixed a bug, so i got it in.
> i'll add tests but all the existing eo tests work. i have tested the
> ecore_thread_main_loop_begin/end separately. i'd have to spend quite some time
> writing these tests by hand to test this etc. most of it is invisible EXCEPt
> the mainloop begin/end - the rest no one uses atm. :)

It's just sending the wrong message and setting the wrong example when 
you put code in without tests. It could have waited until the next 
day... It just sends the wrong message.

>
>> reliable over the years by making sure every contribution includes
>> testing, especially big changes like this one. We have no assurances
>> this change even works correctly (because we don't use threads in the
>> efl this way yet) and we have no way to check our future changes to see
>> if they broke it.
>
> i actually have tested that it WORKS with mainloop begin/end as above and it
> works. i just used the elm thread tests in the docs. so i know it works. it
> doesnt have FORMAL tests for make check yet. i know. on my todo for tomorrow.

I don't trust what you say, and it's nothing personal, I don't trust 
what I say either. :) We need to see the tests so we can make sure the 
tests don't have bugs.

>
>> Shared object and recursive wrapping: I'm not really sure I get what you
>> were talking about, but if I understand correctly it sounds unnecessary.
>> People should manage their own mutexes when sharing objects between threads.
>
> why? even so eo_base would have to do it for itself ANYWAY and then every 
> class
> above that at every entry point put a lock and unlock. it's error prone and
> lots of work. since we have a single dispatch point for methods provided by eo
> we can put it there. the mutex HAS to be recursive tho to work and eina mutxes
> right now are NOT recursive. (well on windows they are as windows mutexes are
> recursive out of the box by default).

I still don't understand what you meant there (or at least, so it seems).

--
Tom.

>
>> --
>> Tom.
>>
>> On 07/09/16 10:17, Carsten Haitzler wrote:
>>> raster pushed a commit to branch master.
>>>
>>> http://git.enlightenment.org/core/efl.git/commit/?id=09f19c3c73b734201bb462bad9f2b5276409
>>>
>>> commit 09f19c3c73b734201bb462bad9f2b5276409
>>> Author: Carsten Haitzler (Rasterman) 
>>> Date:   Wed Sep 7 17:53:33 2016 +0900
>>>
>>> eo - make eo id table TLS private data for thread safety and speed
>>>
>>> This moved all the eoid tables, eoid lookup caches, generation count
>>> information ad eo_isa cache into a TLS segment of memory that is
>>> thread private. There is also a shared domain for EO objects that all
>>> threads can access, but it has an added cost of a lock. This means
>>> objects accessed outside the thread they were created in cannot be
>>> accessed by another thread unless they are adopted in temporarily, or
>>> create4d with the shared domain active at the time of creation. child
>>> objects will use their parent object domain if created with a parent
>>> object passed in. If you were accessing EO (EFL) objects across threads
>>> before then this will actually now cause your code to fail as it was
>>> invalid before to do this as no actual objects were threadsafe in EFL,
>>> so this will force things to "fail early".
>>> ecore_thread_main_loop_begin() and end() still work as this uses the
>>> eo domain adoption features to temporarily adopt a domain during this
>>> section and then return it when done.
>>>
>>> This returns speed back to eo brining the overhead in my tests of
>>> lookup for the elm genlist autobounce test in elementary from about
>>> 5-7% down to 2.5-2.6%. A steep drop.
>>>
>>> This does not mean everything is perfect. Still to do are:
>>>
>>> 1. Tests in the test suite
>>> 2. Some API's to help for sending objects from thread to thread
>>> 3. Make the eo call cache TLS data to make it also safe
>>> 4. Look at other locks in eo and probably move them to TLS data
>>> 5. Make eo resolve and call wrappers that call the real method func do
>>>recursive mutex wrapping of the given object IF it is a shared object
>>>to provide threadsafety transparently for shared objects (but adding
>>>some overhead as a result)
>>> 6. Test test est, and that is why this commit is going in now for wider
>>>testing
>>> 7. Decide how to make this work with sending IPC (between threads)
>>> 8. Deciding what makes an object sendable (a sendable property in base?)
>>> 

[EGIT] [core/efl] master 01/01: Eo class creation: Simplify code using recursive locks.

2016-09-08 Thread Tom Hacohen
tasn pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=6b60560773f59398427f12c21945d31b852db72a

commit 6b60560773f59398427f12c21945d31b852db72a
Author: Tom Hacohen 
Date:   Thu Sep 8 11:14:32 2016 +0100

Eo class creation: Simplify code using recursive locks.

Now that we have recursive locks, the class creation code can be much 
simpler.
All the code there was essentially our own implementation of recursive 
locks,
or rather a special case of those.

This is no longer needed.
---
 src/lib/eo/Eo.h | 24 +---
 src/lib/eo/eo.c | 14 +++---
 2 files changed, 12 insertions(+), 26 deletions(-)

diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index a530604..f1aabd5 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -128,7 +128,7 @@ typedef Eo Efl_Object;
  * Don't touch it if you don't know what you are doing.
  * @internal
  */
-EAPI extern Eina_Spinlock _efl_class_creation_lock;
+EAPI extern Eina_Lock _efl_class_creation_lock;
 
 /**
  * @var _efl_object_init_generation
@@ -320,39 +320,25 @@ const Efl_Class * \
 class_get_func_name(void) \
 { \
const Efl_Class *_tmp_parent_class; \
-   static volatile unsigned char lk_init = 0; \
-   static Eina_Spinlock _my_lock; \
static const Efl_Class * volatile _my_class = NULL; \
static unsigned int _my_init_generation = 1; \
if (EINA_UNLIKELY(_efl_object_init_generation != _my_init_generation)) \
  { \
 _my_class = NULL; /* It's freed in efl_object_shutdown(). */ \
-lk_init = 0; \
  } \
if (EINA_LIKELY(!!_my_class)) return _my_class; \
\
-   eina_spinlock_take(&_efl_class_creation_lock); \
-   if (!lk_init) \
-  eina_spinlock_new(&_my_lock); \
-   if (lk_init < 2) eina_spinlock_take(&_my_lock); \
-   if (!lk_init) \
-  lk_init = 1; \
-   else \
+   eina_lock_take(&_efl_class_creation_lock); \
+   if (!!_my_class) \
  { \
-if (lk_init < 2) eina_spinlock_release(&_my_lock); \
-eina_spinlock_release(&_efl_class_creation_lock); \
+eina_lock_release(&_efl_class_creation_lock); \
 return _my_class; \
  } \
-   eina_spinlock_release(&_efl_class_creation_lock); \
_tmp_parent_class = parent_class; \
_my_class = efl_class_new(class_desc, _tmp_parent_class, __VA_ARGS__); \
_my_init_generation = _efl_object_init_generation; \
-   eina_spinlock_release(&_my_lock); \
+   eina_lock_release(&_efl_class_creation_lock); \
\
-   eina_spinlock_take(&_efl_class_creation_lock); \
-   eina_spinlock_free(&_my_lock); \
-   lk_init = 2; \
-   eina_spinlock_release(&_efl_class_creation_lock); \
return _my_class; \
 }
 
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 7931753..bfc5be5 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -19,7 +19,7 @@
 #define EFL_OBJECT_OP_IDS_FIRST 1
 
 /* Used inside the class_get functions of classes, see #EFL_DEFINE_CLASS */
-EAPI Eina_Spinlock _efl_class_creation_lock;
+EAPI Eina_Lock _efl_class_creation_lock;
 EAPI unsigned int _efl_object_init_generation = 1;
 int _eo_log_dom = -1;
 
@@ -1342,11 +1342,11 @@ efl_class_new(const Efl_Class_Description *desc, const 
Efl_Class *parent_id, ...
  {
 Eo_Id new_id;
 
-eina_spinlock_take(&_efl_class_creation_lock);
+eina_lock_take(&_efl_class_creation_lock);
 new_id = (_eo_classes_last_id + 1) | MASK_CLASS_TAG;
 _eo_classes_expand();
 _eo_classes[_UNMASK_ID(new_id) - 1] = klass;
-eina_spinlock_release(&_efl_class_creation_lock);
+eina_lock_release(&_efl_class_creation_lock);
 
 klass->header.id = new_id;
  }
@@ -1837,7 +1837,7 @@ efl_object_init(void)
 return EINA_FALSE;
  }
 
-   if (!eina_spinlock_new(&_efl_class_creation_lock))
+   if (!eina_lock_recursive_new(&_efl_class_creation_lock))
  {
 EINA_LOG_ERR("Could not init lock.");
 return EINA_FALSE;
@@ -1927,15 +1927,15 @@ efl_object_shutdown(void)
   eo_class_free(*cls_itr);
  }
 
-   eina_spinlock_take(&_efl_class_creation_lock);
+   eina_lock_take(&_efl_class_creation_lock);
_eo_classes_release();
-   eina_spinlock_release(&_efl_class_creation_lock);
+   eina_lock_release(&_efl_class_creation_lock);
 
eina_hash_free(_ops_storage);
 
eina_spinlock_free(&_super_class_lock);
eina_spinlock_free(&_ops_storage_lock);
-   eina_spinlock_free(&_efl_class_creation_lock);
+   eina_lock_free(&_efl_class_creation_lock);
 
_eo_free_ids_tables(_eo_table_data_get());
eina_tls_free(_eo_table_data);

-- 




[EGIT] [tools/eflete] master 01/01: project_manager_import_edj: avoid update and save on project on import edj

2016-09-08 Thread Vitalii Vorobiov
rimmed pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=985ff9f8b3d761779feb0e8dee2932c6865686c7

commit 985ff9f8b3d761779feb0e8dee2932c6865686c7
Author: Vitalii Vorobiov 
Date:   Thu Sep 8 13:37:58 2016 +0300

project_manager_import_edj: avoid update and save on project on import edj

when Project is not created yet and it is trying to create dummy objects
we don't need it to update

@fix
---
 src/bin/project_manager/project_manager_import_edj.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/bin/project_manager/project_manager_import_edj.c 
b/src/bin/project_manager/project_manager_import_edj.c
index dda8e56..1650c2d 100644
--- a/src/bin/project_manager/project_manager_import_edj.c
+++ b/src/bin/project_manager/project_manager_import_edj.c
@@ -135,9 +135,13 @@ _edje_pick_end_cb(void *data,
 
_project_edj_file_copy(ptd);
_copy_meta_data_to_pro(ptd);
+
+   you_shall_not_pass_editor_signals(NULL);
_project_special_group_add(ptd->project);
_project_dummy_image_add(ptd->project);
_project_dummy_sample_add(ptd->project);
+   you_shall_pass_editor_signals(NULL);
+
_project_open_internal(ptd);
ecore_file_unlink(ptd->source_edj);
 

-- 




[EGIT] [core/efl] master 01/01: docs: actually close all ref files properly in order to not exceed maximum

2016-09-08 Thread Daniel Kolesa
q66 pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=1041edc6dc657e91df27b5a4e4a594b4430d7558

commit 1041edc6dc657e91df27b5a4e4a594b4430d7558
Author: Daniel Kolesa 
Date:   Thu Sep 8 13:34:19 2016 +0200

docs: actually close all ref files properly in order to not exceed maximum
---
 src/scripts/elua/apps/docgen/keyref.lua | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/scripts/elua/apps/docgen/keyref.lua 
b/src/scripts/elua/apps/docgen/keyref.lua
index 832f00a..a28e612 100644
--- a/src/scripts/elua/apps/docgen/keyref.lua
+++ b/src/scripts/elua/apps/docgen/keyref.lua
@@ -22,6 +22,7 @@ M.build = function()
 local rf = writer.Writer({ "ref", lang, "key", refn })
 v[#v + 1] = true
 rf:write_include(rf.INCLUDE_PAGE, v)
+rf:finish()
 end
 table.sort(arr)
 f:write_raw(table.concat(arr, "\n"))

-- 




[EGIT] [core/efl] master 01/01: evas: Fix jpeg snafu and properly send hold events to children

2016-09-08 Thread Christopher Michael
devilhorns pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=0f8fb7ef88d1bbb53e70c5ea0a4e8ef6a55c1a47

commit 0f8fb7ef88d1bbb53e70c5ea0a4e8ef6a55c1a47
Author: Chris Michael 
Date:   Thu Sep 8 08:38:38 2016 -0400

evas: Fix jpeg snafu and properly send hold events to children

Commit 405680e836eb47d7dd8f59a4761386e7a80d9244 changed how hold
events were being sent. Previous code was sending the hold events to
child objects, however after mentioned commit, they were being sent to
main objects. This patch fixes that.

Signed-off-by: Chris Michael 
---
 src/lib/evas/canvas/evas_events.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/lib/evas/canvas/evas_events.c 
b/src/lib/evas/canvas/evas_events.c
index 6efd032..fd2f89f 100644
--- a/src/lib/evas/canvas/evas_events.c
+++ b/src/lib/evas/canvas/evas_events.c
@@ -681,6 +681,7 @@ _evas_event_source_hold_events(Evas_Object *eo_obj, int 
event_id, Efl_Input_Hold
Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, 
EFL_CANVAS_OBJECT_CLASS);
Evas_Object *eo_src = _evas_object_image_source_get(eo_obj);
Evas_Object_Protected_Data *src = efl_data_scope_get(eo_src, 
EFL_CANVAS_OBJECT_CLASS);
+   Evas_Object_Protected_Data *child;
Evas_Object *eo_child;
Eina_List *l;
 
@@ -689,7 +690,9 @@ _evas_event_source_hold_events(Evas_Object *eo_obj, int 
event_id, Efl_Input_Hold
EINA_LIST_FOREACH(src->proxy->src_event_in, l, eo_child)
  {
 if (src->delete_me) return;
-evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_HOLD, evt,
+child = efl_data_scope_get(eo_child, EFL_CANVAS_OBJECT_CLASS);
+evas_object_event_callback_call(eo_child, child,
+EVAS_CALLBACK_HOLD, evt,
 event_id, EFL_EVENT_HOLD);
 if (src->layer->evas->delete_me) break;
  }

-- 




Re: [E-devel] Evas Events

2016-09-08 Thread Christopher Michael
On 09/07/2016 06:55 PM, Carsten Haitzler wrote:
> On Wed, 07 Sep 2016 13:52:40 -0400 Christopher Michael 
> 
> said:
>
>> I would appear that commit 405680e836eb47d7dd8f59a4761386e7a80d9244
>> changed the way that hold events are sent. They are no longer being sent
>> to the child objects, but rather the main 'obj':
>>
>> -EV_CALL(eo_child, child, EVAS_CALLBACK_HOLD, ev, event_id, he,
>> parent_he);
>> +evas_object_event_callback_call(eo_obj, obj,
>> EVAS_CALLBACK_HOLD, NULL,
>> +event_id, EFL_EVENT_HOLD, evt);
>>
>> This seems to me like a simple copy/paste problem, however I did not
>> want to push a fix for it (to make the event be sent to the child
>> object) until I can confirm that it is indeed an err.
>>
>> Anyone know ?? (I know jpeg is on vacation right now).
>
> fix it! :) make the commit title noticeable for jp when he comes back.
>

Fixed :)

dh

>> Cheers,
>> dh
>>
>> --
>> ___
>> enlightenment-devel mailing list
>> enlightenment-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>>
>
>


--
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


[EGIT] [core/efl] master 01/01: Eo: Make function overrides implicit.

2016-09-08 Thread Tom Hacohen
tasn pushed a commit to branch master.

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

commit bd3801247e50ff1cda48af33345a918240d7d315
Author: Tom Hacohen 
Date:   Thu Sep 8 13:08:08 2016 +0100

Eo: Make function overrides implicit.

Before this commit, function overrides were explicit. That is, you'd
have to explicitly state you were overriding a function instead of
creating a new one. This made the code a tad more complex, and was also
a bit more annoying to use. This commit removes this extra piece of
information.

This means we now store much less information per function, that will
let us further optimise out structures in the future.
---
 src/benchmarks/eo/eo_bench_eo_do.c |  2 +-
 src/bin/elementary/test_ui_box.c   |  2 +-
 src/bin/elementary/test_ui_grid.c  |  2 +-
 src/bin/eolian/eo_generator.c  |  6 ++--
 src/lib/elementary/efl_ui_grid.c   |  2 +-
 src/lib/eo/Eo.h|  8 ++---
 src/lib/eo/eo.c| 42 +++---
 .../eo/composite_objects/composite_objects_comp.c  |  4 +--
 src/tests/eo/constructors/constructors_mixin.c |  4 +--
 src/tests/eo/constructors/constructors_simple.c|  6 ++--
 src/tests/eo/constructors/constructors_simple2.c   |  2 +-
 src/tests/eo/constructors/constructors_simple3.c   |  2 +-
 src/tests/eo/constructors/constructors_simple5.c   |  2 +-
 src/tests/eo/constructors/constructors_simple6.c   |  2 +-
 src/tests/eo/constructors/constructors_simple7.c   |  2 +-
 .../function_overrides_inherit2.c  |  4 +--
 .../function_overrides_inherit3.c  |  2 +-
 src/tests/eo/interface/interface_simple.c  |  4 +--
 src/tests/eo/mixin/mixin_inherit.c |  2 +-
 src/tests/eo/mixin/mixin_mixin.c   |  4 +--
 src/tests/eo/mixin/mixin_mixin2.c  |  6 ++--
 src/tests/eo/mixin/mixin_mixin3.c  |  6 ++--
 src/tests/eo/signals/signals_simple.c  |  2 +-
 .../eo/suite/eo_test_class_behaviour_errors.c  |  2 +-
 src/tests/eo/suite/eo_test_class_errors.c  | 40 ++---
 src/tests/eo/suite/eo_test_class_simple.c  |  4 +--
 src/tests/eo/suite/eo_test_class_singleton.c   |  2 +-
 src/tests/eo/suite/eo_test_general.c   | 12 +++
 src/tests/eolian/data/override_ref.c   |  6 ++--
 29 files changed, 74 insertions(+), 110 deletions(-)

diff --git a/src/benchmarks/eo/eo_bench_eo_do.c 
b/src/benchmarks/eo/eo_bench_eo_do.c
index 0666580..d434ab9 100644
--- a/src/benchmarks/eo/eo_bench_eo_do.c
+++ b/src/benchmarks/eo/eo_bench_eo_do.c
@@ -62,7 +62,7 @@ static Eina_Bool
 _class_initializer(Efl_Class *klass)
 {
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(simple_a_set, _a_set),
+ EFL_OBJECT_OP_FUNC(simple_a_set, _a_set),
);
 
return efl_class_functions_set(klass, &ops);
diff --git a/src/bin/elementary/test_ui_box.c b/src/bin/elementary/test_ui_box.c
index 5e918be..99e3e93 100644
--- a/src/bin/elementary/test_ui_box.c
+++ b/src/bin/elementary/test_ui_box.c
@@ -178,7 +178,7 @@ static void
 custom_check_cb(void *data, const Efl_Event *event)
 {
EFL_OPS_DEFINE(custom_layout_ops,
-  EFL_OBJECT_OP_FUNC_OVERRIDE(efl_pack_layout_update, 
_custom_layout_update));
+  EFL_OBJECT_OP_FUNC(efl_pack_layout_update, 
_custom_layout_update));
 
Eina_Bool chk = elm_check_selected_get(event->object);
Eo *obj = data;
diff --git a/src/bin/elementary/test_ui_grid.c 
b/src/bin/elementary/test_ui_grid.c
index def80b1..6902b01 100644
--- a/src/bin/elementary/test_ui_grid.c
+++ b/src/bin/elementary/test_ui_grid.c
@@ -23,7 +23,7 @@ static Eina_Bool
 _custom_engine_class_initializer(Efl_Class *klass)
 {
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_CLASS_FUNC_OVERRIDE(efl_pack_layout_do, 
_custom_engine_layout_do),
+ EFL_OBJECT_OP_CLASS_FUNC(efl_pack_layout_do, 
_custom_engine_layout_do),
);
 
return efl_class_functions_set(klass, &ops);
diff --git a/src/bin/eolian/eo_generator.c b/src/bin/eolian/eo_generator.c
index 35b0593..c76c7b5 100644
--- a/src/bin/eolian/eo_generator.c
+++ b/src/bin/eolian/eo_generator.c
@@ -822,7 +822,7 @@ eo_source_end_generate(const Eolian_Class *class, 
Eina_Strbuf *buf)
   if (ftype != EOLIAN_PROP_GET)
 {
Eina_Stringshare *rets = 
eolian_function_full_c_name_get(fnid, EOLIAN_PROP_SET, EINA_FALSE);
-   eina_strbuf_append_printf(str_op, "\n  
EFL_OBJECT_OP_%sFUNC_OVERRIDE(%s, %s_%s_set),",
+   eina_strbuf_append_printf(str_op, "\n  
EFL_OBJECT_OP_%sFUNC(%s, %s_%s_set),",
  class_str, rets, implname, funcname);
eo_bind_func_generate(class, fnid, EOLIAN_PROP_SET,

[EGIT] [tools/eflete] master 01/01: project_manager: better fix of editor usage when Project is not created yet

2016-09-08 Thread Vitalii Vorobiov
rimmed pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=e02c171c28d9490d53924aaf03337bd8ab11a952

commit e02c171c28d9490d53924aaf03337bd8ab11a952
Author: Vitalii Vorobiov 
Date:   Thu Sep 8 15:07:55 2016 +0300

project_manager: better fix of editor usage when Project is not created yet

quick fix

@fix
---
 src/bin/project_manager/group_manager.c  | 2 ++
 src/bin/project_manager/project_manager.c| 8 ++--
 src/bin/project_manager/project_manager_import_edj.c | 4 
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/bin/project_manager/group_manager.c 
b/src/bin/project_manager/group_manager.c
index bb054ce..0b897be 100644
--- a/src/bin/project_manager/group_manager.c
+++ b/src/bin/project_manager/group_manager.c
@@ -413,8 +413,10 @@ gm_state_add(Project *pro, Part *part, const char 
*state_name, double state_valu
  /* Colorclass can be specified but not defined in edc.
 If colorclass don't exist yet adding it */ \
  TODO("move this code to colorclass resource manager"); \
+ you_shall_not_pass_editor_signals(NULL); \
  if (editor_color_class_add(pro->global_object, name, false)) \
ERR("Something wrong happened"); \
+ you_shall_pass_editor_signals(NULL); \
  Colorclass_Resource *res = (Colorclass_Resource 
*)resource_add(name, RESOURCE_TYPE_COLORCLASS); \
  res->color1.r = res->color1.g = res->color1.b = res->color1.a = 
255; \
  res->color2.r = res->color2.g = res->color2.b = res->color2.a = 
255; \
diff --git a/src/bin/project_manager/project_manager.c 
b/src/bin/project_manager/project_manager.c
index 2c5e5a0..2f87579 100644
--- a/src/bin/project_manager/project_manager.c
+++ b/src/bin/project_manager/project_manager.c
@@ -385,7 +385,9 @@ _project_special_group_add(Project *project)
 
ret = edje_object_file_set(edje_edit_obj, project->saved_edj, 
eina_list_data_get(list));
assert(true == ret);
+   you_shall_not_pass_editor_signals(NULL);
CRIT_ON_FAIL(editor_internal_group_add(edje_edit_obj));
+   you_shall_pass_editor_signals(NULL);
 
edje_edit_string_list_free(list);
evas_object_del(edje_edit_obj);
@@ -411,12 +413,12 @@ _project_dummy_sample_add(Project *project)
 
edje_object_file_set(edje_edit_obj, project->saved_edj, 
EFLETE_INTERNAL_GROUP_NAME);
snprintf(buf, sizeof(buf), "%s"EFLETE_DUMMY_SAMPLE_NAME, 
ap.path.sound_path);
+   you_shall_not_pass_editor_signals(NULL);
if (editor_sound_sample_add(edje_edit_obj, EFLETE_DUMMY_SAMPLE_NAME, buf, 
false))
  {
-you_shall_not_pass_editor_signals(NULL);
 CRIT_ON_FAIL(editor_save(edje_edit_obj));
-you_shall_pass_editor_signals(NULL);
  }
+   you_shall_pass_editor_signals(NULL);
 
evas_object_del(edje_edit_obj);
ecore_evas_free(project->ecore_evas);
@@ -441,7 +443,9 @@ _project_dummy_image_add(Project *project)
 
edje_object_file_set(edje_edit_obj, project->saved_edj, 
EFLETE_INTERNAL_GROUP_NAME);
snprintf(buf, sizeof(buf), "%s"EFLETE_DUMMY_IMAGE_NAME, ap.path.image_path);
+   you_shall_not_pass_editor_signals(NULL);
CRIT_ON_FAIL(editor_image_add(edje_edit_obj, buf, false));
+   you_shall_pass_editor_signals(NULL);
 
evas_object_del(edje_edit_obj);
ecore_evas_free(project->ecore_evas);
diff --git a/src/bin/project_manager/project_manager_import_edj.c 
b/src/bin/project_manager/project_manager_import_edj.c
index 1650c2d..dda8e56 100644
--- a/src/bin/project_manager/project_manager_import_edj.c
+++ b/src/bin/project_manager/project_manager_import_edj.c
@@ -135,13 +135,9 @@ _edje_pick_end_cb(void *data,
 
_project_edj_file_copy(ptd);
_copy_meta_data_to_pro(ptd);
-
-   you_shall_not_pass_editor_signals(NULL);
_project_special_group_add(ptd->project);
_project_dummy_image_add(ptd->project);
_project_dummy_sample_add(ptd->project);
-   you_shall_pass_editor_signals(NULL);
-
_project_open_internal(ptd);
ecore_file_unlink(ptd->source_edj);
 

-- 




Re: [E-devel] RFC: EOID + Threads + TLS proposal

2016-09-08 Thread Felipe Magno de Almeida
On Sep 3, 2016 12:17 PM, "Carsten Haitzler"  wrote:
>

[snip]

> Result? Cost of EOID lookup (to find the real pointer of the object) went
from
> 2% to 5% of CPU time.

How are you measuring? Which tool and example? I'd like to try a few things
too, but being sure all would measure the same thing.

> --
> - Codito, ergo sum - "I code, therefore I am" --
> The Rasterman (Carsten Haitzler)ras...@rasterman.com
>
>
>
--
>
> ___
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>
--
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


[EGIT] [tools/eflete] master 01/02: popup: finish migration to async version

2016-09-08 Thread Andrii Kroitor
rimmed pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=bbfdadeefcf95bbac68bbb28b82799388487fc72

commit bbfdadeefcf95bbac68bbb28b82799388487fc72
Author: Andrii Kroitor 
Date:   Thu Sep 8 16:42:55 2016 +0300

popup: finish migration to async version

remove old popup_buttons_disabled_set method
add popup object as argument to Popup_Content_Cb
---
 src/bin/ui/colorclass_manager.c| 24 ++--
 src/bin/ui/main_window.c   |  6 +++---
 src/bin/ui/main_window.h   |  4 +---
 src/bin/ui/popup.c | 15 +--
 src/bin/ui/project_navigator.c | 16 +---
 src/bin/ui/sound_manager.c | 19 +++
 src/bin/ui/style_manager.c | 24 +---
 src/bin/ui/workspace/group_navigator.c | 10 +-
 8 files changed, 57 insertions(+), 61 deletions(-)

diff --git a/src/bin/ui/colorclass_manager.c b/src/bin/ui/colorclass_manager.c
index dcc2ae3..b1f4249 100644
--- a/src/bin/ui/colorclass_manager.c
+++ b/src/bin/ui/colorclass_manager.c
@@ -59,36 +59,40 @@ struct _Colorclasses_Manager
 static Colorclasses_Manager mng;
 
 static void
-_validation(void *data __UNUSED__,
+_validation(void *data,
 Evas_Object *obj __UNUSED__,
 void *event_info __UNUSED__)
 {
-  if (ELM_REG_NOERROR != 
resource_name_validator_status_get(mng.name_validator))
+   Evas_Object *popup = data;
+
+   assert(popup != NULL);
+
+   if (ELM_REG_NOERROR != 
resource_name_validator_status_get(mng.name_validator))
  {
-   popup_buttons_disabled_set(BTN_OK, true);
-   elm_object_signal_emit(obj, "validation,default,fail", "elm");
+popup_button_disabled_set(popup, BTN_OK, true);
+elm_object_signal_emit(obj, "validation,default,fail", "elm");
  }
else
  {
-   popup_buttons_disabled_set(BTN_OK, false);
-   elm_object_signal_emit(obj, "validation,default,pass", "elm");
+popup_button_disabled_set(popup, BTN_OK, false);
+elm_object_signal_emit(obj, "validation,default,pass", "elm");
  }
 }
 
-Evas_Object *
-_add_colorclass_content_get(void *data __UNUSED__, Evas_Object **to_focus)
+static Evas_Object *
+_add_colorclass_content_get(void *data __UNUSED__, Evas_Object *popup, 
Evas_Object **to_focus)
 {
Evas_Object *item = NULL;
 
LAYOUT_PROP_ADD(ap.win, _("Color class name: "), "property", "1swallow")
ENTRY_ADD(item, mng.entry, true);
efl_event_callback_add(mng.entry, ELM_ENTRY_EVENT_VALIDATE, 
resource_name_validator_helper, mng.name_validator);
-   evas_object_smart_callback_add(mng.entry, "changed", _validation, NULL);
+   evas_object_smart_callback_add(mng.entry, "changed", _validation, popup);
elm_object_part_text_set(mng.entry, "guide", _("Type new color class name 
here"));
elm_object_part_content_set(item, "elm.swallow.content", mng.entry);
mng.item = item;
if (to_focus) *to_focus = mng.entry;
-   popup_buttons_disabled_set(BTN_OK, true);
+   popup_button_disabled_set(popup, BTN_OK, true);
 
return mng.item;
 }
diff --git a/src/bin/ui/main_window.c b/src/bin/ui/main_window.c
index c96c090..771faeb 100644
--- a/src/bin/ui/main_window.c
+++ b/src/bin/ui/main_window.c
@@ -177,7 +177,7 @@ ui_main_window_add(void)
 
 #if !HAVE_TIZEN
 Evas_Object *
-_about_window_content_get(void *data, Evas_Object **to_focus __UNUSED__)
+_about_window_content_get(void *data, Evas_Object *popup __UNUSED__, 
Evas_Object **to_focus __UNUSED__)
 {
Evas_Object *label = (Evas_Object *) data;
elm_object_text_set(label,
@@ -220,7 +220,7 @@ about_window_add(void)
 
 #else
 Evas_Object *
-_about_window_content_get(void *data, Evas_Object **to_focus __UNUSED__)
+_about_window_content_get(void *data, Evas_Object *popup __UNUSED__, 
Evas_Object **to_focus __UNUSED__)
 {
   Evas_Object *layout = (Evas_Object *)data;
   elm_layout_theme_set(layout, "layout", "about", "default");
@@ -240,7 +240,7 @@ about_window_add(void)
 
 #endif
 static Evas_Object *
-_shortcuts_window_content_get(void *data, Evas_Object **to_focus __UNUSED__)
+_shortcuts_window_content_get(void *data, Evas_Object *popup __UNUSED__, 
Evas_Object **to_focus __UNUSED__)
 {
Evas_Object *box = data;
Evas_Object *scroller = elm_scroller_add(ap.win);
diff --git a/src/bin/ui/main_window.h b/src/bin/ui/main_window.h
index c0166f1..19cd2d5 100644
--- a/src/bin/ui/main_window.h
+++ b/src/bin/ui/main_window.h
@@ -121,7 +121,7 @@ typedef Eina_Bool(* Popup_Validator_Func)(void *data);
  *
  * @ingroup Window
  */
-typedef Evas_Object *(* Popup_Content_Get_Func)(void *data, Evas_Object 
**to_focus);
+typedef Evas_Object *(* Popup_Content_Get_Func)(void *data, Evas_Object 
*popup, Evas_Object **to_focus);
 
 #define POPUP_CLOSE_CB "POPUP_CLOSE_CB"
 /**
@@ -364,8 +364,6 @@ popup_active_helper_close(void *data,
  * @ingroup Window
  */
 void
-popup_buttons_disabled_set(Popup_Button p_btns, Eina_Bool disabled

[EGIT] [tools/eflete] master 02/02: sound_manager:fix tones validator

2016-09-08 Thread Andrii Kroitor
rimmed pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=2dc202ad8badcac346ead87e2b2f5895c55844e9

commit 2dc202ad8badcac346ead87e2b2f5895c55844e9
Author: Andrii Kroitor 
Date:   Thu Sep 8 16:50:13 2016 +0300

sound_manager:fix tones validator
---
 src/bin/ui/sound_manager.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/bin/ui/sound_manager.c b/src/bin/ui/sound_manager.c
index 7e01cbc..49efecf 100644
--- a/src/bin/ui/sound_manager.c
+++ b/src/bin/ui/sound_manager.c
@@ -374,6 +374,8 @@ _add_tone_content_get(void *data __UNUSED__, Evas_Object 
*popup, Evas_Object **t
ENTRY_ADD(item, mng.frq_entry, true);
efl_event_callback_add(mng.frq_entry, ELM_ENTRY_EVENT_VALIDATE, 
elm_validator_regexp_helper, mng.frq_validator);
evas_object_smart_callback_add(mng.frq_entry, "changed", _validation, 
popup);
+   /* force validator trigger */
+   elm_entry_entry_set(mng.frq_entry, " ");
elm_object_part_text_set(mng.frq_entry, "guide", _("Type a frequency (20 - 
2)"));
elm_object_part_content_set(item, "elm.swallow.content", mng.frq_entry);
/* need to manualy set not valid string for triggered validator */

-- 




[EGIT] [core/enlightenment] master 01/01: OpenBSD non-PAM lokker authentication.

2016-09-08 Thread Al Poole
discomfitor pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=fddcaa43c43c14a9510fd198accb71389985bd96

commit fddcaa43c43c14a9510fd198accb71389985bd96
Author: Al Poole 
Date:   Thu Sep 8 10:06:51 2016 -0400

OpenBSD non-PAM lokker authentication.

Reviewers: ManMower, zmike!

Subscribers: raster, ManMower, cedric

Differential Revision: https://phab.enlightenment.org/D4204
---
 src/bin/e_auth.c | 39 --
 src/bin/e_desklock.c |  2 +-
 src/bin/e_sys_main.c | 59 
 3 files changed, 97 insertions(+), 3 deletions(-)

diff --git a/src/bin/e_auth.c b/src/bin/e_auth.c
index 78d171c..9754ce2 100644
--- a/src/bin/e_auth.c
+++ b/src/bin/e_auth.c
@@ -1,6 +1,6 @@
 #include "e.h"
 
-#if defined(HAVE_PAM) && !defined(__FreeBSD__)
+#if defined(HAVE_PAM) && !defined(__FreeBSD__)  && !defined(__OpenBSD__)
 # include 
 # include 
 
@@ -128,7 +128,7 @@ _auth_pam_init(E_Auth *da)
free(current_host);
return 0;
 }
-#endif  // HAVE_PAM && !__FreeBSD__
+#endif  // HAVE_PAM && !__FreeBSD__ && !_OpenBSD__
 
 E_API int
 #if defined(__FreeBSD__)
@@ -165,6 +165,41 @@ out:
 
return ret;
 }
+#elif defined(__OpenBSD__)
+e_auth_begin(char *passwd)
+{
+   char exe_path[PATH_MAX], *p;
+   Ecore_Exe *exe = NULL;
+   int ret = 0;
+   int len = strlen(passwd);
+
+   if (len == 0) goto out;
+
+   snprintf(exe_path, sizeof(exe_path), 
"%s/enlightenment/utils/enlightenment_sys -z",
+e_prefix_lib_get());
+
+   exe = ecore_exe_pipe_run(exe_path, ECORE_EXE_PIPE_WRITE, NULL);
+   if (!exe) goto out;
+   if (ecore_exe_send(exe, passwd, len) != EINA_TRUE) goto out;
+   if (ecore_exe_send(exe, "\n", 1) != EINA_TRUE) goto out;
+   ecore_exe_close_stdin(exe);
+
+   ret = ecore_exe_pid_get(exe);
+   if (ret == -1)
+ {
+   ret = 0;
+   goto out;
+ }
+ 
+   exe = NULL;
+out:
+   if (exe) ecore_exe_free(exe);
+
+   for (p = passwd; *p; p++)
+ *p = 0;
+
+   return ret;
+}
 #elif defined(HAVE_PAM)
 e_auth_begin(char *passwd)
 {
diff --git a/src/bin/e_desklock.c b/src/bin/e_desklock.c
index d291835..7b2a767 100644
--- a/src/bin/e_desklock.c
+++ b/src/bin/e_desklock.c
@@ -259,7 +259,7 @@ e_desklock_show(Eina_Bool suspend)
 return 1;
  }
 
-#ifndef HAVE_PAM
+#if ! defined(HAVE_PAM) && ! defined(__OpenBSD__)
if (e_desklock_is_system())
  {
 e_util_dialog_show(_("Error - no PAM support"),
diff --git a/src/bin/e_sys_main.c b/src/bin/e_sys_main.c
index 79f30ef..54c60b9 100644
--- a/src/bin/e_sys_main.c
+++ b/src/bin/e_sys_main.c
@@ -49,6 +49,56 @@ static int   auth_etc_enlightenment_sysactions(char *a,
 static void  auth_etc_enlightenment_sysactions_perm(char *path);
 static char *get_word(char *s,
   char *d);
+#if defined(__OpenBSD__)
+
+static void
+_exit_backoff(void)
+{
+   sleep(3);
+   exit(1 << 7);
+}
+
+static int
+_check_auth(const char *guess)
+{
+   struct passwd *pw_ent;
+   uid_t uid = getuid();
+
+   pw_ent = getpwuid_shadow(uid);
+   if (!pw_ent)
+ _exit_backoff();
+
+   return crypt_checkpass(guess, pw_ent->pw_passwd);
+}
+
+static int
+auth_generic_enlightenment_desklock(void)
+{
+   char buf[4096];
+   char byte[1];
+   int res = -1;
+   int i = 0;
+
+   while (read(STDIN_FILENO, byte, sizeof(byte)) > 0)
+ {
+if (byte[0] == '\n') break;
+buf[i++] = byte[0];
+if (i == sizeof(buf) -1) break;
+ }
+
+   buf[i] = '\0';
+
+   if (!i)
+ _exit_backoff();
+
+   res = _check_auth(buf);
+
+   if (res) _exit_backoff();
+
+   return res;
+}
+
+#endif
 
 /* local subsystem globals */
 static Eina_Hash *actions = NULL;
@@ -82,6 +132,15 @@ main(int argc,
  exit(0);
   }
  }
+#if defined(__OpenBSD__)
+   if (argc >= 2)
+ {
+if (!strcmp(argv[1], "-z"))
+  {
+ exit(auth_generic_enlightenment_desklock());
+  }
+ }
+#endif
if (argc >= 3)
  {
 if ((argc == 3) && (!strcmp(argv[1], "-t")))

-- 




[EGIT] [core/enlightenment] master 01/01: add event handler for evry event type, not #define value

2016-09-08 Thread Mike Blumenkrantz
discomfitor pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=4e7c50553619feb46e1e1bcfe24c0d8e95750d1f

commit 4e7c50553619feb46e1e1bcfe24c0d8e95750d1f
Author: Mike Blumenkrantz 
Date:   Thu Sep 8 10:27:05 2016 -0400

add event handler for evry event type, not #define value

fix T4007
---
 src/modules/everything/evry.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/modules/everything/evry.c b/src/modules/everything/evry.c
index e17898c..5f7a2b6 100644
--- a/src/modules/everything/evry.c
+++ b/src/modules/everything/evry.c
@@ -259,7 +259,7 @@ evry_show(E_Zone *zone, E_Zone_Edge edge, const char 
*params, Eina_Bool popup)
 #endif
evas_object_event_callback_add(e_win_client_get(win->ewin)->frame, 
EVAS_CALLBACK_SHOW, (Evas_Object_Event_Cb)_evry_cb_show, win);
 
-   E_LIST_HANDLER_APPEND(win->handlers, EVRY_EVENT_ITEM_CHANGED, 
_evry_cb_item_changed, win);
+   E_LIST_HANDLER_APPEND(win->handlers, _evry_events[EVRY_EVENT_ITEM_CHANGED], 
_evry_cb_item_changed, win);
 
E_LIST_HANDLER_APPEND(win->handlers, ECORE_EVENT_MOUSE_BUTTON_DOWN, 
_evry_cb_mouse, win);
 

-- 




[EGIT] [core/enlightenment] master 01/01: do not attempt to populate gadgets during type_add if site has not yet been populated

2016-09-08 Thread Mike Blumenkrantz
discomfitor pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=0a9b8889e0730774ae9c6183e6ff8a72455a0e02

commit 0a9b8889e0730774ae9c6183e6ff8a72455a0e02
Author: Mike Blumenkrantz 
Date:   Thu Sep 8 10:29:22 2016 -0400

do not attempt to populate gadgets during type_add if site has not yet been 
populated

mostly just fixes some ERRs on init
---
 src/bin/e_gadget.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/bin/e_gadget.c b/src/bin/e_gadget.c
index ba5e41a..7f46492 100644
--- a/src/bin/e_gadget.c
+++ b/src/bin/e_gadget.c
@@ -1360,9 +1360,10 @@ e_gadget_type_add(const char *type, E_Gadget_Create_Cb 
callback, E_Gadget_Wizard
t->wizard = wizard;
eina_hash_add(gadget_types, type, t);
EINA_LIST_FOREACH(sites->sites, l, zgs)
- EINA_LIST_FOREACH(zgs->gadgets, ll, zgc)
-   if (eina_streq(type, zgc->type))
- _gadget_object_create(zgc);
+ if (zgs->layout)
+   EINA_LIST_FOREACH(zgs->gadgets, ll, zgc)
+ if (eina_streq(type, zgc->type))
+   _gadget_object_create(zgc);
 }
 
 E_API void

-- 




Re: [E-devel] [EGIT] [core/efl] master 01/01: Eo class creation: Simplify code using recursive locks.

2016-09-08 Thread Cedric BAIL
On Sep 8, 2016 3:14 AM, "Tom Hacohen"  wrote:
>
> tasn pushed a commit to branch master.
>
>
http://git.enlightenment.org/core/efl.git/commit/?id=6b60560773f59398427f12c21945d31b852db72a
>
> commit 6b60560773f59398427f12c21945d31b852db72a
> Author: Tom Hacohen 
> Date:   Thu Sep 8 11:14:32 2016 +0100
>
> Eo class creation: Simplify code using recursive locks.
>
> Now that we have recursive locks, the class creation code can be much
simpler.
> All the code there was essentially our own implementation of
recursive locks,
> or rather a special case of those.
>
> This is no longer needed.

I have started to look into implementing a light and fast spinlock. This
make me realize that recursive lock are a pain. There memory usage grow
linearly with the number of locker in a thread obviously, but the book
keeping itself is a serious impact on performance. So if you are going to
use recursive lock, avoid it in the hot path ! Not sure if it apply here,
but better share this with everyone.

> ---
>  src/lib/eo/Eo.h | 24 +---
>  src/lib/eo/eo.c | 14 +++---
>  2 files changed, 12 insertions(+), 26 deletions(-)
>
> diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
> index a530604..f1aabd5 100644
> --- a/src/lib/eo/Eo.h
> +++ b/src/lib/eo/Eo.h
> @@ -128,7 +128,7 @@ typedef Eo Efl_Object;
>   * Don't touch it if you don't know what you are doing.
>   * @internal
>   */
> -EAPI extern Eina_Spinlock _efl_class_creation_lock;
> +EAPI extern Eina_Lock _efl_class_creation_lock;
>
>  /**
>   * @var _efl_object_init_generation
> @@ -320,39 +320,25 @@ const Efl_Class * \
>  class_get_func_name(void) \
>  { \
> const Efl_Class *_tmp_parent_class; \
> -   static volatile unsigned char lk_init = 0; \
> -   static Eina_Spinlock _my_lock; \
> static const Efl_Class * volatile _my_class = NULL; \
> static unsigned int _my_init_generation = 1; \
> if (EINA_UNLIKELY(_efl_object_init_generation !=
_my_init_generation)) \
>   { \
>  _my_class = NULL; /* It's freed in efl_object_shutdown(). */ \
> -lk_init = 0; \
>   } \
> if (EINA_LIKELY(!!_my_class)) return _my_class; \
> \
> -   eina_spinlock_take(&_efl_class_creation_lock); \
> -   if (!lk_init) \
> -  eina_spinlock_new(&_my_lock); \
> -   if (lk_init < 2) eina_spinlock_take(&_my_lock); \
> -   if (!lk_init) \
> -  lk_init = 1; \
> -   else \
> +   eina_lock_take(&_efl_class_creation_lock); \
> +   if (!!_my_class) \
>   { \
> -if (lk_init < 2) eina_spinlock_release(&_my_lock); \
> -eina_spinlock_release(&_efl_class_creation_lock); \
> +eina_lock_release(&_efl_class_creation_lock); \
>  return _my_class; \
>   } \
> -   eina_spinlock_release(&_efl_class_creation_lock); \
> _tmp_parent_class = parent_class; \
> _my_class = efl_class_new(class_desc, _tmp_parent_class,
__VA_ARGS__); \
> _my_init_generation = _efl_object_init_generation; \
> -   eina_spinlock_release(&_my_lock); \
> +   eina_lock_release(&_efl_class_creation_lock); \
> \
> -   eina_spinlock_take(&_efl_class_creation_lock); \
> -   eina_spinlock_free(&_my_lock); \
> -   lk_init = 2; \
> -   eina_spinlock_release(&_efl_class_creation_lock); \
> return _my_class; \
>  }
>
> diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
> index 7931753..bfc5be5 100644
> --- a/src/lib/eo/eo.c
> +++ b/src/lib/eo/eo.c
> @@ -19,7 +19,7 @@
>  #define EFL_OBJECT_OP_IDS_FIRST 1
>
>  /* Used inside the class_get functions of classes, see #EFL_DEFINE_CLASS
*/
> -EAPI Eina_Spinlock _efl_class_creation_lock;
> +EAPI Eina_Lock _efl_class_creation_lock;
>  EAPI unsigned int _efl_object_init_generation = 1;
>  int _eo_log_dom = -1;
>
> @@ -1342,11 +1342,11 @@ efl_class_new(const Efl_Class_Description *desc,
const Efl_Class *parent_id, ...
>   {
>  Eo_Id new_id;
>
> -eina_spinlock_take(&_efl_class_creation_lock);
> +eina_lock_take(&_efl_class_creation_lock);
>  new_id = (_eo_classes_last_id + 1) | MASK_CLASS_TAG;
>  _eo_classes_expand();
>  _eo_classes[_UNMASK_ID(new_id) - 1] = klass;
> -eina_spinlock_release(&_efl_class_creation_lock);
> +eina_lock_release(&_efl_class_creation_lock);
>
>  klass->header.id = new_id;
>   }
> @@ -1837,7 +1837,7 @@ efl_object_init(void)
>  return EINA_FALSE;
>   }
>
> -   if (!eina_spinlock_new(&_efl_class_creation_lock))
> +   if (!eina_lock_recursive_new(&_efl_class_creation_lock))
>   {
>  EINA_LOG_ERR("Could not init lock.");
>  return EINA_FALSE;
> @@ -1927,15 +1927,15 @@ efl_object_shutdown(void)
>eo_class_free(*cls_itr);
>   }
>
> -   eina_spinlock_take(&_efl_class_creation_lock);
> +   eina_lock_take(&_efl_class_creation_lock);
> _eo_classes_release();
> -   eina_spinlock_release(&_efl_class_creation_lock);
> +   eina_lock_release(&_efl_class_creation_lock);
>
> eina_hash_free(_ops_storage);
>
> eina_spinlock_free(&_super_cl

[EGIT] [core/efl] master 15/20: ecore_drm2: Add a page flip completion call

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

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

commit b4cbf860b9d483f7ad7a50c672a000927cb2b39f
Author: Derek Foreman 
Date:   Wed Sep 7 22:24:45 2016 -0500

ecore_drm2: Add a page flip completion call

Add a function for ecore_evas_drm to call after a page flip happens so
ecore_drm2 can track busy status for fbs itself (including for the fb
that's currently being flipped to scanout)

Also, call the completion function from ecore_evas_drm
---
 src/lib/ecore_drm2/Ecore_Drm2.h| 15 
 src/lib/ecore_drm2/ecore_drm2_fb.c | 27 +++---
 src/lib/ecore_drm2/ecore_drm2_private.h|  2 +-
 .../ecore_evas/engines/drm/ecore_evas_drm.c|  2 ++
 4 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h
index 0a8411f..013abb0 100644
--- a/src/lib/ecore_drm2/Ecore_Drm2.h
+++ b/src/lib/ecore_drm2/Ecore_Drm2.h
@@ -768,6 +768,9 @@ EAPI void ecore_drm2_fb_dirty(Ecore_Drm2_Fb *fb, 
Eina_Rectangle *rects, unsigned
 /**
  * Schedule a pageflip to the given Ecore_Drm2_Fb
  *
+ * The caller is responsible for running a page flip handler
+ * and calling ecore_drm2_fb_flip_complete() when it completes.
+ *
  * @param fb
  * @param output
  *
@@ -779,6 +782,18 @@ EAPI void ecore_drm2_fb_dirty(Ecore_Drm2_Fb *fb, 
Eina_Rectangle *rects, unsigned
 EAPI int ecore_drm2_fb_flip(Ecore_Drm2_Fb *fb, Ecore_Drm2_Output *output);
 
 /**
+ * Must be called by a page flip handler when the flip completes.
+ *
+ * @param output
+ *
+ * @return Whether there's an undisplayed buffer still in the queue.
+ *
+ * @ingroup Ecore_Drm2_Fb_Group
+ * @since 1.18
+ */
+EAPI Eina_Bool ecore_drm2_fb_flip_complete(Ecore_Drm2_Output *output);
+
+/**
  * Return the Ecore_Drm2_Fb's busy status
  *
  * @param fb
diff --git a/src/lib/ecore_drm2/ecore_drm2_fb.c 
b/src/lib/ecore_drm2/ecore_drm2_fb.c
index b56486e..f660f05 100644
--- a/src/lib/ecore_drm2/ecore_drm2_fb.c
+++ b/src/lib/ecore_drm2/ecore_drm2_fb.c
@@ -223,6 +223,19 @@ ecore_drm2_fb_dirty(Ecore_Drm2_Fb *fb, Eina_Rectangle 
*rects, unsigned int count
 #endif
 }
 
+EAPI Eina_Bool
+ecore_drm2_fb_flip_complete(Ecore_Drm2_Output *output)
+{
+   if (output->current) output->current->busy = EINA_FALSE;
+   output->current = output->pending;
+   output->pending = NULL;
+
+   /* In case they were the same buffer... */
+   if (output->current) output->current->busy = EINA_TRUE;
+
+   return !!output->next;
+}
+
 EAPI int
 ecore_drm2_fb_flip(Ecore_Drm2_Fb *fb, Ecore_Drm2_Output *output)
 {
@@ -233,6 +246,13 @@ ecore_drm2_fb_flip(Ecore_Drm2_Fb *fb, Ecore_Drm2_Output 
*output)
 
if (!output->enabled) return -1;
 
+   if (output->pending)
+ {
+if (output->next) output->next->busy = EINA_FALSE;
+output->next = fb;
+if (output->next) output->next->busy = EINA_TRUE;
+return 0;
+ }
if (!fb) fb = output->next;
 
/* So we can generate a tick by flipping to the current fb */
@@ -262,7 +282,9 @@ ecore_drm2_fb_flip(Ecore_Drm2_Fb *fb, Ecore_Drm2_Output 
*output)
  return ret;
   }
 
+if (output->current) output->current->busy = EINA_FALSE;
 output->current = fb;
+output->current->busy = EINA_TRUE;
 output->next = NULL;
 
 return 0;
@@ -284,9 +306,8 @@ ecore_drm2_fb_flip(Ecore_Drm2_Fb *fb, Ecore_Drm2_Output 
*output)
 return 0;
  }
 
-   if (output->current) output->current->busy = EINA_FALSE;
-   output->current = fb;
-   fb->busy = EINA_TRUE;
+   output->pending = fb;
+   output->pending->busy = EINA_TRUE;
return 0;
 }
 
diff --git a/src/lib/ecore_drm2/ecore_drm2_private.h 
b/src/lib/ecore_drm2/ecore_drm2_private.h
index 8c16c04..96acfa4 100644
--- a/src/lib/ecore_drm2/ecore_drm2_private.h
+++ b/src/lib/ecore_drm2/ecore_drm2_private.h
@@ -138,7 +138,7 @@ struct _Ecore_Drm2_Output
 
drmModeCrtcPtr ocrtc;
 
-   Ecore_Drm2_Fb *current, *next;
+   Ecore_Drm2_Fb *current, *next, *pending;
 
Eina_Matrix4 matrix, inverse;
Ecore_Drm2_Transform transform;
diff --git a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c 
b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
index 9b456b7..90a3444 100644
--- a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
+++ b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
@@ -639,6 +639,8 @@ _cb_pageflip(int fd EINA_UNUSED, unsigned int frame 
EINA_UNUSED, unsigned int se
ee = data;
edata = ee->engine.data;
 
+   ecore_drm2_fb_flip_complete(edata->output);
+
next = ecore_drm2_output_next_fb_get(edata->output);
if (next)
  {

-- 




[EGIT] [core/efl] master 18/20: ecore_drm2: simplify API to get latest FB

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

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

commit cc29a25c47bf12b4a3fc94396cc5c39e6d3e7739
Author: Derek Foreman 
Date:   Thu Sep 8 11:40:11 2016 -0500

ecore_drm2: simplify API to get latest FB

What we've always wanted when getting the "current" FB is to get
the most recently submit one - this may be current, next, or pending.

Replace ecore_drm2_output_current_fb_get() with a function that gets the
most recent one - ecore_drm2_output_latest_fb_get().  Now callers don't
have to check the next buffer themselves first, and we don't have to
add an API for pending.
---
 src/lib/ecore_drm2/Ecore_Drm2.h | 12 
 src/lib/ecore_drm2/ecore_drm2_outputs.c |  6 --
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h
index 013abb0..ee5f54e 100644
--- a/src/lib/ecore_drm2/Ecore_Drm2.h
+++ b/src/lib/ecore_drm2/Ecore_Drm2.h
@@ -456,16 +456,20 @@ EAPI unsigned int 
ecore_drm2_output_crtc_get(Ecore_Drm2_Output *output);
 EAPI Ecore_Drm2_Fb *ecore_drm2_output_next_fb_get(Ecore_Drm2_Output *output);
 
 /**
- * Return the current Ecore_Drm2_Fb used on a given output
+ * Return the most recently set Ecore_Drm2_Fb for a given output
+ *
+ * This may be the currently scanned out buffer, a buffer currently being
+ * flipped to scanout, or a buffer that has been submit but may not
+ * actually ever hit scanout at all.
  *
  * @param output
  *
- * @return The current Ecore_Drm2_Fb used on this output, or NULL otherwise
+ * @return The latest Ecore_Drm2_Fb submit for this output, or NULL otherwise
  *
  * @ingroup Ecore_Drm2_Output_Group
- * @since 1.18
+ * @since 1.19
  */
-EAPI Ecore_Drm2_Fb *ecore_drm2_output_current_fb_get(Ecore_Drm2_Output 
*output);
+EAPI Ecore_Drm2_Fb *ecore_drm2_output_latest_fb_get(Ecore_Drm2_Output *output);
 
 /**
  * Set the next Ecore_Drm2_Fb to be used on a given output
diff --git a/src/lib/ecore_drm2/ecore_drm2_outputs.c 
b/src/lib/ecore_drm2/ecore_drm2_outputs.c
index fda51f3..fc7e2eb 100644
--- a/src/lib/ecore_drm2/ecore_drm2_outputs.c
+++ b/src/lib/ecore_drm2/ecore_drm2_outputs.c
@@ -945,10 +945,12 @@ ecore_drm2_output_next_fb_set(Ecore_Drm2_Output *output, 
Ecore_Drm2_Fb *fb)
 }
 
 EAPI Ecore_Drm2_Fb *
-ecore_drm2_output_current_fb_get(Ecore_Drm2_Output *output)
+ecore_drm2_output_latest_fb_get(Ecore_Drm2_Output *output)
 {
EINA_SAFETY_ON_NULL_RETURN_VAL(output, NULL);
-   return output->current;
+   if (output->pending) return output->pending;
+   if (output->current) return output->current;
+   return output->next;
 }
 
 EAPI void

-- 




[EGIT] [core/efl] master 01/20: ee_drm: Fix max buffer age

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=1591e095d5e834a67bd270019068c6b6edf6bfba

commit 1591e095d5e834a67bd270019068c6b6edf6bfba
Author: Derek Foreman 
Date:   Wed Sep 7 21:19:30 2016 -0500

ee_drm: Fix max buffer age

The highest possible buffer age should actually be 4, not the number of
available buffers.
---
 src/modules/evas/engines/drm/evas_outbuf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/modules/evas/engines/drm/evas_outbuf.c 
b/src/modules/evas/engines/drm/evas_outbuf.c
index e26fea7..aec09ff 100644
--- a/src/modules/evas/engines/drm/evas_outbuf.c
+++ b/src/modules/evas/engines/drm/evas_outbuf.c
@@ -408,7 +408,7 @@ _outbuf_fb_assign(Outbuf *ob)
 if ((ob->priv.ofb[i].valid) && (ob->priv.ofb[i].drawn))
   {
  ob->priv.ofb[i].age++;
- if (ob->priv.ofb[i].age > ob->priv.num)
+ if (ob->priv.ofb[i].age > 4)
{
   ob->priv.ofb[i].age = 0;
   ob->priv.ofb[i].drawn = EINA_FALSE;

-- 




[EGIT] [core/efl] master 16/20: ecore_evas_drm: Use pageflips, not vblanks, to drive animation

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=0f534dc3bd12daaf7ae840c5a303a5aff0da1acf

commit 0f534dc3bd12daaf7ae840c5a303a5aff0da1acf
Author: Derek Foreman 
Date:   Fri Sep 2 15:38:32 2016 -0500

ecore_evas_drm: Use pageflips, not vblanks, to drive animation

This should sort some timing problems.
---
 .../ecore_evas/engines/drm/ecore_evas_drm.c| 49 +++---
 1 file changed, 15 insertions(+), 34 deletions(-)

diff --git a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c 
b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
index 90a3444..d8709d6 100644
--- a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
+++ b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
@@ -55,6 +55,7 @@ typedef struct _Ecore_Evas_Engine_Drm_Data
Ecore_Fd_Handler *hdlr;
Ecore_Drm2_Device *dev;
Ecore_Drm2_Output *output;
+   Eina_Bool pending : 1;
Eina_Bool ticking : 1;
 } Ecore_Evas_Engine_Drm_Data;
 
@@ -611,55 +612,36 @@ _cb_drm_event(void *data, Ecore_Fd_Handler *hdlr 
EINA_UNUSED)
 }
 
 static void
-_tick_schedule(int fd, Ecore_Evas *ee)
-{
-   Ecore_Evas_Engine_Drm_Data *edata;
-
-   edata = ee->engine.data;
-   if (!edata->ticking) return;
-
-   drmVBlank vbl =
- {
-.request.type = DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT,
-.request.sequence = 1,
-.request.signal = (unsigned long)ee,
- };
-
-   /* FIXME: On some systems this can fail, breaking ticking forever. */
-   drmWaitVBlank(fd, &vbl);
-}
-
-static void
 _cb_pageflip(int fd EINA_UNUSED, unsigned int frame EINA_UNUSED, unsigned int 
sec EINA_UNUSED, unsigned int usec EINA_UNUSED, void *data)
 {
Ecore_Evas *ee;
Ecore_Evas_Engine_Drm_Data *edata;
-   Ecore_Drm2_Fb *next;
+   int ret;
 
ee = data;
edata = ee->engine.data;
 
-   ecore_drm2_fb_flip_complete(edata->output);
+   ret = ecore_drm2_fb_flip_complete(edata->output);
+
+   edata->pending = EINA_FALSE;
 
-   next = ecore_drm2_output_next_fb_get(edata->output);
-   if (next)
+   if (edata->ticking)
  {
-ecore_drm2_output_next_fb_set(edata->output, NULL);
-ecore_drm2_fb_flip(next, edata->output);
+ecore_evas_animator_tick(ee, NULL);
+ecore_drm2_fb_flip(NULL, edata->output);
  }
+   else if (ret) ecore_drm2_fb_flip(NULL, edata->output);
 }
 
 static void
-_cb_vblank(int fd, unsigned int frame EINA_UNUSED, unsigned int sec 
EINA_UNUSED, unsigned int usec EINA_UNUSED, void *data)
+_drm_evas_changed(Ecore_Evas *ee, Eina_Bool changed)
 {
-   Ecore_Evas *ee;
Ecore_Evas_Engine_Drm_Data *edata;
 
-   ee = data;
-   edata = ee->engine.data;
+   if (changed) return;
 
-   ecore_evas_animator_tick(ee, NULL);
-   if (edata->ticking) _tick_schedule(fd, ee);
+   edata = ee->engine.data;
+   if (edata->ticking && !edata->pending) ecore_drm2_fb_flip(NULL, 
edata->output);
 }
 
 static void
@@ -669,7 +651,7 @@ _drm_animator_register(Ecore_Evas *ee)
 
edata = ee->engine.data;
edata->ticking = EINA_TRUE;
-   _tick_schedule(edata->fd, ee);
+   if (!edata->pending) ecore_drm2_fb_flip(NULL, edata->output);
 }
 
 static void
@@ -760,7 +742,7 @@ static Ecore_Evas_Engine_Func _ecore_evas_drm_engine_func =
_drm_animator_register, // animator_register
_drm_animator_unregister, // animator_unregister
 
-   NULL // evas_changed
+   _drm_evas_changed, // evas_changed
 };
 
 static Ecore_Evas *
@@ -906,7 +888,6 @@ _ecore_evas_new_internal(const char *device, int x, int y, 
int w, int h, Eina_Bo
/* setup vblank handler */
memset(&edata->ctx, 0, sizeof(edata->ctx));
edata->ctx.version = DRM_EVENT_CONTEXT_VERSION;
-   edata->ctx.vblank_handler = _cb_vblank;
edata->ctx.page_flip_handler = _cb_pageflip;
 
edata->hdlr =

-- 




[EGIT] [core/efl] master 05/20: ecore_drm2: Add busy status to ecore_drm2_fb

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

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

commit d8c9f8ef17b0e52ec6e7d07ac33b5a54777d0de7
Author: Derek Foreman 
Date:   Fri Sep 2 12:17:01 2016 -0500

ecore_drm2: Add busy status to ecore_drm2_fb

We've been tracking this in the outbuf code, but that logic is going to
be moved into ecore_evas_drm to use the new ticking paradigm.
---
 src/lib/ecore_drm2/Ecore_Drm2.h | 23 +++
 src/lib/ecore_drm2/ecore_drm2_fb.c  | 12 
 src/lib/ecore_drm2/ecore_drm2_private.h |  1 +
 3 files changed, 36 insertions(+)

diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h
index 3de7999..ce9340f 100644
--- a/src/lib/ecore_drm2/Ecore_Drm2.h
+++ b/src/lib/ecore_drm2/Ecore_Drm2.h
@@ -779,6 +779,29 @@ EAPI void ecore_drm2_fb_dirty(Ecore_Drm2_Fb *fb, 
Eina_Rectangle *rects, unsigned
  */
 EAPI int ecore_drm2_fb_flip(Ecore_Drm2_Fb *fb, Ecore_Drm2_Output *output, void 
*data);
 
+/**
+ * Return the Ecore_Drm2_Fb's busy status
+ *
+ * @param fb
+ *
+ * @return The busy status
+ *
+ * @ingroup Ecore_Drm2_Fb_Group
+ * @since 1.19
+ */
+EAPI Eina_Bool ecore_drm2_fb_busy_get(Ecore_Drm2_Fb *fb);
+
+/**
+ * Change the Ecore_Drm2_Fb's busy status
+ *
+ * @param fb
+ * @param busy The new busy status
+ *
+ * @ingroup Ecore_Drm2_Fb_Group
+ * @since 1.19
+ */
+EAPI void ecore_drm2_fb_busy_set(Ecore_Drm2_Fb *fb, Eina_Bool busy);
+
 # endif
 
 #endif
diff --git a/src/lib/ecore_drm2/ecore_drm2_fb.c 
b/src/lib/ecore_drm2/ecore_drm2_fb.c
index f91a477..6ac0dde 100644
--- a/src/lib/ecore_drm2/ecore_drm2_fb.c
+++ b/src/lib/ecore_drm2/ecore_drm2_fb.c
@@ -272,3 +272,15 @@ ecore_drm2_fb_flip(Ecore_Drm2_Fb *fb, Ecore_Drm2_Output 
*output, void *data)
output->current = fb;
return 0;
 }
+
+EAPI Eina_Bool
+ecore_drm2_fb_busy_get(Ecore_Drm2_Fb *fb)
+{
+   return fb->busy;
+}
+
+EAPI void
+ecore_drm2_fb_busy_set(Ecore_Drm2_Fb *fb, Eina_Bool busy)
+{
+   fb->busy = busy;
+}
diff --git a/src/lib/ecore_drm2/ecore_drm2_private.h 
b/src/lib/ecore_drm2/ecore_drm2_private.h
index e3a9c90..05f7102 100644
--- a/src/lib/ecore_drm2/ecore_drm2_private.h
+++ b/src/lib/ecore_drm2/ecore_drm2_private.h
@@ -94,6 +94,7 @@ struct _Ecore_Drm2_Fb
uint32_t format;
 
Eina_Bool gbm : 1;
+   Eina_Bool busy : 1;
 
void *mmap;
 };

-- 




[EGIT] [core/efl] master 17/20: ee_drm: simplify flipping

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

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

commit ace55231a3b92fd46ae3be9ef6b0379538fe7927
Author: Derek Foreman 
Date:   Wed Sep 7 22:25:43 2016 -0500

ee_drm: simplify flipping

We no longer have to track draw and display buffers - the display buffer
is completely handled by ecore_evas_drm's busy tracking.
---
 src/modules/evas/engines/drm/evas_engine.h | 2 +-
 src/modules/evas/engines/drm/evas_outbuf.c | 5 +
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/modules/evas/engines/drm/evas_engine.h 
b/src/modules/evas/engines/drm/evas_engine.h
index 3a5c3c2..f125379 100644
--- a/src/modules/evas/engines/drm/evas_engine.h
+++ b/src/modules/evas/engines/drm/evas_engine.h
@@ -58,7 +58,7 @@ struct _Outbuf
struct
  {
 int num;
-Outbuf_Fb ofb[4], *draw, *display;
+Outbuf_Fb ofb[4], *draw;
 Ecore_Drm2_Output *output;
 Eina_List *pending;
 Eina_Rectangle *rects;
diff --git a/src/modules/evas/engines/drm/evas_outbuf.c 
b/src/modules/evas/engines/drm/evas_outbuf.c
index 01394d0..c3f6c4e 100644
--- a/src/modules/evas/engines/drm/evas_outbuf.c
+++ b/src/modules/evas/engines/drm/evas_outbuf.c
@@ -18,9 +18,7 @@ _outbuf_buffer_swap(Outbuf *ob, Eina_Rectangle *rects, 
unsigned int count)
if (!ofb) return;
 
ecore_drm2_fb_dirty(ofb->fb, rects, count);
-   if (ecore_drm2_fb_flip(ofb->fb, ob->priv.output) == 0)
- ob->priv.display = ofb;
-
+   ecore_drm2_fb_flip(ofb->fb, ob->priv.output);
ofb->drawn = EINA_TRUE;
ofb->age = 0;
 
@@ -231,7 +229,6 @@ _outbuf_fb_wait(Outbuf *ob)
 */
for (i = 0; i < ob->priv.num; i++)
  {
-if (&ob->priv.ofb[i] == ob->priv.display) continue;
 if (ecore_drm2_fb_busy_get(ob->priv.ofb[i].fb)) continue;
 if (ob->priv.ofb[i].valid && (ob->priv.ofb[i].age > best_age))
   {

-- 




[EGIT] [core/efl] master 03/20: ecore_evas_drm: check for libglapi presence first

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=31de16d40840381cf9d425441cd55c3b1d57301c

commit 31de16d40840381cf9d425441cd55c3b1d57301c
Author: Derek Foreman 
Date:   Thu Sep 1 14:53:47 2016 -0500

ecore_evas_drm: check for libglapi presence first

Minor refactor
---
 src/modules/ecore_evas/engines/drm/ecore_evas_drm.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c 
b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
index 59278aa..eef1bda 100644
--- a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
+++ b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
@@ -796,6 +796,9 @@ ecore_evas_gl_drm_new_internal(const char *device, unsigned 
int parent EINA_UNUS
Ecore_Evas_Engine_Drm_Data *edata;
int method, mw, mh;
 
+   dlopen("libglapi.so.0", RTLD_LAZY | RTLD_GLOBAL);
+   if (dlerror()) return NULL;
+
method = evas_render_method_lookup("gl_drm");
if (!method) return NULL;
 
@@ -817,14 +820,6 @@ ecore_evas_gl_drm_new_internal(const char *device, 
unsigned int parent EINA_UNUS
edata->bpp = 32; // FIXME: Remove hardcode
edata->format = DRM_FORMAT_XRGB;
 
-   dlopen("libglapi.so.0", RTLD_LAZY | RTLD_GLOBAL);
-   if (dlerror())
- {
-free(edata);
-free(ee);
-return NULL;
- }
-
if (_ecore_evas_drm_init(edata, device) < 1)
  {
 free(edata);

-- 




[EGIT] [core/efl] master 10/20: evas_engines: Add a redraws_clear callback

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=5eec34812efa5b73ed18d71871e87a997928d214

commit 5eec34812efa5b73ed18d71871e87a997928d214
Author: Derek Foreman 
Date:   Tue Sep 6 17:01:37 2016 -0500

evas_engines: Add a redraws_clear callback

This gives us a callback from the main thread after outbuf_flush occurs -
this is useful to get timing right on the drm and wayland engines.
---
 src/modules/evas/engines/buffer/evas_engine.c | 1 +
 src/modules/evas/engines/drm/evas_engine.c| 1 +
 src/modules/evas/engines/eglfs/evas_engine.c  | 1 +
 src/modules/evas/engines/fb/evas_engine.c | 1 +
 src/modules/evas/engines/gl_cocoa/evas_engine.c   | 1 +
 src/modules/evas/engines/gl_drm/evas_engine.c | 1 +
 src/modules/evas/engines/gl_generic/Evas_Engine_GL_Generic.h  | 2 ++
 src/modules/evas/engines/gl_sdl/evas_engine.c | 1 +
 src/modules/evas/engines/gl_x11/evas_engine.c | 1 +
 src/modules/evas/engines/software_ddraw/evas_engine.c | 1 +
 src/modules/evas/engines/software_gdi/evas_engine.c   | 1 +
 .../evas/engines/software_generic/Evas_Engine_Software_Generic.h  | 4 
 src/modules/evas/engines/software_generic/evas_engine.c   | 1 +
 src/modules/evas/engines/software_x11/evas_engine.c   | 3 +++
 src/modules/evas/engines/wayland_egl/evas_engine.c| 1 +
 src/modules/evas/engines/wayland_shm/evas_engine.c| 1 +
 16 files changed, 22 insertions(+)

diff --git a/src/modules/evas/engines/buffer/evas_engine.c 
b/src/modules/evas/engines/buffer/evas_engine.c
index 021f7c5..bef4a45 100644
--- a/src/modules/evas/engines/buffer/evas_engine.c
+++ b/src/modules/evas/engines/buffer/evas_engine.c
@@ -103,6 +103,7 @@ _output_setup(int w,
  
evas_buffer_outbuf_buf_free_region_for_update,
  NULL,
  
evas_buffer_outbuf_buf_switch_buffer,
+ NULL,
  evas_buffer_outbuf_buf_free,
  w, h))
  goto on_error;
diff --git a/src/modules/evas/engines/drm/evas_engine.c 
b/src/modules/evas/engines/drm/evas_engine.c
index 0499a96..e28037d 100644
--- a/src/modules/evas/engines/drm/evas_engine.c
+++ b/src/modules/evas/engines/drm/evas_engine.c
@@ -32,6 +32,7 @@ _render_engine_setup(Evas_Engine_Info_Drm *info, int w, int h)
  _outbuf_update_region_free,
  NULL,
  _outbuf_flush,
+ NULL,
  _outbuf_free,
  ob->w, ob->h))
  goto init_err;
diff --git a/src/modules/evas/engines/eglfs/evas_engine.c 
b/src/modules/evas/engines/eglfs/evas_engine.c
index 630cd9c..c881f29 100644
--- a/src/modules/evas/engines/eglfs/evas_engine.c
+++ b/src/modules/evas/engines/eglfs/evas_engine.c
@@ -793,6 +793,7 @@ eng_setup(Evas *evas, void *in)
 evas_outbuf_update_region_free,
 NULL,
 evas_outbuf_flush,
+NULL,
 evas_outbuf_free,
 evas_outbuf_use,
 evas_outbuf_gl_context_get,
diff --git a/src/modules/evas/engines/fb/evas_engine.c 
b/src/modules/evas/engines/fb/evas_engine.c
index f78e7a1..9457485 100644
--- a/src/modules/evas/engines/fb/evas_engine.c
+++ b/src/modules/evas/engines/fb/evas_engine.c
@@ -53,6 +53,7 @@ _output_setup(int w, int h, int rot, int vt, int dev, int 
refresh)
  
evas_fb_outbuf_fb_free_region_for_update,
  NULL,
  NULL,
+ NULL,
  evas_fb_outbuf_fb_free,
  
evas_fb_outbuf_fb_get_width(ob),
  
evas_fb_outbuf_fb_get_height(ob)))
diff --git a/src/modules/evas/engines/gl_cocoa/evas_engine.c 
b/src/modules/evas/engines/gl_cocoa/evas_engine.c
index 2031166..585323a 100644
--- a/src/modules/evas/engines/gl_cocoa/evas_engine.c
+++ b/src/modules/evas/engines/gl_cocoa/evas_

[EGIT] [core/efl] master 12/20: ee_drm: Get page flips out of the render thread

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=95a00b8e496839c4976259692fb7c308f7a850dc

commit 95a00b8e496839c4976259692fb7c308f7a850dc
Author: Derek Foreman 
Date:   Wed Sep 7 21:31:08 2016 -0500

ee_drm: Get page flips out of the render thread

Now that we have redraws_clear exposed through software generic, we can
use that to do the final buffer swap from the main thread instead of doing
it in outbuf_flush which runs from the render thread.

This becomes more important later when other call sites in the main thread
will perform buffer flips.
---
 src/modules/evas/engines/drm/evas_engine.c |  2 +-
 src/modules/evas/engines/drm/evas_engine.h |  3 +++
 src/modules/evas/engines/drm/evas_outbuf.c | 24 +---
 3 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/modules/evas/engines/drm/evas_engine.c 
b/src/modules/evas/engines/drm/evas_engine.c
index e28037d..d712093 100644
--- a/src/modules/evas/engines/drm/evas_engine.c
+++ b/src/modules/evas/engines/drm/evas_engine.c
@@ -32,7 +32,7 @@ _render_engine_setup(Evas_Engine_Info_Drm *info, int w, int h)
  _outbuf_update_region_free,
  NULL,
  _outbuf_flush,
- NULL,
+ _outbuf_redraws_clear,
  _outbuf_free,
  ob->w, ob->h))
  goto init_err;
diff --git a/src/modules/evas/engines/drm/evas_engine.h 
b/src/modules/evas/engines/drm/evas_engine.h
index 94ddcf4..3a5c3c2 100644
--- a/src/modules/evas/engines/drm/evas_engine.h
+++ b/src/modules/evas/engines/drm/evas_engine.h
@@ -61,6 +61,8 @@ struct _Outbuf
 Outbuf_Fb ofb[4], *draw, *display;
 Ecore_Drm2_Output *output;
 Eina_List *pending;
+Eina_Rectangle *rects;
+unsigned int rect_count;
  } priv;
 
Eina_Bool alpha : 1;
@@ -76,5 +78,6 @@ void *_outbuf_update_region_new(Outbuf *ob, int x, int y, int 
w, int h, int *cx,
 void _outbuf_update_region_push(Outbuf *ob, RGBA_Image *update, int x, int y, 
int w, int h);
 void _outbuf_update_region_free(Outbuf *ob, RGBA_Image *update);
 void _outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects, Evas_Render_Mode 
render_mode);
+void _outbuf_redraws_clear(Outbuf *ob);
 
 #endif
diff --git a/src/modules/evas/engines/drm/evas_outbuf.c 
b/src/modules/evas/engines/drm/evas_outbuf.c
index b62d952..01394d0 100644
--- a/src/modules/evas/engines/drm/evas_outbuf.c
+++ b/src/modules/evas/engines/drm/evas_outbuf.c
@@ -494,17 +494,20 @@ _outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects 
EINA_UNUSED, Evas_Render_Mode rend
 {
Eina_Rectangle *r;
RGBA_Image *img;
-   unsigned int n = 0, i = 0;
+   unsigned int i = 0;
 
if (render_mode == EVAS_RENDER_MODE_ASYNC_INIT) return;
 
+   if (ob->priv.rect_count) free(ob->priv.rects);
+
/* get number of pending writes */
-   n = eina_list_count(ob->priv.pending);
-   if (n == 0) return;
+   ob->priv.rect_count = eina_list_count(ob->priv.pending);
+   if (ob->priv.rect_count == 0) return;
 
/* allocate rectangles */
-   r = alloca(n * sizeof(Eina_Rectangle));
-   if (!r) return;
+   ob->priv.rects = malloc(ob->priv.rect_count * sizeof(Eina_Rectangle));
+   if (!ob->priv.rects) return;
+   r = ob->priv.rects;
 
/* loop the pending writes */
EINA_LIST_FREE(ob->priv.pending, img)
@@ -562,7 +565,14 @@ _outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects EINA_UNUSED, 
Evas_Render_Mode rend
 
 i++;
  }
+}
+
+void
+_outbuf_redraws_clear(Outbuf *ob)
+{
+   if (!ob->priv.rect_count) return;
 
-   /* force a buffer swap */
-   _outbuf_buffer_swap(ob, r, n);
+   _outbuf_buffer_swap(ob, ob->priv.rects, ob->priv.rect_count);
+   free(ob->priv.rects);
+   ob->priv.rect_count = 0;
 }

-- 




[EGIT] [core/efl] master 08/20: ee_drm: Move all ticking into ecore_evas_drm and use new tick system

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=794798f55906d3704955ac3f108340eafdb06256

commit 794798f55906d3704955ac3f108340eafdb06256
Author: Derek Foreman 
Date:   Fri Sep 2 14:47:49 2016 -0500

ee_drm: Move all ticking into ecore_evas_drm and use new tick system

Combines all the gl_drm and drm ticking code into one set in
ecore_evas_drm and uses the new evas tick register/unregister callbacks
to set it up.
---
 .../ecore_evas/engines/drm/ecore_evas_drm.c| 117 ++-
 src/modules/evas/engines/drm/evas_engine.h |   3 -
 src/modules/evas/engines/drm/evas_outbuf.c | 130 +
 src/modules/evas/engines/gl_drm/evas_engine.c  |  40 ---
 src/modules/evas/engines/gl_drm/evas_engine.h  |   4 -
 src/modules/evas/engines/gl_drm/evas_outbuf.c  |  80 +
 6 files changed, 117 insertions(+), 257 deletions(-)

diff --git a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c 
b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
index 8289a76..e53ffda 100644
--- a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
+++ b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
@@ -19,6 +19,8 @@
 # include 
 #endif
 
+#include 
+
 #ifdef EAPI
 # undef EAPI
 #endif
@@ -49,14 +51,17 @@ typedef struct _Ecore_Evas_Engine_Drm_Data
int x, y, w, h;
int depth, bpp;
unsigned int format;
+   drmEventContext ctx;
+   Ecore_Fd_Handler *hdlr;
Ecore_Drm2_Device *dev;
Ecore_Drm2_Output *output;
+   Eina_Bool ticking : 1;
 } Ecore_Evas_Engine_Drm_Data;
 
 static int _drm_init_count = 0;
 
 static int
-_ecore_evas_drm_init(Ecore_Evas_Engine_Drm_Data *edata, const char *device)
+_ecore_evas_drm_init(Ecore_Evas *ee, Ecore_Evas_Engine_Drm_Data *edata, const 
char *device)
 {
if (++_drm_init_count != 1) return _drm_init_count;
 
@@ -92,8 +97,8 @@ _ecore_evas_drm_init(Ecore_Evas_Engine_Drm_Data *edata, const 
char *device)
  }
 
edata->output = ecore_drm2_output_find(edata->dev, edata->x, edata->y);
-   if (!edata->output)
- WRN("Could not find output at %d %d", edata->x, edata->y);
+   if (edata->output) ecore_drm2_output_user_data_set(edata->output, ee);
+   else WRN("Could not find output at %d %d", edata->x, edata->y);
 
ecore_event_evas_init();
 
@@ -586,6 +591,97 @@ _ecore_evas_drm_interface_new(void)
return iface;
 }
 
+static Eina_Bool
+_cb_drm_event(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED)
+{
+   Ecore_Evas *ee;
+   Ecore_Evas_Engine_Drm_Data *edata;
+   int ret;
+
+   ee = data;
+   edata = ee->engine.data;
+   ret = drmHandleEvent(edata->fd, &edata->ctx);
+   if (ret)
+ {
+WRN("drmHandleEvent failed to read an event");
+return EINA_FALSE;
+ }
+
+   return EINA_TRUE;
+}
+
+static void
+_tick_schedule(int fd, Ecore_Evas *ee)
+{
+   Ecore_Evas_Engine_Drm_Data *edata;
+
+   edata = ee->engine.data;
+   if (!edata->ticking) return;
+
+   drmVBlank vbl =
+ {
+.request.type = DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT,
+.request.sequence = 1,
+.request.signal = (unsigned long)ee,
+ };
+
+   /* FIXME: On some systems this can fail, breaking ticking forever. */
+   drmWaitVBlank(fd, &vbl);
+}
+
+static void
+_cb_pageflip(int fd EINA_UNUSED, unsigned int frame EINA_UNUSED, unsigned int 
sec EINA_UNUSED, unsigned int usec EINA_UNUSED, void *data)
+{
+   Ecore_Evas *ee;
+   Ecore_Evas_Engine_Drm_Data *edata;
+   Ecore_Drm2_Fb *current, *next;
+
+   ee = data;
+   edata = ee->engine.data;
+
+   current = ecore_drm2_output_current_fb_get(edata->output);
+   if (current) ecore_drm2_fb_busy_set(current, EINA_FALSE);
+
+   next = ecore_drm2_output_next_fb_get(edata->output);
+   if (next)
+ {
+ecore_drm2_output_next_fb_set(edata->output, NULL);
+ecore_drm2_fb_flip(next, edata->output);
+ }
+}
+
+static void
+_cb_vblank(int fd, unsigned int frame EINA_UNUSED, unsigned int sec 
EINA_UNUSED, unsigned int usec EINA_UNUSED, void *data)
+{
+   Ecore_Evas *ee;
+   Ecore_Evas_Engine_Drm_Data *edata;
+
+   ee = data;
+   edata = ee->engine.data;
+
+   ecore_evas_animator_tick(ee, NULL);
+   if (edata->ticking) _tick_schedule(fd, ee);
+}
+
+static void
+_drm_animator_register(Ecore_Evas *ee)
+{
+   Ecore_Evas_Engine_Drm_Data *edata;
+
+   edata = ee->engine.data;
+   edata->ticking = EINA_TRUE;
+   _tick_schedule(edata->fd, ee);
+}
+
+static void
+_drm_animator_unregister(Ecore_Evas *ee)
+{
+   Ecore_Evas_Engine_Drm_Data *edata;
+
+   edata = ee->engine.data;
+   edata->ticking = EINA_FALSE;
+}
+
 static Ecore_Evas_Engine_Func _ecore_evas_drm_engine_func =
 {
_drm_free,
@@ -662,8 +758,8 @@ static Ecore_Evas_Engine_Func _ecore_evas_drm_engine_func =
 
NULL, // aux_hints_set
 
-   NULL, // animator_register
-   NULL, // animator_unregister
+   _drm_animator_register, // animator_register
+   _drm_animator_unregister, // animator_unregister
 
NULL // evas_changed
 };
@@ -700,7 +796,

[EGIT] [core/efl] master 04/20: ecore_evas_drm: Refactor common code

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=316ca09b0d705bf38c5cc0dda066351116807cd7

commit 316ca09b0d705bf38c5cc0dda066351116807cd7
Author: Derek Foreman 
Date:   Fri Sep 2 11:07:17 2016 -0500

ecore_evas_drm: Refactor common code

ecore_evas_gl_drm_new_internal and ecore_Evas_drm_new_internal are huge
functions differing in very few lines.  Combined them.
---
 .../ecore_evas/engines/drm/ecore_evas_drm.c| 163 +
 1 file changed, 39 insertions(+), 124 deletions(-)

diff --git a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c 
b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
index eef1bda..8289a76 100644
--- a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
+++ b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
@@ -668,16 +668,18 @@ static Ecore_Evas_Engine_Func _ecore_evas_drm_engine_func 
=
NULL // evas_changed
 };
 
-EAPI Ecore_Evas *
-ecore_evas_drm_new_internal(const char *device, unsigned int parent 
EINA_UNUSED, int x, int y, int w, int h)
+static Ecore_Evas *
+_ecore_evas_new_internal(const char *device, int x, int y, int w, int h, 
Eina_Bool gl)
 {
Ecore_Evas *ee;
-   Evas_Engine_Info_Drm *einfo;
Ecore_Evas_Interface_Drm *iface;
Ecore_Evas_Engine_Drm_Data *edata;
int method, mw, mh;
+   void *tinfo;
+
+   if (gl) method = evas_render_method_lookup("gl_drm");
+   else method = evas_render_method_lookup("drm");
 
-   method = evas_render_method_lookup("drm");
if (!method) return NULL;
 
ee = calloc(1, sizeof(Ecore_Evas));
@@ -707,7 +709,9 @@ ecore_evas_drm_new_internal(const char *device, unsigned 
int parent EINA_UNUSED,
 
ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
 
-   ee->driver = "drm";
+   if (gl) ee->driver = "gl_drm";
+   else ee->driver = "drm";
+
ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_evas_drm_engine_func;
ee->engine.data = edata;
 
@@ -730,7 +734,7 @@ ecore_evas_drm_new_internal(const char *device, unsigned 
int parent EINA_UNUSED,
ee->prop.withdrawn = EINA_TRUE;
ee->alpha = EINA_FALSE;
 
-   ee->can_async_render = 1;
+   ee->can_async_render = !gl;
if (getenv("ECORE_EVAS_FORCE_SYNC_RENDER"))
  ee->can_async_render = 0;
 
@@ -744,9 +748,18 @@ ecore_evas_drm_new_internal(const char *device, unsigned 
int parent EINA_UNUSED,
  evas_event_callback_add(ee->evas, EVAS_CALLBACK_RENDER_POST,
  _drm_render_updates, ee);
 
-   einfo = (Evas_Engine_Info_Drm *)evas_engine_info_get(ee->evas);
-   if (einfo)
+   tinfo = evas_engine_info_get(ee->evas);
+   if (tinfo && gl)
  {
+char *num;
+Evas_Engine_Info_GL_Drm *einfo = tinfo;
+
+einfo->info.vsync = EINA_TRUE;
+
+num = getenv("EVAS_DRM_VSYNC");
+if ((num) && (!atoi(num)))
+  einfo->info.vsync = EINA_FALSE;
+
 einfo->info.fd = edata->fd;
 einfo->info.bpp = edata->bpp;
 einfo->info.depth = edata->depth;
@@ -759,123 +772,9 @@ ecore_evas_drm_new_internal(const char *device, unsigned 
int parent EINA_UNUSED,
  goto eng_err;
   }
  }
-
-   ee->prop.window = ecore_drm2_output_crtc_get(edata->output);
-   ecore_drm2_device_window_set(edata->dev, ee->prop.window);
-
-   ecore_evas_data_set(ee, "device", edata->dev);
-
-   _ecore_evas_register(ee);
-   ecore_event_window_register(ee->prop.window, ee, ee->evas,
-   
(Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
-   
(Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
-   
(Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
-   
(Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
-   _ecore_event_window_direct_cb_set(ee->prop.window, 
_ecore_evas_input_direct_cb);
-
-   ecore_drm2_output_crtc_size_get(edata->output, &mw, &mh);
-
-   ecore_drm2_device_calibrate(edata->dev, mw, mh);
-   ecore_drm2_device_pointer_max_set(edata->dev, mw, mh);
-   ecore_drm2_device_pointer_warp(edata->dev, mw / 2, mh / 2);
-
-   return ee;
-
-eng_err:
-   ecore_evas_free(ee);
-   return NULL;
-}
-
-#ifdef BUILD_ECORE_EVAS_GL_DRM
-EAPI Ecore_Evas *
-ecore_evas_gl_drm_new_internal(const char *device, unsigned int parent 
EINA_UNUSED, int x, int y, int w, int h)
-{
-   Ecore_Evas *ee;
-   Evas_Engine_Info_GL_Drm *einfo;
-   Ecore_Evas_Interface_Drm *iface;
-   Ecore_Evas_Engine_Drm_Data *edata;
-   int method, mw, mh;
-
-   dlopen("libglapi.so.0", RTLD_LAZY | RTLD_GLOBAL);
-   if (dlerror()) return NULL;
-
-   method = evas_render_method_lookup("gl_drm");
-   if (!method) return NULL;
-
-   ee = calloc(1, sizeof(Ecore_Evas));
-   if (!ee) return NULL;
-
-   edata = calloc(1, sizeof(Ecore_Evas_Engine_Drm_Data));
-   if (!edata)
- {
-free(ee);
-return NULL;
- }
-
-   edata->x = x;
-   edata->y = y;
-   edata->w = w;
-   edata->h = h;
-   edata->depth = 24;

[EGIT] [core/efl] master 02/20: evas_engines: Add fn_evas_changed callback

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=398771bf8afb0399184854b87b30b4a58c1d2aa3

commit 398771bf8afb0399184854b87b30b4a58c1d2aa3
Author: Derek Foreman 
Date:   Tue Aug 30 15:47:17 2016 -0500

evas_engines: Add fn_evas_changed callback

To allow using the pageflip completion event to drive timing in the DRM
engine we need to know as soon as possible that a render has been after
a render has been considered if it will cause a page flip or not.

The fn_evas_changed callback sends this information.
---
 src/lib/ecore_evas/ecore_evas.c | 7 +++
 src/lib/ecore_evas/ecore_evas_buffer.c  | 2 ++
 src/lib/ecore_evas/ecore_evas_ews.c | 2 ++
 src/lib/ecore_evas/ecore_evas_private.h | 2 ++
 src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c | 4 +++-
 src/modules/ecore_evas/engines/drm/ecore_evas_drm.c | 4 +++-
 src/modules/ecore_evas/engines/extn/ecore_evas_extn.c   | 6 +-
 src/modules/ecore_evas/engines/fb/ecore_evas_fb.c   | 4 +++-
 src/modules/ecore_evas/engines/psl1ght/ecore_evas_psl1ght.c | 4 +++-
 src/modules/ecore_evas/engines/sdl/ecore_evas_sdl.c | 4 +++-
 src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_egl.c | 4 +++-
 src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_shm.c | 4 +++-
 src/modules/ecore_evas/engines/win32/ecore_evas_win32.c | 4 +++-
 src/modules/ecore_evas/engines/x/ecore_evas_x.c | 4 +++-
 14 files changed, 45 insertions(+), 10 deletions(-)

diff --git a/src/lib/ecore_evas/ecore_evas.c b/src/lib/ecore_evas/ecore_evas.c
index 769855d..72e4699 100644
--- a/src/lib/ecore_evas/ecore_evas.c
+++ b/src/lib/ecore_evas/ecore_evas.c
@@ -175,6 +175,13 @@ _ecore_evas_idle_enter(void *data EINA_UNUSED)
   {
  if (ee->engine.func->fn_render)
rend |= ee->engine.func->fn_render(ee);
+  /*
+   * Some engines that generate their own ticks based on hardware
+   * events need to know that render has been considered, and
+   * whether it will actually generate a new image or not
+   */
+ if (ee->engine.func->fn_evas_changed)
+   ee->engine.func->fn_evas_changed(ee, rend);
   }
 #ifdef ECORE_EVAS_ASYNC_RENDER_DEBUG
 if ((ee->in_async_render) && (ee->async_render_start <= 0.0))
diff --git a/src/lib/ecore_evas/ecore_evas_buffer.c 
b/src/lib/ecore_evas/ecore_evas_buffer.c
index 795f5b7..deb2387 100644
--- a/src/lib/ecore_evas/ecore_evas_buffer.c
+++ b/src/lib/ecore_evas/ecore_evas_buffer.c
@@ -606,6 +606,8 @@ static Ecore_Evas_Engine_Func _ecore_buffer_engine_func =
 
  NULL, // fn_animator_register
  NULL, // fn_animator_unregister
+
+ NULL, // fn_evas_changed
 };
 
 static void *
diff --git a/src/lib/ecore_evas/ecore_evas_ews.c 
b/src/lib/ecore_evas/ecore_evas_ews.c
index 904c504..6f90654 100644
--- a/src/lib/ecore_evas/ecore_evas_ews.c
+++ b/src/lib/ecore_evas/ecore_evas_ews.c
@@ -719,6 +719,8 @@ static const Ecore_Evas_Engine_Func _ecore_ews_engine_func =
 
  NULL, // fn_animator_register
  NULL, // fn_animator_unregister
+
+ NULL, // fn_evas_changed
 };
 
 void
diff --git a/src/lib/ecore_evas/ecore_evas_private.h 
b/src/lib/ecore_evas/ecore_evas_private.h
index 4eaa369..ee75fd0 100644
--- a/src/lib/ecore_evas/ecore_evas_private.h
+++ b/src/lib/ecore_evas/ecore_evas_private.h
@@ -156,6 +156,8 @@ struct _Ecore_Evas_Engine_Func
 
void (*fn_animator_register)  (Ecore_Evas *ee);
void (*fn_animator_unregister)(Ecore_Evas *ee);
+
+   void (*fn_evas_changed)(Ecore_Evas *ee, Eina_Bool changed);
 };
 
 struct _Ecore_Evas_Interface
diff --git a/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c 
b/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c
index 0624212..98dca01 100644
--- a/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c
+++ b/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c
@@ -673,7 +673,9 @@ static Ecore_Evas_Engine_Func _ecore_cocoa_engine_func =
 
 NULL, // fn_aux_hints_set
 NULL, // fn_animator_register
-NULL  // fn_animator_unregister
+NULL, // fn_animator_unregister
+
+NULL, // fn_evas_changed
   };
 
 static Ecore_Cocoa_Window *
diff --git a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c 
b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
index 0ba8968..59278aa 100644
--- a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
+++ b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
@@ -663,7 +663,9 @@ static Ecore_Evas_Engine_Func _ecore_evas_drm_engine_func =
NULL, // aux_hints_set
 
NULL, // animator_register
-   NULL // animator_unregister
+   NULL, // animator_unregister
+
+   NULL // evas_changed
 };
 
 EAPI Ecore_Evas *
diff --git a/src/modules/ecore_evas/engines/extn/ecore_evas_ex

[EGIT] [core/efl] master 14/20: ecore_drm2: distinguish real flip failure from flip deferral

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=33043ff1ebb78aee92700459cda70745bedcaeb6

commit 33043ff1ebb78aee92700459cda70745bedcaeb6
Author: Derek Foreman 
Date:   Wed Sep 7 22:16:10 2016 -0500

ecore_drm2: distinguish real flip failure from flip deferral

If we try to flip too soon we get EBUSY and should queue up the buffer
for later presentation.  Only the other errors need to be dealt with
elsewhere.
---
 src/lib/ecore_drm2/ecore_drm2_fb.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/lib/ecore_drm2/ecore_drm2_fb.c 
b/src/lib/ecore_drm2/ecore_drm2_fb.c
index 1c1c947..b56486e 100644
--- a/src/lib/ecore_drm2/ecore_drm2_fb.c
+++ b/src/lib/ecore_drm2/ecore_drm2_fb.c
@@ -271,14 +271,18 @@ ecore_drm2_fb_flip(Ecore_Drm2_Fb *fb, Ecore_Drm2_Output 
*output)
ret =
  drmModePageFlip(fb->fd, output->crtc_id, fb->id,
  DRM_MODE_PAGE_FLIP_EVENT, output->user_data);
-   if (ret < 0)
+   if ((ret < 0) && (errno != EBUSY))
  {
 DBG("Pageflip Failed for Crtc %u on Connector %u: %m",
 output->crtc_id, output->conn_id);
-output->next = fb;
-fb->busy = EINA_TRUE;
 return ret;
  }
+   else if (ret < 0)
+ {
+output->next = fb;
+output->next->busy = EINA_TRUE;
+return 0;
+ }
 
if (output->current) output->current->busy = EINA_FALSE;
output->current = fb;

-- 




[EGIT] [core/efl] master 13/20: ecore_drm2: make flip to NULL buffer mean something

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

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

commit 3be2630a3050dab9f73a181324813bda727ed0fd
Author: Derek Foreman 
Date:   Wed Sep 7 22:13:34 2016 -0500

ecore_drm2: make flip to NULL buffer mean something

When triple buffering we'll have a buffer in ecore_drm2's "next" position.
Until now we've had to query it from the engine then try to re post it.

Also, when generating ticks we need to flip to the current buffer when no
changes have been made to get another callback.

Now a NULL fb to fb_flip will either flip to next, if available, or current
if there's nothing new to flip to.
---
 src/lib/ecore_drm2/ecore_drm2_fb.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/lib/ecore_drm2/ecore_drm2_fb.c 
b/src/lib/ecore_drm2/ecore_drm2_fb.c
index 36de500..1c1c947 100644
--- a/src/lib/ecore_drm2/ecore_drm2_fb.c
+++ b/src/lib/ecore_drm2/ecore_drm2_fb.c
@@ -228,18 +228,25 @@ ecore_drm2_fb_flip(Ecore_Drm2_Fb *fb, Ecore_Drm2_Output 
*output)
 {
int ret = 0;
 
-   EINA_SAFETY_ON_NULL_RETURN_VAL(fb, -1);
EINA_SAFETY_ON_NULL_RETURN_VAL(output, -1);
EINA_SAFETY_ON_NULL_RETURN_VAL(output->current_mode, -1);
 
if (!output->enabled) return -1;
 
+   if (!fb) fb = output->next;
+
+   /* So we can generate a tick by flipping to the current fb */
+   if (!fb) fb = output->current;
+
if (output->next)
  {
 output->next->busy = EINA_FALSE;
 output->next = NULL;
  }
 
+   /* If we don't have an fb to set by now, BAIL! */
+   if (!fb) return -1;
+
if ((!output->current) ||
(output->current->stride != fb->stride))
  {

-- 




[EGIT] [core/efl] master 09/20: ecore_drm2: Implicitly set buffer busy status when flipping

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

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

commit ce7991b9934d469419d3a3982d30329184cc287e
Author: Derek Foreman 
Date:   Fri Sep 2 15:24:24 2016 -0500

ecore_drm2: Implicitly set buffer busy status when flipping

This simplifies other code that shouldn't need to deal with this.
---
 src/lib/ecore_drm2/ecore_drm2_fb.c |  8 ++-
 .../ecore_evas/engines/drm/ecore_evas_drm.c|  5 +
 src/modules/evas/engines/drm/evas_outbuf.c | 26 +-
 3 files changed, 9 insertions(+), 30 deletions(-)

diff --git a/src/lib/ecore_drm2/ecore_drm2_fb.c 
b/src/lib/ecore_drm2/ecore_drm2_fb.c
index 3160e5c..36de500 100644
--- a/src/lib/ecore_drm2/ecore_drm2_fb.c
+++ b/src/lib/ecore_drm2/ecore_drm2_fb.c
@@ -235,7 +235,10 @@ ecore_drm2_fb_flip(Ecore_Drm2_Fb *fb, Ecore_Drm2_Output 
*output)
if (!output->enabled) return -1;
 
if (output->next)
- WRN("Fb reused too soon, tearing may be visible");
+ {
+output->next->busy = EINA_FALSE;
+output->next = NULL;
+ }
 
if ((!output->current) ||
(output->current->stride != fb->stride))
@@ -266,10 +269,13 @@ ecore_drm2_fb_flip(Ecore_Drm2_Fb *fb, Ecore_Drm2_Output 
*output)
 DBG("Pageflip Failed for Crtc %u on Connector %u: %m",
 output->crtc_id, output->conn_id);
 output->next = fb;
+fb->busy = EINA_TRUE;
 return ret;
  }
 
+   if (output->current) output->current->busy = EINA_FALSE;
output->current = fb;
+   fb->busy = EINA_TRUE;
return 0;
 }
 
diff --git a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c 
b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
index e53ffda..9b456b7 100644
--- a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
+++ b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
@@ -634,14 +634,11 @@ _cb_pageflip(int fd EINA_UNUSED, unsigned int frame 
EINA_UNUSED, unsigned int se
 {
Ecore_Evas *ee;
Ecore_Evas_Engine_Drm_Data *edata;
-   Ecore_Drm2_Fb *current, *next;
+   Ecore_Drm2_Fb *next;
 
ee = data;
edata = ee->engine.data;
 
-   current = ecore_drm2_output_current_fb_get(edata->output);
-   if (current) ecore_drm2_fb_busy_set(current, EINA_FALSE);
-
next = ecore_drm2_output_next_fb_get(edata->output);
if (next)
  {
diff --git a/src/modules/evas/engines/drm/evas_outbuf.c 
b/src/modules/evas/engines/drm/evas_outbuf.c
index 891be79..97e4f10 100644
--- a/src/modules/evas/engines/drm/evas_outbuf.c
+++ b/src/modules/evas/engines/drm/evas_outbuf.c
@@ -8,43 +8,19 @@
 #define GREEN_MASK 0x00ff00
 #define BLUE_MASK 0xff
 
-Outbuf_Fb *
-_outbuf_fb_find(Outbuf *ob, Ecore_Drm2_Fb *key)
-{
-   int i;
-
-   for (i = 0; i < ob->priv.num; i++)
- if (key == ob->priv.ofb[i].fb) return &ob->priv.ofb[i];
-
-   return NULL;
-}
-
 static void
 _outbuf_buffer_swap(Outbuf *ob, Eina_Rectangle *rects, unsigned int count)
 {
/* Ecore_Drm2_Plane *plane; */
-   Outbuf_Fb *ofb, *next_ofb;
-   Ecore_Drm2_Fb *next;
+   Outbuf_Fb *ofb;
 
ofb = ob->priv.draw;
if (!ofb) return;
 
-   /* If there's a next buffer set, we just dump it back into
-* the available buffers and it becomes a dropped frame
-*/
-   next = ecore_drm2_output_next_fb_get(ob->priv.output);
-   if (next)
- {
-next_ofb = _outbuf_fb_find(ob, next);
-ecore_drm2_fb_busy_set(next_ofb->fb, EINA_FALSE);
-ecore_drm2_output_next_fb_set(ob->priv.output, NULL);
- }
-
ecore_drm2_fb_dirty(ofb->fb, rects, count);
if (ecore_drm2_fb_flip(ofb->fb, ob->priv.output) == 0)
  ob->priv.display = ofb;
 
-   ecore_drm2_fb_busy_set(ofb->fb, EINA_TRUE);
ofb->drawn = EINA_TRUE;
ofb->age = 0;
 

-- 




[EGIT] [core/efl] master 19/20: ecore_drm2: Remove get/set for next fb

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=255b990055ceb13724ca217c7d8c8cc23373b2bb

commit 255b990055ceb13724ca217c7d8c8cc23373b2bb
Author: Derek Foreman 
Date:   Thu Sep 8 11:41:03 2016 -0500

ecore_drm2: Remove get/set for next fb

We no longer needs these at all.
---
 src/lib/ecore_drm2/Ecore_Drm2.h | 23 ---
 src/lib/ecore_drm2/ecore_drm2_outputs.c | 14 --
 2 files changed, 37 deletions(-)

diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h
index ee5f54e..598d831 100644
--- a/src/lib/ecore_drm2/Ecore_Drm2.h
+++ b/src/lib/ecore_drm2/Ecore_Drm2.h
@@ -444,18 +444,6 @@ EAPI void ecore_drm2_output_geometry_get(Ecore_Drm2_Output 
*output, int *x, int
 EAPI unsigned int ecore_drm2_output_crtc_get(Ecore_Drm2_Output *output);
 
 /**
- * Return the next Ecore_Drm2_Fb to be used on a given output
- *
- * @param output
- *
- * @return The next Ecore_Drm2_Fb which is scheduled to to be flipped, or NULL 
otherwise
- *
- * @ingroup Ecore_Drm2_Output_Group
- * @since 1.18
- */
-EAPI Ecore_Drm2_Fb *ecore_drm2_output_next_fb_get(Ecore_Drm2_Output *output);
-
-/**
  * Return the most recently set Ecore_Drm2_Fb for a given output
  *
  * This may be the currently scanned out buffer, a buffer currently being
@@ -472,17 +460,6 @@ EAPI Ecore_Drm2_Fb 
*ecore_drm2_output_next_fb_get(Ecore_Drm2_Output *output);
 EAPI Ecore_Drm2_Fb *ecore_drm2_output_latest_fb_get(Ecore_Drm2_Output *output);
 
 /**
- * Set the next Ecore_Drm2_Fb to be used on a given output
- *
- * @param output
- * @param fb
- *
- * @ingroup Ecore_Drm2_Output_Group
- * @since 1.18
- */
-EAPI void ecore_drm2_output_next_fb_set(Ecore_Drm2_Output *output, 
Ecore_Drm2_Fb *fb);
-
-/**
  * Get the size of the crtc for a given output
  *
  * @param output
diff --git a/src/lib/ecore_drm2/ecore_drm2_outputs.c 
b/src/lib/ecore_drm2/ecore_drm2_outputs.c
index fc7e2eb..3f32092 100644
--- a/src/lib/ecore_drm2/ecore_drm2_outputs.c
+++ b/src/lib/ecore_drm2/ecore_drm2_outputs.c
@@ -931,20 +931,6 @@ ecore_drm2_output_crtc_get(Ecore_Drm2_Output *output)
 }
 
 EAPI Ecore_Drm2_Fb *
-ecore_drm2_output_next_fb_get(Ecore_Drm2_Output *output)
-{
-   EINA_SAFETY_ON_NULL_RETURN_VAL(output, NULL);
-   return output->next;
-}
-
-EAPI void
-ecore_drm2_output_next_fb_set(Ecore_Drm2_Output *output, Ecore_Drm2_Fb *fb)
-{
-   EINA_SAFETY_ON_NULL_RETURN(output);
-   output->next = fb;
-}
-
-EAPI Ecore_Drm2_Fb *
 ecore_drm2_output_latest_fb_get(Ecore_Drm2_Output *output)
 {
EINA_SAFETY_ON_NULL_RETURN_VAL(output, NULL);

-- 




[EGIT] [core/efl] master 11/20: ee_drm: Improve next buffer selection algorithm

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=79409757c6493738c21015708a1ba5178942ad94

commit 79409757c6493738c21015708a1ba5178942ad94
Author: Derek Foreman 
Date:   Wed Sep 7 21:25:32 2016 -0500

ee_drm: Improve next buffer selection algorithm

When triple buffering it's possible that we'll only need two buffers at
a time for long durations.  When we finally call upon a third buffer it
hasn't been used recently enough to do a partial redraw.

By picking the oldest available buffer when multiple buffers are free we
can increase the likelihood of doing partial redraws.
---
 src/modules/evas/engines/drm/evas_outbuf.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/modules/evas/engines/drm/evas_outbuf.c 
b/src/modules/evas/engines/drm/evas_outbuf.c
index 97e4f10..b62d952 100644
--- a/src/modules/evas/engines/drm/evas_outbuf.c
+++ b/src/modules/evas/engines/drm/evas_outbuf.c
@@ -224,15 +224,23 @@ _outbuf_reconfigure(Outbuf *ob, int w, int h, int 
rotation, Outbuf_Depth depth)
 static Outbuf_Fb *
 _outbuf_fb_wait(Outbuf *ob)
 {
-   int i = 0;
+   int i = 0, best = -1, best_age = -1;
 
+   /* We pick the oldest available buffer to avoid using the same two
+* repeatedly and then having the third be stale when we need it
+*/
for (i = 0; i < ob->priv.num; i++)
  {
 if (&ob->priv.ofb[i] == ob->priv.display) continue;
 if (ecore_drm2_fb_busy_get(ob->priv.ofb[i].fb)) continue;
-if (ob->priv.ofb[i].valid) return &(ob->priv.ofb[i]);
+if (ob->priv.ofb[i].valid && (ob->priv.ofb[i].age > best_age))
+  {
+ best = i;
+ best_age = ob->priv.ofb[i].age;
+  }
  }
 
+   if (best >= 0) return &(ob->priv.ofb[best]);
return NULL;
 }
 

-- 




[EGIT] [core/efl] master 07/20: ecore_drm2: Add a function to set the pageflip callback data once

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

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

commit 3d39c1e9b8647aebb12d4edfe426ec88e361c70d
Author: Derek Foreman 
Date:   Fri Sep 2 13:59:12 2016 -0500

ecore_drm2: Add a function to set the pageflip callback data once

Instead of passing the user data for the page flip callback every time,
set it just once.

This will make it easier to push tick logic into ecore_evas_drm, as there
will be a transitional period where page flips are driven in two places
that don't have access to the same pointers.
---
 src/lib/ecore_drm2/Ecore_Drm2.h   | 14 --
 src/lib/ecore_drm2/ecore_drm2_fb.c|  4 ++--
 src/lib/ecore_drm2/ecore_drm2_outputs.c   |  6 ++
 src/lib/ecore_drm2/ecore_drm2_private.h   |  2 ++
 src/modules/evas/engines/drm/evas_outbuf.c|  6 --
 src/modules/evas/engines/gl_drm/evas_outbuf.c |  5 +++--
 6 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h
index ce9340f..0a8411f 100644
--- a/src/lib/ecore_drm2/Ecore_Drm2.h
+++ b/src/lib/ecore_drm2/Ecore_Drm2.h
@@ -770,14 +770,13 @@ EAPI void ecore_drm2_fb_dirty(Ecore_Drm2_Fb *fb, 
Eina_Rectangle *rects, unsigned
  *
  * @param fb
  * @param output
- * @param data
  *
  * @return The result of drmModePageFlip function call
  *
  * @ingroup Ecore_Drm2_Fb_Group
  * @since 1.18
  */
-EAPI int ecore_drm2_fb_flip(Ecore_Drm2_Fb *fb, Ecore_Drm2_Output *output, void 
*data);
+EAPI int ecore_drm2_fb_flip(Ecore_Drm2_Fb *fb, Ecore_Drm2_Output *output);
 
 /**
  * Return the Ecore_Drm2_Fb's busy status
@@ -802,6 +801,17 @@ EAPI Eina_Bool ecore_drm2_fb_busy_get(Ecore_Drm2_Fb *fb);
  */
 EAPI void ecore_drm2_fb_busy_set(Ecore_Drm2_Fb *fb, Eina_Bool busy);
 
+/**
+ * Set the user data for the output's page flip handler
+ *
+ * @param output The output to update user data for
+ * @param data The new user data pointer
+ *
+ * @ingroup Ecore_Drm2_Output_Group
+ * @since 1.19
+ */
+EAPI void ecore_drm2_output_user_data_set(Ecore_Drm2_Output *o, void *data);
+
 # endif
 
 #endif
diff --git a/src/lib/ecore_drm2/ecore_drm2_fb.c 
b/src/lib/ecore_drm2/ecore_drm2_fb.c
index 6ac0dde..3160e5c 100644
--- a/src/lib/ecore_drm2/ecore_drm2_fb.c
+++ b/src/lib/ecore_drm2/ecore_drm2_fb.c
@@ -224,7 +224,7 @@ ecore_drm2_fb_dirty(Ecore_Drm2_Fb *fb, Eina_Rectangle 
*rects, unsigned int count
 }
 
 EAPI int
-ecore_drm2_fb_flip(Ecore_Drm2_Fb *fb, Ecore_Drm2_Output *output, void *data)
+ecore_drm2_fb_flip(Ecore_Drm2_Fb *fb, Ecore_Drm2_Output *output)
 {
int ret = 0;
 
@@ -260,7 +260,7 @@ ecore_drm2_fb_flip(Ecore_Drm2_Fb *fb, Ecore_Drm2_Output 
*output, void *data)
 
ret =
  drmModePageFlip(fb->fd, output->crtc_id, fb->id,
- DRM_MODE_PAGE_FLIP_EVENT, data);
+ DRM_MODE_PAGE_FLIP_EVENT, output->user_data);
if (ret < 0)
  {
 DBG("Pageflip Failed for Crtc %u on Connector %u: %m",
diff --git a/src/lib/ecore_drm2/ecore_drm2_outputs.c 
b/src/lib/ecore_drm2/ecore_drm2_outputs.c
index a48170c..fda51f3 100644
--- a/src/lib/ecore_drm2/ecore_drm2_outputs.c
+++ b/src/lib/ecore_drm2/ecore_drm2_outputs.c
@@ -1208,3 +1208,9 @@ next:
 
return ret;
 }
+
+EAPI void
+ecore_drm2_output_user_data_set(Ecore_Drm2_Output *o, void *data)
+{
+   o->user_data = data;
+}
diff --git a/src/lib/ecore_drm2/ecore_drm2_private.h 
b/src/lib/ecore_drm2/ecore_drm2_private.h
index 05f7102..8c16c04 100644
--- a/src/lib/ecore_drm2/ecore_drm2_private.h
+++ b/src/lib/ecore_drm2/ecore_drm2_private.h
@@ -151,6 +151,8 @@ struct _Ecore_Drm2_Output
 
Eina_List *planes;
 
+   void *user_data;
+
Eina_Bool connected : 1;
Eina_Bool primary : 1;
Eina_Bool cloned : 1;
diff --git a/src/modules/evas/engines/drm/evas_outbuf.c 
b/src/modules/evas/engines/drm/evas_outbuf.c
index e2f0c2e..3ae032e 100644
--- a/src/modules/evas/engines/drm/evas_outbuf.c
+++ b/src/modules/evas/engines/drm/evas_outbuf.c
@@ -97,7 +97,7 @@ _cb_pageflip(int fd EINA_UNUSED, unsigned int frame 
EINA_UNUSED, unsigned int se
if (next)
  {
 ecore_drm2_output_next_fb_set(ob->priv.output, NULL);
-ecore_drm2_fb_flip(next, ob->priv.output, ob);
+ecore_drm2_fb_flip(next, ob->priv.output);
  }
 }
 
@@ -140,7 +140,7 @@ _outbuf_buffer_swap(Outbuf *ob, Eina_Rectangle *rects, 
unsigned int count)
  }
 
ecore_drm2_fb_dirty(ofb->fb, rects, count);
-   if (ecore_drm2_fb_flip(ofb->fb, ob->priv.output, ob) == 0)
+   if (ecore_drm2_fb_flip(ofb->fb, ob->priv.output) == 0)
  ob->priv.display = ofb;
 
ecore_drm2_fb_busy_set(ofb->fb, EINA_TRUE);
@@ -256,6 +256,8 @@ _outbuf_setup(Evas_Engine_Info_Drm *info, int w, int h)
ob->ctx.vblank_handler = _cb_vblank;
ob->ctx.page_flip_handler = _cb_pageflip;
 
+   ecore_drm2_output_user_data_set(ob->priv.output, ob);
+
ob->hdlr =
  ecore_main_fd_handler_add(ob->fd, ECOR

[EGIT] [core/enlightenment] master 01/01: bump ecore_drm2 dependency, update to latest beta API

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=dc2bad0fcda063ee72b35beb3954cc2fc1eb94ba

commit dc2bad0fcda063ee72b35beb3954cc2fc1eb94ba
Author: Derek Foreman 
Date:   Thu Sep 8 11:51:36 2016 -0500

bump ecore_drm2 dependency, update to latest beta API
---
 configure.ac| 10 +++---
 src/bin/e_alert_main.c  |  2 +-
 src/modules/wl_drm/e_mod_main.c |  8 ++--
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/configure.ac b/configure.ac
index ec14351..e35493c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -94,6 +94,10 @@ AC_DEFINE(HAVE_ENVIRON, 1, [Have environ var])
 efl_version="1.17.0"
 AC_SUBST(efl_version)
 
+#We use ecore_drm2 beta API
+efl_ecore_drm2_version="1.18.99"
+AC_SUBST(efl_ecore_drm2_version)
+
 AC_CHECK_HEADERS([sys/timerfd.h sys/ptrace.h arpa/inet.h netinet/in.h])
 
 dnl AC_CHECK_HEADERS(X11/extensions/shape.h,, AC_MSG_ERROR([Cannot find 
X11/extensions/shape.h. Make sure your CFLAGS environment variable contains 
include lines for the location of this file]))
@@ -763,9 +767,9 @@ WL_DRM=false
 define([CHECK_MODULE_WL_DRM],
 [
   if test "x${have_wayland}" = "xyes" ; then
-PKG_CHECK_EXISTS([ecore-drm2 >= $efl_version], [have_ecore_drm2="yes"], 
[have_ecore_drm2="no"])
+PKG_CHECK_EXISTS([ecore-drm2 >= $efl_ecore_drm2_version], 
[have_ecore_drm2="yes"], [have_ecore_drm2="no"])
 if test "x${have_ecore_drm2}" = "xyes"; then
-  AC_E_CHECK_PKG(WL_DRM, [ ecore-drm2 >= $efl_version ecore >= 
$efl_version eina >= $efl_version ],
+  AC_E_CHECK_PKG(WL_DRM, [ ecore-drm2 >= $efl_ecore_drm2_version ecore >= 
$efl_version eina >= $efl_version ],
 [
   WL_DRM=true
   AC_DEFINE_UNQUOTED([HAVE_DRM2],[1],[enable ecore-drm2 support])
@@ -901,7 +905,7 @@ if test "x${have_wayland}" = "xyes"; then
   e_alert_requires="\
 $e_alert_requires \
 ecore-input >= ${efl_version} \
-ecore-drm2 >= ${efl_version} \
+ecore-drm2 >= ${efl_ecore_drm2_version} \
 evas >= ${efl_version}"
 else
   e_alert_requires="\
diff --git a/src/bin/e_alert_main.c b/src/bin/e_alert_main.c
index c0cb3c6..7317896 100644
--- a/src/bin/e_alert_main.c
+++ b/src/bin/e_alert_main.c
@@ -456,7 +456,7 @@ _e_alert_drm_display(void)
updates = evas_render_updates(canvas);
evas_render_updates_free(updates);
 
-   ecore_drm2_fb_flip(buffer, output, NULL);
+   ecore_drm2_fb_flip(buffer, output);
 }
 
 static void
diff --git a/src/modules/wl_drm/e_mod_main.c b/src/modules/wl_drm/e_mod_main.c
index 5f50f2d..1052c62 100644
--- a/src/modules/wl_drm/e_mod_main.c
+++ b/src/modules/wl_drm/e_mod_main.c
@@ -788,12 +788,8 @@ _drm2_read_pixels(E_Comp_Wl_Output *output, void *pixels)
out = ecore_drm2_output_find(dev, output->x, output->y);
if (!out) return;
 
-   fb = ecore_drm2_output_next_fb_get(out);
-   if (!fb)
- {
-fb = ecore_drm2_output_current_fb_get(out);
-if (!fb) return;
- }
+   fb = ecore_drm2_output_latest_fb_get(out);
+   if (!fb) return;
 
data = ecore_drm2_fb_data_get(fb);
fstride = ecore_drm2_fb_stride_get(fb);

-- 




[EGIT] [core/efl] master 20/20: ee_gl_drm: Stop calling fb_dirty

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=088c9675efc791d3fb2d6c79d24fec53f6fcfabd

commit 088c9675efc791d3fb2d6c79d24fec53f6fcfabd
Author: Derek Foreman 
Date:   Thu Sep 8 13:21:32 2016 -0500

ee_gl_drm: Stop calling fb_dirty

So yeah, fb_dirty is for marking dirty regions when rendering
directly into the front buffer attached for scanout on a manually
updated display.  Absolutely none of those things apply here, so
let's stop doing it.
---
 src/modules/evas/engines/gl_drm/evas_outbuf.c | 26 ++
 1 file changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/modules/evas/engines/gl_drm/evas_outbuf.c 
b/src/modules/evas/engines/gl_drm/evas_outbuf.c
index 0737c57..fb16c29 100644
--- a/src/modules/evas/engines/gl_drm/evas_outbuf.c
+++ b/src/modules/evas/engines/gl_drm/evas_outbuf.c
@@ -77,7 +77,7 @@ _evas_outbuf_fb_get(Outbuf *ob, struct gbm_bo *bo)
 }
 
 static void
-_evas_outbuf_buffer_swap(Outbuf *ob, Eina_Rectangle *rects, unsigned int count)
+_evas_outbuf_buffer_swap(Outbuf *ob)
 {
Ecore_Drm2_Fb *fb;
 
@@ -101,7 +101,6 @@ _evas_outbuf_buffer_swap(Outbuf *ob, Eina_Rectangle *rects, 
unsigned int count)
fb = _evas_outbuf_fb_get(ob, ob->priv.bo[0]);
if (fb)
  {
-ecore_drm2_fb_dirty(fb, rects, count);
 ecore_drm2_fb_flip(fb, ob->priv.output);
 
 /* Ecore_Drm2_Plane *plane; */
@@ -763,28 +762,7 @@ evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects, 
Evas_Render_Mode render_mode)
if (ob->info->callback.post_swap)
  ob->info->callback.post_swap(ob->info->callback.data, ob->evas);
 
-   if (rects)
- {
-Tilebuf_Rect *r;
-Eina_Rectangle *res;
-int num, i = 0;
-
-num = eina_inlist_count(EINA_INLIST_GET(rects));
-res = alloca(sizeof(Eina_Rectangle) * num);
-EINA_INLIST_FOREACH(EINA_INLIST_GET(rects), r)
-  {
- res[i].x = r->x;
- res[i].y = r->y;
- res[i].w = r->w;
- res[i].h = r->h;
- i++;
-  }
-
-_evas_outbuf_buffer_swap(ob, res, num);
- }
-   else
- //Flush GL Surface data to Framebuffer
- _evas_outbuf_buffer_swap(ob, NULL, 0);
+   _evas_outbuf_buffer_swap(ob);
 
 end:
//TODO: Need render unlock after drm page flip?

-- 




[EGIT] [core/efl] master 06/20: ee_drm: use the ecore_drm2_fb busy bit

2016-09-08 Thread Derek Foreman
derekf pushed a commit to branch master.

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

commit cfd172c64bf021c70b9c31adae25f7edb09d6eec
Author: Derek Foreman 
Date:   Fri Sep 2 12:18:06 2016 -0500

ee_drm: use the ecore_drm2_fb busy bit

Use the new busy getter/setter on the fb instead of keeping state in the
outbuf
---
 src/modules/evas/engines/drm/evas_engine.h |  1 -
 src/modules/evas/engines/drm/evas_outbuf.c | 12 +---
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/modules/evas/engines/drm/evas_engine.h 
b/src/modules/evas/engines/drm/evas_engine.h
index 1bfe40e..3733610 100644
--- a/src/modules/evas/engines/drm/evas_engine.h
+++ b/src/modules/evas/engines/drm/evas_engine.h
@@ -48,7 +48,6 @@ typedef struct _Outbuf_Fb
 
Eina_Bool valid : 1;
Eina_Bool drawn : 1;
-   Eina_Bool busy : 1;
 } Outbuf_Fb;
 
 struct _Outbuf
diff --git a/src/modules/evas/engines/drm/evas_outbuf.c 
b/src/modules/evas/engines/drm/evas_outbuf.c
index aec09ff..e2f0c2e 100644
--- a/src/modules/evas/engines/drm/evas_outbuf.c
+++ b/src/modules/evas/engines/drm/evas_outbuf.c
@@ -91,7 +91,7 @@ _cb_pageflip(int fd EINA_UNUSED, unsigned int frame 
EINA_UNUSED, unsigned int se
ob = data;
 
ofb = ob->priv.display;
-   if (ofb) ofb->busy = EINA_FALSE;
+   if (ofb) ecore_drm2_fb_busy_set(ofb->fb, EINA_FALSE);
 
next = ecore_drm2_output_next_fb_get(ob->priv.output);
if (next)
@@ -135,7 +135,7 @@ _outbuf_buffer_swap(Outbuf *ob, Eina_Rectangle *rects, 
unsigned int count)
if (next)
  {
 next_ofb = _outbuf_fb_find(ob, next);
-next_ofb->busy = EINA_FALSE;
+ecore_drm2_fb_busy_set(next_ofb->fb, EINA_FALSE);
 ecore_drm2_output_next_fb_set(ob->priv.output, NULL);
  }
 
@@ -143,7 +143,7 @@ _outbuf_buffer_swap(Outbuf *ob, Eina_Rectangle *rects, 
unsigned int count)
if (ecore_drm2_fb_flip(ofb->fb, ob->priv.output, ob) == 0)
  ob->priv.display = ofb;
 
-   ofb->busy = EINA_TRUE;
+   ecore_drm2_fb_busy_set(ofb->fb, EINA_TRUE);
ofb->drawn = EINA_TRUE;
ofb->age = 0;
 
@@ -192,7 +192,6 @@ _outbuf_fb_create(Outbuf *ob, Outbuf_Fb *ofb)
if (!ofb->fb) return EINA_FALSE;
 
ofb->age = 0;
-   ofb->busy = EINA_FALSE;
ofb->drawn = EINA_FALSE;
ofb->valid = EINA_TRUE;
 
@@ -206,7 +205,6 @@ _outbuf_fb_destroy(Outbuf_Fb *ofb)
 
memset(ofb, 0, sizeof(*ofb));
ofb->valid = EINA_FALSE;
-   ofb->busy = EINA_FALSE;
ofb->drawn = EINA_FALSE;
ofb->age = 0;
 }
@@ -370,7 +368,7 @@ _outbuf_fb_wait(Outbuf *ob)
 for (i = 0; i < ob->priv.num; i++)
   {
  if (&ob->priv.ofb[i] == ob->priv.display) continue;
- if (ob->priv.ofb[i].busy) continue;
+ if (ecore_drm2_fb_busy_get(ob->priv.ofb[i].fb)) continue;
  if (ob->priv.ofb[i].valid) return &(ob->priv.ofb[i]);
   }
 
@@ -394,7 +392,7 @@ _outbuf_fb_assign(Outbuf *ob)
   {
  if (ob->priv.ofb[i].valid)
{
-  ob->priv.ofb[i].busy = 0;
+  ecore_drm2_fb_busy_set(ob->priv.ofb[i].fb, EINA_FALSE);
   ob->priv.ofb[i].age = 0;
   ob->priv.ofb[i].drawn = EINA_FALSE;
}

-- 




[EGIT] [core/efl] master 01/01: efl_net_socket_fd: make it more win32 friendly.

2016-09-08 Thread Gustavo Sverzut Barbieri
barbieri pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=4814f937e2e1b7705daf3c5cf7e32d9cb0fe120c

commit 4814f937e2e1b7705daf3c5cf7e32d9cb0fe120c
Author: Gustavo Sverzut Barbieri 
Date:   Thu Sep 8 16:12:18 2016 -0300

efl_net_socket_fd: make it more win32 friendly.

it seems that on windows read() and write() won't work with sockets,
so use recv() and send().

Note that this code is still untested on windows, at least the errors
must be fetched using WSAGetLastError() instead of errno directly, but
I don't have a Windows machine I can test.
---
 src/lib/ecore_con/ecore_con_private.h | 74 
 src/lib/ecore_con/efl_net_socket_fd.c | 92 ++-
 2 files changed, 155 insertions(+), 11 deletions(-)

diff --git a/src/lib/ecore_con/ecore_con_private.h 
b/src/lib/ecore_con/ecore_con_private.h
index e2fab7a..69102d7 100644
--- a/src/lib/ecore_con/ecore_con_private.h
+++ b/src/lib/ecore_con/ecore_con_private.h
@@ -377,4 +377,78 @@ Eina_Bool efl_net_ip_port_fmt(char *buf, int buflen, const 
struct sockaddr *addr
 
 int efl_net_socket4(int domain, int type, int protocol, Eina_Bool 
close_on_exec);
 
+static inline Eina_Error
+efl_net_socket_error_get(void)
+{
+#ifndef _WIN32
+   return errno;
+#else
+   Eina_Error err = WSAGetLastError();
+
+   if (0) { }
+
+   /* used by send() */
+#if defined(WSAEACCES) && (WSAEACCES != EACCES)
+   else if (err == WSAEACCES) err = EACCES;
+#endif
+#if defined(WSAEWOULDBLOCK) && (WSAEWOULDBLOCK != EAGAIN)
+   else if (err == WSAEWOULDBLOCK) err = EAGAIN;
+#endif
+#if defined(WSAEBADF) && (WSAEBADF != EBADF)
+   else if (err == WSAEBADF) err = EBADF;
+#endif
+#if defined(WSAECONNRESET) && (WSAECONNRESET != ECONNRESET)
+   else if (err == WSAECONNRESET) err = ECONNRESET;
+#endif
+#if defined(WSAEDESTADDRREQ) && (WSAEDESTADDRREQ != EDESTADDRREQ)
+   else if (err == WSAEDESTADDRREQ) err = EDESTADDRREQ;
+#endif
+#if defined(WSAEFAULT) && (WSAEFAULT != EFAULT)
+   else if (err == WSAEFAULT) err = EFAULT;
+#endif
+#if defined(WSAEINTR) && (WSAEINTR != EINTR)
+   else if (err == WSAEINTR) err = EINTR;
+#endif
+#if defined(WSAEINVAL) && (WSAEINVAL != EINVAL)
+   else if (err == WSAEINVAL) err = EINVAL;
+#endif
+#if defined(WSAEISCONN) && (WSAEISCONN != EISCONN)
+   else if (err == WSAEISCONN) err = EISCONN;
+#endif
+#if defined(WSAEMSGSIZE) && (WSAEMSGSIZE != EMSGSIZE)
+   else if (err == WSAEMSGSIZE) err = EMSGSIZE;
+#endif
+#if defined(WSAENOBUFS) && (WSAENOBUFS != ENOBUFS)
+   else if (err == WSAENOBUFS) err = ENOBUFS;
+#endif
+#if defined(WSA_NOT_ENOUGH_MEMORY) && (WSA_NOT_ENOUGH_MEMORY != ENOMEM)
+   else if (err == WSA_NOT_ENOUGH_MEMORY) err = ENOMEM;
+#endif
+#if defined(WSAENOTCONN) && (WSAENOTCONN != ENOTCONN)
+   else if (err == WSAENOTCONN) err = ENOTCONN;
+#endif
+#if defined(WSAENOTSOCK) && (WSAENOTSOCK != ENOTSOCK)
+   else if (err == WSAENOTSOCK) err = ENOTSOCK;
+#endif
+#if defined(WSAEOPNOTSUPP) && (WSAEOPNOTSUPP != EOPNOTSUPP)
+   else if (err == WSAEOPNOTSUPP) err = EOPNOTSUPP;
+#endif
+#if defined(WSAESHUTDOWN) && (WSAESHUTDOWN != EPIPE)
+   else if (err == WSAESHUTDOWN) err = EPIPE;
+#endif
+
+   /* extras used by recv() */
+#if defined(WSAECONNREFUSED) && (WSAECONNREFUSED != ECONNREFUSED)
+   else if (err == WSAECONNREFUSED) err = ECONNREFUSED;
+#endif
+
+   /* extras used by getsockopt() */
+#if defined(WSAENOPROTOOPT) && (WSAENOPROTOOPT != ENOPROTOOPT)
+   else if (err == WSAENOPROTOOPT) err = ENOPROTOOPT;
+#endif
+
+   return err;
+#endif
+}
+
 #endif
diff --git a/src/lib/ecore_con/efl_net_socket_fd.c 
b/src/lib/ecore_con/efl_net_socket_fd.c
index 0cc9152..339e7ef 100644
--- a/src/lib/ecore_con/efl_net_socket_fd.c
+++ b/src/lib/ecore_con/efl_net_socket_fd.c
@@ -120,7 +120,7 @@ _efl_net_socket_fd_efl_loop_fd_fd_set(Eo *o, 
Efl_Net_Socket_Fd_Data *pd, int fd)
 struct sockaddr_storage addr;
 socklen_t addrlen = sizeof(addr);
 if (getsockname(fd, (struct sockaddr *)&addr, &addrlen) < 0)
-  ERR("getsockname(%d): %s", fd, strerror(errno));
+  ERR("getsockname(%d): %s", fd, 
eina_error_msg_get(efl_net_socket_error_get()));
 else
   efl_net_socket_fd_family_set(o, addr.ss_family);
  }
@@ -157,25 +157,84 @@ _efl_net_socket_fd_efl_io_closer_close(Eo *o, 
Efl_Net_Socket_Fd_Data *pd EINA_UN
 EOLIAN static Eina_Error
 _efl_net_socket_fd_efl_io_reader_read(Eo *o, Efl_Net_Socket_Fd_Data *pd 
EINA_UNUSED, Eina_Rw_Slice *rw_slice)
 {
-   Eina_Error ret;
+   int fd = efl_io_reader_fd_reader_fd_get(o);
+   ssize_t r;
 
-   ret = efl_io_reader_read(efl_super(o, MY_CLASS), rw_slice);
-   if (rw_slice && rw_slice->len > 0)
- efl_io_reader_can_read_set(o, EINA_FALSE); /* wait Efl.Loop.Fd "read" */
+   EINA_SAFETY_ON_NULL_RETURN_VAL(rw_slice, EINVAL);
+   if (fd < 0) goto error;
+   do
+ {
+r = recv(fd, rw_slice->mem, rw_slice->len, 0);
+if (r < 0)
+  {
+ Eina_Err

[EGIT] [core/efl] master 01/01: examples: elementary: ignore generated codegen example files

2016-09-08 Thread Stefan Schmidt
stefan pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=6023143b781e764a356e5d21326f9d41e3f2f7bc

commit 6023143b781e764a356e5d21326f9d41e3f2f7bc
Author: Stefan Schmidt 
Date:   Thu Sep 8 11:52:54 2016 +0200

examples: elementary: ignore generated codegen example files
---
 src/examples/elementary/.gitignore | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/examples/elementary/.gitignore 
b/src/examples/elementary/.gitignore
index 9d210a9..214d1b6 100644
--- a/src/examples/elementary/.gitignore
+++ b/src/examples/elementary/.gitignore
@@ -153,4 +153,6 @@
 /table_cxx_example_02
 /thumb_cxx_example_01
 /benchmark3d
-/sphere-hunter
\ No newline at end of file
+/sphere-hunter
+/codegen_example_generated.c
+/codegen_example_generated.h

-- 




[EGIT] [core/efl] master 18/27: eo: add Eina.Binbuf native type.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

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

commit f17f389b66c734571e85d1b008dfd43fc7d40b28
Author: Cedric Bail 
Date:   Tue Aug 2 14:04:24 2016 -0700

eo: add Eina.Binbuf native type.
---
 src/lib/eo/eina_types.eot | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/lib/eo/eina_types.eot b/src/lib/eo/eina_types.eot
index c7b9c95..4191626 100644
--- a/src/lib/eo/eina_types.eot
+++ b/src/lib/eo/eina_types.eot
@@ -22,6 +22,7 @@ struct @extern Eina.Matrix3 {
 }
 
 struct @extern Eina.Inarray;
+struct @extern Eina.Binbuf;
 
 type @extern Eina.Unicode: uint32;
 

-- 




[EGIT] [core/efl] master 15/27: ecore: test efl_future_link.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

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

commit d8310b71802ab64e145092178c545119e6e80b23
Author: Cedric Bail 
Date:   Wed Jul 27 17:17:20 2016 -0700

ecore: test efl_future_link.
---
 src/tests/ecore/ecore_test_promise.c | 29 +
 1 file changed, 29 insertions(+)

diff --git a/src/tests/ecore/ecore_test_promise.c 
b/src/tests/ecore/ecore_test_promise.c
index 131e5af..0f35ac0 100644
--- a/src/tests/ecore/ecore_test_promise.c
+++ b/src/tests/ecore/ecore_test_promise.c
@@ -1097,6 +1097,34 @@ START_TEST(efl_test_promise_race)
 }
 END_TEST
 
+START_TEST(efl_test_future_link)
+{
+   Efl_Promise *p;
+   Efl_Future *f;
+   Eo *o;
+
+   ecore_init();
+
+   o = efl_add(EFL_LOOP_TIMER_CLASS, ecore_main_loop_get());
+   p = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
+   efl_future_use(&f, efl_promise_future_get(p));
+   efl_future_link(o, f);
+
+   fail_if(!o || !p || !f);
+   efl_del(o);
+   fail_if(f);
+
+   o = efl_add(EFL_LOOP_TIMER_CLASS, ecore_main_loop_get());
+   efl_future_use(&f, efl_promise_future_get(p));
+   efl_future_cancel(f);
+
+   efl_del(o);
+   efl_del(p);
+
+   ecore_shutdown();
+}
+END_TEST
+
 void ecore_test_ecore_promise(TCase *tc)
 {
tcase_add_test(tc, ecore_test_promise);
@@ -1126,4 +1154,5 @@ void ecore_test_ecore_promise(TCase *tc)
tcase_add_test(tc, efl_test_promise_future_optional_cancel);
tcase_add_test(tc, efl_test_promise_all);
tcase_add_test(tc, efl_test_promise_race);
+   tcase_add_test(tc, efl_test_future_link);
 }

-- 




[EGIT] [core/efl] master 24/27: eio: make xattr list packed for better performance.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=5579d2f5cdda0286d908e4975c0cd9f5361b8df0

commit 5579d2f5cdda0286d908e4975c0cd9f5361b8df0
Author: Cedric BAIL 
Date:   Wed Sep 7 15:57:25 2016 -0700

eio: make xattr list packed for better performance.
---
 src/lib/eio/eio_xattr.c | 44 +---
 1 file changed, 33 insertions(+), 11 deletions(-)

diff --git a/src/lib/eio/eio_xattr.c b/src/lib/eio/eio_xattr.c
index a795b95..0dfec5b 100644
--- a/src/lib/eio/eio_xattr.c
+++ b/src/lib/eio/eio_xattr.c
@@ -33,11 +33,17 @@ _eio_ls_xattr_heavy(void *data, Ecore_Thread *thread)
 {
Eio_File_Char_Ls *async = data;
Eina_Iterator *it;
+   Eina_List *pack = NULL;
const char *tmp;
+   double start;
 
it = eina_xattr_ls(async->ls.directory);
if (!it) return;
 
+   eio_file_container_set(&async->ls.common, eina_iterator_container_get(it));
+
+   start = ecore_time_get();
+
EINA_ITERATOR_FOREACH(it, tmp)
  {
 Eina_Bool filter = EINA_TRUE;
@@ -49,22 +55,38 @@ _eio_ls_xattr_heavy(void *data, Ecore_Thread *thread)
tmp);
   }
 
-if (filter) ecore_thread_feedback(thread, eina_stringshare_add(tmp));
+if (filter)
+  {
+ Eio_File_Char *send_fc;
+
+ send_fc = eio_char_malloc();
+ if (!send_fc) goto on_error;
+
+ send_fc->filename = eina_stringshare_add(tmp);
+ send_fc->associated = async->ls.common.worker.associated;
+ async->ls.common.worker.associated = NULL;
+
+ pack = eina_list_append(pack, send_fc);
+  }
+else
+  {
+  on_error:
+ if (async->ls.common.worker.associated)
+   {
+  eina_hash_free(async->ls.common.worker.associated);
+  async->ls.common.worker.associated = NULL;
+   }
+  }
+
+pack = eio_pack_send(thread, pack, &start);
 
 if (ecore_thread_check(thread))
   break;
  }
 
-   eina_iterator_free(it);
-}
-
-static void
-_eio_ls_xattr_notify(void *data, Ecore_Thread *thread EINA_UNUSED, void 
*msg_data)
-{
-   Eio_File_Char_Ls *async = data;
-   const char *xattr = msg_data;
+   if (pack) ecore_thread_feedback(thread, pack);
 
-   async->main_cb((void*) async->ls.common.data, &async->ls.common, xattr);
+   async->ls.ls = it;
 }
 
 static void
@@ -310,7 +332,7 @@ eio_file_xattr(const char *path,
  error_cb,
  data,
  _eio_ls_xattr_heavy,
- _eio_ls_xattr_notify,
+ _eio_string_notify,
  eio_async_end,
  eio_async_error))
 return NULL;

-- 




[EGIT] [core/efl] master 11/27: ecore: add efl_future_iterator_all.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=56df83e2c09db7a549a712c21a6cfecc055a8bcd

commit 56df83e2c09db7a549a712c21a6cfecc055a8bcd
Author: Cedric BAIL 
Date:   Tue Aug 30 16:29:49 2016 -0700

ecore: add efl_future_iterator_all.
---
 src/lib/ecore/Ecore_Eo.h|  1 +
 src/lib/ecore/efl_promise.c | 23 +++
 2 files changed, 24 insertions(+)

diff --git a/src/lib/ecore/Ecore_Eo.h b/src/lib/ecore/Ecore_Eo.h
index ef2b17f..1209232 100644
--- a/src/lib/ecore/Ecore_Eo.h
+++ b/src/lib/ecore/Ecore_Eo.h
@@ -70,6 +70,7 @@ struct _Efl_Future_Composite_Progress
 };
 
 EAPI Efl_Future *efl_future_all_internal(Efl_Future *f1, ...);
+EAPI Efl_Future *efl_future_iterator_all(Eina_Iterator *it);
 
 #define efl_future_all(...) efl_future_all_internal(__VA_ARGS__, NULL)
 
diff --git a/src/lib/ecore/efl_promise.c b/src/lib/ecore/efl_promise.c
index 2bdf219..275c56a 100644
--- a/src/lib/ecore/efl_promise.c
+++ b/src/lib/ecore/efl_promise.c
@@ -934,9 +934,32 @@ efl_future_all_internal(Efl_Future *f1, ...)
 
return _efl_future_all_done(all);
 
+ on_error:
+   _efl_promise_all_die(all, NULL);
+   return NULL;
+}
+
+EAPI Efl_Future *
+efl_future_iterator_all(Eina_Iterator *it)
+{
+   Efl_Promise_All *all = NULL;
+   Efl_Future *fn;
+
+   if (!it) return NULL;
 
+   EINA_ITERATOR_FOREACH(it, fn)
+ {
+if (!all) _efl_future_all_new(fn);
+if (!all) goto on_error;
+if (!_efl_future_all_append(all, fn))
+  goto on_error;
+ }
+   eina_iterator_free(it);
+
+   return _efl_future_all_done(all);
 
  on_error:
+   eina_iterator_free(it);
_efl_promise_all_die(all, NULL);
return NULL;
 }

-- 




[EGIT] [core/efl] master 13/27: ecore: add test for efl_future_race.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=5edb42d3715366fb0b141763da43bdaaec19dc8f

commit 5edb42d3715366fb0b141763da43bdaaec19dc8f
Author: Cedric Bail 
Date:   Wed Jul 27 14:28:19 2016 -0700

ecore: add test for efl_future_race.
---
 src/tests/ecore/ecore_test_promise.c | 50 
 1 file changed, 50 insertions(+)

diff --git a/src/tests/ecore/ecore_test_promise.c 
b/src/tests/ecore/ecore_test_promise.c
index e998d99..131e5af 100644
--- a/src/tests/ecore/ecore_test_promise.c
+++ b/src/tests/ecore/ecore_test_promise.c
@@ -1048,6 +1048,55 @@ START_TEST(efl_test_promise_all)
 }
 END_TEST
 
+static void
+_then_race(void *data, const Efl_Event *ev)
+{
+   Future_Ok *fo = data;
+   Efl_Future_Event_Success *s = ev->info;
+   Efl_Future_Race_Success *rs = s->value;
+
+   fail_if(rs->index != 1);
+   fail_if(rs->value != &value[0]);
+
+   fo->then = EINA_TRUE;
+}
+
+START_TEST(efl_test_promise_race)
+{
+   Efl_Promise *p1, *p2, *p3;
+   Efl_Future *race = NULL, *f1;
+   Future_Ok donea = { EINA_FALSE, EINA_FALSE, EINA_FALSE };
+   Future_Ok donep1 = { EINA_FALSE, EINA_FALSE, EINA_FALSE };
+
+   ecore_init();
+
+   p1 = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
+   p2 = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
+   p3 = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
+   fail_if(!p1 || !p2 || !p3);
+
+   f1 = efl_ref(efl_promise_future_get(p1));
+   fail_if(!efl_future_then(f1, _then, _cancel, _progress, &donep1));
+   efl_future_use(&race, efl_future_race(f1, efl_promise_future_get(p2), 
efl_promise_future_get(p3)));
+   efl_unref(f1);
+
+   fail_if(!efl_future_then(race, _then_race, _cancel, _progress, &donea));
+   fail_if(!race);
+
+   efl_promise_value_set(p2, &value[0], NULL);
+   fail_if(donep1.then || !donep1.cancel || donep1.progress);
+   fail_if(!donea.then || donea.cancel || donea.progress);
+
+   fail_if(race);
+
+   efl_del(p1);
+   efl_del(p2);
+   efl_del(p3);
+
+   ecore_shutdown();
+}
+END_TEST
+
 void ecore_test_ecore_promise(TCase *tc)
 {
tcase_add_test(tc, ecore_test_promise);
@@ -1076,4 +1125,5 @@ void ecore_test_ecore_promise(TCase *tc)
tcase_add_test(tc, efl_test_promise_future_optional_success);
tcase_add_test(tc, efl_test_promise_future_optional_cancel);
tcase_add_test(tc, efl_test_promise_all);
+   tcase_add_test(tc, efl_test_promise_race);
 }

-- 




[EGIT] [core/efl] master 06/27: ecore: add support for optional futures.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

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

commit cd6a8aa6b3ed49c7d246bad27837a306acff9630
Author: Cedric Bail 
Date:   Fri Jul 8 14:00:43 2016 -0700

ecore: add support for optional futures.
---
 src/lib/ecore/ecore_main.c| 21 +
 src/lib/ecore/ecore_private.h |  3 +++
 src/lib/ecore/efl_promise.c   | 19 +--
 3 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/src/lib/ecore/ecore_main.c b/src/lib/ecore/ecore_main.c
index 851d6fe..3a34580 100644
--- a/src/lib/ecore/ecore_main.c
+++ b/src/lib/ecore/ecore_main.c
@@ -275,6 +275,7 @@ static void _ecore_main_win32_handlers_cleanup(void);
 
 int in_main_loop = 0;
 
+static Eina_List *_pending_futures = NULL;
 static unsigned char _ecore_exit_code = 0;
 static int do_quit = 0;
 static Ecore_Fd_Handler *fd_handlers = NULL;
@@ -2226,8 +2227,14 @@ static void
 _ecore_main_loop_iterate_internal(int once_only)
 {
double next_time = -1.0;
+   Eo *f;
 
in_main_loop++;
+
+   /* destroy all optional futures */
+   EINA_LIST_FREE(_pending_futures, f)
+ efl_del(f);
+
/* expire any timers */
_efl_loop_timer_expired_timers_call(_ecore_time_loop_time);
 
@@ -2905,6 +2912,20 @@ ecore_loop_arguments_send(int argc, const char **argv)
 static void _efl_loop_timeout_force_cancel_cb(void *data, const Efl_Event 
*event EINA_UNUSED);
 static void _efl_loop_timeout_cb(void *data, const Efl_Event *event 
EINA_UNUSED);
 
+// Only one main loop handle for now
+void
+ecore_loop_future_register(Efl_Loop *l EINA_UNUSED, Efl_Future *f)
+{
+   _pending_futures = eina_list_append(_pending_futures, f);
+}
+
+void
+ecore_loop_future_unregister(Efl_Loop *l EINA_UNUSED, Efl_Future *f)
+{
+   _pending_futures = eina_list_remove(_pending_futures, f);
+}
+
+
 EFL_CALLBACKS_ARRAY_DEFINE(timeout,
   { EFL_LOOP_TIMER_EVENT_TICK, _efl_loop_timeout_cb },
   { EFL_EVENT_DEL, _efl_loop_timeout_force_cancel_cb 
});
diff --git a/src/lib/ecore/ecore_private.h b/src/lib/ecore/ecore_private.h
index e476b32..f31b2f5 100644
--- a/src/lib/ecore/ecore_private.h
+++ b/src/lib/ecore/ecore_private.h
@@ -371,6 +371,9 @@ extern Efl_Version _app_efl_version;
 #define ECORE_PARENT_CLASS ecore_parent_class_get()
 EAPI const Efl_Class *ecore_parent_class_get(void) EINA_CONST;
 
+void ecore_loop_future_register(Efl_Loop *l EINA_UNUSED, Efl_Future *f);
+void ecore_loop_future_unregister(Efl_Loop *l EINA_UNUSED, Efl_Future *f);
+
 // access to direct input cb
 #define ECORE_EVAS_INTERNAL
 
diff --git a/src/lib/ecore/efl_promise.c b/src/lib/ecore/efl_promise.c
index 5a03cee..38e1f2f 100644
--- a/src/lib/ecore/efl_promise.c
+++ b/src/lib/ecore/efl_promise.c
@@ -6,8 +6,6 @@
 
 #include "ecore_private.h"
 
-// FIXME: handle self destruction when back in the main loop
-
 typedef struct _Efl_Promise_Data Efl_Promise_Data;
 typedef struct _Efl_Promise_Msg Efl_Promise_Msg;
 
@@ -77,6 +75,7 @@ struct _Efl_Loop_Future_Data
Eina_Bool fulfilled : 1;
Eina_Bool death : 1;
Eina_Bool delayed : 1;
+   Eina_Bool optional : 1;
 };
 
 static void
@@ -178,6 +177,12 @@ _efl_loop_future_prepare_events(Efl_Loop_Future_Data *pd, 
Eina_Bool progress)
 {
if (!pd->promise) return ;
 
+   if (pd->optional)
+ {
+pd->optional = EINA_FALSE;
+ecore_loop_future_unregister(efl_provider_find(pd->self, 
EFL_LOOP_CLASS), pd->self);
+ }
+
pd->promise->set.future = EINA_TRUE;
if (progress)
  pd->promise->set.progress = EINA_TRUE;
@@ -288,6 +293,9 @@ _efl_loop_future_efl_object_constructor(Eo *obj, 
Efl_Loop_Future_Data *pd)
obj = efl_constructor(efl_super(obj, EFL_LOOP_FUTURE_CLASS));
 
pd->self = obj;
+   pd->optional = EINA_TRUE;
+
+   ecore_loop_future_register(efl_provider_find(obj, EFL_LOOP_CLASS), obj);
 
efl_del_intercept_set(obj, _efl_loop_future_intercept);
 
@@ -318,6 +326,13 @@ _efl_loop_future_efl_object_destructor(Eo *obj, 
Efl_Loop_Future_Data *pd)
 pd->message = NULL;
  }
 
+   // Stop the main loop handler that would destroy this optional future
+   if (pd->optional)
+ {
+pd->optional = EINA_FALSE;
+ecore_loop_future_unregister(efl_provider_find(pd->self, 
EFL_LOOP_CLASS), pd->self);
+ }
+
efl_destructor(efl_super(obj, EFL_LOOP_FUTURE_CLASS));
 
// Disconnect from the promise

-- 




[EGIT] [core/efl] master 10/27: ecore: add tests for efl_future_all.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=61957ace36ea0473777155584e29c1588e0290b3

commit 61957ace36ea0473777155584e29c1588e0290b3
Author: Cedric Bail 
Date:   Tue Jul 26 12:08:48 2016 -0700

ecore: add tests for efl_future_all.
---
 src/tests/ecore/ecore_test_promise.c | 61 
 1 file changed, 61 insertions(+)

diff --git a/src/tests/ecore/ecore_test_promise.c 
b/src/tests/ecore/ecore_test_promise.c
index d813aca..e998d99 100644
--- a/src/tests/ecore/ecore_test_promise.c
+++ b/src/tests/ecore/ecore_test_promise.c
@@ -988,6 +988,66 @@ START_TEST(efl_test_promise_future_optional_cancel)
 }
 END_TEST
 
+static int value[] = { 42, 7, 3 };
+
+static void
+_then_all(void *data, const Efl_Event *ev)
+{
+   Future_Ok *fo = data;
+   Efl_Future_Event_Success *s = ev->info;
+   Eina_Accessor *ac = s->value;
+   int *i;
+
+   fail_if(!eina_accessor_data_get(ac, 0, (void**) &i));
+   fail_if(i != &value[0]);
+   fail_if(!eina_accessor_data_get(ac, 1, (void**) &i));
+   fail_if(i != &value[1]);
+   fail_if(!eina_accessor_data_get(ac, 2, (void**) &i));
+   fail_if(i != &value[2]);
+
+   fo->then = EINA_TRUE;
+}
+
+START_TEST(efl_test_promise_all)
+{
+   Efl_Promise *p1, *p2, *p3;
+   Efl_Future *all = NULL, *f1;
+   Future_Ok donea = { EINA_FALSE, EINA_FALSE, EINA_FALSE };
+   Future_Ok donep1 = { EINA_FALSE, EINA_FALSE, EINA_FALSE };
+
+   ecore_init();
+
+   p1 = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
+   p2 = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
+   p3 = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
+   fail_if(!p1 || !p2 || !p3);
+
+   f1 = efl_ref(efl_promise_future_get(p1));
+   fail_if(!efl_future_then(f1, _then, _cancel, _progress, &donep1));
+   efl_future_use(&all, efl_future_all(f1, efl_promise_future_get(p2), 
efl_promise_future_get(p3)));
+   efl_unref(f1);
+
+   fail_if(!efl_future_then(all, _then_all, _cancel, _progress, &donea));
+   fail_if(!all);
+
+   efl_promise_value_set(p1, &value[0], NULL);
+   fail_if(!donep1.then || donep1.cancel || donep1.progress);
+   fail_if(donea.then || donea.cancel || donea.progress);
+
+   efl_promise_value_set(p2, &value[1], NULL);
+   efl_promise_value_set(p3, &value[2], NULL);
+
+   fail_if(!donea.then || donea.cancel || donea.progress);
+   fail_if(all);
+
+   efl_del(p1);
+   efl_del(p2);
+   efl_del(p3);
+
+   ecore_shutdown();
+}
+END_TEST
+
 void ecore_test_ecore_promise(TCase *tc)
 {
tcase_add_test(tc, ecore_test_promise);
@@ -1015,4 +1075,5 @@ void ecore_test_ecore_promise(TCase *tc)
tcase_add_test(tc, efl_test_promise_before_future_multi_cancel);
tcase_add_test(tc, efl_test_promise_future_optional_success);
tcase_add_test(tc, efl_test_promise_future_optional_cancel);
+   tcase_add_test(tc, efl_test_promise_all);
 }

-- 




[EGIT] [core/efl] master 07/27: ecore: add tests for Efl.Promise.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=674acaf63d6c17e96c8ddb4fcaee10130d820c1a

commit 674acaf63d6c17e96c8ddb4fcaee10130d820c1a
Author: Cedric Bail 
Date:   Thu Jul 7 18:01:38 2016 -0700

ecore: add tests for Efl.Promise.
---
 src/tests/ecore/ecore_test_promise.c | 625 +++
 1 file changed, 625 insertions(+)

diff --git a/src/tests/ecore/ecore_test_promise.c 
b/src/tests/ecore/ecore_test_promise.c
index 50df508..d813aca 100644
--- a/src/tests/ecore/ecore_test_promise.c
+++ b/src/tests/ecore/ecore_test_promise.c
@@ -376,6 +376,618 @@ START_TEST(ecore_test_promise_progress_promise)
 }
 END_TEST
 
+typedef struct _Future_Ok Future_Ok;
+struct _Future_Ok
+{
+   Eina_Bool then : 1;
+   Eina_Bool cancel : 1;
+   Eina_Bool progress : 1;
+};
+
+static void
+_then(void *data, const Efl_Event *ev)
+{
+   Efl_Future_Event_Success *s = ev->info;
+   int *value = s->value;
+   Future_Ok *fo = data;
+
+   fail_if(*value != 42);
+   fo->then = EINA_TRUE;
+}
+
+static void
+_cancel(void *data, const Efl_Event *ev)
+{
+   Efl_Future_Event_Failure *f = ev->info;
+   Future_Ok *fo = data;
+
+   fail_if(f->error != EINA_ERROR_FUTURE_CANCEL);
+   fo->cancel = EINA_TRUE;
+}
+
+static void
+_progress(void *data, const Efl_Event *ev)
+{
+   Efl_Future_Event_Progress *p = ev->info;
+   int *value = p->progress;
+   Future_Ok *fo = data;
+
+   fail_if(*value != 7);
+   fo->progress = EINA_TRUE;
+}
+
+static void
+_death(void *data, const Efl_Event *ev EINA_UNUSED)
+{
+   Eina_Bool *death = data;
+
+   *death = EINA_TRUE;
+}
+
+// Test value set after then
+START_TEST(efl_test_promise_future_success)
+{
+   Efl_Promise *p;
+   Efl_Future *f;
+   Future_Ok fo = { EINA_FALSE, EINA_FALSE, EINA_FALSE };
+   Eina_Bool deadf = EINA_FALSE, deadp = EINA_FALSE;
+   int progress = 7;
+   int value = 42;
+
+   ecore_init();
+
+   p = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
+   fail_if(!p);
+
+   f = efl_promise_future_get(p);
+   fail_if(!f);
+
+   efl_event_callback_add(f, EFL_EVENT_DEL, _death, &deadf);
+   efl_event_callback_add(p, EFL_EVENT_DEL, _death, &deadp);
+
+   fail_if(!efl_future_then(f, _then, _cancel, _progress, &fo));
+
+   fail_if(deadp || deadf);
+
+   efl_promise_progress_set(p, &progress);
+   efl_promise_value_set(p, &value, NULL);
+
+   fail_if(!fo.then || fo.cancel || !fo.progress);
+   fail_if(!deadf || deadp);
+
+   efl_del(p);
+
+   fail_if(!deadp);
+
+   ecore_shutdown();
+}
+END_TEST
+
+START_TEST(efl_test_promise_future_cancel)
+{
+   Efl_Promise *p;
+   Efl_Future *f;
+   Future_Ok fo = { EINA_FALSE, EINA_FALSE, EINA_FALSE };
+   Eina_Bool deadf = EINA_FALSE, deadp = EINA_FALSE, none = EINA_FALSE;
+   int progress = 7;
+   int value = 42;
+
+   ecore_init();
+
+   p = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
+   fail_if(!p);
+
+   efl_future_use(&f, efl_promise_future_get(p));
+   fail_if(!f);
+
+   efl_event_callback_add(f, EFL_EVENT_DEL, _death, &deadf);
+   efl_event_callback_add(p, EFL_EVENT_DEL, _death, &deadp);
+   efl_event_callback_add(p, EFL_PROMISE_EVENT_FUTURE_NONE, _death, &none);
+
+   fail_if(!efl_future_then(f, _then, _cancel, _progress, &fo));
+
+   fail_if(deadp || deadf);
+
+   efl_promise_progress_set(p, &progress);
+   efl_future_cancel(f);
+
+   efl_promise_value_set(p, &value, NULL);
+
+   fail_if(fo.then || !fo.cancel || !fo.progress);
+   fail_if(!deadf || deadp);
+   fail_if(!none);
+
+   efl_del(p);
+
+   fail_if(!deadp);
+
+   ecore_shutdown();
+}
+END_TEST
+
+// Test value set before then
+START_TEST(efl_test_promise_before_future_success)
+{
+   Efl_Promise *p;
+   Efl_Future *f;
+   Future_Ok fo = { EINA_FALSE, EINA_FALSE, EINA_FALSE };
+   Eina_Bool deadf = EINA_FALSE, deadp = EINA_FALSE;
+   int progress = 7;
+   int value = 42;
+
+   ecore_init();
+
+   p = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
+   fail_if(!p);
+
+   f = efl_promise_future_get(p);
+   fail_if(!f);
+
+   efl_event_callback_add(f, EFL_EVENT_DEL, _death, &deadf);
+   efl_event_callback_add(p, EFL_EVENT_DEL, _death, &deadp);
+
+   efl_promise_progress_set(p, &progress);
+   efl_promise_value_set(p, &value, NULL);
+
+   fail_if(!efl_future_then(f, _then, _cancel, _progress, &fo));
+
+   fail_if(deadp || !deadf);
+   fail_if(!fo.then || fo.cancel || fo.progress);
+
+   efl_del(p);
+
+   fail_if(!deadp);
+
+   ecore_shutdown();
+}
+END_TEST
+
+START_TEST(efl_test_promise_before_future_cancel)
+{
+   Efl_Promise *p;
+   Efl_Future *f;
+   Future_Ok fo = { EINA_FALSE, EINA_FALSE, EINA_FALSE };
+   Eina_Bool deadf = EINA_FALSE, deadp = EINA_FALSE, none = EINA_FALSE;
+   int progress = 7;
+   int value = 42;
+
+   ecore_init();
+
+   p = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
+   fail_if(!p);
+
+   efl_future_use(&f, efl_promise_future_get(p));
+   fail_if(!f);
+
+   efl_event_callback_add(f, EFL_EVENT_DEL, _death, &deadf);
+   efl_event_callback_add(p, EFL_EVENT_DEL, _death, &deadp);
+   ef

[EGIT] [core/efl] master 25/27: eio: add an internal function for getting xattr in bulk.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

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

commit c6e145da2df8f607708effa31ddd5f5131878b54
Author: Cedric BAIL 
Date:   Wed Sep 7 16:20:23 2016 -0700

eio: add an internal function for getting xattr in bulk.
---
 src/lib/eio/eio_private.h |  5 +
 src/lib/eio/eio_xattr.c   | 56 +--
 2 files changed, 50 insertions(+), 11 deletions(-)

diff --git a/src/lib/eio/eio_private.h b/src/lib/eio/eio_private.h
index 69a73d3..dece4c1 100644
--- a/src/lib/eio/eio_private.h
+++ b/src/lib/eio/eio_private.h
@@ -545,6 +545,11 @@ Eio_File * _eio_dir_stat_ls(const char *dir,
 Eio_Done_Cb done_cb,
 Eio_Error_Cb error_cb,
 const void *data);
+Eio_File * _eio_file_xattr(const char *path,
+   Eio_Array_Cb main_internal_cb,
+   Eio_Done_Cb done_cb,
+   Eio_Error_Cb error_cb,
+   const void *data);
 
 // Sharing notifier between recursive and non recursive code.
 void _eio_string_notify(void *data, Ecore_Thread *thread EINA_UNUSED, void 
*msg_data);
diff --git a/src/lib/eio/eio_xattr.c b/src/lib/eio/eio_xattr.c
index 0dfec5b..fdfb899 100644
--- a/src/lib/eio/eio_xattr.c
+++ b/src/lib/eio/eio_xattr.c
@@ -305,27 +305,36 @@ _eio_file_xattr_setup_set(Eio_File_Xattr *async,
  *   API  *
  
**/
 
-EAPI Eio_File *
-eio_file_xattr(const char *path,
-  Eio_Filter_Cb filter_cb,
-  Eio_Main_Cb main_cb,
-  Eio_Done_Cb done_cb,
-  Eio_Error_Cb error_cb,
-  const void *data)
+static Eio_File *
+_eio_file_internal_xattr(const char *path,
+ Eio_Filter_Cb filter_cb,
+ Eio_Main_Cb main_cb,
+ Eio_Array_Cb main_internal_cb,
+ Eio_Done_Cb done_cb,
+ Eio_Error_Cb error_cb,
+ const void *data)
 {
   Eio_File_Char_Ls *async;
 
   EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
-  EINA_SAFETY_ON_NULL_RETURN_VAL(main_cb, NULL);
   EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
   EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
 
-  async = calloc(1, sizeof (Eio_File_Char_Ls));
+  async = eio_common_alloc(sizeof (Eio_File_Char_Ls));
   EINA_SAFETY_ON_NULL_RETURN_VAL(async, NULL);
 
-  async->filter_cb = filter_cb;
-  async->main_cb = main_cb;
   async->ls.directory = eina_stringshare_add(path);
+  async->filter_cb = filter_cb;
+
+  if (main_internal_cb)
+{
+   async->main_internal_cb = main_internal_cb;
+   async->ls.gather = EINA_TRUE;
+}
+  else
+{
+   async->main_cb = main_cb;
+}
 
   if (!eio_long_file_set(&async->ls.common,
  done_cb,
@@ -341,6 +350,31 @@ eio_file_xattr(const char *path,
 }
 
 EAPI Eio_File *
+eio_file_xattr(const char *path,
+   Eio_Filter_Cb filter_cb,
+   Eio_Main_Cb main_cb,
+   Eio_Done_Cb done_cb,
+   Eio_Error_Cb error_cb,
+   const void *data)
+{
+  EINA_SAFETY_ON_NULL_RETURN_VAL(main_cb, NULL);
+
+  return _eio_file_internal_xattr(path, filter_cb, main_cb, NULL, done_cb, 
error_cb, data);
+}
+
+Eio_File *
+_eio_file_xattr(const char *path,
+Eio_Array_Cb main_internal_cb,
+Eio_Done_Cb done_cb,
+Eio_Error_Cb error_cb,
+const void *data)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(main_internal_cb, NULL);
+
+   return _eio_file_internal_xattr(path, NULL, NULL, main_internal_cb, 
done_cb, error_cb, data);
+}
+
+EAPI Eio_File *
 eio_file_xattr_get(const char *path,
   const char *attribute,
   Eio_Done_Data_Cb done_cb,

-- 




[EGIT] [core/efl] master 21/27: ecore: fix optional future promise to not complain of there destruction.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

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

commit cb17d46cf5e9f2995a1dde22cb1e465b9fb6de10
Author: Cedric BAIL 
Date:   Tue Aug 30 16:20:36 2016 -0700

ecore: fix optional future promise to not complain of there destruction.
---
 src/lib/ecore/efl_promise.c | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/lib/ecore/efl_promise.c b/src/lib/ecore/efl_promise.c
index 8592c00..13a25cf 100644
--- a/src/lib/ecore/efl_promise.c
+++ b/src/lib/ecore/efl_promise.c
@@ -31,6 +31,8 @@ struct _Efl_Promise_Data
   Eina_Bool progress : 1;
   Eina_Bool progress_triggered : 1;
} set;
+
+   Eina_Bool optional : 1;
 };
 
 static void
@@ -218,17 +220,25 @@ _efl_loop_future_then(Eo *obj, Efl_Loop_Future_Data *pd,
   Efl_Event_Cb success, Efl_Event_Cb failure, Efl_Event_Cb 
progress, const void *data)
 {
Efl_Loop_Future_Callback *cb;
+   Efl_Promise_Data *epd;
Efl_Future *f;
 
cb = _efl_loop_future_then_internal(pd, success, failure, progress, data);
if (!cb) return NULL;
 
+   efl_ref(obj);
+
cb->next = efl_add(EFL_PROMISE_CLASS, obj);
+   epd = efl_data_scope_get(cb->next, EFL_PROMISE_CLASS);
+   epd->optional = EINA_TRUE;
+
f = efl_promise_future_get(cb->next);
 
_efl_loop_future_prepare_events(pd, !!progress, EINA_FALSE);
_efl_loop_future_fulfilling(obj, pd);
 
+   efl_unref(obj);
+
return f;
 }
 
@@ -242,9 +252,13 @@ _efl_loop_future_internal_then(Efl_Future *f,
cb = _efl_loop_future_then_internal(pd, success, failure, progress, data);
if (!cb) return EINA_FALSE;
 
+   efl_ref(f);
+
_efl_loop_future_prepare_events(pd, !!progress, EINA_TRUE);
_efl_loop_future_fulfilling(f, pd);
 
+   efl_unref(f);
+
return EINA_FALSE;
 }
 
@@ -292,9 +306,13 @@ _efl_loop_future_cancel(Eo *obj, Efl_Loop_Future_Data *pd)
pd->fulfilled = EINA_TRUE;
 
// Trigger failure
+   efl_ref(obj);
+
_efl_loop_future_propagate(obj, pd);
 
_efl_loop_future_disconnect(obj, pd);
+
+   efl_unref(obj);
 }
 
 static void
@@ -574,7 +592,7 @@ _efl_promise_efl_object_destructor(Eo *obj, 
Efl_Promise_Data *pd)
// Unref refcounted structure
if (!pd->message && pd->futures)
  {
-ERR("This promise has not been fulfilled. Forcefully cancelling %p.", 
obj);
+if (!pd->optional) ERR("This promise has not been fulfilled. 
Forcefully cancelling %p.", obj);
 efl_promise_failed(obj, EINA_ERROR_FUTURE_CANCEL);
  }
 

-- 




[EGIT] [core/efl] master 20/27: eio: fix manager tests.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=8e8c50e7a187ecef73c20e0e368351e7751100f9

commit 8e8c50e7a187ecef73c20e0e368351e7751100f9
Author: Cedric BAIL 
Date:   Fri Aug 26 16:52:11 2016 -0700

eio: fix manager tests.
---
 src/tests/eio/eio_test_manager.c   | 220 +++--
 src/tests/eio/eio_test_manager_xattr.c |  96 +++---
 2 files changed, 148 insertions(+), 168 deletions(-)

diff --git a/src/tests/eio/eio_test_manager.c b/src/tests/eio/eio_test_manager.c
index cdf0644..c20530e 100644
--- a/src/tests/eio/eio_test_manager.c
+++ b/src/tests/eio/eio_test_manager.c
@@ -13,87 +13,64 @@
 # define O_BINARY 0
 #endif
 
-static int test_count = 0;
+static uint64_t test_count = 0;
+static Eina_Bool direct = EINA_FALSE;
 
-static int DONE_CALLED = 0xdeadbeef;
+#define DONE_CALLED 0xdeadbeef
 
 static void
-_filter_direct_cb(void *data EINA_UNUSED, const Efl_Event *event)
+_progress_cb(void *data, const Efl_Event *ev)
 {
-   Eio_Filter_Direct_Data *event_info = event->info;
-   char *last_slash = strrchr(event_info->info->path, '/');
-
-   //Check if it is a hidden file
-   if (last_slash != NULL && strlen(last_slash) > 1 && last_slash[1] == '.')
- event_info->filter = EINA_FALSE;
-   else
- event_info->filter = EINA_TRUE;
-}
-
-static void
-_main_direct_cb(void *data, const Eina_File_Direct_Info *info)
-{
-   int *number_of_listed_files = (int *)data;
+   Efl_Future_Event_Progress *p = ev->info;
+   Eina_Array *batch = p->progress;
+   uint64_t *number_of_listed_files = data;
 
-   fprintf(stderr, "Processing file:%s\n", info->path);
-   (*number_of_listed_files)++;
-}
-
-static void
-_filter_cb(void *data EINA_UNUSED, const Efl_Event *event)
-{
-   Eio_Filter_Name_Data *event_info = event->info;
-   char *last_slash = strrchr(event_info->file, '/');
-
-   //Check if it is a hidden file
-   if (last_slash != NULL && strlen(last_slash) > 1 && last_slash[1] == '.')
- event_info->filter = EINA_FALSE;
-   else
- event_info->filter = EINA_TRUE;
+   (*number_of_listed_files) += eina_array_count(batch);
 }
 
 static void
-_main_cb(void *data, const char *file)
+_done_cb(void *data, const Efl_Event *ev)
 {
-   int *number_of_listed_files = (int *)data;
+   Efl_Future_Event_Success *success = ev->info;
+   uint64_t *files_count = success->value;
+   uint64_t *number_of_listed_files = data;
 
-   fprintf(stderr, "Processing file:%s\n", file);
-   (*number_of_listed_files)++;
-}
-
-static void
-_done_cb(void *data, void* value EINA_UNUSED)
-{
-   int *number_of_listed_files = (int *)data;
fail_if((*number_of_listed_files) != test_count);
+   fail_if(*files_count != test_count);
*number_of_listed_files = DONE_CALLED;
ecore_main_loop_quit();
 }
 
 static void
-_error_cb(void *data EINA_UNUSED, Eina_Error error)
+_error_cb(void *data EINA_UNUSED, const Efl_Event *ev)
 {
-   const char *msg = eina_error_msg_get(error);
+   Efl_Future_Event_Failure *failure = ev->info;
+   const char *msg = eina_error_msg_get(failure->error);
+
EINA_LOG_ERR("error: %s", msg);
ecore_main_loop_quit();
 }
 
 static void
-_open_done_cb(void *data, void *file_value)
+_open_done_cb(void *data, const Efl_Event *ev)
 {
+   Efl_Future_Event_Success *success = ev->info;
Eina_Bool *opened = (Eina_Bool *)data;
-   *opened = EINA_TRUE;
-   Eina_File* file = eina_file_dup(file_value);
+   Eina_File* file = eina_file_dup(success->value);
eina_file_close(file);
+
+   *opened = EINA_TRUE;
ecore_main_loop_quit();
 }
 
 static void
-_stat_done_cb(void *data, void *value)
+_stat_done_cb(void *data, const Efl_Event *ev)
 {
-   Eina_Stat const* stat = value;
+   Efl_Future_Event_Success *success = ev->info;
+   Eina_Stat const* stat = success->value;
Eina_Bool *is_dir = data;
unsigned int rights;
+
fail_if(eio_file_is_dir(stat) != *is_dir);
fail_if(eio_file_is_lnk(stat));
rights = stat->mode & (S_IRWXU | S_IRWXG | S_IRWXO);
@@ -101,50 +78,46 @@ _stat_done_cb(void *data, void *value)
ecore_main_loop_quit();
 }
 
-typedef Eina_Promise* (*Efl_Io_Manager_Test_Stat_Ls_Func)(Eo *job, const char 
*path);
-
 static void
-_do_ls_test(Efl_Io_Manager_Test_Stat_Ls_Func ls_func,
-  const Efl_Event_Description *event,
-  Efl_Event_Cb filter_cb,
-  Eina_Promise_Progress_Cb progress_cb,
-  int expected_test_count,
-  const char* test_dirname)
+_test_ls(Efl_Future *(*func)(Eo *obj, const char *path, Eina_Bool recursive),
+ uint64_t expected_test_count,
+ const char* test_dirname)
 {
-   int main_files = 0;
+   Efl_Io_Manager *job = efl_add(EFL_IO_MANAGER_CLASS, ecore_main_loop_get());
+   Efl_Future *f = NULL;
+   uint64_t main_files = 0;
 
-   Efl_Io_Manager *job = efl_add(EFL_IO_MANAGER_CLASS, NULL);
-   Eina_Promise *promise = NULL;
+   fail_if(!job);
 
-   efl_event_callback_add(job, event, filter_cb, NULL);
-   promise = ls_func(job, test_dirname);
+   f = func(job, test_dirname, EIN

[EGIT] [core/efl] master 23/27: eio: fix allocation in eio_dir to reuse common safer infra.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

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

commit d7fbd6f13ef0f32838db89f331790edbeb8a2bf1
Author: Cedric BAIL 
Date:   Tue Aug 30 16:31:41 2016 -0700

eio: fix allocation in eio_dir to reuse common safer infra.
---
 src/lib/eio/eio_dir.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/lib/eio/eio_dir.c b/src/lib/eio/eio_dir.c
index e275ae9..7423774 100644
--- a/src/lib/eio/eio_dir.c
+++ b/src/lib/eio/eio_dir.c
@@ -791,7 +791,7 @@ eio_dir_copy(const char *source,
EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
 
-   copy = malloc(sizeof(Eio_Dir_Copy));
+   copy = eio_common_alloc(sizeof(Eio_Dir_Copy));
EINA_SAFETY_ON_NULL_RETURN_VAL(copy, NULL);
 
copy->progress.op = EIO_DIR_COPY;
@@ -832,7 +832,7 @@ eio_dir_move(const char *source,
EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
 
-   move = malloc(sizeof(Eio_Dir_Copy));
+   move = eio_common_alloc(sizeof(Eio_Dir_Copy));
EINA_SAFETY_ON_NULL_RETURN_VAL(move, NULL);
 
move->progress.op = EIO_DIR_MOVE;
@@ -871,7 +871,7 @@ eio_dir_unlink(const char *path,
EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
 
-   rmrf = malloc(sizeof(Eio_Dir_Copy));
+   rmrf = eio_common_alloc(sizeof(Eio_Dir_Copy));
EINA_SAFETY_ON_NULL_RETURN_VAL(rmrf, NULL);
 
rmrf->progress.op = EIO_UNLINK;
@@ -911,7 +911,7 @@ _eio_dir_stat_internal_ls(const char *dir,
EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
 
-   async = malloc(sizeof(Eio_File_Dir_Ls));
+   async = eio_common_alloc(sizeof(Eio_File_Dir_Ls));
EINA_SAFETY_ON_NULL_RETURN_VAL(async, NULL);
 
/* Eio_Filter_Direct_Cb must be casted to Eio_Filter_Dir_Cb here
@@ -984,7 +984,7 @@ _eio_dir_direct_internal_ls(const char *dir,
EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
 
-   async = malloc(sizeof(Eio_File_Dir_Ls));
+   async = eio_common_alloc(sizeof(Eio_File_Dir_Ls));
EINA_SAFETY_ON_NULL_RETURN_VAL(async, NULL);
 
async->ls.directory = eina_stringshare_add(dir);

-- 




[EGIT] [core/efl] master 19/27: eio: rework efl_io_manager to use efl_future.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=52c63190d5b9906698b5e1872ce6448185218d91

commit 52c63190d5b9906698b5e1872ce6448185218d91
Author: Cedric Bail 
Date:   Sun Jul 31 21:41:05 2016 -0700

eio: rework efl_io_manager to use efl_future.
---
 src/lib/eio/efl_io_manager.c  | 758 --
 src/lib/eio/efl_io_manager.eo | 105 ++
 src/lib/eo/eina_types.eot |   1 -
 3 files changed, 383 insertions(+), 481 deletions(-)

diff --git a/src/lib/eio/efl_io_manager.c b/src/lib/eio/efl_io_manager.c
index 81514f5..c3c0809 100644
--- a/src/lib/eio/efl_io_manager.c
+++ b/src/lib/eio/efl_io_manager.c
@@ -22,10 +22,12 @@
 # include 
 #endif
 
-
 #include 
+#include 
 #include "Eio.h"
 
+#include "eio_private.h"
+
 typedef struct _Efl_Io_Manager_Data Efl_Io_Manager_Data;
 
 struct _Efl_Io_Manager_Data
@@ -50,389 +52,364 @@ struct _Job_Closure
 
 /* Helper functions */
 
-static Job_Closure *
-_job_closure_create(Eo *obj, Efl_Io_Manager_Data *pdata, Eina_Promise_Owner 
*owner)
+static void
+_no_future(void *data, const Efl_Event *ev EINA_UNUSED)
 {
-   EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(pdata, NULL);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(owner, NULL);
-
-   Job_Closure *closure = malloc(sizeof(Job_Closure));
-
-   if (!closure)
- {
-EINA_LOG_CRIT("Failed to allocate memory.");
-return 0;
- }
-
-   closure->object = efl_ref(obj);
-   closure->pdata = pdata;
-   closure->promise = owner;
-   closure->file = NULL; // Will be set once the Eio operation is under way
-   closure->delete_me = EINA_FALSE;
-   closure->delayed_arg = NULL;
-   closure->direct_func = NULL;
-
-   pdata->operations = eina_list_prepend(pdata->operations, closure);
+   Eio_File *h = data;
 
-   return closure;
+   eio_file_cancel(h);
 }
 
 static void
-_job_closure_del(Job_Closure *closure)
+_forced_shutdown(void *data, const Efl_Event *ev EINA_UNUSED)
 {
-   EINA_SAFETY_ON_NULL_RETURN(closure);
-   Efl_Io_Manager_Data *pdata = closure->pdata;
-   if (pdata)
- pdata->operations = eina_list_remove(pdata->operations, closure);
+   Eio_File *h = data;
 
-   efl_unref(closure->object);
-
-   if (closure->delayed_arg)
- free(closure->delayed_arg);
-
-   free(closure);
+   eio_file_cancel(h);
+   // FIXME: handle memory lock here !
+   // Acceptable strategy will be to unlock all thread as
+   // if we were freeing some memory
+   // FIXME: Handle long to finish thread
+   ecore_thread_wait(h->thread, 1.0);
 }
 
 static void
-_file_error_cb(void *data, Eio_File *handler EINA_UNUSED, int error)
+_progress(void *data EINA_UNUSED, const Efl_Event *ev)
 {
-   Job_Closure *operation = data;
-
-   EINA_SAFETY_ON_NULL_RETURN(operation);
-   EINA_SAFETY_ON_NULL_RETURN(operation->promise);
-
-   eina_promise_owner_error_set(operation->promise, error);
-
-   _job_closure_del(operation);
+   efl_key_data_set(ev->object, "_eio.progress", (void*) EINA_TRUE);
 }
 
-/* Basic listing callbacks */
-
-static Eina_Bool
-_file_ls_filter_cb_helper(const Efl_Event_Description *event, void *data, 
const char *file)
-{
-   Job_Closure *operation = data;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(operation, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(operation->pdata, EINA_FALSE);
+EFL_CALLBACKS_ARRAY_DEFINE(promise_progress_handling,
+   { EFL_PROMISE_EVENT_FUTURE_PROGRESS_SET, _progress 
},
+   { EFL_PROMISE_EVENT_FUTURE_NONE, _no_future },
+   { EFL_EVENT_DEL, _forced_shutdown });
 
-   Eio_Filter_Name_Data* event_info = malloc(sizeof(Eio_Filter_Name_Data));
+EFL_CALLBACKS_ARRAY_DEFINE(promise_handling,
+   { EFL_PROMISE_EVENT_FUTURE_NONE, _no_future },
+   { EFL_EVENT_DEL, _forced_shutdown });
 
-   EINA_SAFETY_ON_NULL_RETURN_VAL(event_info, EINA_FALSE);
-
-   event_info->file = file;
-   event_info->filter = EINA_FALSE;
+static void
+_file_done_data_cb(void *data, Eio_File *handler, const char *attr_data, 
unsigned int size)
+{
+   Efl_Promise *p = data;
+   Eina_Binbuf *buf;
 
-   efl_event_callback_legacy_call(operation->pdata->object, event, event_info);
+   efl_event_callback_array_del(p, promise_handling(), handler);
 
-   Eina_Bool filter = event_info->filter;
+   buf = eina_binbuf_new();
+   eina_binbuf_append_length(buf, (const unsigned char*) attr_data, size);
 
-   free(event_info);
+   efl_promise_value_set(p, buf, EINA_FREE_CB(eina_binbuf_free));
 
-   return filter;
+   efl_del(p);
 }
 
-static Eina_Bool
-_file_ls_filter_xattr_cb(void *data, Eio_File *handler EINA_UNUSED, const char 
*file)
+static void
+_file_error_cb(void *data, Eio_File *handler, int error)
 {
-   return _file_ls_filter_cb_helper(EFL_IO_MANAGER_EVENT_XATTR, data, file);
-}
+   Efl_Promise *p = data;
 
-static Eina_Bool
-_file_ls_filter_named_cb(void *data, Eio_File *handler EINA_UNUSED, const char 
*file)
-{
-   ret

[EGIT] [core/efl] master 04/27: efl: remove unecessary legacy_prefix set to null.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=7ae43659f66fd5351a7e649b03d41cffc91358e8

commit 7ae43659f66fd5351a7e649b03d41cffc91358e8
Author: Cedric BAIL 
Date:   Wed Jun 29 16:05:52 2016 -0700

efl: remove unecessary legacy_prefix set to null.
---
 src/lib/efl/interfaces/efl_input_device.eo | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/lib/efl/interfaces/efl_input_device.eo 
b/src/lib/efl/interfaces/efl_input_device.eo
index 28b2fdf..14f4470 100644
--- a/src/lib/efl/interfaces/efl_input_device.eo
+++ b/src/lib/efl/interfaces/efl_input_device.eo
@@ -47,7 +47,6 @@ class Efl.Input.Device (Efl.Object)
 
  @since 1.18
]]
-   legacy_prefix: null;
methods {
   /* FIXME: device_class makes compilation error because of class_get() */
   @property device_type {

-- 




[EGIT] [core/efl] master 14/27: ecore: add efl_future_iterator_race.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

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

commit aaac15126b8fd4d691d46c52496d57269d3facdf
Author: Cedric BAIL 
Date:   Tue Aug 30 16:30:52 2016 -0700

ecore: add efl_future_iterator_race.
---
 src/lib/ecore/Ecore_Eo.h|  1 +
 src/lib/ecore/efl_promise.c | 15 +++
 2 files changed, 16 insertions(+)

diff --git a/src/lib/ecore/Ecore_Eo.h b/src/lib/ecore/Ecore_Eo.h
index 62c4192..fc46941 100644
--- a/src/lib/ecore/Ecore_Eo.h
+++ b/src/lib/ecore/Ecore_Eo.h
@@ -86,6 +86,7 @@ struct _Efl_Future_Race_Success
 };
 
 EAPI Efl_Future *efl_future_race_internal(Efl_Future *f1, ...);
+EAPI Efl_Future *efl_future_iterator_race(Eina_Iterator *it);
 
 #define efl_future_race(...) efl_future_race_internal(__VA_ARGS__, NULL)
 
diff --git a/src/lib/ecore/efl_promise.c b/src/lib/ecore/efl_promise.c
index 72dfdde..8592c00 100644
--- a/src/lib/ecore/efl_promise.c
+++ b/src/lib/ecore/efl_promise.c
@@ -1154,7 +1154,22 @@ efl_future_race_internal(Efl_Future *f1, ...)
 eina_array_push(&race->members, fn);
  }
 
+   return _efl_future_race_done(race);
+}
+
+EAPI Efl_Future *
+efl_future_iterator_race(Eina_Iterator *it)
+{
+   Efl_Promise_Race *race = NULL;
+   Efl_Future *fn;
 
+   if (!it) return NULL;
+
+   EINA_ITERATOR_FOREACH(it, fn)
+ {
+if (!race) race = _efl_future_race_new(fn);
+if (race) eina_array_push(&race->members, fn);
+ }
 
return _efl_future_race_done(race);
 }

-- 




[EGIT] [core/efl] master 17/27: eio: add internal function able to build array instead of triggering a callback per files.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=11fe9b8cd9e4eee6f95e70fcef8727087c1a49a2

commit 11fe9b8cd9e4eee6f95e70fcef8727087c1a49a2
Author: Cedric Bail 
Date:   Sun Jul 31 21:39:39 2016 -0700

eio: add internal function able to build array instead of triggering a 
callback per files.
---
 src/lib/eio/eio_dir.c | 131 +++--
 src/lib/eio/eio_file.c| 210 ++
 src/lib/eio/eio_private.h |  51 ++-
 3 files changed, 309 insertions(+), 83 deletions(-)

diff --git a/src/lib/eio/eio_dir.c b/src/lib/eio/eio_dir.c
index 9d0c72e..e275ae9 100644
--- a/src/lib/eio/eio_dir.c
+++ b/src/lib/eio/eio_dir.c
@@ -742,29 +742,6 @@ _eio_dir_direct_find_heavy(void *data, Ecore_Thread 
*thread)
 }
 
 static void
-_eio_dir_stat_find_notify(void *data, Ecore_Thread *thread EINA_UNUSED, void 
*msg_data)
-{
-   Eio_File_Dir_Ls *async = data;
-   Eina_List *pack = msg_data;
-   Eio_File_Direct_Info *info;
-
-   EINA_LIST_FREE(pack, info)
- {
-async->ls.common.main.associated = info->associated;
-
-async->main_cb((void*) async->ls.common.data, &async->ls.common, 
&info->info);
-
-if (async->ls.common.main.associated)
-  {
- eina_hash_free(async->ls.common.main.associated);
- async->ls.common.main.associated = NULL;
-  }
-
-eio_direct_info_free(info);
- }
-}
-
-static void
 _eio_dir_stat_done(void *data, Ecore_Thread *thread EINA_UNUSED)
 {
Eio_File_Ls *async = data;
@@ -919,18 +896,18 @@ eio_dir_unlink(const char *path,
return &rmrf->progress.common;
 }
 
-EAPI Eio_File *
-eio_dir_stat_ls(const char *dir,
-Eio_Filter_Direct_Cb filter_cb,
-Eio_Main_Direct_Cb main_cb,
-Eio_Done_Cb done_cb,
-Eio_Error_Cb error_cb,
-const void *data)
+static Eio_File *
+_eio_dir_stat_internal_ls(const char *dir,
+  Eio_Filter_Direct_Cb filter_cb,
+  Eio_Main_Direct_Cb main_cb,
+  Eio_Array_Cb main_internal_cb,
+  Eio_Done_Cb done_cb,
+  Eio_Error_Cb error_cb,
+  const void *data)
 {
Eio_File_Dir_Ls *async;
 
EINA_SAFETY_ON_NULL_RETURN_VAL(dir, NULL);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(main_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
 
@@ -942,16 +919,24 @@ eio_dir_stat_ls(const char *dir,
 * where info can be modified, but in our case it's already doing
 * stat() then it shouldn't be needed!
 */
-   async->filter_cb = (Eio_Filter_Dir_Cb)filter_cb;
-   async->main_cb = main_cb;
async->ls.directory = eina_stringshare_add(dir);
+   async->filter_cb = (Eio_Filter_Dir_Cb)filter_cb;
+   if (main_internal_cb)
+ {
+async->main_internal_cb = main_internal_cb;
+async->ls.gather = EINA_TRUE;
+ }
+   else
+ {
+async->main_cb = main_cb;
+ }
 
if (!eio_long_file_set(&async->ls.common,
   done_cb,
   error_cb,
   data,
   _eio_dir_stat_find_heavy,
-  _eio_dir_stat_find_notify,
+  _eio_direct_notify,
   _eio_dir_stat_done,
   _eio_dir_stat_error))
  return NULL;
@@ -960,36 +945,94 @@ eio_dir_stat_ls(const char *dir,
 }
 
 EAPI Eio_File *
-eio_dir_direct_ls(const char *dir,
- Eio_Filter_Dir_Cb filter_cb,
- Eio_Main_Direct_Cb main_cb,
- Eio_Done_Cb done_cb,
- Eio_Error_Cb error_cb,
- const void *data)
+eio_dir_stat_ls(const char *dir,
+Eio_Filter_Direct_Cb filter_cb,
+Eio_Main_Direct_Cb main_cb,
+Eio_Done_Cb done_cb,
+Eio_Error_Cb error_cb,
+const void *data)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(main_cb, NULL);
+
+   return _eio_dir_stat_internal_ls(dir, filter_cb, main_cb, NULL, done_cb, 
error_cb, data);
+}
+
+Eio_File *
+_eio_dir_stat_ls(const char *dir,
+ Eio_Array_Cb main_internal_cb,
+ Eio_Done_Cb done_cb,
+ Eio_Error_Cb error_cb,
+ const void *data)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(main_internal_cb, NULL);
+
+   return _eio_dir_stat_internal_ls(dir, NULL, NULL, main_internal_cb, 
done_cb, error_cb, data);
+}
+
+static Eio_File *
+_eio_dir_direct_internal_ls(const char *dir,
+Eio_Filter_Dir_Cb filter_cb,
+Eio_Main_Direct_Cb main_cb,
+Eio_Array_Cb main_internal_cb,
+Eio_Done_Cb done_cb,
+Eio_Error_Cb error_cb,
+

[EGIT] [core/efl] master 26/27: eio: implement efl_io_manager_xattr_ls

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=0c067fb62f58ae789722729c809bee9237aba315

commit 0c067fb62f58ae789722729c809bee9237aba315
Author: Cedric BAIL 
Date:   Wed Sep 7 16:20:52 2016 -0700

eio: implement efl_io_manager_xattr_ls
---
 src/lib/eio/efl_io_manager.c | 38 +-
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/src/lib/eio/efl_io_manager.c b/src/lib/eio/efl_io_manager.c
index c3c0809..fba276c 100644
--- a/src/lib/eio/efl_io_manager.c
+++ b/src/lib/eio/efl_io_manager.c
@@ -405,32 +405,28 @@ _efl_io_manager_stat(Eo *obj,
 
 static Efl_Future *
 _efl_io_manager_xattr_ls(Eo *obj,
- Efl_Io_Manager_Data *pd,
+ Efl_Io_Manager_Data *pd EINA_UNUSED,
  const char *path)
 {
-   // FIXME
-#if 0
-   Eina_Promise_Owner *promise = eina_promise_add();
-   Job_Closure *operation_data = _job_closure_create(obj, pd, promise);
+   Efl_Promise *p;
+   Eio_File *h;
 
-   Eina_Promise* p = eina_promise_owner_promise_get(promise);
-   if (!operation_data)
- {
-EINA_LOG_CRIT("Failed to create eio job operation data.");
-eina_promise_owner_error_set(promise, eina_error_get());
-eina_error_set(0);
-return p;
- }
+   p = efl_add(EFL_PROMISE_CLASS, obj);
+   if (!p) return NULL;
+
+   h = _eio_file_xattr(path,
+   _file_string_cb,
+   _file_done_cb,
+   _file_error_cb,
+   p);
+   if (!h) goto end;
 
-   operation_data->delayed_arg = (char*)calloc(sizeof(char), strlen(path) + 1);
-   strcpy(operation_data->delayed_arg, path);
+   efl_event_callback_array_add(p, promise_progress_handling(), h);
+   return efl_promise_future_get(p);
 
-   eina_promise_owner_progress_notify(promise,
-  _xattr_notify_start,
-  operation_data,
-  _free_notify_start_data);
-   return p;
-#endif
+ end:
+   efl_del(p);
+   return NULL;
 }
 
 static Efl_Future *

-- 




[EGIT] [core/efl] master 22/27: ecore: fix parenting to be done right on promise and future.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

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

commit f1c8c82e5f5cac217e2aa9c6aad90f1cdfb8fbd5
Author: Cedric BAIL 
Date:   Tue Aug 30 16:21:30 2016 -0700

ecore: fix parenting to be done right on promise and future.
---
 src/lib/ecore/efl_promise.c | 29 -
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/src/lib/ecore/efl_promise.c b/src/lib/ecore/efl_promise.c
index 13a25cf..6ef7691 100644
--- a/src/lib/ecore/efl_promise.c
+++ b/src/lib/ecore/efl_promise.c
@@ -67,6 +67,7 @@ struct _Efl_Loop_Future_Data
Eina_Inlist *callbacks;
 
Efl_Future *self;
+   Efl_Loop *loop;
Efl_Promise_Msg  *message;
Efl_Promise_Data *promise;
 
@@ -344,6 +345,8 @@ _efl_loop_future_efl_object_constructor(Eo *obj, 
Efl_Loop_Future_Data *pd)
 {
obj = efl_constructor(efl_super(obj, EFL_LOOP_FUTURE_CLASS));
 
+   pd->loop = efl_ref(efl_provider_find(obj, EFL_LOOP_CLASS));
+
pd->self = obj;
pd->optional = EINA_TRUE;
 
@@ -357,6 +360,8 @@ _efl_loop_future_efl_object_constructor(Eo *obj, 
Efl_Loop_Future_Data *pd)
 static void
 _efl_loop_future_efl_object_destructor(Eo *obj, Efl_Loop_Future_Data *pd)
 {
+   Eo *promise = NULL;
+
if (!pd->fulfilled)
  {
 ERR("Lost reference to a future without fulfilling it. Forcefully 
cancelling it.");
@@ -385,10 +390,16 @@ _efl_loop_future_efl_object_destructor(Eo *obj, 
Efl_Loop_Future_Data *pd)
 ecore_loop_future_unregister(efl_provider_find(pd->self, 
EFL_LOOP_CLASS), pd->self);
  }
 
+   if (pd->promise) promise = efl_ref(pd->promise->promise);
+
efl_destructor(efl_super(obj, EFL_LOOP_FUTURE_CLASS));
 
// Disconnect from the promise
_efl_loop_future_disconnect(obj, pd);
+
+   efl_unref(promise);
+
+   efl_unref(pd->loop);
 }
 
 #ifndef NDEBUG
@@ -409,10 +420,26 @@ _efl_future_wref_del(Eo *obj, Efl_Loop_Future_Data *pd, 
Eo **wref)
 }
 #endif
 
+static Efl_Object *
+_efl_loop_future_efl_object_provider_find(Eo *obj EINA_UNUSED, 
Efl_Loop_Future_Data *pd, const Efl_Object *klass)
+{
+   Efl_Object *r = NULL;
+
+   if (pd->loop) r = efl_provider_find(pd->loop, klass);
+   if (r) return r;
+
+   return efl_provider_find(efl_super(obj, EFL_LOOP_FUTURE_CLASS), klass);
+}
+
 static Eina_Bool
 _efl_loop_future_class_initializer(Efl_Class *klass)
 {
EFL_OPS_DEFINE(ops,
+#ifndef NDEBUG
+  EFL_OBJECT_OP_FUNC(efl_wref_add, _efl_future_wref_add),
+  EFL_OBJECT_OP_FUNC(efl_wref_del, _efl_future_wref_del),
+#endif
+  EFL_OBJECT_OP_FUNC(efl_provider_find, 
_efl_loop_future_efl_object_provider_find),
   EFL_OBJECT_OP_FUNC(efl_future_then, _efl_loop_future_then),
   EFL_OBJECT_OP_FUNC(efl_future_cancel, 
_efl_loop_future_cancel),
   EFL_OBJECT_OP_FUNC(efl_constructor, 
_efl_loop_future_efl_object_constructor),
@@ -440,7 +467,7 @@ _efl_promise_future_get(Eo *obj, Efl_Promise_Data *pd 
EINA_UNUSED)
Efl_Loop_Future_Data *fd;
 
// Build a new future, attach it and return it
-   f = efl_add(EFL_LOOP_FUTURE_CLASS, NULL);
+   f = efl_add(EFL_LOOP_FUTURE_CLASS, obj);
if (!f) return NULL;
 
fd = efl_data_scope_get(f, EFL_LOOP_FUTURE_CLASS);

-- 




[EGIT] [core/efl] master 12/27: ecore: add efl_future_race.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=0789156c86fb51cadbf173bbb230a4d2ddef9612

commit 0789156c86fb51cadbf173bbb230a4d2ddef9612
Author: Cedric Bail 
Date:   Wed Jul 27 09:56:07 2016 -0700

ecore: add efl_future_race.
---
 src/lib/ecore/Ecore_Eo.h|  15 +++
 src/lib/ecore/efl_promise.c | 245 +++-
 2 files changed, 235 insertions(+), 25 deletions(-)

diff --git a/src/lib/ecore/Ecore_Eo.h b/src/lib/ecore/Ecore_Eo.h
index 1209232..62c4192 100644
--- a/src/lib/ecore/Ecore_Eo.h
+++ b/src/lib/ecore/Ecore_Eo.h
@@ -74,6 +74,21 @@ EAPI Efl_Future *efl_future_iterator_all(Eina_Iterator *it);
 
 #define efl_future_all(...) efl_future_all_internal(__VA_ARGS__, NULL)
 
+typedef struct _Efl_Future_Race_Success Efl_Future_Race_Success;
+typedef struct _Efl_Future_Composite_Progress Efl_Future_Race_Progress;
+
+struct _Efl_Future_Race_Success
+{
+   Efl_Future *winner;
+   void *value;
+
+   unsigned int index;
+};
+
+EAPI Efl_Future *efl_future_race_internal(Efl_Future *f1, ...);
+
+#define efl_future_race(...) efl_future_race_internal(__VA_ARGS__, NULL)
+
 /**
  * @}
  */
diff --git a/src/lib/ecore/efl_promise.c b/src/lib/ecore/efl_promise.c
index 275c56a..72dfdde 100644
--- a/src/lib/ecore/efl_promise.c
+++ b/src/lib/ecore/efl_promise.c
@@ -588,10 +588,12 @@ _efl_promise_efl_object_destructor(Eo *obj, 
Efl_Promise_Data *pd)
efl_destructor(efl_super(obj, EFL_PROMISE_CLASS));
 }
 
-typedef struct _Efl_Promise_All Efl_Promise_All;
+typedef struct _Efl_Promise_Composite Efl_Promise_All;
 typedef struct _Efl_Future_All Efl_Future_All;
 typedef struct _Efl_Accessor_All Efl_Accessor_All;
 
+typedef struct _Efl_Promise_Composite Efl_Promise_Race;
+
 struct _Efl_Accessor_All
 {
Eina_Accessor accessor;
@@ -607,17 +609,34 @@ struct _Efl_Future_All
Efl_Promise_Msg *d;
 };
 
-struct _Efl_Promise_All
+struct _Efl_Promise_Composite
 {
Eina_Array members;
 
Efl_Promise *promise;
 
+   Efl_Future *(*future_get)(void *item);
+
Eina_Bool failed : 1;
Eina_Bool progress_triggered : 1;
Eina_Bool future_triggered : 1;
+   Eina_Bool done : 1;
 };
 
+static Efl_Future *
+_efl_promise_all_future_get(void *item)
+{
+   Efl_Future_All *fa = item;
+
+   return fa->f;
+}
+
+static Efl_Future *
+_efl_promise_race_future_get(void *item)
+{
+   return item;
+}
+
 static void
 _efl_promise_all_free(Efl_Promise_All *all)
 {
@@ -643,10 +662,19 @@ _efl_promise_all_die(void *data, const Efl_Event *ev 
EINA_UNUSED)
 }
 
 static void
-_efl_all_future_set(void *data, const Eo_Event *ev EINA_UNUSED)
+_efl_promise_race_die(void *data, const Efl_Event *ev EINA_UNUSED)
 {
Efl_Promise_All *all = data;
-   Efl_Future_All *fa;
+
+   eina_array_flush(&all->members);
+   free(all);
+}
+
+static void
+_efl_future_set(void *data, const Efl_Event *ev EINA_UNUSED)
+{
+   Efl_Promise_All *all = data;
+   void *item;
Eina_Array_Iterator iterator;
unsigned int i;
 
@@ -654,15 +682,17 @@ _efl_all_future_set(void *data, const Eo_Event *ev 
EINA_UNUSED)
all->future_triggered = EINA_TRUE;
 
// Propagate set on demand
-   EINA_ARRAY_ITER_NEXT(&all->members, i, fa, iterator)
+   EINA_ARRAY_ITER_NEXT(&all->members, i, item, iterator)
  {
-if (fa->f)
+Efl_Future *f = all->future_get(item);
+
+if (f)
   {
- Efl_Loop_Future_Data *pd = efl_data_scope_get(fa->f, 
EFL_LOOP_FUTURE_CLASS);
+ Efl_Loop_Future_Data *pd = efl_data_scope_get(f, 
EFL_LOOP_FUTURE_CLASS);
 
  if (!pd->promise->set.future && 
!pd->promise->set.future_triggered)
{
-  efl_event_callback_call(pd->promise->promise, 
EFL_PROMISE_EVENT_FUTURE_SET, fa->f);
+  efl_event_callback_call(pd->promise->promise, 
EFL_PROMISE_EVENT_FUTURE_SET, f);
   pd->promise->set.future_triggered = EINA_TRUE;
   pd->promise->set.future = EINA_TRUE;
}
@@ -671,10 +701,10 @@ _efl_all_future_set(void *data, const Eo_Event *ev 
EINA_UNUSED)
 }
 
 static void
-_efl_all_future_progress_set(void *data, const Eo_Event *ev EINA_UNUSED)
+_efl_future_progress_set(void *data, const Efl_Event *ev EINA_UNUSED)
 {
Efl_Promise_All *all = data;
-   Efl_Future_All *fa;
+   void *item;
Eina_Array_Iterator iterator;
unsigned int i;
 
@@ -682,15 +712,17 @@ _efl_all_future_progress_set(void *data, const Eo_Event 
*ev EINA_UNUSED)
all->progress_triggered = 1;
 
// Propagate progress set
-   EINA_ARRAY_ITER_NEXT(&all->members, i, fa, iterator)
+   EINA_ARRAY_ITER_NEXT(&all->members, i, item, iterator)
  {
-if (fa->f)
+Efl_Future *f = all->future_get(item);
+
+if (f)
   {
- Efl_Loop_Future_Data *pd = efl_data_scope_get(fa->f, 
EFL_LOOP_FUTURE_CLASS);
+ Efl_Loop_Future_Data *pd = efl_data_scope_get(f, 
EFL_LOOP_FUTURE_CLASS);
 
  if (!pd->promise->set.progress &&

[EGIT] [core/efl] master 27/27: efl: add documentation and last cleanup of the API.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

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

commit bd362b13d656e779f4851d57257bf04883b34ba8
Author: Cedric BAIL 
Date:   Thu Sep 8 14:51:13 2016 -0700

efl: add documentation and last cleanup of the API.
---
 src/lib/ecore/efl_promise.c  | 10 
 src/lib/ecore/efl_promise.eo | 45 +++-
 src/lib/eio/efl_io_manager.c |  6 ++---
 src/lib/eo/efl_future.h  | 50 +---
 src/tests/ecore/ecore_test_promise.c |  2 +-
 5 files changed, 83 insertions(+), 30 deletions(-)

diff --git a/src/lib/ecore/efl_promise.c b/src/lib/ecore/efl_promise.c
index 6ef7691..53c79ed 100644
--- a/src/lib/ecore/efl_promise.c
+++ b/src/lib/ecore/efl_promise.c
@@ -535,7 +535,7 @@ _efl_promise_value_set(Eo *obj, Efl_Promise_Data *pd, void 
*v, Eina_Free_Cb free
 }
 
 static void
-_efl_promise_failed(Eo *obj, Efl_Promise_Data *pd, Eina_Error err)
+_efl_promise_failed_set(Eo *obj, Efl_Promise_Data *pd, Eina_Error err)
 {
Efl_Promise_Msg *message;
Efl_Loop_Future_Data *f;
@@ -576,7 +576,7 @@ _efl_promise_failed(Eo *obj, Efl_Promise_Data *pd, 
Eina_Error err)
 }
 
 static void
-_efl_promise_progress_set(Eo *obj, Efl_Promise_Data *pd, void *p)
+_efl_promise_progress_set(Eo *obj, Efl_Promise_Data *pd, const void *p)
 {
Efl_Loop_Future_Data *f;
Eina_List *l, *ln;
@@ -620,7 +620,7 @@ _efl_promise_efl_object_destructor(Eo *obj, 
Efl_Promise_Data *pd)
if (!pd->message && pd->futures)
  {
 if (!pd->optional) ERR("This promise has not been fulfilled. 
Forcefully cancelling %p.", obj);
-efl_promise_failed(obj, EINA_ERROR_FUTURE_CANCEL);
+efl_promise_failed_set(obj, EINA_ERROR_FUTURE_CANCEL);
  }
 
if (pd->message)
@@ -916,7 +916,7 @@ _fail_all(void *data, const Efl_Event *ev)
   }
  }
 
-   efl_promise_failed(all->promise, fail->error);
+   efl_promise_failed_set(all->promise, fail->error);
_efl_promise_all_free(all);
efl_unref(all->promise);
 }
@@ -1128,7 +1128,7 @@ _fail_race(void *data, const Efl_Event *ev)
   }
  }
 
-   efl_promise_failed(race->promise, fail->error);
+   efl_promise_failed_set(race->promise, fail->error);
_efl_promise_all_free(race);
efl_unref(race->promise);
 }
diff --git a/src/lib/ecore/efl_promise.eo b/src/lib/ecore/efl_promise.eo
index 7d3b348..e78cad8 100644
--- a/src/lib/ecore/efl_promise.eo
+++ b/src/lib/ecore/efl_promise.eo
@@ -3,32 +3,53 @@ import eina_types;
 class Efl.Promise (Efl.Loop_User)
 {
methods {
-  @property progress {
- set {
- }
- values {
-p: void_ptr;
+  progress_set {
+ [[Update the progress and send it immediately to all connected 
Efl_Future.
+
+   The progress is not kept and when the function return it will not 
be accessed
+   anymore. The pointer is owned by the caller and will remain so 
after the return
+  of the function call.
+]]
+ params {
+@in p: const(void_ptr);
 }
   }
   @property future {
+ [[Request a new future linked to this promise.
+
+  Efl_Future are optional and will be automatically deleted if no then 
callback have
+  been set before the next iteration of the main loop.
+]]
  get {
-   [[The returned future is optional and if no then/chain_then are 
registered before it goes back to run in the main loop, it will be destroyed.]]
+   [[The returned new future.]]
  }
  values {
-f: future;
+f: future; [[Return a future where the value 
will be set by calling value_set while the progress will be updated by 
progress_set.]]
  }
   }
   @property value {
+[[The value expected by all connected future.]]
  set {
+   [[
+  This function can be called only once and you can not call 
#failed.set after that.
+  The value will be owned by the promise until it is destroyed. 
The value will be cleaned
+  when the promise and all the future depending on it are 
destroyed.
+]]
 }
 values {
-   v: void_ptr;
-   free_cb: __builtin_free_cb;
+   v: void_ptr; [[The pointer to the value.]]
+   free_cb: __builtin_free_cb; [[The function to call to free the 
value.]]
 }
   }
-  failed {
- params {
-   @in err: Eina.Error;
+  @property failed {
+ [[Define the failure state of this promise.]]
+set {
+   [[
+  This function can be called only once and you can not call 
#value.set after that.
+   ]]
+}
+ values {
+   err: Eina.Error; [[The reason for failure of this promise.]]
  }
   }
}
diff --git a/src/lib/eio/efl_io_manager.c b/src/lib/eio/efl_io_manager.c

[EGIT] [core/efl] master 03/27: eolian: add a builtin to handle a free callback.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=36bc9aa187dc5d1ba257c4bf03060f0792e65866

commit 36bc9aa187dc5d1ba257c4bf03060f0792e65866
Author: Cedric BAIL 
Date:   Wed Jun 29 15:25:22 2016 -0700

eolian: add a builtin to handle a free callback.
---
 src/lib/eolian/database_type.c   | 21 +++--
 src/lib/eolian/eo_lexer.c|  1 +
 src/lib/eolian/eo_lexer.h|  1 +
 src/tests/eolian/data/typedef.eo |  2 ++
 src/tests/eolian/data/typedef_ref.c  |  2 ++
 src/tests/eolian/data/typedef_ref_stub.c |  2 ++
 src/tests/eolian/eolian_parsing.c|  3 ++-
 7 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c
index f55d772..7b142d7 100644
--- a/src/lib/eolian/database_type.c
+++ b/src/lib/eolian/database_type.c
@@ -198,13 +198,22 @@ _atype_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
 {
eina_strbuf_append(buf, "typedef ");
 
-   if (tp->base_type->type == EOLIAN_TYPE_REGULAR &&
-   !strcmp(tp->base_type->name, "__builtin_event_cb"))
+   if (tp->base_type->type == EOLIAN_TYPE_REGULAR)
  {
-eina_strbuf_append(buf, "void (*");
-_append_name(tp, buf);
-eina_strbuf_append(buf, ")(void *data, const Efl_Event *event)");
-return;
+if (!strcmp(tp->base_type->name, "__builtin_event_cb"))
+  {
+ eina_strbuf_append(buf, "void (*");
+ _append_name(tp, buf);
+ eina_strbuf_append(buf, ")(void *data, const Efl_Event *event)");
+ return;
+  }
+if (!strcmp(tp->base_type->name, "__builtin_free_cb"))
+  {
+ eina_strbuf_append(buf, "void (*");
+ _append_name(tp, buf);
+ eina_strbuf_append(buf, ")(void *data)");
+ return;
+  }
  }
 
Eina_Strbuf *fulln = eina_strbuf_new();
diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c
index 499ff92..9b7fe5a 100644
--- a/src/lib/eolian/eo_lexer.c
+++ b/src/lib/eolian/eo_lexer.c
@@ -81,6 +81,7 @@ static const char * const ctypes[] =
"void *",
 
"Efl_Event_Cb",
+   "Eina_Free_Cb",
 };
 
 #undef KW
diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h
index b33f047..beaeca6 100644
--- a/src/lib/eolian/eo_lexer.h
+++ b/src/lib/eolian/eo_lexer.h
@@ -58,6 +58,7 @@ enum Tokens
 \
 KW(void_ptr), \
 KW(__builtin_event_cb), \
+KW(__builtin_free_cb), \
 KW(__undefined_type), \
 \
 KW(true), KW(false), KW(null)
diff --git a/src/tests/eolian/data/typedef.eo b/src/tests/eolian/data/typedef.eo
index b76ecb3..6c87ccd 100644
--- a/src/tests/eolian/data/typedef.eo
+++ b/src/tests/eolian/data/typedef.eo
@@ -10,6 +10,8 @@ type Undef: __undefined_type; /* not generated */
 
 type Event: __builtin_event_cb; /* specially generated */
 
+type Free: __builtin_free_cb; /* specially generated */
+
 enum Enum.Bar
 {
legacy: bar;
diff --git a/src/tests/eolian/data/typedef_ref.c 
b/src/tests/eolian/data/typedef_ref.c
index fa9a655..c5c3339 100644
--- a/src/tests/eolian/data/typedef_ref.c
+++ b/src/tests/eolian/data/typedef_ref.c
@@ -21,6 +21,8 @@ typedef Evas_Coord2 Evas_Coord3;
 
 typedef void (*Event)(void *data, const Efl_Event *event);
 
+typedef void (*Free)(void *data);
+
 typedef enum
 {
   BAR_FIRST_ITEM = 0,
diff --git a/src/tests/eolian/data/typedef_ref_stub.c 
b/src/tests/eolian/data/typedef_ref_stub.c
index 2e52edc..cb5d53f 100644
--- a/src/tests/eolian/data/typedef_ref_stub.c
+++ b/src/tests/eolian/data/typedef_ref_stub.c
@@ -13,5 +13,7 @@ typedef Evas_Coord2 Evas_Coord3;
 
 typedef void (*Event)(void *data, const Efl_Event *event);
 
+typedef void (*Free)(void *data);
+
 
 #endif
diff --git a/src/tests/eolian/eolian_parsing.c 
b/src/tests/eolian/eolian_parsing.c
index 2a880da..d10dcdd 100644
--- a/src/tests/eolian/eolian_parsing.c
+++ b/src/tests/eolian/eolian_parsing.c
@@ -410,7 +410,8 @@ START_TEST(eolian_typedef)
fail_if(!eina_iterator_next(iter, (void**)&tdl));
/* not generated undefined type, skip */
fail_if(!eina_iterator_next(iter, (void**)&tdl));
-   /* event type, tested by generation tests */
+   /* event type and free cb, tested by generation tests */
+   fail_if(!eina_iterator_next(iter, (void**)&tdl));
fail_if(!eina_iterator_next(iter, (void**)&tdl));
fail_if(eina_iterator_next(iter, (void**)&tdl));
 

-- 




[EGIT] [core/efl] master 01/27: eo: add abstract efl.future.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=9a2ada6d87f4a80becec142dbe9186d8385737b8

commit 9a2ada6d87f4a80becec142dbe9186d8385737b8
Author: Cedric BAIL 
Date:   Wed Jun 29 14:09:40 2016 -0700

eo: add abstract efl.future.
---
 src/Makefile_Eo.am  |   5 ++-
 src/lib/eo/Eo.h |  10 +++--
 src/lib/eo/efl_future.c |  56 +
 src/lib/eo/efl_future.h | 107 
 src/lib/eo/eo.c |   3 ++
 src/lib/eo/eo_private.h |   3 ++
 6 files changed, 179 insertions(+), 5 deletions(-)

diff --git a/src/Makefile_Eo.am b/src/Makefile_Eo.am
index bd5dcba..80460ef 100644
--- a/src/Makefile_Eo.am
+++ b/src/Makefile_Eo.am
@@ -17,7 +17,7 @@ BUILT_SOURCES += \
 lib_LTLIBRARIES += lib/eo/libeo.la
 
 installed_eomainheadersdir = $(includedir)/eo-@VMAJ@
-dist_installed_eomainheaders_DATA = lib/eo/Eo.h
+dist_installed_eomainheaders_DATA = lib/eo/Eo.h lib/eo/efl_future.h
 
 nodist_installed_eomainheaders_DATA = \
  
$(eo_eolian_h)
@@ -30,7 +30,8 @@ lib/eo/eo_base_class.c \
 lib/eo/eo_class_class.c \
 lib/eo/eo_add_fallback.c \
 lib/eo/eo_add_fallback.h \
-lib/eo/eo_private.h
+lib/eo/eo_private.h \
+lib/eo/efl_future.c
 
 lib_eo_libeo_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @EO_CFLAGS@
 lib_eo_libeo_la_LIBADD = @EO_LIBS@
diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index 8fd5ca7..f1ce4c1 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -167,6 +167,12 @@ typedef enum _Efl_Object_Op_Type Efl_Object_Op_Type;
  */
 typedef void (*Efl_Del_Intercept) (Eo *obj_id);
 
+/**
+ * @typedef Efl_Future
+ * The type of Efl Future used in asynchronous operation, the read side of a 
promise.
+ */
+typedef Eo Efl_Future;
+
 #include "efl_object_override.eo.h"
 #include "efl_object.eo.h"
 #include "efl_interface.eo.h"
@@ -1321,9 +1327,7 @@ EAPI int efl_callbacks_cmp(const Efl_Callback_Array_Item 
*a, const Efl_Callback_
  * @}
  */
 
-/**
- * @}
- */
+#include "efl_future.h"
 
 /**
  * @}
diff --git a/src/lib/eo/efl_future.c b/src/lib/eo/efl_future.c
new file mode 100644
index 000..5f37f7a
--- /dev/null
+++ b/src/lib/eo/efl_future.c
@@ -0,0 +1,56 @@
+#ifdef HAVE_CONFIG_H
+# include 
+#endif
+
+#include 
+#include "Eo.h"
+
+// Efl.Future implementation is an opaque type in Ecore.
+EOAPI const Efl_Event_Description _EFL_FUTURE_EVENT_FAILURE =
+  EFL_EVENT_DESCRIPTION("future,failure");
+EOAPI const Efl_Event_Description _EFL_FUTURE_EVENT_SUCCESS =
+  EFL_EVENT_DESCRIPTION("future,success");
+EOAPI const Efl_Event_Description _EFL_FUTURE_EVENT_PROGRESS =
+  EFL_EVENT_DESCRIPTION("future,progress");
+
+EOAPI EFL_FUNC_BODYV(efl_future_then, Efl_Future *, 0, EFL_FUNC_CALL(success, 
failure, progress, data), Efl_Event_Cb success, Efl_Event_Cb failure, 
Efl_Event_Cb progress, const void *data);
+EOAPI EFL_VOID_FUNC_BODY(efl_future_cancel);
+
+static Eina_Bool
+_efl_future_class_initializer(Efl_Class *klass)
+{
+   EFL_OPS_DEFINE(ops,
+  EFL_OBJECT_OP_FUNC(efl_future_then, NULL),
+  EFL_OBJECT_OP_FUNC(efl_future_cancel, NULL));
+
+   return efl_class_functions_set(klass, &ops);
+}
+
+static const Efl_Class_Description _efl_future_class_desc = {
+  EO_VERSION,
+  "Efl_Future",
+  EFL_CLASS_TYPE_REGULAR_NO_INSTANT,
+  0,
+  _efl_future_class_initializer,
+  NULL,
+  NULL
+};
+
+EFL_DEFINE_CLASS(efl_future_class_get, &_efl_future_class_desc, 
EFL_OBJECT_CLASS, NULL);
+
+static const char EINA_ERROR_FUTURE_CANCEL_STR[] = "Future cancelled";
+EAPI Eina_Error EINA_ERROR_FUTURE_CANCEL;
+
+Eina_Bool
+efl_future_init(void)
+{
+   EINA_ERROR_FUTURE_CANCEL = 
eina_error_msg_static_register(EINA_ERROR_FUTURE_CANCEL_STR);
+
+   return EINA_TRUE;
+}
+
+Eina_Bool
+efl_future_shutdown(void)
+{
+   return EINA_TRUE;
+}
diff --git a/src/lib/eo/efl_future.h b/src/lib/eo/efl_future.h
new file mode 100644
index 000..243d660
--- /dev/null
+++ b/src/lib/eo/efl_future.h
@@ -0,0 +1,107 @@
+#ifndef EFL_FUTURE_H_
+# define EFL_FUTURE_H_
+
+/**
+ * @addtogroup Efl_Future Efl future and promise.
+ * @{
+ */
+
+/**
+ * @typedef Efl_Promise
+ * The type of Efl Promise used in asynchronous operation, the write side of a 
promise.
+ */
+typedef Eo Efl_Promise;
+
+#define EFL_FUTURE_CLASS efl_future_class_get()
+EWAPI const Efl_Class *efl_future_class_get(void);
+
+EAPI extern Eina_Error EINA_ERROR_FUTURE_CANCEL;
+
+typedef struct _Efl_Future_Event_Failure Efl_Future_Event_Failure;
+struct _Efl_Future_Event_Failure
+{
+   Efl_Promise *next;
+   Eina_Error error;
+};
+
+typedef struct _Efl_Future_Event_Success Efl_Future_Event_Success;
+struct _Efl_Future_Event_Success
+{
+   Efl_Promise *next;
+   void *value;
+};
+
+typedef struct _Efl_Future_Event_Progress Efl_Future_Event_Progress;
+struct _Efl_Future_Event_Progress
+{
+   Efl_Promise *next;
+   void *progress;
+};
+
+EOAPI extern const Efl_Event_Description _EFL_FUTURE_EVENT_FAILURE;
+E

[EGIT] [core/efl] master 05/27: ecore: add Efl.Promise.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

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

commit b2fb5e375a266dd667a490c4a96ef878dbac699c
Author: Cedric BAIL 
Date:   Thu Jun 30 16:51:06 2016 -0700

ecore: add Efl.Promise.
---
 src/Makefile_Ecore.am|   2 +
 src/lib/ecore/Ecore_Eo.h |   4 +-
 src/lib/ecore/efl_promise.c  | 542 +++
 src/lib/ecore/efl_promise.eo |  44 
 4 files changed, 591 insertions(+), 1 deletion(-)

diff --git a/src/Makefile_Ecore.am b/src/Makefile_Ecore.am
index 303a648..4a1d6a6 100644
--- a/src/Makefile_Ecore.am
+++ b/src/Makefile_Ecore.am
@@ -20,6 +20,7 @@ ecore_eolian_files = \
lib/ecore/efl_io_stderr.eo \
lib/ecore/efl_io_file.eo \
 lib/ecore/efl_io_copier.eo \
+   lib/ecore/efl_promise.eo \
lib/ecore/ecore_parent.eo \
$(ecore_eolian_files_legacy)
 
@@ -79,6 +80,7 @@ lib/ecore/efl_io_stdout.c \
 lib/ecore/efl_io_stderr.c \
 lib/ecore/efl_io_file.c \
 lib/ecore/efl_io_copier.c \
+lib/ecore/efl_promise.c \
 lib/ecore/ecore_pipe.c \
 lib/ecore/ecore_poller.c \
 lib/ecore/ecore_time.c \
diff --git a/src/lib/ecore/Ecore_Eo.h b/src/lib/ecore/Ecore_Eo.h
index feb66dc..7e10c51 100644
--- a/src/lib/ecore/Ecore_Eo.h
+++ b/src/lib/ecore/Ecore_Eo.h
@@ -54,7 +54,9 @@ extern "C" {
 
 #include "efl_loop_fd.eo.h"
 
-/* We ue the factory pattern here, so you shouldn't call efl_add directly. */
+#include "efl_promise.eo.h"
+
+/* We ue the factory pattern here, so you shouldn't call eo_add directly. */
 EAPI Eo *ecore_main_loop_get(void);
 
 /**
diff --git a/src/lib/ecore/efl_promise.c b/src/lib/ecore/efl_promise.c
new file mode 100644
index 000..5a03cee
--- /dev/null
+++ b/src/lib/ecore/efl_promise.c
@@ -0,0 +1,542 @@
+#ifdef HAVE_CONFIG_H
+# include 
+#endif
+
+#include 
+
+#include "ecore_private.h"
+
+// FIXME: handle self destruction when back in the main loop
+
+typedef struct _Efl_Promise_Data Efl_Promise_Data;
+typedef struct _Efl_Promise_Msg Efl_Promise_Msg;
+
+struct _Efl_Promise_Msg
+{
+   EINA_REFCOUNT;
+
+   void *value;
+   Eina_Free_Cb free_cb;
+
+   Eina_Error error;
+};
+
+struct _Efl_Promise_Data
+{
+   Efl_Promise *promise;
+   Efl_Promise_Msg *message;
+   Eina_List *futures;
+
+   struct {
+  Eina_Bool future : 1;
+  Eina_Bool future_triggered : 1;
+  Eina_Bool progress : 1;
+  Eina_Bool progress_triggered : 1;
+   } set;
+};
+
+static void
+_efl_promise_msg_free(Efl_Promise_Msg *msg)
+{
+   if (msg->free_cb)
+ msg->free_cb(msg->value);
+   free(msg);
+}
+
+#define EFL_LOOP_FUTURE_CLASS efl_loop_future_class_get()
+static const Efl_Class *efl_loop_future_class_get(void);
+
+typedef struct _Efl_Loop_Future_Data Efl_Loop_Future_Data;
+typedef struct _Efl_Loop_Future_Callback Efl_Loop_Future_Callback;
+
+struct _Efl_Loop_Future_Callback
+{
+   EINA_INLIST;
+
+   Efl_Event_Cb success;
+   Efl_Event_Cb failure;
+   Efl_Event_Cb progress;
+
+   Efl_Promise *next;
+
+   const void *data;
+};
+
+struct _Efl_Loop_Future_Data
+{
+   Eina_Inlist *callbacks;
+
+   Efl_Future *self;
+   Efl_Promise_Msg  *message;
+   Efl_Promise_Data *promise;
+
+#ifndef NDEBUG
+   int wref;
+#endif
+
+   Eina_Bool fulfilled : 1;
+   Eina_Bool death : 1;
+   Eina_Bool delayed : 1;
+};
+
+static void
+_efl_loop_future_success(Efl_Event *ev, Efl_Loop_Future_Data *pd, void *value)
+{
+   Efl_Loop_Future_Callback *cb;
+   Efl_Future_Event_Success chain_success;
+
+   ev->info = &chain_success;
+   ev->desc = EFL_FUTURE_EVENT_SUCCESS;
+
+   chain_success.value = value;
+
+   EINA_INLIST_FREE(pd->callbacks, cb)
+ {
+if (cb->next)
+  {
+ chain_success.next = cb->next;
+
+ cb->success((void*) cb->data, ev);
+  }
+
+pd->callbacks = eina_inlist_remove(pd->callbacks, pd->callbacks);
+free(cb);
+ }
+}
+
+static void
+_efl_loop_future_failure(Efl_Event *ev, Efl_Loop_Future_Data *pd, Eina_Error 
error)
+{
+   Efl_Loop_Future_Callback *cb;
+   Efl_Future_Event_Failure chain_fail;
+
+   ev->info = &chain_fail;
+   ev->desc = EFL_FUTURE_EVENT_FAILURE;
+
+   chain_fail.error = error;
+
+   EINA_INLIST_FREE(pd->callbacks, cb)
+ {
+if (cb->next)
+  {
+ chain_fail.next = cb->next;
+
+ cb->failure((void*) cb->data, ev);
+  }
+
+pd->callbacks = eina_inlist_remove(pd->callbacks, pd->callbacks);
+free(cb);
+ }
+}
+
+static void
+_efl_loop_future_propagate(Eo *obj, Efl_Loop_Future_Data *pd)
+{
+   Efl_Event ev;
+
+   ev.object = obj;
+
+   if (pd->fulfilled &&
+   !pd->message)
+ {
+_efl_loop_future_failure(&ev, pd, EINA_ERROR_FUTURE_CANCEL);
+ }
+   else if (pd->message->error == 0)
+ {
+_efl_loop_future_success(&ev, pd, pd->message->value);
+ }
+   else
+ {
+_efl_loop_future_failure(&ev, pd, pd->message->error);
+ }
+   pd->fulfilled = EINA_TRUE;
+
+   if (!pd->delayed)

[EGIT] [core/efl] master 16/27: eio: track length of resulting operation to be reported by futures.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

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

commit d26a0a2f70a77457f9faf35d945a2947f5f5cdba
Author: Cedric Bail 
Date:   Sun Jul 31 21:37:25 2016 -0700

eio: track length of resulting operation to be reported by futures.
---
 src/lib/eio/eio_file.c| 4 
 src/lib/eio/eio_map.c | 1 +
 src/lib/eio/eio_private.h | 2 ++
 src/lib/eio/eio_single.c  | 2 ++
 src/lib/eio/eio_xattr.c   | 4 
 5 files changed, 13 insertions(+)

diff --git a/src/lib/eio/eio_file.c b/src/lib/eio/eio_file.c
index 7d3757f..a7c02b9 100644
--- a/src/lib/eio/eio_file.c
+++ b/src/lib/eio/eio_file.c
@@ -102,6 +102,8 @@ _eio_file_notify(void *data, Ecore_Thread *thread 
EINA_UNUSED, void *msg_data)
Eina_List *pack = msg_data;
Eio_File_Char *info;
 
+   async->ls.common.length += eina_list_count(pack);
+
EINA_LIST_FREE(pack, info)
  {
 async->ls.common.main.associated = info->associated;
@@ -206,6 +208,8 @@ _eio_file_direct_notify(void *data, Ecore_Thread *thread 
EINA_UNUSED, void *msg_
Eina_List *pack = msg_data;
Eio_File_Direct_Info *info;
 
+   async->ls.common.length += eina_list_count(pack);
+
EINA_LIST_FREE(pack, info)
  {
 async->ls.common.main.associated = info->associated;
diff --git a/src/lib/eio/eio_map.c b/src/lib/eio/eio_map.c
index 194b338..897519f 100644
--- a/src/lib/eio/eio_map.c
+++ b/src/lib/eio/eio_map.c
@@ -70,6 +70,7 @@ _eio_file_close_job(void *data, Ecore_Thread *thread 
EINA_UNUSED)
 {
Eio_File_Map *map = data;
 
+   map->common.length = eina_file_size_get(map->result);
eina_file_close(map->result);
 }
 
diff --git a/src/lib/eio/eio_private.h b/src/lib/eio/eio_private.h
index 6d58f9f..39c37ae 100644
--- a/src/lib/eio/eio_private.h
+++ b/src/lib/eio/eio_private.h
@@ -168,6 +168,8 @@ struct _Eio_File
struct {
   Eina_Hash *associated;
} worker, main;
+
+   uint64_t length;
 };
 
 struct _Eio_Eet_Simple
diff --git a/src/lib/eio/eio_single.c b/src/lib/eio/eio_single.c
index c7841b1..b2a7a49 100644
--- a/src/lib/eio/eio_single.c
+++ b/src/lib/eio/eio_single.c
@@ -347,6 +347,7 @@ eio_long_file_set(Eio_File *common,
common->error_cb = error_cb;
common->data = data;
common->error = 0;
+   common->length = 0;
common->thread = NULL;
common->container = NULL;
common->worker.associated = NULL;
@@ -384,6 +385,7 @@ eio_file_set(Eio_File *common,
common->error_cb = error_cb;
common->data = data;
common->error = 0;
+   common->length = 0;
common->thread = NULL;
common->container = NULL;
common->worker.associated = NULL;
diff --git a/src/lib/eio/eio_xattr.c b/src/lib/eio/eio_xattr.c
index 9d6dc48..a795b95 100644
--- a/src/lib/eio/eio_xattr.c
+++ b/src/lib/eio/eio_xattr.c
@@ -170,15 +170,19 @@ _eio_file_xattr_set(void *data, Ecore_Thread *thread)
  {
  case EIO_XATTR_DATA:
failure = !eina_xattr_set(file, attribute, 
async->todo.xdata.xattr_data, async->todo.xdata.xattr_size, flags);
+   async->common.length = async->todo.xdata.xattr_size;
break;
  case EIO_XATTR_STRING:
failure = !eina_xattr_string_set(file, attribute, 
async->todo.xstring.xattr_string, flags);
+   async->common.length = strlen(async->todo.xstring.xattr_string) + 1;
break;
  case EIO_XATTR_DOUBLE:
failure = !eina_xattr_double_set(file, attribute, 
async->todo.xdouble.xattr_double, flags);
+   async->common.length = sizeof (double);
break;
  case EIO_XATTR_INT:
failure = !eina_xattr_int_set(file, attribute, 
async->todo.xint.xattr_int, flags);
+   async->common.length = sizeof (int);
break;
  }
 

-- 




[EGIT] [core/efl] master 09/27: ecore: add efl_future_all.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=84958dc6ca42114068a1aa4b185fdab5f640ae34

commit 84958dc6ca42114068a1aa4b185fdab5f640ae34
Author: Cedric Bail 
Date:   Tue Jul 26 12:08:30 2016 -0700

ecore: add efl_future_all.
---
 src/lib/ecore/Ecore_Eo.h|  14 ++
 src/lib/ecore/efl_promise.c | 421 ++--
 2 files changed, 418 insertions(+), 17 deletions(-)

diff --git a/src/lib/ecore/Ecore_Eo.h b/src/lib/ecore/Ecore_Eo.h
index 7e10c51..ef2b17f 100644
--- a/src/lib/ecore/Ecore_Eo.h
+++ b/src/lib/ecore/Ecore_Eo.h
@@ -59,6 +59,20 @@ extern "C" {
 /* We ue the factory pattern here, so you shouldn't call eo_add directly. */
 EAPI Eo *ecore_main_loop_get(void);
 
+typedef struct _Efl_Future_Composite_Progress Efl_Future_All_Progress;
+
+struct _Efl_Future_Composite_Progress
+{
+   Efl_Future *inprogress;
+   void *progress;
+
+   unsigned int index;
+};
+
+EAPI Efl_Future *efl_future_all_internal(Efl_Future *f1, ...);
+
+#define efl_future_all(...) efl_future_all_internal(__VA_ARGS__, NULL)
+
 /**
  * @}
  */
diff --git a/src/lib/ecore/efl_promise.c b/src/lib/ecore/efl_promise.c
index 38e1f2f..2bdf219 100644
--- a/src/lib/ecore/efl_promise.c
+++ b/src/lib/ecore/efl_promise.c
@@ -97,6 +97,13 @@ _efl_loop_future_success(Efl_Event *ev, Efl_Loop_Future_Data 
*pd, void *value)
 
  cb->success((void*) cb->data, ev);
   }
+else
+  {
+ chain_success.next = NULL;
+ chain_success.value = pd->message;
+ cb->success((void*) cb->data, ev);
+ chain_success.value = value;
+  }
 
 pd->callbacks = eina_inlist_remove(pd->callbacks, pd->callbacks);
 free(cb);
@@ -116,12 +123,9 @@ _efl_loop_future_failure(Efl_Event *ev, 
Efl_Loop_Future_Data *pd, Eina_Error err
 
EINA_INLIST_FREE(pd->callbacks, cb)
  {
-if (cb->next)
-  {
- chain_fail.next = cb->next;
+chain_fail.next = cb->next;
 
- cb->failure((void*) cb->data, ev);
-  }
+cb->failure((void*) cb->data, ev);
 
 pd->callbacks = eina_inlist_remove(pd->callbacks, pd->callbacks);
 free(cb);
@@ -173,7 +177,7 @@ _efl_loop_future_fulfilling(Eo *obj, Efl_Loop_Future_Data 
*pd)
 }
 
 static void
-_efl_loop_future_prepare_events(Efl_Loop_Future_Data *pd, Eina_Bool progress)
+_efl_loop_future_prepare_events(Efl_Loop_Future_Data *pd, Eina_Bool progress, 
Eina_Bool optional)
 {
if (!pd->promise) return ;
 
@@ -183,17 +187,19 @@ _efl_loop_future_prepare_events(Efl_Loop_Future_Data *pd, 
Eina_Bool progress)
 ecore_loop_future_unregister(efl_provider_find(pd->self, 
EFL_LOOP_CLASS), pd->self);
  }
 
-   pd->promise->set.future = EINA_TRUE;
-   if (progress)
- pd->promise->set.progress = EINA_TRUE;
+   if (!optional)
+ {
+pd->promise->set.future = EINA_TRUE;
+if (progress)
+  pd->promise->set.progress = EINA_TRUE;
+ }
 }
 
-static Efl_Future *
-_efl_loop_future_then(Eo *obj, Efl_Loop_Future_Data *pd,
-  Efl_Event_Cb success, Efl_Event_Cb failure, Efl_Event_Cb 
progress, const void *data)
+static Efl_Loop_Future_Callback *
+_efl_loop_future_then_internal(Efl_Loop_Future_Data *pd,
+   Efl_Event_Cb success, Efl_Event_Cb failure, 
Efl_Event_Cb progress, const void *data)
 {
Efl_Loop_Future_Callback *cb;
-   Efl_Future *f;
 
cb = calloc(1, sizeof (Efl_Loop_Future_Callback));
if (!cb) return NULL;
@@ -202,18 +208,46 @@ _efl_loop_future_then(Eo *obj, Efl_Loop_Future_Data *pd,
cb->failure = failure;
cb->progress = progress;
cb->data = data;
-   cb->next = efl_add(EFL_PROMISE_CLASS, obj);
+   pd->callbacks = eina_inlist_append(pd->callbacks, EINA_INLIST_GET(cb));
 
-   f = efl_promise_future_get(cb->next);
+   return cb;
+}
 
-   pd->callbacks = eina_inlist_append(pd->callbacks, EINA_INLIST_GET(cb));
+static Efl_Future *
+_efl_loop_future_then(Eo *obj, Efl_Loop_Future_Data *pd,
+  Efl_Event_Cb success, Efl_Event_Cb failure, Efl_Event_Cb 
progress, const void *data)
+{
+   Efl_Loop_Future_Callback *cb;
+   Efl_Future *f;
 
-   _efl_loop_future_prepare_events(pd, !!progress);
+   cb = _efl_loop_future_then_internal(pd, success, failure, progress, data);
+   if (!cb) return NULL;
+
+   cb->next = efl_add(EFL_PROMISE_CLASS, obj);
+   f = efl_promise_future_get(cb->next);
+
+   _efl_loop_future_prepare_events(pd, !!progress, EINA_FALSE);
_efl_loop_future_fulfilling(obj, pd);
 
return f;
 }
 
+static Eina_Bool
+_efl_loop_future_internal_then(Efl_Future *f,
+   Efl_Event_Cb success, Efl_Event_Cb failure, 
Efl_Event_Cb progress, const void *data)
+{
+   Efl_Loop_Future_Data *pd = efl_data_scope_get(f, EFL_LOOP_FUTURE_CLASS);
+   Efl_Loop_Future_Callback *cb;
+
+   cb = _efl_loop_future_then_internal(pd, success, failure, progress, data);
+   if (!cb) retu

[EGIT] [core/efl] master 08/27: efl: add a possibility to link death of Eo object with a future.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=6f2cad6439c14aed465f2cc1a0d59d0308002054

commit 6f2cad6439c14aed465f2cc1a0d59d0308002054
Author: Cedric BAIL 
Date:   Wed Jul 13 17:07:47 2016 -0700

efl: add a possibility to link death of Eo object with a future.
---
 src/lib/eo/efl_object.eo   |  7 +++
 src/lib/eo/eo_base_class.c | 49 +++---
 2 files changed, 45 insertions(+), 11 deletions(-)

diff --git a/src/lib/eo/efl_object.eo b/src/lib/eo/efl_object.eo
index 83b54ea..6b9c56c 100644
--- a/src/lib/eo/efl_object.eo
+++ b/src/lib/eo/efl_object.eo
@@ -456,6 +456,13 @@ abstract Efl.Object ()
]]
return: bool; [[$true if it is. $false otherwise.]]
   }
+  future_link {
+   [[Track a future life cycle and cancel it if the object die]]
+   params {
+@in link: future; [[The future to link with the 
object]]
+   }
+   return: bool; [[$true if it succeeded on setting up the tracking.]]
+  }
}
implements {
 class.constructor;
diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c
index 6f0a5b7..1398142 100644
--- a/src/lib/eo/eo_base_class.c
+++ b/src/lib/eo/eo_base_class.c
@@ -20,6 +20,7 @@ typedef struct
Eo*composite_parent;
Eina_Inlist   *generic_data;
Eo  ***wrefs;
+   Eina_List *futures;
 } Efl_Object_Extension;
 
 typedef struct
@@ -73,19 +74,24 @@ _efl_object_extension_free(Efl_Object_Extension *ext)
free(ext);
 }
 
-static inline void
+static inline Efl_Object_Extension *
 _efl_object_extension_need(Efl_Object_Data *pd)
 {
-   if (pd->ext) return;
-   pd->ext = calloc(1, sizeof(Efl_Object_Extension));
+   if (!pd->ext) pd->ext = calloc(1, sizeof(Efl_Object_Extension));
+   return pd->ext;
 }
 
 static inline void
 _efl_object_extension_noneed(Efl_Object_Data *pd)
 {
Efl_Object_Extension *ext = pd->ext;
-   if ((!ext) || (ext->name) || (ext->comment) || (ext->generic_data) ||
-   (ext->wrefs) || (ext->composite_parent)) return;
+   if ((!ext) ||
+   (ext->name) ||
+   (ext->comment) ||
+   (ext->generic_data) ||
+   (ext->wrefs) ||
+   (ext->composite_parent) ||
+   (ext->futures)) return;
_efl_object_extension_free(pd->ext);
pd->ext = NULL;
 }
@@ -189,8 +195,7 @@ _key_generic_set(const Eo *obj, Efl_Object_Data *pd, const 
char *key, const void
   }
  }
 
-   _efl_object_extension_need(pd);
-   ext = pd->ext;
+   ext = _efl_object_extension_need(pd);
if (ext)
  {
 node = calloc(1, sizeof(Eo_Generic_Data_Node));
@@ -735,8 +740,7 @@ _efl_object_wref_add(Eo *obj, Efl_Object_Data *pd, Eo 
**wref)
count = _wref_count(pd);
count += 1; /* New wref. */
 
-   _efl_object_extension_need(pd);
-   ext = pd->ext;
+   ext = _efl_object_extension_need(pd);
if (!ext) return;
 
tmp = realloc(ext->wrefs, sizeof(*ext->wrefs) * (count + 1));
@@ -1655,8 +1659,10 @@ _efl_object_destructor(Eo *obj, Efl_Object_Data *pd)
 ext->name = NULL;
 eina_stringshare_del(ext->comment);
 ext->comment = NULL;
-_efl_object_extension_free(ext);
-pd->ext = NULL;
+while (pd->ext && ext->futures)
+  efl_future_cancel(eina_list_data_get(ext->futures));
+
+_efl_object_extension_noneed(pd);
  }
 
_eo_condtor_done(obj);
@@ -1681,4 +1687,25 @@ _efl_object_class_destructor(Efl_Class *klass 
EINA_UNUSED)
eina_hash_free(_legacy_events_hash);
 }
 
+static void
+_efl_object_future_link_tracking_end(void *data, const Efl_Event *ev)
+{
+   Efl_Future *link = ev->object;
+   Eo *obj = data;
+   Efl_Object_Data *pd = efl_data_scope_get(obj, EFL_OBJECT_CLASS);
+   Efl_Object_Extension *ext = _efl_object_extension_need(pd);
+
+   ext->futures = eina_list_remove(ext->futures, link);
+   _efl_object_extension_noneed(pd);
+}
+
+EOLIAN static Eina_Bool
+_efl_object_future_link(Eo *obj EINA_UNUSED, Efl_Object_Data *pd, Efl_Future 
*link)
+{
+   Efl_Object_Extension *ext = _efl_object_extension_need(pd);
+
+   ext->futures = eina_list_append(ext->futures, link);
+   return !!efl_future_then(link, _efl_object_future_link_tracking_end, 
_efl_object_future_link_tracking_end, NULL, obj);
+}
+
 #include "efl_object.eo.c"

-- 




[EGIT] [core/efl] master 02/27: eolian: add support for future.

2016-09-08 Thread Cedric BAIL
cedric pushed a commit to branch master.

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

commit ed9dff8fbd422b613042cd9f402018eda28ffc67
Author: Cedric BAIL 
Date:   Wed Jun 29 15:00:17 2016 -0700

eolian: add support for future.

Future is the read only side of a Promise. For now, I am not removing
Eina_Promise until everything is in place, but eventually the promise
type of eolian will be gone.
---
 src/Makefile_Eolian.am |  4 +++
 src/lib/eolian/eo_lexer.c  |  2 +-
 src/lib/eolian/eo_lexer.h  |  2 +-
 src/lib/eolian/eo_parser.c |  4 +--
 src/tests/eolian/eolian_generated_future.c | 51 ++
 src/tests/eolian/generated_future.eo   | 58 ++
 6 files changed, 117 insertions(+), 4 deletions(-)

diff --git a/src/Makefile_Eolian.am b/src/Makefile_Eolian.am
index 164495b..dac5638 100644
--- a/src/Makefile_Eolian.am
+++ b/src/Makefile_Eolian.am
@@ -112,12 +112,15 @@ tests_eolian_eolian_suite_SOURCES = \
 tests/eolian/eolian_parsing.c \
 tests/eolian/eolian_generation.c \
 tests/eolian/eolian_generated_promise.c \
+tests/eolian/eolian_generated_future.c \
 tests/eolian/eolian_suite.c \
 tests/eolian/eolian_suite.h
 
 tests/eolian/tests_eolian_eolian_suite-eolian_generated_promise.$(OBJEXT): 
tests/eolian/generated_promise.eo.h tests/eolian/generated_promise.eo.c
+tests/eolian/tests_eolian_eolian_suite-eolian_generated_future.$(OBJEXT): 
tests/eolian/generated_future.eo.h tests/eolian/generated_future.eo.c
 
 CLEANFILES += tests/eolian/generated_promise.eo.h 
tests/eolian/generated_promise.eo.c
+CLEANFILES += tests/eolian/generated_future.eo.h 
tests/eolian/generated_future.eo.c
 
 tests_eolian_eolian_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl 
-I$(top_builddir)/src/tests/eolian \
 -DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/eolian\" \
@@ -148,4 +151,5 @@ tests/eolian/data/import_types_ref.h \
 tests/eolian/data/docs_ref.h \
 tests/eolian/data/docs_ref_legacy.h \
 tests/eolian/generated_promise.eo \
+tests/eolian/generated_future.eo \
 $(EOLIAN_TESTS_EOS)
diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c
index 5a55b01..499ff92 100644
--- a/src/lib/eolian/eo_lexer.c
+++ b/src/lib/eolian/eo_lexer.c
@@ -75,7 +75,7 @@ static const char * const ctypes[] =
NULL, NULL, /* array types */
 
"Eina_Accessor", "Eina_Array", "Eina_Iterator", "Eina_Hash", "Eina_List",
-   "Eina_Promise",
+   "Eina_Promise", "Efl_Future",
"Eina_Value", "const char *", "Eina_Stringshare *",
 
"void *",
diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h
index cc36d77..b33f047 100644
--- a/src/lib/eolian/eo_lexer.h
+++ b/src/lib/eolian/eo_lexer.h
@@ -53,7 +53,7 @@ enum Tokens
 KW(static_array), KW(terminated_array), \
 \
 KW(accessor), KW(array), KW(iterator), KW(hash), KW(list), \
-KW(promise), \
+KW(promise), KW(future),   \
 KW(generic_value), KW(string), KW(stringshare), \
 \
 KW(void_ptr), \
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 0f302c1..1fc4b97 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -887,7 +887,7 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, 
Eina_Bool allow_sarray)
  _fill_name(eina_stringshare_ref(ls->t.value.s), &def->full_name,
 &def->name, &def->namespaces);
  eo_lexer_get(ls);
- if (tpid >= KW_accessor && tpid <= KW_promise)
+ if (tpid >= KW_accessor && tpid <= KW_future)
{
   int bline = ls->line_number, bcol = ls->column;
   def->type = EOLIAN_TYPE_COMPLEX;
@@ -900,7 +900,7 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, 
Eina_Bool allow_sarray)
def->base_type->next_type = parse_type(ls, EINA_FALSE, 
EINA_FALSE);
pop_type(ls);
 }
-  else if(tpid == KW_promise && test_next(ls, ','))
+  else if((tpid == KW_promise || tpid == KW_future) && 
test_next(ls, ','))
 {
def->base_type->next_type = parse_type(ls, EINA_FALSE, 
EINA_FALSE);
pop_type(ls);
diff --git a/src/tests/eolian/eolian_generated_future.c 
b/src/tests/eolian/eolian_generated_future.c
new file mode 100644
index 000..47f3251
--- /dev/null
+++ b/src/tests/eolian/eolian_generated_future.c
@@ -0,0 +1,51 @@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include 
+#include 
+
+#include 
+
+struct Generated_Future_Data {};
+typedef struct Generated_Future_Data Generated_Future_Data;
+
+static void _generated_future_method_progress_type(Eo *obj EINA_UNUSED, 
Generated_Future_Data *pd EINA_UNUSED,
+Efl_Future **future1 
EINA_UNUSED)
+{
+}
+
+static Ef

[E-devel] Efl_Promise and Efl_Future

2016-09-08 Thread Cedric BAIL
Hello,

So I have now landed Efl_Future and Efl_Promise as previously
discussed in a lengthy email thread. The split was necessary to make
it possible to handle the lifecycle using eo object. This
implementation simplify and clarify the API compare to the eina api we
have.

Still there is some strong concern for me. Efl_Promise/Efl_Future are
primitive that shall not be inherited from as they require manual
binding in every language to take advantage of native asynchronous
behavior as defined in that language. I have given up on Efl_Promise
not being in an .eo file, but not Efl_Future.

The reason is that Efl_Future being an Eo object make just absolutely
no sense in any context. The only feature we are really using is weak
reference and refcounting when setting multiple callback on the same
future. Other than that we do not rely on Eo at all. It require its
own event propagation and reusing Eo event prototype make the API less
usable actually as we need to do a double cast prone to error in my
opinion. I do also have serious concern on speed and it might affect
us in the future when we start using this more. Remember how genlist
scrolling benchmark is spending more time in eo function than
rendering, not going to improve with this.

In any case this is better than our event model based model for
asynchronous request as it ties the result to a specific request.
There is less risk for the user to forget handling the previous
request or setup there event handler to late. Now, what would be
interesting is to see how to integrate that with Gustavo proposal on
channel in separated thread.

HAve fun,
-- 
Cedric BAIL

--
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] [EGIT] [core/efl] master 01/01: Eo class creation: Simplify code using recursive locks.

2016-09-08 Thread The Rasterman
On Thu, 8 Sep 2016 08:36:30 -0700 Cedric BAIL  said:

> On Sep 8, 2016 3:14 AM, "Tom Hacohen"  wrote:
> >
> > tasn pushed a commit to branch master.
> >
> >
> http://git.enlightenment.org/core/efl.git/commit/?id=6b60560773f59398427f12c21945d31b852db72a
> >
> > commit 6b60560773f59398427f12c21945d31b852db72a
> > Author: Tom Hacohen 
> > Date:   Thu Sep 8 11:14:32 2016 +0100
> >
> > Eo class creation: Simplify code using recursive locks.
> >
> > Now that we have recursive locks, the class creation code can be much
> simpler.
> > All the code there was essentially our own implementation of
> recursive locks,
> > or rather a special case of those.
> >
> > This is no longer needed.
> 
> I have started to look into implementing a light and fast spinlock. This
> make me realize that recursive lock are a pain. There memory usage grow
> linearly with the number of locker in a thread obviously, but the book
> keeping itself is a serious impact on performance. So if you are going to
> use recursive lock, avoid it in the hot path ! Not sure if it apply here,
> but better share this with everyone.

well i've used a single global recursive lock around ALL shared objects. call a
method on any eo objects in the shared table and it will lock all eo shared
object access until that method returns. it's recursive or otherwise you could
never call a callback or a method on yourself within such an object. it's
necessary. well otherwise you have to unlock on every possible exit point from
that func and that means it has to be manual and that would duck.

so technically if an eo obj is allocated in the shared domain now... it is
actually able to be seen by all threads AND is threadsafe.

BUT accessing it comes with a higher cost. instead of 2.5% avg eoid resolv cost
it goes up to maybe 5-7%. there is ALSO this big fat recursive mutex around the
method call. yup. sharing objects is not cheap. do it to very special objects
you really MUST share. it's already limited like no parent or child or key->obj
property on an obj can cross a domain boundary so that means you cannot just
make a button or a window or a timer shared as their parents will be a local
domain object, so you break this rule. you have to "deal with it" yourself.

so this is a cost, but it should not be paid commonly. rarely. in fact right
now we have no objects that can actually become shared. well eo base... that's
it. you'd have to inherit your own classes from there.

this is why i added the recursive mutex so this could be implemented. it's not
easy to make a shared object and will never be that common.

> > ---
> >  src/lib/eo/Eo.h | 24 +---
> >  src/lib/eo/eo.c | 14 +++---
> >  2 files changed, 12 insertions(+), 26 deletions(-)
> >
> > diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
> > index a530604..f1aabd5 100644
> > --- a/src/lib/eo/Eo.h
> > +++ b/src/lib/eo/Eo.h
> > @@ -128,7 +128,7 @@ typedef Eo Efl_Object;
> >   * Don't touch it if you don't know what you are doing.
> >   * @internal
> >   */
> > -EAPI extern Eina_Spinlock _efl_class_creation_lock;
> > +EAPI extern Eina_Lock _efl_class_creation_lock;
> >
> >  /**
> >   * @var _efl_object_init_generation
> > @@ -320,39 +320,25 @@ const Efl_Class * \
> >  class_get_func_name(void) \
> >  { \
> > const Efl_Class *_tmp_parent_class; \
> > -   static volatile unsigned char lk_init = 0; \
> > -   static Eina_Spinlock _my_lock; \
> > static const Efl_Class * volatile _my_class = NULL; \
> > static unsigned int _my_init_generation = 1; \
> > if (EINA_UNLIKELY(_efl_object_init_generation !=
> _my_init_generation)) \
> >   { \
> >  _my_class = NULL; /* It's freed in efl_object_shutdown(). */ \
> > -lk_init = 0; \
> >   } \
> > if (EINA_LIKELY(!!_my_class)) return _my_class; \
> > \
> > -   eina_spinlock_take(&_efl_class_creation_lock); \
> > -   if (!lk_init) \
> > -  eina_spinlock_new(&_my_lock); \
> > -   if (lk_init < 2) eina_spinlock_take(&_my_lock); \
> > -   if (!lk_init) \
> > -  lk_init = 1; \
> > -   else \
> > +   eina_lock_take(&_efl_class_creation_lock); \
> > +   if (!!_my_class) \
> >   { \
> > -if (lk_init < 2) eina_spinlock_release(&_my_lock); \
> > -eina_spinlock_release(&_efl_class_creation_lock); \
> > +eina_lock_release(&_efl_class_creation_lock); \
> >  return _my_class; \
> >   } \
> > -   eina_spinlock_release(&_efl_class_creation_lock); \
> > _tmp_parent_class = parent_class; \
> > _my_class = efl_class_new(class_desc, _tmp_parent_class,
> __VA_ARGS__); \
> > _my_init_generation = _efl_object_init_generation; \
> > -   eina_spinlock_release(&_my_lock); \
> > +   eina_lock_release(&_efl_class_creation_lock); \
> > \
> > -   eina_spinlock_take(&_efl_class_creation_lock); \
> > -   eina_spinlock_free(&_my_lock); \
> > -   lk_init = 2; \
> > -   eina_spinlock_release(&_efl_class_creation_lock); \
> > return _my_class; \
> >  }
> >
> >

Re: [E-devel] RFC: EOID + Threads + TLS proposal

2016-09-08 Thread The Rasterman
On Thu, 8 Sep 2016 10:24:45 -0300 Felipe Magno de Almeida
 said:

> On Sep 3, 2016 12:17 PM, "Carsten Haitzler"  wrote:
> >
> 
> [snip]
> 
> > Result? Cost of EOID lookup (to find the real pointer of the object) went
> from
> > 2% to 5% of CPU time.
> 
> How are you measuring? Which tool and example? I'd like to try a few things
> too, but being sure all would measure the same thing.

using perf.

sync; sync; sync;
sudo ~/s/perfrec elementary_test -to genlist
sudo chmod a+r+w perf.data
perf report --symbol-filter=_eo_obj_pointer_get --source -g --stdio | cat

and perfrec is:

#!/bin/sh
export ELM_TEST_AUTOBOUNCE=10
echo 55000 > /proc/sys/kernel/perf_event_max_sample_rate;
exec perf record --call-graph=dwarf -F 5  $@

results will vary a bit from machine to machine. on 2 different i7's on one i
saw about 5.x, on another 5.x up to 7.x. now i actually see a fairly consistent
about 2.5 or so. well for "local id's". the shared eoid domain should have more
like the 5-7% range like above.

> > --
> > - Codito, ergo sum - "I code, therefore I am" --
> > The Rasterman (Carsten Haitzler)ras...@rasterman.com
> >
> >
> >
> --
> >
> > ___
> > enlightenment-devel mailing list
> > enlightenment-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
> >
> --
> ___
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
> 


-- 
- Codito, ergo sum - "I code, therefore I am" --
The Rasterman (Carsten Haitzler)ras...@rasterman.com


--
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


[EGIT] [core/efl] master 01/01: eo: avoid redefinition of type Efl_Promise

2016-09-08 Thread Jean Guyomarc'h
jayji pushed a commit to branch master.

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

commit a336e761d2499e7976250e3a1c9d17a48377d796
Author: Jean Guyomarc'h 
Date:   Fri Sep 9 08:39:02 2016 +0200

eo: avoid redefinition of type Efl_Promise

clang complained about type redefinition being a C11 feature, throwing a
warning for each compiling unit including Eo.h.
---
 src/lib/eo/efl_future.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/lib/eo/efl_future.h b/src/lib/eo/efl_future.h
index 78dc273..61ce03d 100644
--- a/src/lib/eo/efl_future.h
+++ b/src/lib/eo/efl_future.h
@@ -11,6 +11,7 @@
  * The type of Efl Promise used in asynchronous operation, the write side of a 
promise.
  */
 typedef Eo Efl_Promise;
+#define _EFL_PROMISE_EO_CLASS_TYPE
 
 #define EFL_FUTURE_CLASS efl_future_class_get()
 EWAPI const Efl_Class *efl_future_class_get(void);

--