hwc2: atrace

Add atrace on validate and present display.

Test: Add "TARGET_USES_HWC2 := true" to BoardConfig.mk.
      Recompile.
      Run testcases: https://android-review.googlesource.com/#/q/project:
            platform/frameworks/native+branch:master+topic:test-hwc2

Change-Id: I6d7c3853eb73ab7638980824f9c7b6a4bca69d7f
diff --git a/hwc2/Android.mk b/hwc2/Android.mk
index b2c32c0..ec95af1 100644
--- a/hwc2/Android.mk
+++ b/hwc2/Android.mk
@@ -32,7 +32,8 @@
 
 LOCAL_SHARED_LIBRARIES := \
 	liblog \
-	libutils
+	libutils \
+	libcutils
 
 LOCAL_STATIC_LIBRARIES := \
 	libadfhwc \
diff --git a/hwc2/hwc2_dev.cpp b/hwc2/hwc2_dev.cpp
index adffecf..a854958 100644
--- a/hwc2/hwc2_dev.cpp
+++ b/hwc2/hwc2_dev.cpp
@@ -24,6 +24,9 @@
 
 #include "hwc2.h"
 
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+#include "cutils/trace.h"
+
 static void hwc2_vsync(void *data, int dpy_id, uint64_t timestamp)
 {
     hwc2_dev *dev = static_cast<hwc2_dev *>(data);
@@ -180,6 +183,8 @@
 hwc2_error_t hwc2_dev::validate_display(hwc2_display_t dpy_id,
         uint32_t *out_num_types, uint32_t *out_num_requests)
 {
+    ATRACE_BEGIN(__func__);
+
     std::lock_guard<std::mutex> guard(state_mutex);
 
     auto it = displays.find(dpy_id);
@@ -188,7 +193,12 @@
         return HWC2_ERROR_BAD_DISPLAY;
     }
 
-    return it->second.validate_display(out_num_types, out_num_requests);
+    hwc2_error_t ret = it->second.validate_display(out_num_types,
+            out_num_requests);
+
+    ATRACE_END();
+
+    return ret;
 }
 
 hwc2_error_t hwc2_dev::get_changed_composition_types(hwc2_display_t dpy_id,
@@ -240,6 +250,8 @@
 hwc2_error_t hwc2_dev::present_display(hwc2_display_t dpy_id,
         int32_t *out_present_fence)
 {
+    ATRACE_BEGIN(__func__);
+
     std::lock_guard<std::mutex> guard(state_mutex);
 
     auto it = displays.find(dpy_id);
@@ -248,7 +260,11 @@
         return HWC2_ERROR_BAD_DISPLAY;
     }
 
-    return it->second.present_display(out_present_fence);
+    hwc2_error_t ret = it->second.present_display(out_present_fence);
+
+    ATRACE_END();
+
+    return ret;
 }
 
 hwc2_error_t hwc2_dev::get_release_fences(hwc2_display_t dpy_id,