summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Angel Aguayo <xxayedawgxx@google.com> 2021-10-14 00:39:15 +0000
committer Angel Aguayo <xxayedawgxx@google.com> 2021-10-15 23:15:03 +0000
commitb398ee21f8cac1d785994e8cc313d32d98ed4c75 (patch)
tree9f8a1463b98b356010f8d150f62a96601d1fc7ca
parent2c57783414c8343114c9d8548ac7c3dbbb26898c (diff)
Consolidate WpHash declaration to a common file
Bug: b/193932763 Test: frameworks/native/test Change-Id: Ib19f191ed8031b77c059b644fe5df3c8137e6619
-rw-r--r--services/surfaceflinger/FpsReporter.h6
-rw-r--r--services/surfaceflinger/HdrLayerInfoReporter.h7
-rw-r--r--services/surfaceflinger/RegionSamplingThread.h6
-rw-r--r--services/surfaceflinger/Scheduler/VsyncModulator.h8
-rw-r--r--services/surfaceflinger/TunnelModeEnabledReporter.h7
-rw-r--r--services/surfaceflinger/WindowInfosListenerInvoker.h8
-rw-r--r--services/surfaceflinger/WpHash.h25
7 files changed, 35 insertions, 32 deletions
diff --git a/services/surfaceflinger/FpsReporter.h b/services/surfaceflinger/FpsReporter.h
index bd7b9a5222..438b1aa362 100644
--- a/services/surfaceflinger/FpsReporter.h
+++ b/services/surfaceflinger/FpsReporter.h
@@ -24,6 +24,7 @@
#include "Clock.h"
#include "FrameTimeline/FrameTimeline.h"
+#include "WpHash.h"
namespace android {
@@ -50,11 +51,6 @@ public:
private:
mutable std::mutex mMutex;
- struct WpHash {
- size_t operator()(const wp<IBinder>& p) const {
- return std::hash<IBinder*>()(p.unsafe_get());
- }
- };
struct TrackedListener {
sp<gui::IFpsListener> listener;
diff --git a/services/surfaceflinger/HdrLayerInfoReporter.h b/services/surfaceflinger/HdrLayerInfoReporter.h
index 671395f8de..4ada2b6372 100644
--- a/services/surfaceflinger/HdrLayerInfoReporter.h
+++ b/services/surfaceflinger/HdrLayerInfoReporter.h
@@ -22,6 +22,8 @@
#include <unordered_map>
+#include "WpHash.h"
+
namespace android {
class HdrLayerInfoReporter final : public IBinder::DeathRecipient {
@@ -63,11 +65,6 @@ public:
private:
mutable std::mutex mMutex;
- struct WpHash {
- size_t operator()(const wp<IBinder>& p) const {
- return std::hash<IBinder*>()(p.unsafe_get());
- }
- };
struct TrackedListener {
sp<gui::IHdrLayerInfoListener> listener;
diff --git a/services/surfaceflinger/RegionSamplingThread.h b/services/surfaceflinger/RegionSamplingThread.h
index 2231853fcb..f715309b2e 100644
--- a/services/surfaceflinger/RegionSamplingThread.h
+++ b/services/surfaceflinger/RegionSamplingThread.h
@@ -30,6 +30,7 @@
#include <unordered_map>
#include "Scheduler/OneShotTimer.h"
+#include "WpHash.h"
namespace android {
@@ -88,11 +89,6 @@ private:
sp<IRegionSamplingListener> listener;
};
- struct WpHash {
- size_t operator()(const wp<IBinder>& p) const {
- return std::hash<IBinder*>()(p.unsafe_get());
- }
- };
std::vector<float> sampleBuffer(
const sp<GraphicBuffer>& buffer, const Point& leftTop,
const std::vector<RegionSamplingThread::Descriptor>& descriptors, uint32_t orientation);
diff --git a/services/surfaceflinger/Scheduler/VsyncModulator.h b/services/surfaceflinger/Scheduler/VsyncModulator.h
index b2b0451666..2000c546a0 100644
--- a/services/surfaceflinger/Scheduler/VsyncModulator.h
+++ b/services/surfaceflinger/Scheduler/VsyncModulator.h
@@ -25,6 +25,8 @@
#include <binder/IBinder.h>
#include <utils/Timers.h>
+#include "../WpHash.h"
+
namespace android::scheduler {
// State machine controlled by transaction flags. VsyncModulator switches to early phase offsets
@@ -124,12 +126,6 @@ private:
using Schedule = TransactionSchedule;
std::atomic<Schedule> mTransactionSchedule = Schedule::Late;
- struct WpHash {
- size_t operator()(const wp<IBinder>& p) const {
- return std::hash<IBinder*>()(p.unsafe_get());
- }
- };
-
std::unordered_set<wp<IBinder>, WpHash> mEarlyWakeupRequests GUARDED_BY(mMutex);
std::atomic<bool> mRefreshRateChangePending = false;
diff --git a/services/surfaceflinger/TunnelModeEnabledReporter.h b/services/surfaceflinger/TunnelModeEnabledReporter.h
index 935502a6e1..802d22d86a 100644
--- a/services/surfaceflinger/TunnelModeEnabledReporter.h
+++ b/services/surfaceflinger/TunnelModeEnabledReporter.h
@@ -22,6 +22,8 @@
#include <unordered_map>
+#include "WpHash.h"
+
namespace android {
class Layer;
@@ -54,11 +56,6 @@ public:
private:
mutable std::mutex mMutex;
- struct WpHash {
- size_t operator()(const wp<IBinder>& p) const {
- return std::hash<IBinder*>()(p.unsafe_get());
- }
- };
std::unordered_map<wp<IBinder>, sp<gui::ITunnelModeEnabledListener>, WpHash> mListeners
GUARDED_BY(mMutex);
diff --git a/services/surfaceflinger/WindowInfosListenerInvoker.h b/services/surfaceflinger/WindowInfosListenerInvoker.h
index ecd797a631..4e08393940 100644
--- a/services/surfaceflinger/WindowInfosListenerInvoker.h
+++ b/services/surfaceflinger/WindowInfosListenerInvoker.h
@@ -23,6 +23,8 @@
#include <utils/Mutex.h>
#include <unordered_map>
+#include "WpHash.h"
+
namespace android {
class SurfaceFlinger;
@@ -42,12 +44,6 @@ protected:
private:
void windowInfosReported();
- struct WpHash {
- size_t operator()(const wp<IBinder>& p) const {
- return std::hash<IBinder*>()(p.unsafe_get());
- }
- };
-
const sp<SurfaceFlinger> mSf;
std::mutex mListenersMutex;
std::unordered_map<wp<IBinder>, const sp<gui::IWindowInfosListener>, WpHash>
diff --git a/services/surfaceflinger/WpHash.h b/services/surfaceflinger/WpHash.h
new file mode 100644
index 0000000000..86777b71d1
--- /dev/null
+++ b/services/surfaceflinger/WpHash.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+namespace android {
+
+struct WpHash {
+ size_t operator()(const wp<IBinder>& p) const { return std::hash<IBinder*>()(p.unsafe_get()); }
+};
+
+} // namespace android \ No newline at end of file