summaryrefslogtreecommitdiff
path: root/src/lib/ecore_evas
diff options
context:
space:
mode:
authorCedric Bail <cedric@osg.samsung.com>2017-11-02 15:21:37 -0700
committerCedric Bail <cedric@osg.samsung.com>2017-11-02 15:26:08 -0700
commite5d1cc731a6ea6d8336b6b887352f7a4e02537ae (patch)
tree1dce2316ff08c16bd421ddd70c16c221fa114fa4 /src/lib/ecore_evas
parent82b0da0c8ab214007c8129b9f7f62d23232d14b0 (diff)
ecore_evas: always find a source for ticking legacy animator.
As we do not know when a window won't be able to tick, and we do not know which window a legacy animator is attached to, we require all windows to tick as often as they can and only generate one tick per loop run. This might need more adjustement especially with multi output.
Diffstat (limited to 'src/lib/ecore_evas')
-rw-r--r--src/lib/ecore_evas/ecore_evas.c105
-rw-r--r--src/lib/ecore_evas/ecore_evas_private.h2
2 files changed, 56 insertions, 51 deletions
diff --git a/src/lib/ecore_evas/ecore_evas.c b/src/lib/ecore_evas/ecore_evas.c
index 12a32179cf..77ab679107 100644
--- a/src/lib/ecore_evas/ecore_evas.c
+++ b/src/lib/ecore_evas/ecore_evas.c
@@ -2641,7 +2641,7 @@ ecore_evas_manual_render_set(Ecore_Evas *ee, Eina_Bool manual_render)
2641{ 2641{
2642 ECORE_EVAS_CHECK(ee); 2642 ECORE_EVAS_CHECK(ee);
2643 ee->manual_render = manual_render; 2643 ee->manual_render = manual_render;
2644 if (!ee->anim_count) return; 2644 if (!ee->animator_count) return;
2645 if (!ee->engine.func->fn_animator_register) return; 2645 if (!ee->engine.func->fn_animator_register) return;
2646 if (!ee->engine.func->fn_animator_unregister) return; 2646 if (!ee->engine.func->fn_animator_unregister) return;
2647 2647
@@ -3054,8 +3054,6 @@ _ecore_evas_fps_debug_rendertime_add(double t)
3054 } 3054 }
3055} 3055}
3056 3056
3057static Ecore_Evas *_general_tick = NULL;
3058
3059EAPI void 3057EAPI void
3060ecore_evas_animator_tick(Ecore_Evas *ee, Eina_Rectangle *viewport, double loop_time) 3058ecore_evas_animator_tick(Ecore_Evas *ee, Eina_Rectangle *viewport, double loop_time)
3061{ 3059{
@@ -3083,23 +3081,22 @@ ecore_evas_animator_tick(Ecore_Evas *ee, Eina_Rectangle *viewport, double loop_t
3083 ecore_evas_animator_tick(subee, NULL, loop_time); 3081 ecore_evas_animator_tick(subee, NULL, loop_time);
3084 } 3082 }
3085 3083
3086 // We are the source of sync for general animator. 3084 // We are a source of sync for general animator.
3087 if (_general_tick == ee) 3085 // Let's only trigger the animator once per rendering loop
3086 if (!ecore_main_loop_animator_ticked_get())
3088 { 3087 {
3089 // Check first we didn't tick during this loop 3088 // FIXME: We might want to enforce also Ecore_Animatore frametime
3090 if (!ecore_main_loop_animator_ticked_get()) 3089 ecore_animator_custom_tick();
3091 ecore_animator_custom_tick();
3092 } 3090 }
3093 3091
3094 DBG("Animator ticked on %p.", ee->evas); 3092 DBG("Animator ticked on %p.", ee->evas);
3095} 3093}
3096 3094
3095// Per Ecore_Evas ticking
3097static void 3096static void
3098_ecore_evas_custom_tick_begin(void *data) 3097ecore_evas_tick_begin(Ecore_Evas *ee)
3099{ 3098{
3100 Ecore_Evas *ee = data; 3099 if (ee->animator_count++ > 0) return;
3101
3102 if (ee->anim_count++ > 0) return;
3103 3100
3104 if (ee->manual_render) 3101 if (ee->manual_render)
3105 { 3102 {
@@ -3110,47 +3107,58 @@ _ecore_evas_custom_tick_begin(void *data)
3110} 3107}
3111 3108
3112static void 3109static void
3113_ecore_evas_custom_tick_end(void *data) 3110ecore_evas_tick_end(Ecore_Evas *ee)
3114{ 3111{
3115 Ecore_Evas *ee = data; 3112 if ((--ee->animator_count) > 0) return;
3116
3117 if ((--ee->anim_count) > 0) return;
3118 3113
3119 if (ee->manual_render) return; 3114 if (ee->manual_render) return;
3120 3115
3121 ee->engine.func->fn_animator_unregister(ee); 3116 ee->engine.func->fn_animator_unregister(ee);
3122} 3117}
3123 3118
3119// Need all possible tick to tick for animator fallback as we don't
3120// know if a window is the source of animator
3121static void
3122_ecore_evas_custom_tick_begin(void *data EINA_UNUSED)
3123{
3124 Ecore_Evas *ee;
3125
3126 EINA_INLIST_FOREACH(ecore_evases, ee)
3127 if (!ee->deleted &&
3128 ee->engine.func->fn_animator_register &&
3129 ee->engine.func->fn_animator_unregister)
3130 ecore_evas_tick_begin(ee);
3131}
3132
3133static void
3134_ecore_evas_custom_tick_end(void *data EINA_UNUSED)
3135{
3136 Ecore_Evas *ee;
3137
3138 EINA_INLIST_FOREACH(ecore_evases, ee)
3139 if (!ee->deleted &&
3140 ee->engine.func->fn_animator_register &&
3141 ee->engine.func->fn_animator_unregister)
3142 ecore_evas_tick_end(ee);
3143}
3144
3124static void 3145static void
3125_ecore_evas_tick_source_find(void) 3146_ecore_evas_tick_source_find(void)
3126{ 3147{
3127 Ecore_Evas *ee; 3148 Ecore_Evas *ee;
3128 Ecore_Evas *standby = NULL; 3149 Eina_Bool source = EINA_FALSE;
3129 3150
3130 _general_tick = NULL;
3131 EINA_INLIST_FOREACH(ecore_evases, ee) 3151 EINA_INLIST_FOREACH(ecore_evases, ee)
3132 if (!ee->deleted && 3152 if (!ee->deleted &&
3133 ee->engine.func->fn_animator_register && 3153 ee->engine.func->fn_animator_register &&
3134 ee->engine.func->fn_animator_unregister) 3154 ee->engine.func->fn_animator_unregister)
3135 { 3155 {
3136 if (ee->anim_count) 3156 source = EINA_TRUE;
3137 { 3157 break;
3138 _general_tick = ee;
3139 break;
3140 }
3141 else
3142 {
3143 standby = ee;
3144 }
3145 } 3158 }
3146 3159
3147 // If no general source is already ticking pick one. 3160 // If no source is available for ticking, fallback to timer.
3148 if (!_general_tick && standby) 3161 if (!source)
3149 {
3150 _general_tick = standby;
3151 }
3152
3153 if (!_general_tick)
3154 { 3162 {
3155 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER); 3163 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
3156 } 3164 }
@@ -3158,9 +3166,9 @@ _ecore_evas_tick_source_find(void)
3158 { 3166 {
3159 // Source set will trigger the previous tick end registered and then the new begin. 3167 // Source set will trigger the previous tick end registered and then the new begin.
3160 // As we don't what was in behind, better first begin and end after source is set. 3168 // As we don't what was in behind, better first begin and end after source is set.
3161 ecore_animator_custom_source_tick_begin_callback_set(_ecore_evas_custom_tick_begin, _general_tick); 3169 ecore_animator_custom_source_tick_begin_callback_set(_ecore_evas_custom_tick_begin, NULL);
3162 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM); 3170 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);
3163 ecore_animator_custom_source_tick_end_callback_set(_ecore_evas_custom_tick_end, _general_tick); 3171 ecore_animator_custom_source_tick_end_callback_set(_ecore_evas_custom_tick_end, NULL);
3164 } 3172 }
3165} 3173}
3166 3174
@@ -3182,22 +3190,19 @@ _check_animator_event_catcher_add(void *data, const Efl_Event *event)
3182 { 3190 {
3183 if (array[i].desc == EFL_EVENT_ANIMATOR_TICK) 3191 if (array[i].desc == EFL_EVENT_ANIMATOR_TICK)
3184 { 3192 {
3185 if (!ee->anim_count) 3193 if (!ee->animator_count)
3186 INF("Setting up animator for %p from '%s' with title '%s'.", ee->evas, ee->driver, ee->prop.title); 3194 INF("Setting up animator for %p from '%s' with title '%s'.", ee->evas, ee->driver, ee->prop.title);
3187 3195
3188 if (ee->engine.func->fn_animator_register && 3196 if (ee->engine.func->fn_animator_register &&
3189 ee->engine.func->fn_animator_unregister) 3197 ee->engine.func->fn_animator_unregister)
3190 { 3198 {
3191 // Backend support per window vsync 3199 // Backend support per window vsync
3192 _ecore_evas_custom_tick_begin(ee); 3200 ecore_evas_tick_begin(ee);
3193
3194 if (ee->anim_count > 0) return;
3195 if (!_general_tick) _general_tick = ee;
3196 } 3201 }
3197 else 3202 else
3198 { 3203 {
3199 // Backend doesn't support per window vsync, fallback to generic support 3204 // Backend doesn't support per window vsync, fallback to generic support
3200 if (ee->anim_count++ > 0) return; 3205 if (ee->animator_count++ > 0) return;
3201 ee->anim = ecore_animator_add(_ecore_evas_animator_fallback, ee); 3206 ee->anim = ecore_animator_add(_ecore_evas_animator_fallback, ee);
3202 } 3207 }
3203 3208
@@ -3219,21 +3224,19 @@ _check_animator_event_catcher_del(void *data, const Efl_Event *event)
3219 { 3224 {
3220 if (array[i].desc == EFL_EVENT_ANIMATOR_TICK) 3225 if (array[i].desc == EFL_EVENT_ANIMATOR_TICK)
3221 { 3226 {
3222 if (ee->anim_count == 1) 3227 if (ee->animator_count == 1)
3223 INF("Unsetting up animator for %p from '%s' titled '%s'.", ee->evas, ee->driver, ee->prop.title); 3228 INF("Unsetting up animator for %p from '%s' titled '%s'.", ee->evas, ee->driver, ee->prop.title);
3224 3229
3225 if (ee->engine.func->fn_animator_register && 3230 if (ee->engine.func->fn_animator_register &&
3226 ee->engine.func->fn_animator_unregister) 3231 ee->engine.func->fn_animator_unregister)
3227 { 3232 {
3228 // Backend support per window vsync 3233 // Backend support per window vsync
3229 _ecore_evas_custom_tick_end(ee); 3234 ecore_evas_tick_end(ee);
3230 if (ee->anim_count > 0) return;
3231 if (_general_tick == ee) _ecore_evas_tick_source_find();
3232 } 3235 }
3233 else 3236 else
3234 { 3237 {
3235 // Backend doesn't support per window vsync, fallback to generic support 3238 // Backend doesn't support per window vsync, fallback to generic support
3236 if (--ee->anim_count > 0) return; 3239 if (--ee->animator_count > 0) return;
3237 ecore_animator_del(ee->anim); 3240 ecore_animator_del(ee->anim);
3238 ee->anim = NULL; 3241 ee->anim = NULL;
3239 } 3242 }
@@ -3261,8 +3264,8 @@ _ecore_evas_register(Ecore_Evas *ee)
3261 3264
3262 _ecore_evas_register_animators(ee); 3265 _ecore_evas_register_animators(ee);
3263 3266
3267 _ecore_evas_tick_source_find();
3264 if (_ecore_evas_render_sync) ee->first_frame = EINA_TRUE; 3268 if (_ecore_evas_render_sync) ee->first_frame = EINA_TRUE;
3265 if (!_general_tick) _ecore_evas_tick_source_find();
3266 if (!ee->engine.func->fn_render) 3269 if (!ee->engine.func->fn_render)
3267 evas_event_callback_priority_add(ee->evas, EVAS_CALLBACK_RENDER_POST, EVAS_CALLBACK_PRIORITY_AFTER, 3270 evas_event_callback_priority_add(ee->evas, EVAS_CALLBACK_RENDER_POST, EVAS_CALLBACK_PRIORITY_AFTER,
3268 _evas_evas_buffer_rendered, ee); 3271 _evas_evas_buffer_rendered, ee);
@@ -3320,13 +3323,15 @@ _ecore_evas_free(Ecore_Evas *ee)
3320 if (ee->refcount > 0) return; 3323 if (ee->refcount > 0) return;
3321 3324
3322 // Stop all vsync first 3325 // Stop all vsync first
3323 if (ee->engine.func->fn_animator_register && 3326 if (ee->animator_count > 0 &&
3327 ee->engine.func->fn_animator_register &&
3324 ee->engine.func->fn_animator_unregister) 3328 ee->engine.func->fn_animator_unregister)
3325 { 3329 {
3326 // Backend support per window vsync 3330 // Backend support per window vsync
3327 ee->engine.func->fn_animator_unregister(ee); 3331 ee->engine.func->fn_animator_unregister(ee);
3328 if (_general_tick == ee) _ecore_evas_tick_source_find(); 3332 _ecore_evas_tick_source_find();
3329 } 3333 }
3334 ee->animator_count = 0;
3330 3335
3331 efl_event_callback_array_del(ee->evas, animator_watch(), ee); 3336 efl_event_callback_array_del(ee->evas, animator_watch(), ee);
3332 if (ee->anim) 3337 if (ee->anim)
diff --git a/src/lib/ecore_evas/ecore_evas_private.h b/src/lib/ecore_evas/ecore_evas_private.h
index b808cb2fed..7b83589347 100644
--- a/src/lib/ecore_evas/ecore_evas_private.h
+++ b/src/lib/ecore_evas/ecore_evas_private.h
@@ -330,7 +330,7 @@ struct _Ecore_Evas
330 330
331 // Animator code 331 // Animator code
332 Ecore_Animator *anim; 332 Ecore_Animator *anim;
333 unsigned int anim_count; 333 unsigned int animator_count;
334 334
335 struct { 335 struct {
336 unsigned char avoid_damage; 336 unsigned char avoid_damage;