tdm_hwc: support tdm-monitor -fps function 23/213523/1
authorJunkyeong Kim <jk0430.kim@samsung.com>
Fri, 6 Sep 2019 07:56:31 +0000 (16:56 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Fri, 6 Sep 2019 07:56:36 +0000 (16:56 +0900)
Change-Id: I4f11ab53483058283717c4b592cb44b989c1daec
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
src/tdm_hwc.c
src/tdm_private_types.h

index f3537bc..f6d1808 100644 (file)
@@ -109,6 +109,24 @@ _tdm_hwc_thread_cb_commit(tdm_private_display *private_display, void *object,
                TDM_INFO("handler(%p)", hwc_commit_handler);
        }
 
+       /* LCOV_EXCL_START */
+       if (private_display->print_fps) {
+               double curr = tdm_helper_get_time();
+               if (private_hwc->fps_stamp == 0) {
+                       private_hwc->fps_stamp = curr;
+               } else if ((curr - private_hwc->fps_stamp) > 1.0) {
+                       TDM_INFO("hwc(%p,%d) fps: %d",
+                                        private_hwc, private_hwc->index, private_hwc->fps_count);
+                       private_hwc->fps_count = 0;
+                       private_hwc->fps_stamp = curr;
+               } else
+                       private_hwc->fps_count++;
+       } else if (private_hwc->fps_stamp != 0) {
+               private_hwc->fps_stamp = 0;
+               private_hwc->fps_count = 0;
+       }
+       /* LCOV_EXCL_STOP */
+
        if (hwc_commit_handler->func) {
                _pthread_mutex_unlock(&private_display->lock);
                hwc_commit_handler->func(private_hwc,
index dfea22a..a778e25 100644 (file)
@@ -329,6 +329,9 @@ struct _tdm_private_hwc {
        tdm_hwc *hwc_backend;
 
        tbm_surface_h display_target_buffer;
+
+       double fps_stamp;
+       unsigned int fps_count;
 };
 
 struct _tdm_private_hwc_window {