e_comp: added new E_EVENT_COMPOSITOR_FPS_UPDATE event type accepted/tizen/mobile/20150816.062243 accepted/tizen/tv/20150816.062355 accepted/tizen/wearable/20150816.062546 submit/tizen/20150815.135314
authorGwanglim Lee <gl77.lee@samsung.com>
Sat, 15 Aug 2015 13:52:49 +0000 (22:52 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Sat, 15 Aug 2015 13:52:49 +0000 (22:52 +0900)
Change-Id: I4f36c584a024847bc9359f1e83be6dd0b15d1004

src/bin/e_comp.c
src/bin/e_comp.h

index efe2167..f07ffa0 100644 (file)
@@ -39,6 +39,7 @@ static int _e_comp_log_dom = -1;
 EAPI int E_EVENT_COMPOSITOR_RESIZE = -1;
 EAPI int E_EVENT_COMPOSITOR_DISABLE = -1;
 EAPI int E_EVENT_COMPOSITOR_ENABLE = -1;
+EAPI int E_EVENT_COMPOSITOR_FPS_UPDATE = -1;
 
 //////////////////////////////////////////////////////////////////////////
 #undef DBG
@@ -436,6 +437,35 @@ _e_comp_cb_update(E_Comp *c)
         evas_object_resize(c->fps_bg, w, h);
         evas_object_move(c->fps_fg, x + 4, y + 4);
      }
+   else
+     {
+        if (c->calc_fps)
+          {
+             double fps = 0.0, dt;
+             double t = ecore_time_get();
+             int i, avg_range = 60;
+
+             dt = t - c->frametimes[avg_range - 1];
+
+             if (dt > 0.0) fps = (double)avg_range / dt;
+             else fps = 0.0;
+
+             if (fps > 60.0) fps = 60.0;
+             if (fps < 0.0) fps = 0.0;
+
+             for (i = avg_range; i >= 1; i--)
+               c->frametimes[i] = c->frametimes[i - 1];
+
+             c->frametimes[0] = t;
+             c->frameskip++;
+             if (c->frameskip >= avg_range)
+               {
+                  c->frameskip = 0;
+                                 c->fps = fps;
+                                 ecore_event_add(E_EVENT_COMPOSITOR_FPS_UPDATE, NULL, NULL, NULL);
+               }
+          }
+     }
    if (conf->lock_fps)
      {
         DBG("MANUAL RENDER...");
@@ -964,6 +994,7 @@ e_comp_init(void)
    E_EVENT_COMP_OBJECT_ADD = ecore_event_type_new();
    E_EVENT_COMPOSITOR_DISABLE = ecore_event_type_new();
    E_EVENT_COMPOSITOR_ENABLE = ecore_event_type_new();
+   E_EVENT_COMPOSITOR_FPS_UPDATE = ecore_event_type_new();
 
    ignores = eina_hash_pointer_new(NULL);
 
index ca49c0e..71bd237 100644 (file)
@@ -58,6 +58,7 @@ typedef enum _E_Layer
 
 extern EAPI int E_EVENT_COMPOSITOR_DISABLE;
 extern EAPI int E_EVENT_COMPOSITOR_ENABLE;
+extern EAPI int E_EVENT_COMPOSITOR_FPS_UPDATE;
 
 struct _E_Comp
 {
@@ -116,6 +117,7 @@ struct _E_Comp
    int             animating;
    double          frametimes[122];
    int             frameskip;
+   double          fps;
 
    int             nocomp_override; //number of times nocomp override has been requested
    Ecore_Window block_win;
@@ -138,6 +140,7 @@ struct _E_Comp
    Eina_Bool       nocomp_want : 1;
    Eina_Bool       saver : 1;
    Eina_Bool       shape_queue_blocked : 1;
+   Eina_Bool       calc_fps : 1;
 };