Commit Graph

55068 Commits

Author SHA1 Message Date
Gustavo Sverzut Barbieri 306ec6937b Efl.Loop.coro: easy to use coroutines attached to a main loop.
While Eina_Coro provides a solid base, to use the main loop to
schedule coroutines it needs some manual work we want to avoid.

Efl.Loop.coro method will take a function and schedule it using the
given priority, the returned value is then resolved in a promise for
the returned future.

Basically all users must do is write a function that looks like a
synchronous code and calls eina_coro_yield() (or helper macros), that
will go back to the main loop and then it will reschedule the
coroutine to run according to its priority.

This should reduce the number of callbacks in user's code.
2017-08-27 11:47:55 -03:00
Gustavo Sverzut Barbieri 109bf1b387 Efl_Object: make main domain accessible in Eina_Coro.
Currently Eina_Coro is implemented with actual threads, that barf Eo
checkings and makes main thread objects unusuable.

Since this is an implementation detail, let's use Eina_Coro hooks to
adopt the main domain and return when it's done... The user doesn't
see this, it's transparent.
2017-08-27 11:47:55 -03:00
Gustavo Sverzut Barbieri d10a35628c eina: add Eina_Coro - coroutine support.
Coroutines are cooperative tasks, in the sense that the caller will
stop until the target function runs. The target function must either
yield control back to the caller (main thread), or exit. There is no
preemption of the two tasks, thus no special care needs to be taken
regarding shared data.

If the target coroutine yields control using eina_coro_yield(), then
it will be paused until it's manually ran again by caller (main
thread), which is executed with eina_coro_run().

Another common usage is to await for another task to be completed,
this can be done by waiting for a future to be resolved. It will
automatically yield and inform the caller of the future so it can
schedule properly instead of keep calling the task. Waiting for many
tasks can be achieved by using eina_future_all() or
eina_future_race(). This is done with eina_coro_await().

Due portability it was implemented using Eina_Thread, Eina_Lock and
Eina_Condition. Regular threads will ensure that the state is fully
preserved (stack, registers) in a platform independent way. Each
thread will wait on its own turn using the Eina_Lock and
Eina_Condition, thus it's guaranteed that only one is being executed
at the same time.

The API is small and should allow different implementations shall we
need them, like manually saving the stack and registers, then
restoring those -- problem is doing that in a portable way,
setjmp()/longjmp() won't save the stack, makecontext()/swapcontext()
doesn't work right on MacOS...

Hooks can be used to be informed when the main routine exits and then
enters, likewise when the coroutine enters and exits. These will be
used, for instance, to automatically get, adopt and return
Efl_Domain_Data needed to make Efl_Object work in such
environment. The flow is simple:

  - main exit (called from main thread)
  - coroutine enter (called from worker thread)
  - coroutine exit (called from worker thread)
  - main enter (called from main thead)

Performance may not be optimal, however this is meant as easy-to-use
and it shouldn't be an issue in real life. It will be mostly exposed
in two layers:

 - Efl.Loop.coro: will wrap eina_coro and and schedule using its main
   loop instance, returns an Eina_Future so it's easy to chain.

 - Eina_Promise/Eina_Future "async/await"-like behavior: will allow to
   write "synchronous" code that can wait for promises to be
   resolved. When eina_future_await(), it will actually register a new
   Eina_Future in the chain and then eina_coro_yield(). Once the
   future is called back it will call eina_coro_run() and allow the
   coroutine to resume. This is done on top fo eina_coro_await().
2017-08-27 11:47:55 -03:00
Gustavo Sverzut Barbieri 4d7661b174 Efl_Loop: add job, timeout and idle based on Eina_Future.
Since some clash with old version, then add Eina_FutureXXX to their
name, later we'll sed.
2017-08-27 11:47:55 -03:00
Gustavo Sverzut Barbieri f3d5642503 export efl_future_then() for Eina_Future syntax sugar.
This is actually written as efl_future_Eina_FutureXXX_then() as the
old API clashes, after removing the old code we'll "sed" to fix those.
2017-08-27 11:35:38 -03:00
Gustavo Sverzut Barbieri 7dc41ab0e5 Eina_Future: add eina_future_resolved()
This is a helper that creates a promise, then a future and immediately
resolves the promise, this will let the future be dispatched as usual,
from a clean main loop context.
2017-08-27 11:35:38 -03:00
Gustavo Sverzut Barbieri 1a0b921789 Eina_Future: add to eina_types.eot 2017-08-27 11:35:38 -03:00
Gustavo Sverzut Barbieri 701aab803d fixup Efl_Object: Add integration with Eina_Future.
Rename _from_array() to _array(), following others.

