Merge "composer: Add 100ms delay upon releasing of large comp hint" into display.lnx.9.0
diff --git a/composer/hwc_display_builtin.cpp b/composer/hwc_display_builtin.cpp
index a8e559b..0047b1d 100644
--- a/composer/hwc_display_builtin.cpp
+++ b/composer/hwc_display_builtin.cpp
@@ -1581,11 +1581,15 @@
       }
     }
 
-    // For long term large composition hint, release the acquired handle after a consecutive number
-    // of basic frames to avoid resending hints in animation launch use cases and others.
-    num_basic_frames_++;
+    // For long term large composition hint, release the acquired handle after 100 milliseconds
+    // to avoid resending hints in animation launch use cases and others.
+    if (hint_release_start_time_ == 0) {
+      hint_release_start_time_ = systemTime(SYSTEM_TIME_MONOTONIC);
+    }
 
-    if (num_basic_frames_ >= active_refresh_rate_) {
+    nsecs_t current_time = systemTime(SYSTEM_TIME_MONOTONIC);
+    if (nanoseconds_to_milliseconds(current_time - hint_release_start_time_) >=
+        elapse_time_threshold_) {
       cpu_hint_->ReqHintRelease();
     }
     return;
@@ -1600,7 +1604,8 @@
     cpu_hint_->ReqHintsOffload(kPerfHintLargeCompCycle, 0);
   }
 
-  num_basic_frames_ = 0;
+  // Reset time when large composition hint is active
+  hint_release_start_time_ = 0;
 }
 
 void HWCDisplayBuiltIn::ReqPerfHintRelease() {
diff --git a/composer/hwc_display_builtin.h b/composer/hwc_display_builtin.h
index 1ddbb5a..5cd318b 100644
--- a/composer/hwc_display_builtin.h
+++ b/composer/hwc_display_builtin.h
@@ -228,8 +228,9 @@
 
   // Long term large composition hint
   int hwc_tid_ = 0;
-  uint32_t num_basic_frames_ = 0;
   uint32_t large_comp_hint_threshold_ = 0;
+  nsecs_t hint_release_start_time_ = 0;
+  nsecs_t elapse_time_threshold_ = 100;  // Time is in milliseconds
 };
 
 }  // namespace sdm