SF: Polish Fps class
For consistent comparison (which will later be changed to check ULP
distance instead of the magnitude-dependent threshold), express the
inequality operators in terms of equality, and avoid hashing floats.
Add Hz literals and (namespaced) operators.
Bug: 129481165
Bug: 185535769
Test: libsurfaceflinger_unittest
Test: dumpsys SurfaceFlinger --vsync
Change-Id: I79be5d2dd031218c4054774d2645efb337211538
diff --git a/services/surfaceflinger/Scheduler/VsyncConfiguration.h b/services/surfaceflinger/Scheduler/VsyncConfiguration.h
index 3e53b3f..8447512 100644
--- a/services/surfaceflinger/Scheduler/VsyncConfiguration.h
+++ b/services/surfaceflinger/Scheduler/VsyncConfiguration.h
@@ -17,10 +17,10 @@
#pragma once
#include <mutex>
-#include <type_traits>
-#include <unordered_map>
-#include <vector>
+#include <optional>
+#include <string>
+#include <ftl/small_map.h>
#include <utils/Timers.h>
#include "Fps.h"
@@ -88,9 +88,8 @@
VsyncConfigSet getConfigsForRefreshRateLocked(Fps fps) const REQUIRES(mLock);
- mutable std::unordered_map<Fps, VsyncConfigSet, std::hash<Fps>, Fps::EqualsInBuckets>
- mOffsetsCache GUARDED_BY(mLock);
- std::atomic<Fps> mRefreshRateFps GUARDED_BY(mLock);
+ mutable ftl::SmallMap<Fps, VsyncConfigSet, 2, FpsApproxEqual> mOffsetsCache GUARDED_BY(mLock);
+ Fps mRefreshRateFps GUARDED_BY(mLock);
mutable std::mutex mLock;
};