SF: Adding Layer History to SF.
Calculate average and median between the timestamp differences that come in for
individual layers, and store them to systrace.
See go/surface-flinger-scheduler for more details and systrace links.
Test: SF tests updated.
Bug: 113612090
Change-Id: I934bbe36ab57d16a5b219c7cb8e0580112238671
diff --git a/services/surfaceflinger/Scheduler/LayerHistory.h b/services/surfaceflinger/Scheduler/LayerHistory.h
index 1a7f9cd..76c1352 100644
--- a/services/surfaceflinger/Scheduler/LayerHistory.h
+++ b/services/surfaceflinger/Scheduler/LayerHistory.h
@@ -42,14 +42,17 @@
~LayerHistory();
// Method for inserting layers and their requested present time into the ring buffer.
- // The elements are going to be inserted into an unordered_map at the position of
- // mCounter.
+ // The elements are going to be inserted into an unordered_map at the position 'now'.
void insert(const std::string layerName, nsecs_t presentTime);
// Method for incrementing the current slot in the ring buffer. It also clears the
// unordered_map, if it was created previously.
void incrementCounter();
- // Returns unordered_map at the given at index.
+ // Returns unordered_map at the given at index. The index is decremented from 'now'. For
+ // example, 0 is now, 1 is previous frame.
const std::unordered_map<std::string, nsecs_t>& get(size_t index) const;
+ // Returns the total size of the ring buffer. The value is always the same regardless
+ // of how many slots we filled in.
+ static constexpr size_t getSize() { return ARRAY_SIZE; }
private:
size_t mCounter = 0;