Fix variable to be signed so -1 is clean (it would work due overlow,
but not that clear).
2017-08-27 11:35:38 -03:00
Gustavo Sverzut Barbieri b2cd2cbf16 fixup Eina: Add Eina_Promise/Eina_Future (convert_to)
convert_to() should just setup for empty, getting the default value.

on errors it should convert to EINA_VALUE_TYPE_ERROR, otherwise pass
thru.
2017-08-27 11:35:38 -03:00
Gustavo Sverzut Barbieri 07f272b52e fixup Eina: Add Eina_Promise/Eina_Future
_eina_promise_clean_dispatch() must call _eina_future_dispatch() since
complex chains will need to be walked -- this bugged me for some
complex tests I'm doing with coroutines.

Unfortunately that will modify the value and cause problems since the
caller trust it wasn't modified and could cause double-free or invalid
memory access. Then we must copy it in _future_proxy().

Other usage for _eina_promise_clean_dispatch() were leaking and are
now "auto fixed".
2017-08-27 11:35:38 -03:00
Guilherme Iscaro c35e929713 Add new Future/Promise API.
Summary:
Eina: Add Eina_Promise/Eina_Future.

This commit adds a new promise/future API which aims to replace
efl_future.

Efl_Object: Add integration with Eina_Future.

This commit adds the EO support for the new future infra.
From now on there's no need to efl_future_link()/efl_future_unlink()
object and futures since the new API already handles that internally.

Eina_Promise/Eina_Future: Add example and tests.

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D5131
2017-08-25 20:42:23 -03:00
Guilherme Iscaro 0dd2c1a530 Efl_Object: Add integration with Eina_Future.
This commit adds the EO support for the new future infra.
From now on there's no need to efl_future_link()/efl_future_unlink()
object and futures since the new API already handles that internally.
2017-08-25 19:53:49 -03:00
Guilherme Iscaro d30c0d4f03 Eina: Add Eina_Promise/Eina_Future.
This commit adds a new promise/future API which aims to replace
efl_future.
2017-08-25 19:53:49 -03:00
Mike Blumenkrantz 27cba99045 theme: let notifications wrap
infinitely wide notification popups are hard to read
2017-08-25 14:48:12 -04:00
Mike Blumenkrantz e436947ff0 evas image cache: notify preload for image objects without explicit callbacks
non-gl images do not have an explicit callback and so the preload inform callback
must be triggered manually for all cases

fix T5200
2017-08-25 14:48:12 -04:00
Mike Blumenkrantz e4ba40c5bc evas image cache: break out preload complete notification code into function
no functional changes
2017-08-25 14:48:12 -04:00
Mike Blumenkrantz 7745520852 efl_ui_image: maintain geometry for prev image while preloading new image
if prev_img exists then it is visible, so continue maintaining its geometry
until it is deleted

fix T5936

@fix
2017-08-25 14:48:12 -04:00
Mike Blumenkrantz 8dbea4a709 elm_win: check for wayland engine during finalize by checking for wl win
fake wins don't provide engine info, but a wl win will still exist

@fix
2017-08-25 14:48:12 -04:00
Mike Blumenkrantz d0f1a57ade elm_win: update opaque region for fake windows
fake windows still gotta render

@fix
2017-08-25 14:48:12 -04:00
Mike Blumenkrantz 2510afe821 efl-wl: match nested wl seats based on display ordering
a nested compositor will have a mismatch between canvas seat id and
compositor seat id, so this attempts to perform matching based on the
order that they are listed, which should be identical

@fix
2017-08-25 14:48:11 -04:00
Mike Blumenkrantz 91f513f77d ecore-wl2: normalize axis event values
this is value * 10 from the compositor, so /= 10 to get real value

fix T5427

