e_hwc_windows: implement the fps 08/194708/3
authorSooChan Lim <sc1.lim@samsung.com>
Fri, 7 Dec 2018 04:45:13 +0000 (13:45 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Sun, 16 Dec 2018 07:54:33 +0000 (07:54 +0000)
Change-Id: Ibf55d9097de11904df0a2b6a2f020a925c1da91c

src/bin/e_hwc.h
src/bin/e_hwc_windows.c
src/bin/e_hwc_windows.h
src/bin/e_info_server.c

index 2fa9b1f..c165b3a 100644 (file)
@@ -77,6 +77,15 @@ struct _E_Hwc
    Eina_Bool             pp_output_commit;
    E_Hwc_Window_Commit_Data  *pp_output_commit_data;
    Eina_Rectangle        pp_rect;
+
+   /* for fps */
+   double               fps;
+   double               old_fps;
+   double               frametimes[122];
+   double               time;
+   double               lapse;
+   int                  cframes;
+   int                  flapse;
 };
 
 EINTERN E_Hwc        *e_hwc_new(E_Output *output);
index 7e3e22d..8b53fcb 100644 (file)
@@ -51,6 +51,35 @@ static uint64_t rendered_windows_key;
 static Eina_Bool _e_hwc_windows_pp_output_data_commit(E_Hwc *hwc, E_Hwc_Window_Commit_Data *data);
 static Eina_Bool _e_hwc_windows_pp_window_commit(E_Hwc *hwc, E_Hwc_Window *hwc_window);
 
+static void
+_e_hwc_windows_update_fps(E_Hwc *hwc)
+{
+   if (e_comp->calc_fps)
+     {
+        double dt;
+        double tim = ecore_time_get();
+
+        dt = tim - hwc->frametimes[0];
+        hwc->frametimes[0] = tim;
+
+        hwc->time += dt;
+        hwc->cframes++;
+
+        if (hwc->lapse == 0.0)
+          {
+             hwc->lapse = tim;
+             hwc->flapse = hwc->cframes;
+          }
+        else if ((tim - hwc->lapse) >= 0.5)
+          {
+             hwc->fps = (hwc->cframes - hwc->flapse) / (tim - hwc->lapse);
+             hwc->lapse = tim;
+             hwc->flapse = hwc->cframes;
+             hwc->time = 0.0;
+          }
+     }
+}
+
 static E_Hwc_Mode
 _e_hwc_windows_hwc_mode_update(E_Hwc *hwc, int num_client, int num_device, int num_video)
 {
@@ -1930,6 +1959,8 @@ e_hwc_windows_commit(E_Hwc *hwc)
      }
    else
      {
+        _e_hwc_windows_update_fps(hwc);
+
         error = tdm_hwc_commit(hwc->thwc, 0, _e_hwc_windows_commit_handler, hwc);
         if (error != TDM_ERROR_NONE)
           {
@@ -2102,3 +2133,21 @@ e_hwc_windows_rendered_window_add(E_Hwc_Window *hwc_window)
    EHWSTRACE(" add ehw:%p ts:%p to the render_list -- {%25s}.", ec, hwc_window,
             hwc_window->buffer.tsurface, e_hwc_window_name_get(hwc_window));
 }
+
+EINTERN Eina_Bool
+e_hwc_windows_fps_get(E_Hwc *hwc, double *fps)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hwc, EINA_FALSE);
+
+   if (hwc->old_fps == hwc->fps)
+     return EINA_FALSE;
+
+   if (hwc->fps > 0.0)
+     {
+        *fps = hwc->fps;
+        hwc->old_fps = hwc->fps;
+        return EINA_TRUE;
+     }
+
+   return EINA_FALSE;
+}
index 43cce17..6c18fc2 100644 (file)
@@ -11,6 +11,7 @@ EINTERN void                 e_hwc_windows_rendered_window_add(E_Hwc_Window *hwc
 EINTERN Eina_Bool            e_hwc_windows_pp_commit_possible_check(E_Hwc *hwc);
 EINTERN Eina_Bool            e_hwc_windows_zoom_set(E_Hwc *hwc, Eina_Rectangle *rect);
 EINTERN void                 e_hwc_windows_zoom_unset(E_Hwc *hwc);
+EINTERN Eina_Bool            e_hwc_windows_fps_get(E_Hwc *hwc, double *fps);
 
 #endif
 #endif
index 4793f8a..ec1274b 100644 (file)
@@ -4322,22 +4322,41 @@ _msg_layer_fps_append(Eldbus_Message_Iter *iter)
 
         strncpy(output_name, output->id, sizeof(char)*30);
 
-        EINA_LIST_FOREACH(output->planes, plane_l, plane)
+        if (output->hwc)
           {
-             if (!plane) continue;
-             if (!e_plane_fps_get(plane, &fps)) continue;
+             if (!e_hwc_windows_fps_get(output->hwc, &fps)) continue;
 
              Eldbus_Message_Iter* struct_of_layer_fps;
 
              eldbus_message_iter_arguments_append(array_of_layer_fps, "("VALUE_TYPE_FOR_LAYER_FPS")", &struct_of_layer_fps);
 
              eldbus_message_iter_arguments_append
-               (struct_of_layer_fps, VALUE_TYPE_FOR_LAYER_FPS,
-                 output_name,
-                 plane->zpos,
-                 plane->fps);
+                (struct_of_layer_fps, VALUE_TYPE_FOR_LAYER_FPS,
+                  output_name,
+                  -999,
+                  fps);
+
+             eldbus_message_iter_container_close(array_of_layer_fps, struct_of_layer_fps);
+          }
+        else
+          {
+             EINA_LIST_FOREACH(output->planes, plane_l, plane)
+               {
+                  if (!plane) continue;
+                  if (!e_plane_fps_get(plane, &fps)) continue;
+
+                  Eldbus_Message_Iter* struct_of_layer_fps;
+
+                  eldbus_message_iter_arguments_append(array_of_layer_fps, "("VALUE_TYPE_FOR_LAYER_FPS")", &struct_of_layer_fps);
 
-            eldbus_message_iter_container_close(array_of_layer_fps, struct_of_layer_fps);
+                  eldbus_message_iter_arguments_append
+                     (struct_of_layer_fps, VALUE_TYPE_FOR_LAYER_FPS,
+                       output_name,
+                       plane->zpos,
+                       plane->fps);
+
+                  eldbus_message_iter_container_close(array_of_layer_fps, struct_of_layer_fps);
+               }
           }
         memset(output_name, 0x0, sizeof(char)*30);
      }