This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch ecore-evas-gl-drm-offscreen
in repository efl.
View the commit online.
commit d2d568230923c9ed4de05198865ffcc835cbb274
Author: Cedric BAIL <[email protected]>
AuthorDate: Wed Dec 2 16:33:25 2026 -0600
ecore_evas: let the consumer pace an offscreen canvas
An offscreen canvas had no animator functions, so ecore_evas ticked it
with an Ecore_Animator and, as for any canvas of that kind, forced the
process-wide animator source to the timer for good, even over a source
set to custom, and taking the vsync of an ecore_evas_drm_new() canvas
from the Ecore_Animator of the process. An encoder has a cadence of
its own, a fixed rate or one frame once the client acknowledged the
last, which that timer cannot follow.
The canvas now registers its own ticks. Left alone it ticks from a
timer of its own at ecore_animator_frametime_get(), so existing
callers still just get frames. With
ecore_evas_gl_drm_tick_callbacks_set() the consumer is told when the
canvas wants ticks and when it does not, and gives them with
ecore_evas_gl_drm_tick(). The public beta
ecore_evas_animator_tick() is not usable for that: it is declared in a
header that is not installed. The tick is ignored when none was
asked for, since it would also draw what the canvas keeps for a better
time, such as while the consumer holds every buffer.
The canvas ticks itself only, like the X11 present window, so it takes
no part in the source of the animators, which the commit before takes
care of.
A render that is withheld because the consumer holds every buffer used
to be asked for again at each wake up of the main loop, and dropped
again, which with consumer ticks is a begin and an end per wake up, and
with the timer one created and deleted. The canvas now stays out of the
idle pass with draw_block until the consumer gives a frame back or the
canvas is resized, and asks then.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
---
src/lib/ecore_evas/Ecore_Evas.h | 99 +++-
src/lib/ecore_evas/ecore_evas.c | 60 +-
src/lib/ecore_evas/ecore_evas_drm.h | 3 +
.../ecore_evas/engines/drm/ecore_evas_drm.c | 146 ++++-
src/tests/ecore/ecore_test_ecore_evas_gl_drm.c | 658 +++++++++++++++++++++
5 files changed, 944 insertions(+), 22 deletions(-)
diff --git a/src/lib/ecore_evas/Ecore_Evas.h b/src/lib/ecore_evas/Ecore_Evas.h
index 28acaf64f2..18b767c07a 100644
--- a/src/lib/ecore_evas/Ecore_Evas.h
+++ b/src/lib/ecore_evas/Ecore_Evas.h
@@ -1832,17 +1832,19 @@ typedef void (*Ecore_Evas_Gl_Drm_Buffer_Free_Cb)(void *data, uint64_t buffer_id)
* animators), so a consumer must never wait for a new frame before it
* releases one.
*
- * @note It has no vsync of its own: its ticks come from an Ecore_Animator
- * on the timer source. While it exists, as for any canvas without tick
- * functions such as one made by ecore_evas_buffer_new(), the process uses
- * ECORE_ANIMATOR_SOURCE_TIMER for its Ecore_Animator, even if the source
- * was set to ECORE_ANIMATOR_SOURCE_CUSTOM before, and the source is not
- * given back when the canvas is freed. A canvas of ecore_evas_drm_new() in
- * the same process then no longer drives the Ecore_Animator by its vsync,
- * though it keeps ticking its own objects. In a process that has an X11
- * canvas ecore_evas leaves the source alone.
+ * It has no vsync, and ticks only itself: what animates on the canvas, and
+ * the render that follows, go at the pace of the ticks it asks for. Left
+ * alone, it asks of a timer of its own, which fires at the frame time of
+ * ecore_animator_frametime_get() as it is when the canvas starts to ask,
+ * while the canvas has something to animate or draw. A consumer that has a
+ * pace of its own, a fixed rate or one frame once the client acknowledged
+ * the last, sets ecore_evas_gl_drm_tick_callbacks_set() and ticks the
+ * canvas with ecore_evas_gl_drm_tick(). The canvas never changes the
+ * source of the Ecore_Animator of the process, nor ticks the animators of
+ * it, whichever canvases are around.
*
* @see ecore_evas_gl_drm_frame_callbacks_set()
+ * @see ecore_evas_gl_drm_tick_callbacks_set()
* @since 1.30
*/
EAPI Ecore_Evas *ecore_evas_gl_drm_offscreen_new(const char *render_node, int w, int h,
@@ -1884,6 +1886,85 @@ EAPI void ecore_evas_gl_drm_frame_callbacks_set(Ecore_Evas *ee,
Ecore_Evas_Gl_Drm_Buffer_Free_Cb free_func,
const void *data);
+/**
+ * @brief The callback that tells a consumer that a canvas made by
+ * ecore_evas_gl_drm_offscreen_new() wants ticks, or does not any more.
+ *
+ * @param data The data given to ecore_evas_gl_drm_tick_callbacks_set().
+ * @param ee The canvas.
+ *
+ * The callbacks run on the main loop. They must not render, resize or free
+ * the canvas, and the begin one must not call ecore_evas_gl_drm_tick()
+ * before it returns. They must not call
+ * ecore_evas_gl_drm_tick_callbacks_set() either: @p end is called by it, to
+ * replace the consumer, and a call from there would end the same ticks
+ * again.
+ *
+ * @see ecore_evas_gl_drm_tick_callbacks_set()
+ * @since 1.30
+ */
+typedef void (*Ecore_Evas_Gl_Drm_Tick_Cb)(void *data, Ecore_Evas *ee);
+
+/**
+ * @brief Sets the consumer that paces a canvas made by
+ * ecore_evas_gl_drm_offscreen_new().
+ *
+ * @param ee The canvas. A canvas of another engine is logged and ignored.
+ * @param begin Called when the canvas wants ticks from now, or @c NULL.
+ * @param end Called when it wants no more, or @c NULL.
+ * @param data The data to give to both.
+ *
+ * With either of them set the canvas does not tick itself: the consumer
+ * ticks it with ecore_evas_gl_drm_tick(), at the pace it chooses, between
+ * @p begin and @p end. With both @c NULL, which is the state of a new
+ * canvas, the canvas ticks itself with a timer of its own.
+ *
+ * The canvas wants ticks from the moment something animates on it, or
+ * something changed that waits for a render, and calls @p begin then. It
+ * does not want them any more, and calls @p end, when the last thing
+ * animating on it is gone, or when a tick leaves nothing to draw: a
+ * consumer ticks, at its pace, from @p begin to @p end, and a canvas that
+ * is not changing ends them with the first tick that finds so. @p begin is
+ * called once for each @p end. A canvas that cannot draw, because the
+ * consumer holds all its buffers or because it is hidden, finds nothing to
+ * draw in a tick: it ends them, without a frame, unless an animator is
+ * still on it, and does not ask again for ticks that it would drop. It
+ * asks when the main loop next goes idle with something waiting to be
+ * drawn, such as after the consumer released a frame.
+ *
+ * When the callbacks are set again while the canvas wants ticks, the old
+ * @p end is called, then the new @p begin, as the canvas still wants
+ * ticks; so is the timer of the canvas stopped, or started, when the
+ * consumer is removed or comes. Freeing the canvas while it wants ticks
+ * calls @p end, before anything of the canvas is gone.
+ *
+ * @see ecore_evas_gl_drm_tick()
+ * @since 1.30
+ */
+EAPI void ecore_evas_gl_drm_tick_callbacks_set(Ecore_Evas *ee,
+ Ecore_Evas_Gl_Drm_Tick_Cb begin,
+ Ecore_Evas_Gl_Drm_Tick_Cb end,
+ const void *data);
+
+/**
+ * @brief Ticks a canvas made by ecore_evas_gl_drm_offscreen_new(), which
+ * runs its animators and, if something changed, draws and gives a frame
+ * when the main loop next goes idle.
+ *
+ * @param ee The canvas. A canvas of another engine is logged and ignored.
+ *
+ * Each tick makes at most one frame. It does nothing, and animates and
+ * draws nothing, unless the consumer set ecore_evas_gl_drm_tick_callbacks_set()
+ * and the canvas wants ticks, between its @c begin and its @c end: a tick
+ * that nothing asked for would draw what the canvas keeps for a better
+ * time, such as while the consumer holds all its buffers. Call it from
+ * the main loop.
+ *
+ * @see ecore_evas_gl_drm_tick_callbacks_set()
+ * @since 1.30
+ */
+EAPI void ecore_evas_gl_drm_tick(Ecore_Evas *ee);
+
/**
* @brief Gives a frame back to the canvas that drew it.
*
diff --git a/src/lib/ecore_evas/ecore_evas.c b/src/lib/ecore_evas/ecore_evas.c
index 68bf2ea254..e77847371a 100644
--- a/src/lib/ecore_evas/ecore_evas.c
+++ b/src/lib/ecore_evas/ecore_evas.c
@@ -4690,6 +4690,25 @@ ecore_evas_gl_drm_offscreen_new(const char *render_node, int w, int h,
return ee;
}
+/* The interface of an older module is a smaller structure, or has other
+ * functions in its slots, and the one of the canvas of a device has none:
+ * version 3 has them. */
+static Ecore_Evas_Interface_Drm *
+_ecore_evas_gl_drm_offscreen_interface_get(Ecore_Evas *ee)
+{
+ Ecore_Evas_Interface_Drm *iface;
+
+ iface = (Ecore_Evas_Interface_Drm *)_ecore_evas_interface_get_internal(ee, "drm", 0);
+ if ((!iface) || (iface->base.version < 3))
+ {
+ ERR("Ecore_Evas %p (engine: %s) was not made by "
+ "ecore_evas_gl_drm_offscreen_new()", ee, ee->driver);
+ return NULL;
+ }
+
+ return iface;
+}
+
EAPI void
ecore_evas_gl_drm_frame_callbacks_set(Ecore_Evas *ee,
Ecore_Evas_Gl_Drm_Frame_Cb frame_func,
@@ -4700,20 +4719,41 @@ ecore_evas_gl_drm_frame_callbacks_set(Ecore_Evas *ee,
ECORE_EVAS_CHECK(ee);
- iface = (Ecore_Evas_Interface_Drm *)_ecore_evas_interface_get_internal(ee, "drm", 0);
- /* The interface of an older module is a smaller structure, or has other
- * functions in its slots, and the one of the canvas of a device has none:
- * version 3 has them. */
- if ((!iface) || (iface->base.version < 3) || (!iface->frame_callbacks_set))
- {
- ERR("Ecore_Evas %p (engine: %s) was not made by "
- "ecore_evas_gl_drm_offscreen_new()", ee, ee->driver);
- return;
- }
+ iface = _ecore_evas_gl_drm_offscreen_interface_get(ee);
+ if (!iface) return;
iface->frame_callbacks_set(ee, frame_func, free_func, data);
}
+EAPI void
+ecore_evas_gl_drm_tick_callbacks_set(Ecore_Evas *ee,
+ Ecore_Evas_Gl_Drm_Tick_Cb begin,
+ Ecore_Evas_Gl_Drm_Tick_Cb end,
+ const void *data)
+{
+ Ecore_Evas_Interface_Drm *iface;
+
+ ECORE_EVAS_CHECK(ee);
+
+ iface = _ecore_evas_gl_drm_offscreen_interface_get(ee);
+ if (!iface) return;
+
+ iface->tick_callbacks_set(ee, begin, end, data);
+}
+
+EAPI void
+ecore_evas_gl_drm_tick(Ecore_Evas *ee)
+{
+ Ecore_Evas_Interface_Drm *iface;
+
+ ECORE_EVAS_CHECK(ee);
+
+ iface = _ecore_evas_gl_drm_offscreen_interface_get(ee);
+ if (!iface) return;
+
+ iface->tick(ee);
+}
+
EAPI void
ecore_evas_gl_drm_frame_release(Ecore_Evas_Gl_Drm_Frame *frame)
{
diff --git a/src/lib/ecore_evas/ecore_evas_drm.h b/src/lib/ecore_evas/ecore_evas_drm.h
index bd8e311bf1..bb5f2e8da4 100644
--- a/src/lib/ecore_evas/ecore_evas_drm.h
+++ b/src/lib/ecore_evas/ecore_evas_drm.h
@@ -14,6 +14,9 @@ struct _Ecore_Evas_Interface_Drm
void (*frame_callbacks_set)(Ecore_Evas *ee, Ecore_Evas_Gl_Drm_Frame_Cb frame_func,
Ecore_Evas_Gl_Drm_Buffer_Free_Cb buffer_free_func,
const void *data);
+ void (*tick_callbacks_set)(Ecore_Evas *ee, Ecore_Evas_Gl_Drm_Tick_Cb begin,
+ Ecore_Evas_Gl_Drm_Tick_Cb end, const void *data);
+ void (*tick)(Ecore_Evas *ee);
};
/* What the library reads of a frame; the module that made it puts it
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 b21402a523..e3c7eae7a7 100644
--- a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
+++ b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
@@ -1208,6 +1208,11 @@ struct _Ecore_Evas_Gl_Drm_Offscreen_Data
Evas *evas;
Ecore_Evas_Gl_Drm_Frame_Cb frame_func;
Ecore_Evas_Gl_Drm_Buffer_Free_Cb buffer_free_func;
+ Ecore_Evas_Gl_Drm_Tick_Cb tick_begin;
+ Ecore_Evas_Gl_Drm_Tick_Cb tick_end;
+ const void *tick_data;
+ /* Ticks the canvas when the consumer does not */
+ Ecore_Timer *tick_timer;
const void *frame_data;
/* The buffers given to frame_func that buffer_free_func was not told
* the end of yet, as uint64_t */
@@ -1220,6 +1225,11 @@ struct _Ecore_Evas_Gl_Drm_Offscreen_Data
/* What the next frame holds is not relative to the last one given to the
* callback in use: it covers the canvas */
Eina_Bool damage_whole : 1;
+ /* The render was withheld for want of a buffer, and the canvas is kept
+ * from asking for ticks again until one comes, with draw_block */
+ Eina_Bool throttled : 1;
+ /* The library asked for ticks, and has not said it is done */
+ Eina_Bool ticking : 1;
};
/* Made for each frame the engine delivers, and freed when the consumer
@@ -1299,6 +1309,17 @@ _offscreen_node_unref(void)
_offscreen_node.fd = -1;
}
+static void
+_offscreen_unthrottle(Ecore_Evas *ee)
+{
+ Ecore_Evas_Gl_Drm_Offscreen_Data *odata = ee->engine.data;
+
+ if (!odata->throttled) return;
+
+ odata->throttled = EINA_FALSE;
+ ee->draw_block = EINA_FALSE;
+}
+
static void
_offscreen_link_unref(Ecore_Evas_Gl_Drm_Offscreen_Link *link)
{
@@ -1324,6 +1345,7 @@ _offscreen_frame_release(Ecore_Evas_Gl_Drm_Frame *released)
frame->engine_release(frame->engine_frame);
free(frame);
+ if (link->ee) _offscreen_unthrottle(link->ee);
_offscreen_link_unref(link);
}
@@ -1523,7 +1545,118 @@ _offscreen_prepare(Ecore_Evas *ee)
* holds of the old one. */
if ((ee->w != odata->frame_w) || (ee->h != odata->frame_h)) return EINA_TRUE;
- return odata->info->func.frame_buffer_available(odata->info);
+ if (odata->info->func.frame_buffer_available(odata->info)) return EINA_TRUE;
+
+ /* The change that waits is still there. Left to the library, it would ask
+ * for a tick at each wake up of the main loop, to drop it each time:
+ * nothing is asked for until the consumer gives a frame back, or the
+ * canvas is resized. */
+ odata->throttled = EINA_TRUE;
+ ee->draw_block = EINA_TRUE;
+ return EINA_FALSE;
+}
+
+static void
+_offscreen_resize(Ecore_Evas *ee, int w, int h)
+{
+ _drm_resize(ee, w, h);
+ _offscreen_unthrottle(ee);
+}
+
+static void
+_offscreen_move_resize(Ecore_Evas *ee, int x, int y, int w, int h)
+{
+ _drm_move_resize(ee, x, y, w, h);
+ _offscreen_unthrottle(ee);
+}
+
+static Eina_Bool
+_offscreen_tick_timer_cb(void *data)
+{
+ ecore_evas_animator_tick(data, NULL, ecore_loop_time_get());
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+static Eina_Bool
+_offscreen_tick_consumer_driven(const Ecore_Evas_Gl_Drm_Offscreen_Data *odata)
+{
+ return (odata->tick_begin) || (odata->tick_end);
+}
+
+static void
+_offscreen_tick_start(Ecore_Evas *ee, Ecore_Evas_Gl_Drm_Offscreen_Data *odata)
+{
+ if (!_offscreen_tick_consumer_driven(odata))
+ {
+ odata->tick_timer = ecore_timer_add(ecore_animator_frametime_get(),
+ _offscreen_tick_timer_cb, ee);
+ return;
+ }
+
+ if (odata->tick_begin) odata->tick_begin((void *)odata->tick_data, ee);
+}
+
+static void
+_offscreen_tick_stop(Ecore_Evas *ee, Ecore_Evas_Gl_Drm_Offscreen_Data *odata)
+{
+ if (!_offscreen_tick_consumer_driven(odata))
+ {
+ if (odata->tick_timer) ecore_timer_del(odata->tick_timer);
+ odata->tick_timer = NULL;
+ return;
+ }
+
+ if (odata->tick_end) odata->tick_end((void *)odata->tick_data, ee);
+}
+
+static void
+_offscreen_animator_register(Ecore_Evas *ee)
+{
+ Ecore_Evas_Gl_Drm_Offscreen_Data *odata = ee->engine.data;
+
+ if (odata->ticking) return;
+
+ odata->ticking = EINA_TRUE;
+ _offscreen_tick_start(ee, odata);
+}
+
+static void
+_offscreen_animator_unregister(Ecore_Evas *ee)
+{
+ Ecore_Evas_Gl_Drm_Offscreen_Data *odata = ee->engine.data;
+
+ if (!odata->ticking) return;
+
+ odata->ticking = EINA_FALSE;
+ _offscreen_tick_stop(ee, odata);
+}
+
+/* The consumer that leaves is told that the canvas does not want ticks
+ * before the one that comes is told that it does. */
+static void
+_offscreen_tick_callbacks_set(Ecore_Evas *ee, Ecore_Evas_Gl_Drm_Tick_Cb begin,
+ Ecore_Evas_Gl_Drm_Tick_Cb end, const void *data)
+{
+ Ecore_Evas_Gl_Drm_Offscreen_Data *odata = ee->engine.data;
+
+ if (odata->ticking) _offscreen_tick_stop(ee, odata);
+
+ odata->tick_begin = begin;
+ odata->tick_end = end;
+ odata->tick_data = data;
+
+ if (odata->ticking) _offscreen_tick_start(ee, odata);
+}
+
+static void
+_offscreen_tick(Ecore_Evas *ee)
+{
+ Ecore_Evas_Gl_Drm_Offscreen_Data *odata = ee->engine.data;
+
+ if ((!odata->ticking) || (!_offscreen_tick_consumer_driven(odata))) return;
+
+ ecore_evas_animator_tick(ee, NULL, ecore_loop_time_get());
}
static void
@@ -1606,8 +1739,8 @@ static const Ecore_Evas_Engine_Func _ecore_evas_gl_drm_offscreen_engine_func =
{
.fn_free = _offscreen_free,
.fn_move = _drm_move,
- .fn_resize = _drm_resize,
- .fn_move_resize = _drm_move_resize,
+ .fn_resize = _offscreen_resize,
+ .fn_move_resize = _offscreen_move_resize,
.fn_rotation_set = _offscreen_rotation_set,
.fn_show = _offscreen_show,
.fn_hide = _offscreen_hide,
@@ -1623,6 +1756,8 @@ static const Ecore_Evas_Engine_Func _ecore_evas_gl_drm_offscreen_engine_func =
.fn_screen_geometry_get = _offscreen_screen_geometry_get,
.fn_pointer_xy_get = _offscreen_pointer_xy_get,
.fn_prepare = _offscreen_prepare,
+ .fn_animator_register = _offscreen_animator_register,
+ .fn_animator_unregister = _offscreen_animator_unregister,
};
EMODAPI Ecore_Evas *
@@ -1684,12 +1819,17 @@ ecore_evas_gl_drm_offscreen_new_internal(const char *render_node, int w, int h,
link->ee = ee;
link->refs = 1;
odata->link = link;
+ /* The ticks of this canvas are its own, and not those of the animators
+ * of the process */
+ ee->animator_tick_local = 1;
iface = _ecore_evas_drm_interface_new();
if (!iface) goto eng_err;
/* 3 has the functions of a canvas with no device */
iface->base.version = 3;
iface->frame_callbacks_set = _offscreen_frame_callbacks_set;
+ iface->tick_callbacks_set = _offscreen_tick_callbacks_set;
+ iface->tick = _offscreen_tick;
ee->engine.ifaces = eina_list_append(ee->engine.ifaces, iface);
ee->w = ee->req.w = w;
diff --git a/src/tests/ecore/ecore_test_ecore_evas_gl_drm.c b/src/tests/ecore/ecore_test_ecore_evas_gl_drm.c
index 719021b4ef..b1455e7c4b 100644
--- a/src/tests/ecore/ecore_test_ecore_evas_gl_drm.c
+++ b/src/tests/ecore/ecore_test_ecore_evas_gl_drm.c
@@ -87,6 +87,10 @@ struct _Test_Canvas
unsigned int held_count;
unsigned int id_count;
unsigned int frame_count;
+ unsigned int begin_calls;
+ unsigned int end_calls;
+ unsigned int end_only_calls;
+ unsigned int animator_ticks;
unsigned int modifier_count;
unsigned int freed_count;
unsigned int other_freed_count;
@@ -2129,6 +2133,646 @@ EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_modifiers_count_without_li
}
EFL_END_TEST
+static void
+_tick_begin_cb(void *data, Ecore_Evas *ee)
+{
+ Test_Canvas *c = data;
+
+ ck_assert_ptr_eq(ee, c->ee);
+ c->begin_calls++;
+ /* Each begin has its end, and no two in a row */
+ ck_assert_uint_eq(c->begin_calls, c->end_calls + 1);
+}
+
+static void
+_tick_end_cb(void *data, Ecore_Evas *ee)
+{
+ Test_Canvas *c = data;
+
+ ck_assert_ptr_eq(ee, c->ee);
+ c->end_calls++;
+ ck_assert_uint_eq(c->end_calls, c->begin_calls);
+}
+
+static void
+_tick_end_only_cb(void *data, Ecore_Evas *ee EINA_UNUSED)
+{
+ Test_Canvas *c = data;
+
+ c->end_only_calls++;
+}
+
+static void
+_consumer_set(Test_Canvas *c)
+{
+ ecore_evas_gl_drm_tick_callbacks_set(c->ee, _tick_begin_cb, _tick_end_cb, c);
+}
+
+static void
+_consumer_unset(Test_Canvas *c)
+{
+ ecore_evas_gl_drm_tick_callbacks_set(c->ee, NULL, NULL, NULL);
+}
+
+static void
+_quit_job(void *data EINA_UNUSED)
+{
+ ecore_main_loop_quit();
+}
+
+/* One turn of the main loop, which goes idle once at the end of it: what
+ * the canvas renders, it renders by then. */
+static void
+_turn(Test_Canvas *c)
+{
+ ecore_job_add(_quit_job, NULL);
+ _loop_run(c);
+}
+
+static void
+_animator_tick_cb(void *data, const Efl_Event *ev EINA_UNUSED)
+{
+ Test_Canvas *c = data;
+
+ c->animator_ticks++;
+ _mover_step(c);
+}
+
+/* What animates on the canvas, so that it wants ticks until it is removed */
+static void
+_animator_add(Test_Canvas *c)
+{
+ efl_event_callback_add(ecore_evas_get(c->ee),
+ EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK,
+ _animator_tick_cb, c);
+}
+
+static void
+_animator_del(Test_Canvas *c)
+{
+ efl_event_callback_del(ecore_evas_get(c->ee),
+ EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK,
+ _animator_tick_cb, c);
+}
+
+/* A canvas that ticks itself does not touch what the process uses for the
+ * animators, whatever that was set to. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_animator_source_kept)
+{
+ Test_Canvas *c;
+
+ ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);
+ c = _canvas_new();
+ if (!c)
+ {
+ ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
+ return;
+ }
+
+ ck_assert_int_eq(ecore_animator_source_get(), ECORE_ANIMATOR_SOURCE_CUSTOM);
+ _frames_wait(c, 1);
+ _animator_add(c);
+ _frames_wait(c, 3);
+ ck_assert_int_eq(ecore_animator_source_get(), ECORE_ANIMATOR_SOURCE_CUSTOM);
+ _animator_del(c);
+
+ ecore_evas_free(c->ee);
+ c->ee = NULL;
+ ck_assert_int_eq(ecore_animator_source_get(), ECORE_ANIMATOR_SOURCE_CUSTOM);
+
+ _canvas_free(c);
+ ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
+}
+EFL_END_TEST
+
+/* What a canvas that has nothing of its own to tick with does to the source
+ * of the animators is what it always did, with the offscreen canvas coming
+ * and going: it neither forces the timer nor gives anything back. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_animator_source_with_buffer)
+{
+ Test_Canvas *c;
+ Ecore_Evas *buffer;
+
+ ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);
+ c = _canvas_new();
+ if (!c)
+ {
+ ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
+ return;
+ }
+ ck_assert_int_eq(ecore_animator_source_get(), ECORE_ANIMATOR_SOURCE_CUSTOM);
+
+ /* The buffer canvas needs the timer, with or without the other */
+ buffer = ecore_evas_buffer_new(CANVAS_W, CANVAS_H);
+ ck_assert_ptr_nonnull(buffer);
+ ck_assert_int_eq(ecore_animator_source_get(), ECORE_ANIMATOR_SOURCE_TIMER);
+ _frames_wait(c, 1);
+
+ /* Nothing here made the source custom, so nothing gives it back */
+ ecore_evas_free(buffer);
+ ck_assert_int_eq(ecore_animator_source_get(), ECORE_ANIMATOR_SOURCE_TIMER);
+ ecore_evas_free(c->ee);
+ c->ee = NULL;
+ ck_assert_int_eq(ecore_animator_source_get(), ECORE_ANIMATOR_SOURCE_TIMER);
+
+ /* And the other way round */
+ ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);
+ buffer = ecore_evas_buffer_new(CANVAS_W, CANVAS_H);
+ ck_assert_ptr_nonnull(buffer);
+ c->ee = ecore_evas_gl_drm_offscreen_new(c->node, CANVAS_W, CANVAS_H, NULL, 0);
+ ck_assert_ptr_nonnull(c->ee);
+ ck_assert_int_eq(ecore_animator_source_get(), ECORE_ANIMATOR_SOURCE_TIMER);
+ ecore_evas_free(c->ee);
+ c->ee = NULL;
+ ck_assert_int_eq(ecore_animator_source_get(), ECORE_ANIMATOR_SOURCE_TIMER);
+ ecore_evas_free(buffer);
+
+ _canvas_free(c);
+ ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
+}
+EFL_END_TEST
+
+static unsigned int _custom_ticks_begun = 0;
+
+static void
+_custom_tick_begin(void *data EINA_UNUSED)
+{
+ _custom_ticks_begun++;
+}
+
+static Eina_Bool
+_custom_animator_cb(void *data EINA_UNUSED)
+{
+ return ECORE_CALLBACK_CANCEL;
+}
+
+/* A source the application chose, with ticks of its own, over a canvas that
+ * needs the timer, which was there first: the offscreen canvas coming, with
+ * something animating on it, and going, leaves the source as it is. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_animator_source_application)
+{
+ Test_Canvas *c;
+ Ecore_Evas *buffer;
+ Ecore_Animator *animator;
+
+ fail_if(ecore_evas_init() == 0);
+ buffer = ecore_evas_buffer_new(CANVAS_W, CANVAS_H);
+ fail_if(buffer == NULL);
+ _custom_ticks_begun = 0;
+ ecore_animator_custom_source_tick_begin_callback_set(_custom_tick_begin, NULL);
+ ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);
+
+ c = _canvas_new();
+ if (c)
+ {
+ ck_assert_int_eq(ecore_animator_source_get(), ECORE_ANIMATOR_SOURCE_CUSTOM);
+ _frames_wait(c, 1);
+ _animator_add(c);
+ _frames_wait(c, 2);
+ _animator_del(c);
+
+ ecore_evas_free(c->ee);
+ c->ee = NULL;
+ ck_assert_int_eq(ecore_animator_source_get(), ECORE_ANIMATOR_SOURCE_CUSTOM);
+ animator = ecore_animator_add(_custom_animator_cb, NULL);
+ ck_assert_uint_eq(_custom_ticks_begun, 1);
+ ecore_animator_del(animator);
+ }
+
+ ecore_animator_custom_source_tick_begin_callback_set(NULL, NULL);
+ ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
+ ecore_evas_free(buffer);
+ /* The count of this test, not that of the canvas */
+ ecore_evas_shutdown();
+ if (c) _canvas_free(c);
+}
+EFL_END_TEST
+
+/* With no pace given the canvas goes by itself, with the process animators
+ * kept from ticking: it needs nothing from them. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_self_ticking)
+{
+ Test_Canvas *c;
+ unsigned int i;
+
+ ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);
+ c = _canvas_new();
+ if (!c)
+ {
+ ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
+ return;
+ }
+
+ _frames_wait(c, 1);
+ _animator_add(c);
+ _frames_wait(c, 4);
+ ck_assert_uint_ge(c->animator_ticks, 4);
+ _animator_del(c);
+
+ /* A change alone, with nothing animating, is drawn too */
+ for (i = 0; i < 3; i++)
+ {
+ unsigned int before = c->frame_count;
+
+ ecore_job_add(_mover_step_job, c);
+ _frames_wait(c, 1);
+ ck_assert_uint_eq(c->frame_count, before + 1);
+ }
+
+ _canvas_free(c);
+ ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
+}
+EFL_END_TEST
+
+/* The timer of the canvas is the frame time of the animators, and not
+ * faster. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_self_ticking_frametime)
+{
+ Test_Canvas *c;
+ double frametime = ecore_animator_frametime_get(), start;
+
+ ecore_animator_frametime_set(0.1);
+ c = _canvas_new();
+ if (!c)
+ {
+ ecore_animator_frametime_set(frametime);
+ return;
+ }
+
+ _frames_wait(c, 1);
+ _animator_add(c);
+ start = ecore_time_get();
+ _frames_wait(c, 4);
+ /* Four frames take at least three of the times between ticks, and the
+ * timer cannot be early; a slow machine only takes longer. */
+ ck_assert_msg((ecore_time_get() - start) >= 0.25,
+ "four frames in %.3f s at a frame time of 0.1 s",
+ ecore_time_get() - start);
+ _animator_del(c);
+
+ _canvas_free(c);
+ ecore_animator_frametime_set(frametime);
+}
+EFL_END_TEST
+
+/* The consumer ticks: nothing comes by itself, begin comes once when the
+ * canvas wants ticks, and each tick is at most one frame. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_consumer_ticks)
+{
+ Test_Canvas *c = _canvas_new();
+ unsigned int i, frames;
+
+ if (!c) return;
+
+ _frames_wait(c, 1);
+ _consumer_set(c);
+ ck_assert_uint_eq(c->begin_calls, 0);
+
+ _animator_add(c);
+ _turn(c);
+ ck_assert_uint_eq(c->begin_calls, 1);
+ ck_assert_uint_eq(c->end_calls, 0);
+
+ /* The animator is there, and the canvas waits for the consumer */
+ _ticks_idle(c, 6);
+ ck_assert_uint_eq(c->frame_count, 1);
+ ck_assert_uint_eq(c->animator_ticks, 0);
+
+ /* The frame rate is the consumer's */
+ for (i = 0; i < 5; i++)
+ {
+ frames = c->frame_count;
+ ecore_evas_gl_drm_tick(c->ee);
+ _frames_wait(c, 1);
+ ck_assert_uint_eq(c->frame_count, frames + 1);
+ ck_assert_uint_eq(c->animator_ticks, i + 1);
+ }
+
+ /* One frame at most for each tick, however many ticks come in a row */
+ frames = c->frame_count;
+ ecore_evas_gl_drm_tick(c->ee);
+ ecore_evas_gl_drm_tick(c->ee);
+ ecore_evas_gl_drm_tick(c->ee);
+ _turn(c);
+ ck_assert_uint_eq(c->animator_ticks, 8);
+ ck_assert_uint_eq(c->frame_count, frames + 1);
+
+ /* Nothing animates any more */
+ _animator_del(c);
+ ck_assert_uint_eq(c->end_calls, 1);
+ ck_assert_uint_eq(c->begin_calls, 1);
+ frames = c->frame_count;
+
+ /* A tick nobody asked for does nothing, whatever waits to be drawn */
+ _mover_step(c);
+ ecore_evas_gl_drm_tick(c->ee);
+ _turn(c);
+ ck_assert_uint_eq(c->frame_count, frames);
+ ck_assert_uint_eq(c->begin_calls, 2);
+ ecore_evas_gl_drm_tick(c->ee);
+ _frames_wait(c, 1);
+ ck_assert_uint_eq(c->frame_count, frames + 1);
+
+ /* What waits to be drawn is asked for until a tick finds nothing */
+ ck_assert_uint_eq(c->end_calls, 1);
+ ecore_evas_gl_drm_tick(c->ee);
+ _turn(c);
+ ck_assert_uint_eq(c->end_calls, 2);
+ ck_assert_uint_eq(c->frame_count, frames + 1);
+
+ _canvas_free(c);
+}
+EFL_END_TEST
+
+/* The canvas that goes by itself ignores the ticks of a consumer it does
+ * not have. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_tick_without_consumer)
+{
+ Test_Canvas *c = _canvas_new();
+ unsigned int frames;
+
+ if (!c) return;
+
+ _frames_wait(c, 1);
+ _animator_add(c);
+ _turn(c);
+ frames = c->frame_count;
+ c->animator_ticks = 0;
+ /* However many, the timer gives the ticks */
+ ecore_evas_gl_drm_tick(c->ee);
+ ecore_evas_gl_drm_tick(c->ee);
+ ecore_evas_gl_drm_tick(c->ee);
+ ck_assert_uint_eq(c->animator_ticks, 0);
+ _animator_del(c);
+ ck_assert_uint_eq(c->frame_count, frames);
+
+ _canvas_free(c);
+}
+EFL_END_TEST
+
+/* Switching the pace while the canvas wants ticks: the consumer that comes
+ * is told at once, the timer stops, and back. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_pace_switched)
+{
+ Test_Canvas *c = _canvas_new();
+ unsigned int frames;
+
+ if (!c) return;
+
+ _frames_wait(c, 1);
+ _animator_add(c);
+ /* The canvas ticks itself, and wants ticks as long as it animates */
+ _frames_wait(c, 2);
+
+ _consumer_set(c);
+ ck_assert_uint_eq(c->begin_calls, 1);
+ ck_assert_uint_eq(c->end_calls, 0);
+
+ /* No timer any more */
+ _turn(c);
+ frames = c->frame_count;
+ _ticks_idle(c, 6);
+ ck_assert_uint_eq(c->frame_count, frames);
+
+ ecore_evas_gl_drm_tick(c->ee);
+ _frames_wait(c, 1);
+ ck_assert_uint_eq(c->frame_count, frames + 1);
+
+ /* The consumer leaves, and the timer takes over */
+ _consumer_unset(c);
+ ck_assert_uint_eq(c->end_calls, 1);
+ ck_assert_uint_eq(c->begin_calls, 1);
+ _frames_wait(c, 3);
+ _animator_del(c);
+
+ _canvas_free(c);
+}
+EFL_END_TEST
+
+/* One consumer replaces another while the canvas wants ticks. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_consumer_replaced)
+{
+ Test_Canvas *c = _canvas_new();
+ unsigned int frames;
+
+ if (!c) return;
+
+ _frames_wait(c, 1);
+ _consumer_set(c);
+ _animator_add(c);
+ _turn(c);
+ ck_assert_uint_eq(c->begin_calls, 1);
+
+ /* The old one ends and the new one begins, in that order, which the
+ * callbacks assert; the same functions stand for both */
+ _consumer_set(c);
+ ck_assert_uint_eq(c->end_calls, 1);
+ ck_assert_uint_eq(c->begin_calls, 2);
+
+ frames = c->frame_count;
+ ecore_evas_gl_drm_tick(c->ee);
+ _frames_wait(c, 1);
+ ck_assert_uint_eq(c->frame_count, frames + 1);
+
+ /* Only an end, or only a begin, is a consumer too */
+ ecore_evas_gl_drm_tick_callbacks_set(c->ee, NULL, _tick_end_only_cb, c);
+ ck_assert_uint_eq(c->end_calls, 2);
+ ck_assert_uint_eq(c->begin_calls, 2);
+ _ticks_idle(c, 4);
+ ck_assert_uint_eq(c->frame_count, frames + 1);
+ _consumer_unset(c);
+ ck_assert_uint_eq(c->end_only_calls, 1);
+ _frames_wait(c, 2);
+ _animator_del(c);
+
+ _canvas_free(c);
+}
+EFL_END_TEST
+
+/* A canvas that is freed while it wants ticks says that it does not, with
+ * nothing of it gone yet, and one that does not say nothing. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_consumer_free)
+{
+ Test_Canvas *c = _canvas_new();
+
+ if (!c) return;
+
+ _frames_wait(c, 1);
+ _consumer_set(c);
+ _animator_add(c);
+ _turn(c);
+ ck_assert_uint_eq(c->begin_calls, 1);
+
+ ecore_evas_free(c->ee);
+ ck_assert_uint_eq(c->end_calls, 1);
+ c->ee = NULL;
+ _canvas_free(c);
+
+ c = _canvas_new();
+ if (!c) return;
+
+ _frames_wait(c, 1);
+ _consumer_set(c);
+ ecore_evas_free(c->ee);
+ ck_assert_uint_eq(c->begin_calls, 0);
+ ck_assert_uint_eq(c->end_calls, 0);
+ c->ee = NULL;
+ _canvas_free(c);
+}
+EFL_END_TEST
+
+/* The consumer holds every buffer and goes on ticking: the canvas gives
+ * up wanting ticks instead of dropping them for ever, and asks again, once,
+ * when a frame is released. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_consumer_throttled)
+{
+ Test_Canvas *c = _canvas_new();
+ unsigned int begins, held, frames;
+ int i;
+
+ if (!c) return;
+
+ _frames_wait(c, 1);
+ c->hold = EINA_TRUE;
+ _consumer_set(c);
+
+ /* Each tick is a change drawn, until no buffer is left */
+ for (i = 0; i < TICKS_BLOCKED; i++)
+ {
+ _mover_step(c);
+ _turn(c);
+ ecore_evas_gl_drm_tick(c->ee);
+ _turn(c);
+ if (c->end_calls) break;
+ }
+ ck_assert_uint_eq(c->end_calls, 1);
+ held = c->held_count;
+ ck_assert_uint_ge(held, 2);
+ ck_assert_uint_lt(held, TICKS_BLOCKED / 2);
+ ck_assert_uint_eq(_warnings, 0);
+
+ /* Nothing spins, nothing is asked: the change is still there, and the
+ * main loop wakes up over and over, but the canvas that could not draw
+ * does not ask for ticks that it would drop until a frame is given
+ * back. The consumer that ticks anyway is not answered. */
+ frames = c->frame_count;
+ begins = c->begin_calls;
+ ck_assert_uint_eq(begins, c->end_calls);
+ _ticks_idle(c, 5);
+ for (i = 0; i < 5; i++)
+ {
+ _turn(c);
+ ecore_evas_gl_drm_tick(c->ee);
+ }
+ ck_assert_uint_eq(c->begin_calls, begins);
+ ck_assert_uint_eq(c->end_calls, begins);
+ ck_assert_uint_eq(c->frame_count, frames);
+
+ /* A frame back, and the change that waited is asked to be drawn */
+ ecore_evas_gl_drm_frame_release(c->held[--c->held_count]);
+ _turn(c);
+ ck_assert_uint_eq(c->begin_calls, c->end_calls + 1);
+ ecore_evas_gl_drm_tick(c->ee);
+ _frames_wait(c, 1);
+ ck_assert_uint_eq(c->frame_count, frames + 1);
+ ck_assert(_damage_covers(c, &c->mover_rect));
+ ck_assert_uint_eq(_warnings, 0);
+
+ _consumer_unset(c);
+ _canvas_free(c);
+}
+EFL_END_TEST
+
+/* A canvas that is hidden does not draw, so a tick finds nothing and ends
+ * the ticks; shown again, it wants them and draws it all. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_consumer_hidden)
+{
+ Test_Canvas *c = _canvas_new();
+ unsigned int frames;
+
+ if (!c) return;
+
+ _frames_wait(c, 1);
+ _consumer_set(c);
+ ecore_evas_hide(c->ee);
+ _mover_step(c);
+ _turn(c);
+ ck_assert_uint_eq(c->begin_calls, 1);
+
+ frames = c->frame_count;
+ ecore_evas_gl_drm_tick(c->ee);
+ _turn(c);
+ ck_assert_uint_eq(c->frame_count, frames);
+ ck_assert_uint_eq(c->end_calls, 1);
+
+ ecore_evas_show(c->ee);
+ _turn(c);
+ ck_assert_uint_eq(c->begin_calls, 2);
+ ecore_evas_gl_drm_tick(c->ee);
+ _frames_wait(c, 1);
+ ck_assert(_damage_is_all(c));
+
+ _canvas_free(c);
+}
+EFL_END_TEST
+
+/* Another canvas of the process goes by itself while this one waits for its
+ * consumer. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_consumer_alone)
+{
+ Test_Canvas *c = _canvas_new();
+ Test_Canvas *other;
+ unsigned int frames;
+
+ if (!c) return;
+
+ other = calloc(1, sizeof(Test_Canvas));
+ ck_assert_ptr_nonnull(other);
+ ck_assert(_canvas_open_on(other, c->node));
+ _first_frame_wait(c);
+ _first_frame_wait(other);
+
+ _consumer_set(c);
+ _animator_add(c);
+ _animator_add(other);
+ _turn(c);
+ frames = c->frame_count;
+ _frames_wait(other, 4);
+ ck_assert_uint_eq(c->frame_count, frames);
+ ck_assert_uint_ge(other->animator_ticks, 4);
+ _animator_del(c);
+ _animator_del(other);
+
+ _canvas_close(other);
+ free(other);
+ _canvas_free(c);
+}
+EFL_END_TEST
+
+/* The canvas of another engine has no pace to set. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_tick_other_engine)
+{
+ Ecore_Evas *ee;
+
+ fail_if(ecore_evas_init() == 0);
+ eina_log_domain_level_set("ecore_evas", EINA_LOG_LEVEL_WARN);
+ eina_log_print_cb_set(_log_count_cb, NULL);
+ _warnings = 0;
+ ee = ecore_evas_buffer_new(CANVAS_W, CANVAS_H);
+ fail_if(ee == NULL);
+
+ ecore_evas_gl_drm_tick_callbacks_set(ee, _tick_begin_cb, _tick_end_cb, NULL);
+ ck_assert_uint_eq(_warnings, 1);
+ ecore_evas_gl_drm_tick(ee);
+ ck_assert_uint_eq(_warnings, 2);
+ ck_assert_ptr_nonnull(strstr(_last_log, "was not made by"));
+
+ ecore_evas_free(ee);
+ eina_log_print_cb_set(NULL, NULL);
+ fail_if(ecore_evas_shutdown() != 0);
+}
+EFL_END_TEST
+
void
ecore_test_ecore_evas_gl_drm(TCase *tc)
{
@@ -2170,6 +2814,20 @@ ecore_test_ecore_evas_gl_drm(TCase *tc)
tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_modifiers_bogus_alone);
tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_modifiers_bogus_and_linear);
tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_modifiers_count_without_list);
+ tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_animator_source_kept);
+ tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_animator_source_with_buffer);
+ tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_animator_source_application);
+ tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_self_ticking);
+ tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_self_ticking_frametime);
+ tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_consumer_ticks);
+ tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_tick_without_consumer);
+ tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_pace_switched);
+ tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_consumer_replaced);
+ tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_consumer_free);
+ tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_consumer_throttled);
+ tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_consumer_hidden);
+ tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_consumer_alone);
+ tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_tick_other_engine);
tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_dmabuf_layout);
tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_dmabuf_pixels);
tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_dmabuf_import);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.