This is an automated email from the git hooks/post-receive script.
git pushed a commit to reference refs/pull/302/head
in repository efl.
View the commit online.
commit 33ea81c0338420f086b758d55110f8f07e47be91
Author: Cedric BAIL <[email protected]>
AuthorDate: Wed Dec 2 18:35:52 2026 -0600
ecore_evas: give the frames of an offscreen canvas the time of their tick
A remote-desktop streamer that paces the canvas itself has three things
to learn from a frame: how long the input it injected waited for the
tick, how long the frame then took from the tick to the callback, and
at what time the frame is to be presented. It can only measure that if
the frame says which tick it was drawn for, and the clients of the
canvas only follow the cadence of the consumer if the tick carries the
consumer's own frame time.
ecore_evas_gl_drm_tick() now takes that time, and it becomes the loop
time of the process for the tick, as ecore_evas_animator_tick() already
does with it. It must come from the clock of ecore_time_get(), not be
later than the call and not go backwards, as timers and animators read
it. A value that is not finite and positive, or is later than the call,
is logged and the tick ignored: ecore_loop_time_set() would refuse a
future time with a message on stderr only, take a NaN, and leave the
frame with a time that the animators never saw.
ecore_evas_gl_drm_frame_time_get() gives the time back on the frame,
taken when the frame is made. The canvas that ticks itself gives the
loop time of its timer.
A tick leads to the one render the main loop tries after it. A tick that
finds nothing to draw gives its time to no frame, so a later frame that
no tick led to cannot carry it. Those frames carry ecore_time_get() as
they are made: the first frame, which the main loop draws at its first
idle after the canvas is registered, shown or not, with no tick (a
canvas shown later draws its first visible frame on a tick); every frame
when ECORE_EVAS_RENDER_NOSYNC is set; and the frame of
ecore_evas_manual_render(), whatever the ticks of its animators, the
simplest definition that stays true.
The time says which tick the frame was drawn for, not what it shows: a
frame whose time is after an input does not prove that the input is in
it. The "drm" interface goes to version 4 for the new signature and the
time in the frame.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
---
src/lib/ecore_evas/Ecore_Evas.h | 44 +++-
src/lib/ecore_evas/ecore_evas.c | 27 +-
src/lib/ecore_evas/ecore_evas_drm.h | 3 +-
.../ecore_evas/engines/drm/ecore_evas_drm.c | 43 +++-
src/tests/ecore/ecore_test_ecore_evas_gl_drm.c | 275 +++++++++++++++++++--
5 files changed, 363 insertions(+), 29 deletions(-)
diff --git a/src/lib/ecore_evas/Ecore_Evas.h b/src/lib/ecore_evas/Ecore_Evas.h
index 18b767c07a..8cfad8ee28 100644
--- a/src/lib/ecore_evas/Ecore_Evas.h
+++ b/src/lib/ecore_evas/Ecore_Evas.h
@@ -1952,6 +1952,15 @@ EAPI void ecore_evas_gl_drm_tick_callbacks_set(Ecore_Evas *ee,
* when the main loop next goes idle.
*
* @param ee The canvas. A canvas of another engine is logged and ignored.
+ * @param loop_time The time of the tick, in seconds of the clock of
+ * ecore_time_get() (@c CLOCK_MONOTONIC). It becomes the loop time of
+ * the process, ecore_loop_time_get(), for this tick, so it must be
+ * in that clock, must not be later than the time of the call and
+ * must not go backwards from one call to the next: the timers and the
+ * animators of the process read it. A value that is not a finite
+ * positive number, or is later than the time of the call, is logged
+ * and the tick ignored. The frame this tick leads to carries it, see
+ * ecore_evas_gl_drm_frame_time_get().
*
* 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()
@@ -1963,7 +1972,7 @@ EAPI void ecore_evas_gl_drm_tick_callbacks_set(Ecore_Evas *ee,
* @see ecore_evas_gl_drm_tick_callbacks_set()
* @since 1.30
*/
-EAPI void ecore_evas_gl_drm_tick(Ecore_Evas *ee);
+EAPI void ecore_evas_gl_drm_tick(Ecore_Evas *ee, double loop_time);
/**
* @brief Gives a frame back to the canvas that drew it.
@@ -2016,6 +2025,39 @@ EAPI void ecore_evas_gl_drm_frame_size_get(const Ecore_Evas_Gl_Drm_Frame *frame,
*/
EAPI uint64_t ecore_evas_gl_drm_frame_buffer_id_get(const Ecore_Evas_Gl_Drm_Frame *frame);
+/**
+ * @brief Gets the time of the tick a frame was drawn for.
+ *
+ * @param frame The frame.
+ * @return A time in seconds of the clock of ecore_time_get(), never zero
+ * for a valid frame.
+ *
+ * It is the @c loop_time of the ecore_evas_gl_drm_tick() call that led to
+ * the render, or, when the canvas ticks itself because the consumer set no
+ * ecore_evas_gl_drm_tick_callbacks_set(), the loop time of its tick. A
+ * consumer can use it to tell how long an input waited for the tick, and
+ * how long the frame took from the tick to the callback, or as the time at
+ * which the frame is to be presented.
+ *
+ * A tick leads to the one render that the main loop tries after it, and
+ * to no other: a tick that finds nothing to draw gives its time to no
+ * frame. A frame that no tick led to carries the time at which the canvas
+ * made it, ecore_time_get() read then. That is the first frame, which the
+ * main loop draws at its first idle after the canvas is registered, with no
+ * tick, whether or not the canvas is shown; a canvas shown later draws its
+ * first visible frame on a tick. It is also every frame when the environment
+ * has @c ECORE_EVAS_RENDER_NOSYNC, and the frame of
+ * ecore_evas_manual_render(), whatever the ticks of its animators.
+ *
+ * It says when the frame was drawn for, not what it shows: a frame whose
+ * time is later than an input does not prove that the input is in it, and
+ * a tick that comes after something changed may leave it to the next frame
+ * when the canvas could not draw it yet.
+ *
+ * @since 1.30
+ */
+EAPI double ecore_evas_gl_drm_frame_time_get(const Ecore_Evas_Gl_Drm_Frame *frame);
+
/**
* @typedef Ecore_Evas_Gl_Drm_Dmabuf
* @brief How the buffer of a frame is laid out as a dmabuf.
diff --git a/src/lib/ecore_evas/ecore_evas.c b/src/lib/ecore_evas/ecore_evas.c
index e77847371a..78e0c1d047 100644
--- a/src/lib/ecore_evas/ecore_evas.c
+++ b/src/lib/ecore_evas/ecore_evas.c
@@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
+#include <math.h>
#include <sys/types.h>
#include <errno.h>
#include <sys/stat.h>
@@ -4699,7 +4700,7 @@ _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))
+ if ((!iface) || (iface->base.version < 4))
{
ERR("Ecore_Evas %p (engine: %s) was not made by "
"ecore_evas_gl_drm_offscreen_new()", ee, ee->driver);
@@ -4742,16 +4743,28 @@ ecore_evas_gl_drm_tick_callbacks_set(Ecore_Evas *ee,
}
EAPI void
-ecore_evas_gl_drm_tick(Ecore_Evas *ee)
+ecore_evas_gl_drm_tick(Ecore_Evas *ee, double loop_time)
{
Ecore_Evas_Interface_Drm *iface;
ECORE_EVAS_CHECK(ee);
+ /* ecore_loop_time_set() refuses a time later than now, with a message
+ * on stderr only, and takes a NaN or an infinity: the frame must carry
+ * the loop time that the animators see. */
+ if ((!isfinite(loop_time)) || (loop_time <= 0.0) ||
+ (loop_time > ecore_time_get()))
+ {
+ ERR("Ecore_Evas %p ticked with %f, which is not a time of the "
+ "ecore_time_get() clock that is not later than now: ignored",
+ ee, loop_time);
+ return;
+ }
+
iface = _ecore_evas_gl_drm_offscreen_interface_get(ee);
if (!iface) return;
- iface->tick(ee);
+ iface->tick(ee, loop_time);
}
EAPI void
@@ -4781,6 +4794,14 @@ ecore_evas_gl_drm_frame_buffer_id_get(const Ecore_Evas_Gl_Drm_Frame *frame)
return frame->buffer_id;
}
+EAPI double
+ecore_evas_gl_drm_frame_time_get(const Ecore_Evas_Gl_Drm_Frame *frame)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(frame, 0.0);
+
+ return frame->time;
+}
+
EAPI Eina_Bool
ecore_evas_gl_drm_frame_dmabuf_get(const Ecore_Evas_Gl_Drm_Frame *frame,
Ecore_Evas_Gl_Drm_Dmabuf *dmabuf)
diff --git a/src/lib/ecore_evas/ecore_evas_drm.h b/src/lib/ecore_evas/ecore_evas_drm.h
index bb5f2e8da4..3b17e7992e 100644
--- a/src/lib/ecore_evas/ecore_evas_drm.h
+++ b/src/lib/ecore_evas/ecore_evas_drm.h
@@ -16,7 +16,7 @@ struct _Ecore_Evas_Interface_Drm
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);
+ void (*tick)(Ecore_Evas *ee, double loop_time);
};
/* What the library reads of a frame; the module that made it puts it
@@ -26,6 +26,7 @@ struct _Ecore_Evas_Gl_Drm_Frame
void (*release)(Ecore_Evas_Gl_Drm_Frame *frame);
Eina_Bool (*dmabuf_get)(const Ecore_Evas_Gl_Drm_Frame *frame, Ecore_Evas_Gl_Drm_Dmabuf *dmabuf);
uint64_t buffer_id;
+ double time;
int w, h;
};
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 456d63af04..96e8e4055e 100644
--- a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
+++ b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
@@ -1227,6 +1227,9 @@ struct _Ecore_Evas_Gl_Drm_Offscreen_Data
uint64_t *modifiers;
/* The size of the last frame given to frame_func */
int frame_w, frame_h;
+ /* The loop time of the last tick, which the render that follows it
+ * carries if tick_unframed */
+ double tick_time;
/* 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;
@@ -1235,6 +1238,8 @@ struct _Ecore_Evas_Gl_Drm_Offscreen_Data
Eina_Bool throttled : 1;
/* The library asked for ticks, and has not said it is done */
Eina_Bool ticking : 1;
+ /* A tick came and the render it leads to was not tried yet */
+ Eina_Bool tick_unframed : 1;
};
/* Made for each frame the engine delivers, and freed when the consumer
@@ -1499,6 +1504,12 @@ _offscreen_frame_cb(void *data, Evas_Engine_GL_Drm_Frame *engine_frame,
frame->base.release = _offscreen_frame_release;
frame->base.dmabuf_get = _offscreen_frame_dmabuf_get;
frame->base.buffer_id = engine_frame->id;
+ if (odata->tick_unframed)
+ {
+ frame->base.time = odata->tick_time;
+ }
+ else
+ frame->base.time = ecore_time_get();
frame->base.w = engine_frame->w;
frame->base.h = engine_frame->h;
frame->engine_frame = engine_frame;
@@ -1575,10 +1586,20 @@ _offscreen_move_resize(Ecore_Evas *ee, int x, int y, int w, int h)
_offscreen_unthrottle(ee);
}
+static void
+_offscreen_tick_run(Ecore_Evas *ee, double loop_time)
+{
+ Ecore_Evas_Gl_Drm_Offscreen_Data *odata = ee->engine.data;
+
+ odata->tick_time = loop_time;
+ odata->tick_unframed = EINA_TRUE;
+ ecore_evas_animator_tick(ee, NULL, loop_time);
+}
+
static Eina_Bool
_offscreen_tick_timer_cb(void *data)
{
- ecore_evas_animator_tick(data, NULL, ecore_loop_time_get());
+ _offscreen_tick_run(data, ecore_loop_time_get());
return ECORE_CALLBACK_RENEW;
}
@@ -1655,13 +1676,24 @@ _offscreen_tick_callbacks_set(Ecore_Evas *ee, Ecore_Evas_Gl_Drm_Tick_Cb begin,
}
static void
-_offscreen_tick(Ecore_Evas *ee)
+_offscreen_tick(Ecore_Evas *ee, double loop_time)
{
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());
+ _offscreen_tick_run(ee, loop_time);
+}
+
+/* Called by the main loop after each render it tried, whether or not it
+ * drew: the tick it followed has had its render, and a later frame, such as
+ * the one of a change that no tick led to, must not carry its time. */
+static void
+_offscreen_evas_changed(Ecore_Evas *ee, Eina_Bool changed EINA_UNUSED)
+{
+ Ecore_Evas_Gl_Drm_Offscreen_Data *odata = ee->engine.data;
+
+ odata->tick_unframed = EINA_FALSE;
}
static void
@@ -1743,6 +1775,7 @@ _offscreen_pointer_xy_get(const Ecore_Evas *ee, Evas_Coord *x, Evas_Coord *y)
static const Ecore_Evas_Engine_Func _ecore_evas_gl_drm_offscreen_engine_func =
{
.fn_free = _offscreen_free,
+ .fn_evas_changed = _offscreen_evas_changed,
.fn_move = _drm_move,
.fn_resize = _offscreen_resize,
.fn_move_resize = _offscreen_move_resize,
@@ -1830,8 +1863,8 @@ ecore_evas_gl_drm_offscreen_new_internal(const char *render_node, int w, int h,
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;
+ /* 3 has the functions of a canvas with no device, 4 the time of a frame */
+ iface->base.version = 4;
iface->frame_callbacks_set = _offscreen_frame_callbacks_set;
iface->tick_callbacks_set = _offscreen_tick_callbacks_set;
iface->tick = _offscreen_tick;
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 b1455e7c4b..4a2eae24d3 100644
--- a/src/tests/ecore/ecore_test_ecore_evas_gl_drm.c
+++ b/src/tests/ecore/ecore_test_ecore_evas_gl_drm.c
@@ -14,6 +14,7 @@
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
+#include <math.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
@@ -83,6 +84,13 @@ struct _Test_Canvas
Eina_Rectangle damage[DAMAGE_MAX];
Eina_Rectangle mover_rect;
+ /* The time of the last frame, and what ecore_time_get() said as it came */
+ double frame_time;
+ double frame_received;
+ /* Before the canvas was shown */
+ double shown_after;
+ /* The loop time the animators saw at their last tick */
+ double animator_loop_time;
unsigned int held_count;
unsigned int id_count;
@@ -102,6 +110,8 @@ struct _Test_Canvas
int frame_w, frame_h;
Eina_Bool hold : 1;
+ /* The animator of the canvas changes nothing */
+ Eina_Bool animator_quiet : 1;
Eina_Bool release_in_buffer_free : 1;
Eina_Bool ticks_change : 1;
Eina_Bool damage_overflow : 1;
@@ -199,6 +209,8 @@ _frame_cb(void *data, Ecore_Evas *ee, Ecore_Evas_Gl_Drm_Frame *frame,
if ((i == c->id_count) && (i < HELD_MAX)) c->ids[c->id_count++] = id;
ecore_evas_gl_drm_frame_size_get(frame, &c->frame_w, &c->frame_h);
+ c->frame_time = ecore_evas_gl_drm_frame_time_get(frame);
+ c->frame_received = ecore_time_get();
if (damage_count > DAMAGE_MAX)
{
c->damage_overflow = EINA_TRUE;
@@ -405,6 +417,7 @@ _canvas_open_on(Test_Canvas *c, const char *node)
c->node = strdup(node);
ecore_evas_gl_drm_frame_callbacks_set(c->ee, _frame_cb, _buffer_free_cb, c);
_scene_build(c);
+ c->shown_after = ecore_time_get();
ecore_evas_show(c->ee);
return EINA_TRUE;
}
@@ -2195,7 +2208,8 @@ _animator_tick_cb(void *data, const Efl_Event *ev EINA_UNUSED)
Test_Canvas *c = data;
c->animator_ticks++;
- _mover_step(c);
+ c->animator_loop_time = ecore_loop_time_get();
+ if (!c->animator_quiet) _mover_step(c);
}
/* What animates on the canvas, so that it wants ticks until it is removed */
@@ -2442,7 +2456,7 @@ EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_consumer_ticks)
for (i = 0; i < 5; i++)
{
frames = c->frame_count;
- ecore_evas_gl_drm_tick(c->ee);
+ ecore_evas_gl_drm_tick(c->ee, ecore_time_get());
_frames_wait(c, 1);
ck_assert_uint_eq(c->frame_count, frames + 1);
ck_assert_uint_eq(c->animator_ticks, i + 1);
@@ -2450,9 +2464,9 @@ EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_consumer_ticks)
/* 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);
+ ecore_evas_gl_drm_tick(c->ee, ecore_time_get());
+ ecore_evas_gl_drm_tick(c->ee, ecore_time_get());
+ ecore_evas_gl_drm_tick(c->ee, ecore_time_get());
_turn(c);
ck_assert_uint_eq(c->animator_ticks, 8);
ck_assert_uint_eq(c->frame_count, frames + 1);
@@ -2465,17 +2479,17 @@ EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_consumer_ticks)
/* A tick nobody asked for does nothing, whatever waits to be drawn */
_mover_step(c);
- ecore_evas_gl_drm_tick(c->ee);
+ ecore_evas_gl_drm_tick(c->ee, ecore_time_get());
_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);
+ ecore_evas_gl_drm_tick(c->ee, ecore_time_get());
_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);
+ ecore_evas_gl_drm_tick(c->ee, ecore_time_get());
_turn(c);
ck_assert_uint_eq(c->end_calls, 2);
ck_assert_uint_eq(c->frame_count, frames + 1);
@@ -2499,9 +2513,9 @@ EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_tick_without_consumer)
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);
+ ecore_evas_gl_drm_tick(c->ee, ecore_time_get());
+ ecore_evas_gl_drm_tick(c->ee, ecore_time_get());
+ ecore_evas_gl_drm_tick(c->ee, ecore_time_get());
ck_assert_uint_eq(c->animator_ticks, 0);
_animator_del(c);
ck_assert_uint_eq(c->frame_count, frames);
@@ -2534,7 +2548,7 @@ EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_pace_switched)
_ticks_idle(c, 6);
ck_assert_uint_eq(c->frame_count, frames);
- ecore_evas_gl_drm_tick(c->ee);
+ ecore_evas_gl_drm_tick(c->ee, ecore_time_get());
_frames_wait(c, 1);
ck_assert_uint_eq(c->frame_count, frames + 1);
@@ -2570,7 +2584,7 @@ EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_consumer_replaced)
ck_assert_uint_eq(c->begin_calls, 2);
frames = c->frame_count;
- ecore_evas_gl_drm_tick(c->ee);
+ ecore_evas_gl_drm_tick(c->ee, ecore_time_get());
_frames_wait(c, 1);
ck_assert_uint_eq(c->frame_count, frames + 1);
@@ -2641,7 +2655,7 @@ EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_consumer_throttled)
{
_mover_step(c);
_turn(c);
- ecore_evas_gl_drm_tick(c->ee);
+ ecore_evas_gl_drm_tick(c->ee, ecore_time_get());
_turn(c);
if (c->end_calls) break;
}
@@ -2662,7 +2676,7 @@ EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_consumer_throttled)
for (i = 0; i < 5; i++)
{
_turn(c);
- ecore_evas_gl_drm_tick(c->ee);
+ ecore_evas_gl_drm_tick(c->ee, ecore_time_get());
}
ck_assert_uint_eq(c->begin_calls, begins);
ck_assert_uint_eq(c->end_calls, begins);
@@ -2672,7 +2686,7 @@ EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_consumer_throttled)
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);
+ ecore_evas_gl_drm_tick(c->ee, ecore_time_get());
_frames_wait(c, 1);
ck_assert_uint_eq(c->frame_count, frames + 1);
ck_assert(_damage_covers(c, &c->mover_rect));
@@ -2700,7 +2714,7 @@ EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_consumer_hidden)
ck_assert_uint_eq(c->begin_calls, 1);
frames = c->frame_count;
- ecore_evas_gl_drm_tick(c->ee);
+ ecore_evas_gl_drm_tick(c->ee, ecore_time_get());
_turn(c);
ck_assert_uint_eq(c->frame_count, frames);
ck_assert_uint_eq(c->end_calls, 1);
@@ -2708,7 +2722,7 @@ EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_consumer_hidden)
ecore_evas_show(c->ee);
_turn(c);
ck_assert_uint_eq(c->begin_calls, 2);
- ecore_evas_gl_drm_tick(c->ee);
+ ecore_evas_gl_drm_tick(c->ee, ecore_time_get());
_frames_wait(c, 1);
ck_assert(_damage_is_all(c));
@@ -2749,6 +2763,223 @@ EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_consumer_alone)
}
EFL_END_TEST
+/* The frame has the time of the tick the consumer gave, and the animators
+ * see it as the loop time of the process. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_frame_time_consumer)
+{
+ Test_Canvas *c = _canvas_new();
+ double first, second;
+
+ if (!c) return;
+
+ _frames_wait(c, 1);
+ _consumer_set(c);
+ _animator_add(c);
+ _turn(c);
+
+ first = ecore_time_get();
+ ecore_evas_gl_drm_tick(c->ee, first);
+ _frames_wait(c, 1);
+ ck_assert(c->frame_time == first);
+ ck_assert(c->animator_loop_time == first);
+
+ second = ecore_time_get();
+ ck_assert(second > first);
+ ecore_evas_gl_drm_tick(c->ee, second);
+ _frames_wait(c, 1);
+ ck_assert(c->frame_time == second);
+ ck_assert(c->animator_loop_time == second);
+
+ _animator_del(c);
+ _consumer_unset(c);
+ _canvas_free(c);
+}
+EFL_END_TEST
+
+/* A tick that is not a time of the clock, or is not yet one, is refused in
+ * the open, and is not the loop time of the process. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_tick_time_invalid)
+{
+ Test_Canvas *c = _canvas_new();
+ double bad[] = { 0.0, -1.0, NAN, INFINITY, -INFINITY, 0.0 };
+ double loop_time;
+ unsigned int frames;
+ unsigned int i;
+
+ if (!c) return;
+
+ _frames_wait(c, 1);
+ _consumer_set(c);
+ _animator_add(c);
+ _turn(c);
+ frames = c->frame_count;
+ loop_time = ecore_loop_time_get();
+
+ for (i = 0; i < EINA_C_ARRAY_LENGTH(bad); i++)
+ {
+ double t = bad[i];
+
+ /* The last one is later than the call */
+ if (i == EINA_C_ARRAY_LENGTH(bad) - 1) t = ecore_time_get() + 0.020;
+ _warnings = 0;
+ ecore_evas_gl_drm_tick(c->ee, t);
+ ck_assert_uint_eq(_warnings, 1);
+ ck_assert_ptr_nonnull(strstr(_last_log, "is not a time"));
+ ck_assert(ecore_loop_time_get() == loop_time);
+ ck_assert_uint_eq(c->animator_ticks, 0);
+ }
+ _warnings = 0;
+ _turn(c);
+ ck_assert_uint_eq(c->frame_count, frames);
+
+ /* Nothing was spoiled */
+ ecore_evas_gl_drm_tick(c->ee, ecore_time_get());
+ _frames_wait(c, 1);
+ ck_assert_uint_eq(c->animator_ticks, 1);
+ ck_assert(c->frame_time == c->animator_loop_time);
+
+ _animator_del(c);
+ _consumer_unset(c);
+ _canvas_free(c);
+}
+EFL_END_TEST
+
+/* The canvas that ticks itself gives the frame the loop time of its timer
+ * tick, which the animators saw. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_frame_time_timer)
+{
+ Test_Canvas *c = _canvas_new();
+ double previous;
+ int i;
+
+ if (!c) return;
+
+ _frames_wait(c, 1);
+ previous = ecore_time_get();
+ _animator_add(c);
+ for (i = 0; i < 3; i++)
+ {
+ _frames_wait(c, 1);
+ ck_assert(c->frame_time == c->animator_loop_time);
+ ck_assert(c->frame_time > previous);
+ previous = c->frame_time;
+ }
+ _animator_del(c);
+
+ _canvas_free(c);
+}
+EFL_END_TEST
+
+/* The first frame has no tick before it. This only bounds its time: it is
+ * made between the show and its delivery, and a time read at either end
+ * cannot say more. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_frame_time_first)
+{
+ Test_Canvas *c = _canvas_new();
+
+ if (!c) return;
+
+ c->hold = EINA_TRUE;
+ _frames_wait(c, 1);
+ ck_assert(c->frame_time >= c->shown_after);
+ ck_assert(c->frame_time <= c->frame_received);
+ _canvas_free(c);
+
+ /* The consumer paces and has not ticked: it is the same */
+ c = _canvas_new();
+ if (!c) return;
+ _consumer_set(c);
+ _frames_wait(c, 1);
+ ck_assert(c->frame_time >= c->shown_after);
+ ck_assert(c->frame_time <= c->frame_received);
+
+ _consumer_unset(c);
+ _canvas_free(c);
+}
+EFL_END_TEST
+
+/* A tick that finds nothing to draw gives its time to no frame: the frame
+ * that a manual render makes later is the time it was made. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_frame_time_stale_manual)
+{
+ Test_Canvas *c = _canvas_new();
+ double tick, after;
+ unsigned int frames;
+
+ if (!c) return;
+
+ _frames_wait(c, 1);
+ c->animator_quiet = EINA_TRUE;
+ _consumer_set(c);
+ _animator_add(c);
+ _turn(c);
+
+ frames = c->frame_count;
+ tick = ecore_time_get();
+ ecore_evas_gl_drm_tick(c->ee, tick);
+ _turn(c);
+ ck_assert_uint_eq(c->frame_count, frames);
+ ck_assert_uint_eq(c->animator_ticks, 1);
+
+ after = ecore_time_get();
+ ecore_evas_manual_render_set(c->ee, EINA_TRUE);
+ _mover_step(c);
+ ecore_evas_manual_render(c->ee);
+ ck_assert_uint_eq(c->frame_count, frames + 1);
+ ck_assert(c->frame_time != tick);
+ ck_assert(c->frame_time >= after);
+ ck_assert(c->frame_time <= c->frame_received);
+
+ _animator_del(c);
+ _consumer_unset(c);
+ _canvas_free(c);
+}
+EFL_END_TEST
+
+/* With ECORE_EVAS_RENDER_NOSYNC a change is drawn with no tick: the tick
+ * that found nothing before it gives it nothing. The library reads the
+ * variable once and keeps it for the process, so the test is not run where
+ * the suite does not fork for each test. */
+EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_frame_time_stale_nosync)
+{
+ Test_Canvas *c;
+ double tick, after;
+ unsigned int frames;
+
+ if (eina_streq(getenv("CK_FORK"), "no")) return;
+
+ ck_assert_int_eq(setenv("ECORE_EVAS_RENDER_NOSYNC", "1", 1), 0);
+ c = _canvas_new();
+ unsetenv("ECORE_EVAS_RENDER_NOSYNC");
+ if (!c) return;
+
+ _frames_wait(c, 1);
+ c->animator_quiet = EINA_TRUE;
+ _consumer_set(c);
+ _animator_add(c);
+ _turn(c);
+
+ frames = c->frame_count;
+ tick = ecore_time_get();
+ ecore_evas_gl_drm_tick(c->ee, tick);
+ _turn(c);
+ ck_assert_uint_eq(c->animator_ticks, 1);
+ ck_assert_uint_eq(c->frame_count, frames);
+
+ after = ecore_time_get();
+ _mover_step(c);
+ _frames_wait(c, 1);
+ ck_assert_uint_eq(c->animator_ticks, 1);
+ ck_assert(c->frame_time != tick);
+ ck_assert(c->frame_time >= after);
+ ck_assert(c->frame_time <= c->frame_received);
+
+ _animator_del(c);
+ _consumer_unset(c);
+ _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)
{
@@ -2763,7 +2994,7 @@ EFL_START_TEST(ecore_test_ecore_evas_gl_drm_offscreen_tick_other_engine)
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);
+ ecore_evas_gl_drm_tick(ee, ecore_time_get());
ck_assert_uint_eq(_warnings, 2);
ck_assert_ptr_nonnull(strstr(_last_log, "was not made by"));
@@ -2821,6 +3052,12 @@ ecore_test_ecore_evas_gl_drm(TCase *tc)
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_frame_time_consumer);
+ tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_tick_time_invalid);
+ tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_frame_time_timer);
+ tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_frame_time_first);
+ tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_frame_time_stale_manual);
+ tcase_add_test(tc, ecore_test_ecore_evas_gl_drm_offscreen_frame_time_stale_nosync);
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);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.