@fix
2017-08-25 14:48:11 -04:00
Cedric BAIL 8286a56279 evas: enable rendering of multiple output. 2017-08-25 10:55:15 -07:00
Cedric BAIL 4b1505c294 evas: no more ENDT. 2017-08-25 10:55:06 -07:00
Cedric BAIL 7fc0ebee37 evas: move updates to be per output. 2017-08-25 10:55:02 -07:00
Cedric BAIL e7527e06d6 evas: decorrelate canvas size from output size. 2017-08-25 10:54:59 -07:00
Cedric BAIL 7453980ccf evas gl: fix glview by avoiding make current
gl_generic_context_find() returns the gl shared context struct but
this is not just a read-only operation. It in turn calls window_use
which may call make_current. This can invalidate the work of evas gl
when the API tried to switch to a specific context.

This fixes evas gl with multiple outputs.

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2017-08-25 10:54:55 -07:00
Cedric BAIL cce4dcc58e evas: remove dead code to improve readability. 2017-08-25 10:54:52 -07:00
Cedric BAIL 545c1a70f4 evas: make Evas_GL work with multi output. 2017-08-25 10:54:19 -07:00
Cedric BAIL 7f8bbe4972 evas: reorder rendering phase to group output related operation. 2017-08-25 10:52:52 -07:00
Cedric BAIL 440238a899 evas: Evas_Canvas3D rendering logic need a complete overhaul.
For now, do not use Evas_Canvas3D in multi output context, it won't work.
The update code for Evas_Canvas3D_Node might trigger rendering logic, which
is opposite to what the scene graph logic should do. It require to much
reshuffle around to handle that case at the moment. So I am just adding a
warning.
2017-08-25 10:52:48 -07:00
Cedric BAIL f354463dc1 evas: propagate output in evas_render_updates_internal_loop instead of using ENDT. 2017-08-25 10:52:42 -07:00
Cedric BAIL 79ed7a0cc2 evas: enable handling multi output in evas_render_mapped. 2017-08-25 10:52:38 -07:00
Cedric BAIL 750b9d065f evas: propagate output to evas_render_mask_subrender and don't use ENDT there. 2017-08-25 10:52:33 -07:00
Cedric BAIL a5b4defdd5 evas: use output instead of default one during rendering of proxy. 2017-08-25 10:52:29 -07:00
Cedric BAIL 84c6d3332e evas: remove unused engine data from error set/get code. 2017-08-25 10:52:26 -07:00
Cedric BAIL 9ba662bd63 evas: destroy seats and inputs before the display disapear. 2017-08-25 10:52:22 -07:00
Cedric BAIL dcfebcd2d9 evas: no more use of ENDT outside of evas_render. 2017-08-25 10:52:18 -07:00
Cedric BAIL e682f64193 evas: make vector graphic support multi output. 2017-08-25 10:52:14 -07:00
Cedric BAIL a0c58276c3 evas: do not use default output or any other during render pre. 2017-08-25 10:52:10 -07:00
Cedric BAIL 68b846c1f4 evas: remove unecessary use of output in filter code. 2017-08-25 10:52:07 -07:00
Cedric BAIL cc4d41c890 evas: make image_native_set use engine context not output. 2017-08-25 10:52:03 -07:00
Cedric BAIL 39d4e343b0 evas: make all window GLES3 or none. 2017-08-25 10:51:59 -07:00
Cedric BAIL 89c34cda21 evas: make function to find evas gl context from engine shared across backend. 2017-08-25 10:51:56 -07:00
Cedric BAIL fc1b7f7835 evas: make filter handle multi output. 2017-08-25 10:51:53 -07:00
Cedric BAIL f3f6a7e535 evas: make Evas_GL start to use engine and output separately. 2017-08-25 10:51:47 -07:00
Cedric BAIL bf0ad88144 evas: convert Evas3D use of output to engine when meaningful. 2017-08-25 10:51:44 -07:00
Cedric BAIL 46767819fd evas: find a best possible output to manage an object to get pixels from.
The code shouldn't really need an output for getting the pixels, it just
happen that some of the backend function really need one to get a GL context.
2017-08-25 10:51:40 -07:00
Cedric BAIL aebeed4454 evas: remove dead code that won't be easy to bring back to life. 2017-08-25 10:51:36 -07:00
Cedric BAIL 3da75d74e3 evas: all context function use already ENC. 2017-08-25 10:51:31 -07:00
Cedric BAIL e9cd3e4c7c evas: remove image_content_hint_get from backend as it is unused. 2017-08-25 10:51:27 -07:00