From 84fb40bb0a858dfb7108e6a318cd0c4a71df7a21 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 7 Dec 2018 13:45:13 +0900 Subject: [PATCH] e_hwc_windows: implement the fps Change-Id: Ibf55d9097de11904df0a2b6a2f020a925c1da91c --- src/bin/e_hwc.h | 9 +++++++++ src/bin/e_hwc_windows.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ src/bin/e_hwc_windows.h | 1 + src/bin/e_info_server.c | 35 +++++++++++++++++++++++++++-------- 4 files changed, 86 insertions(+), 8 deletions(-) diff --git a/src/bin/e_hwc.h b/src/bin/e_hwc.h index 2fa9b1f..c165b3a 100644 --- a/src/bin/e_hwc.h +++ b/src/bin/e_hwc.h @@ -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); diff --git a/src/bin/e_hwc_windows.c b/src/bin/e_hwc_windows.c index 7e3e22d..8b53fcb 100644 --- a/src/bin/e_hwc_windows.c +++ b/src/bin/e_hwc_windows.c @@ -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; +} diff --git a/src/bin/e_hwc_windows.h b/src/bin/e_hwc_windows.h index 43cce17..6c18fc2 100644 --- a/src/bin/e_hwc_windows.h +++ b/src/bin/e_hwc_windows.h @@ -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 diff --git a/src/bin/e_info_server.c b/src/bin/e_info_server.c index 4793f8a..ec1274b 100644 --- a/src/bin/e_info_server.c +++ b/src/bin/e_info_server.c @@ -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); } -- 2.7.4