SF: Cleanup EventThread Part 2
De-refbase EventThread and a bunch of related classes. Convert from
usign StrongPointer to std::unique_ptr to hold owned references, or bare
pointers for unowned references.
I did not see any need for using std::shared_ptr, or anything else, as
SurfaceFlinger appeared to own all the objects, and they were created
once and not really destroyed afterwards.
Test: Things seem to still work on a Pixel XL
Bug: None
Change-Id: Ifff32118d31bc1bb51e38df695ebe5cf86d2bb6d
diff --git a/services/surfaceflinger/DispSync.cpp b/services/surfaceflinger/DispSync.cpp
index b5fc365..9e01fd0 100644
--- a/services/surfaceflinger/DispSync.cpp
+++ b/services/surfaceflinger/DispSync.cpp
@@ -168,8 +168,7 @@
return false;
}
- status_t addEventListener(const char* name, nsecs_t phase,
- const sp<DispSync::Callback>& callback) {
+ status_t addEventListener(const char* name, nsecs_t phase, DispSync::Callback* callback) {
if (kTraceDetailedInfo) ATRACE_CALL();
Mutex::Autolock lock(mMutex);
@@ -195,7 +194,7 @@
return NO_ERROR;
}
- status_t removeEventListener(const sp<DispSync::Callback>& callback) {
+ status_t removeEventListener(DispSync::Callback* callback) {
if (kTraceDetailedInfo) ATRACE_CALL();
Mutex::Autolock lock(mMutex);
@@ -223,11 +222,11 @@
const char* mName;
nsecs_t mPhase;
nsecs_t mLastEventTime;
- sp<DispSync::Callback> mCallback;
+ DispSync::Callback* mCallback;
};
struct CallbackInvocation {
- sp<DispSync::Callback> mCallback;
+ DispSync::Callback* mCallback;
nsecs_t mEventTime;
};
@@ -388,7 +387,8 @@
// not needed because any time there is an event registered we will
// turn on the HW vsync events.
if (!mIgnorePresentFences && kEnableZeroPhaseTracer) {
- addEventListener("ZeroPhaseTracer", 0, new ZeroPhaseTracer());
+ mZeroPhaseTracer = std::make_unique<ZeroPhaseTracer>();
+ addEventListener("ZeroPhaseTracer", 0, mZeroPhaseTracer.get());
}
}
}
@@ -470,7 +470,7 @@
void DispSync::endResync() {}
-status_t DispSync::addEventListener(const char* name, nsecs_t phase, const sp<Callback>& callback) {
+status_t DispSync::addEventListener(const char* name, nsecs_t phase, Callback* callback) {
Mutex::Autolock lock(mMutex);
return mThread->addEventListener(name, phase, callback);
}
@@ -482,7 +482,7 @@
updateModelLocked();
}
-status_t DispSync::removeEventListener(const sp<Callback>& callback) {
+status_t DispSync::removeEventListener(Callback* callback) {
Mutex::Autolock lock(mMutex);
return mThread->removeEventListener(callback);
}