From b236cdaa1b21c9b15657b6fb757c31f791aba7cd Mon Sep 17 00:00:00 2001 From: Juyeon Lee Date: Fri, 26 Feb 2016 15:26:24 +0900 Subject: [PATCH] enlightenment_info: added fps Change-Id: Id3665e81a2e19b317b1a6b28662c5913ab018063 --- src/bin/e_comp.c | 32 +++++++++++++++++++++++++++++ src/bin/e_info_client.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ src/bin/e_info_server.c | 32 +++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+) diff --git a/src/bin/e_comp.c b/src/bin/e_comp.c index aeebbcf..2fe444a 100644 --- a/src/bin/e_comp.c +++ b/src/bin/e_comp.c @@ -382,6 +382,11 @@ _e_comp_cb_update(void) Eina_List *l; // static int doframeinfo = -1; + static double rtime = 0.0; + static double rlapse = 0.0; + static int frames = 0; + static int flapse = 0; + if (!e_comp) return EINA_FALSE; TRACE_DS_BEGIN(COMP:UPDATE CB); @@ -467,6 +472,7 @@ _e_comp_cb_update(void) } else { +#if 0 if (e_comp->calc_fps) { double fps = 0.0, dt; @@ -493,6 +499,32 @@ _e_comp_cb_update(void) ecore_event_add(E_EVENT_COMPOSITOR_FPS_UPDATE, NULL, NULL, NULL); } } +#else + if (e_comp->calc_fps) + { + double dt; + double tim = ecore_time_get(); + + dt = tim - e_comp->frametimes[0]; + e_comp->frametimes[0] = tim; + + rtime += dt; + frames++; + + if (rlapse == 0.0) + { + rlapse = tim; + flapse = frames; + } + else if ((tim - rlapse) >= 1.0) + { + e_comp->fps = (frames - flapse) / (tim - rlapse); + rlapse = tim; + flapse = frames; + rtime = 0.0; + } + } +#endif } if (conf->lock_fps) { diff --git a/src/bin/e_info_client.c b/src/bin/e_info_client.c index 8fffd3a..5e74c60 100644 --- a/src/bin/e_info_client.c +++ b/src/bin/e_info_client.c @@ -43,6 +43,8 @@ typedef struct _E_Win_Info static E_Info_Client e_info_client; +static int keepRunning = 1; +static void end_program (int sig); static Eina_Bool _e_info_client_eldbus_message(const char *method, E_Info_Message_Cb cb); static Eina_Bool _e_info_client_eldbus_message_with_args(const char *method, E_Info_Message_Cb cb, const char *signature, ...); @@ -839,6 +841,41 @@ arg_err: } +static void +_cb_fps_info_get(const Eldbus_Message *msg) +{ + const char *name = NULL, *text = NULL; + Eina_Bool res; + const char *fps; + + res = eldbus_message_error_get(msg, &name, &text); + EINA_SAFETY_ON_TRUE_GOTO(res, finish); + + res = eldbus_message_arguments_get(msg, "s", &fps); + EINA_SAFETY_ON_FALSE_GOTO(res, finish); + if (strcmp(fps, "no_update")) + printf("%s\n", fps); + +finish: + if ((name) || (text )) { + printf("errname:%s errmsg:%s\n", name, text); + } +} + +static void +_e_info_client_proc_fps_info(int argc, char **argv) +{ + keepRunning = 1; + + do { + if (!_e_info_client_eldbus_message("get_fps_info", _cb_fps_info_get)) + return; + + sleep(1); + + }while(keepRunning); +} + static struct { const char *option; @@ -893,6 +930,11 @@ static struct "input_devices", NULL, "Print connected input devices", _e_info_client_proc_input_device_info + }, + { + "fps", NULL, + "Print FPS in every sec", + _e_info_client_proc_fps_info } }; @@ -995,6 +1037,13 @@ _e_info_client_process(int argc, char **argv) int nproc = sizeof(procs) / sizeof(procs[0]); int i; + signal(SIGINT, end_program); + signal(SIGALRM, end_program); + signal(SIGHUP, end_program); + signal(SIGPIPE, end_program); + signal(SIGQUIT, end_program); + signal(SIGTERM, end_program); + for (i = 0; i < nproc; i++) { if (!strncmp(argv[1]+1, procs[i].option, strlen(procs[i].option))) @@ -1031,6 +1080,11 @@ _e_info_client_print_usage(const char *exec) printf("\n"); } +static void end_program (int sig) +{ + keepRunning = 0; +} + int main(int argc, char **argv) { diff --git a/src/bin/e_info_server.c b/src/bin/e_info_server.c index 95a288d..bd7df7b 100644 --- a/src/bin/e_info_server.c +++ b/src/bin/e_info_server.c @@ -692,6 +692,37 @@ _e_info_server_cb_rotation_message(const Eldbus_Service_Interface *iface EINA_UN return reply; } +static Eldbus_Message * +_e_info_server_cb_fps_info_get(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg) +{ + static double old_fps = 0; + + Eldbus_Message *reply = eldbus_message_method_return_new(msg); + char buf[128] = {}; + + if (!e_comp->calc_fps) + { + e_comp->calc_fps = 1; + } + + if (old_fps == e_comp->fps) + { + snprintf(buf, sizeof(buf), "no_update"); + } + else if (e_comp->fps > 0.0) + { + snprintf(buf, sizeof(buf), "... FPS %3.1f", e_comp->fps); + old_fps = e_comp->fps; + } + else + { + snprintf(buf, sizeof(buf), "... FPS N/A"); + } + + eldbus_message_arguments_append(reply, "s", buf); + return reply; +} + static const Eldbus_Method methods[] = { { "get_window_info", NULL, ELDBUS_ARGS({"a("VALUE_TYPE_FOR_TOPVWINS")", "array of ec"}), _e_info_server_cb_window_info_get, 0 }, { "dump_topvwins", ELDBUS_ARGS({"s", "directory"}), NULL, _e_info_server_cb_topvwins_dump, 0 }, @@ -703,6 +734,7 @@ static const Eldbus_Method methods[] = { { "rotation_message", ELDBUS_ARGS({"iii", "rotation_message"}), NULL, _e_info_server_cb_rotation_message, 0}, { "get_res_lists", ELDBUS_ARGS({VALUE_TYPE_REQUEST_RESLIST, "client resource"}), ELDBUS_ARGS({"a("VALUE_TYPE_REPLY_RESLIST")", "array of client resources"}), _e_info_server_cb_res_lists_get, 0 }, { "get_input_devices", NULL, ELDBUS_ARGS({"a("VALUE_TYPE_FOR_INPUTDEV")", "array of input"}), _e_info_server_cb_input_device_info_get, 0}, + { "get_fps_info", NULL, ELDBUS_ARGS({"s", "fps request"}), _e_info_server_cb_fps_info_get, 0}, { NULL, NULL, NULL, NULL, 0 } }; -- 2.7.4