Cache frame event history producer-side.

* Producer maintains a recent history of frames.
* Producer only does a binder call if requested
    informatiVon doesn't exist in the cache.
* Consumer sends fences to the producer, which
    can be queried for timestamps without a
    binder call.

Test: adb shell /data/nativetest/libgui_test/libgui_test
--gtest_filter=*GetFrameTimestamps*

Change-Id: I8a64579407cc2935f5c659462cb227b07ba27e43
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 98ea053..b4d8685 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -407,12 +407,10 @@
     void logFrameStats();
     void getFrameStats(FrameStats* outStats) const;
 
-
     std::vector<OccupancyTracker::Segment> getOccupancyHistory(bool forceFlush);
 
-    bool addAndGetFrameTimestamps(
-            const NewFrameEventsEntry* newTimestamps,
-            uint64_t frameNumber, FrameTimestamps* outTimestamps);
+    void addAndGetFrameTimestamps(const NewFrameEventsEntry* newEntry,
+            FrameEventHistoryDelta* outDelta);
 
     bool getTransformToDisplayInverse() const;
 
@@ -587,7 +585,7 @@
     // Timestamp history for the consumer to query.
     // Accessed by both consumer and producer on main and binder threads.
     Mutex mFrameEventHistoryMutex;
-    FrameEventHistory mFrameEventHistory;
+    ConsumerFrameEventHistory mFrameEventHistory;
 
     // main thread
     sp<GraphicBuffer> mActiveBuffer;