SF: rate-limit luma sampling

Instead of sampling the luma regions every frame, introduce a rate
limiting system to reduce load. Introduces a few tunables to control
the rate, which is defaulted to 10Hz, when there is content being
watched for luma.

Test: manual systrace inspection, using SamplingDemo
Test: libgui_test --gtest_filter="RegionSampling*"
Test: atest CompositionSamplingListenerTest
Fixes: 126747045
Change-Id: I7cae3e90fb405ba72dc2f276a88be48f1533a219
diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp
index 0ba6cf9..0063c8a 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -304,6 +304,10 @@
     mApiHistoryCounter = mApiHistoryCounter % scheduler::ARRAY_SIZE;
 }
 
+void Scheduler::withPrimaryDispSync(std::function<void(DispSync&)> const& fn) {
+    fn(*mPrimaryDispSync);
+}
+
 void Scheduler::updateFpsBasedOnNativeWindowApi() {
     int mode;
     {