Revert "Ensure Choreographer is held as sp<> in SurfaceControl."
This reverts commit 9045666047d55134c2e4f0108a88b5799653003e.
Reason for revert: Supsected cause for b/405669080
Test: presubmit
Flag: EXEMPT refactor
Bug: 405669080
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:ade9b0ca6046beae913335000cdd398ac4381bb9)
Merged-In: I96c45abfe8446c924e9ea31f822e040134e87db9
Change-Id: I96c45abfe8446c924e9ea31f822e040134e87db9
diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp
index 50877f8..1eb9b87 100644
--- a/libs/gui/SurfaceControl.cpp
+++ b/libs/gui/SurfaceControl.cpp
@@ -194,7 +194,7 @@
return mName;
}
-sp<Choreographer> SurfaceControl::getChoreographer() {
+std::shared_ptr<Choreographer> SurfaceControl::getChoreographer() {
if (mChoreographer) {
return mChoreographer;
}
@@ -203,7 +203,7 @@
ALOGE("%s: No looper prepared for thread", __func__);
return nullptr;
}
- mChoreographer = sp<Choreographer>::make(looper, getHandle());
+ mChoreographer = std::make_shared<Choreographer>(looper, getHandle());
status_t result = mChoreographer->initialize();
if (result != OK) {
ALOGE("Failed to initialize choreographer");
diff --git a/libs/gui/include/gui/Choreographer.h b/libs/gui/include/gui/Choreographer.h
index b436af1..c632098 100644
--- a/libs/gui/include/gui/Choreographer.h
+++ b/libs/gui/include/gui/Choreographer.h
@@ -79,6 +79,9 @@
};
static Context gChoreographers;
+ explicit Choreographer(const sp<Looper>& looper, const sp<IBinder>& layerHandle = nullptr)
+ EXCLUDES(gChoreographers.lock);
+
void postFrameCallbackDelayed(AChoreographer_frameCallback cb,
AChoreographer_frameCallback64 cb64,
AChoreographer_vsyncCallback vsyncCallback, void* data,
@@ -111,10 +114,6 @@
private:
Choreographer(const Choreographer&) = delete;
- explicit Choreographer(const sp<Looper>& looper, const sp<IBinder>& layerHandle = nullptr)
- EXCLUDES(gChoreographers.lock);
- friend class sp<Choreographer>;
- friend AChoreographer* AChoreographer_create();
void dispatchVsync(nsecs_t timestamp, PhysicalDisplayId displayId, uint32_t count,
VsyncEventData vsyncEventData) override;
diff --git a/libs/gui/include/gui/SurfaceControl.h b/libs/gui/include/gui/SurfaceControl.h
index 91a422d..344b957 100644
--- a/libs/gui/include/gui/SurfaceControl.h
+++ b/libs/gui/include/gui/SurfaceControl.h
@@ -26,7 +26,6 @@
#include <android/gui/ISurfaceComposerClient.h>
-#include <gui/Choreographer.h>
#include <ui/FrameStats.h>
#include <ui/PixelFormat.h>
#include <ui/Region.h>
@@ -37,6 +36,7 @@
// ---------------------------------------------------------------------------
+class Choreographer;
class IGraphicBufferProducer;
class Surface;
class SurfaceComposerClient;
@@ -82,7 +82,7 @@
const std::string& getName() const;
// TODO(b/267195698): Consider renaming.
- sp<Choreographer> getChoreographer();
+ std::shared_ptr<Choreographer> getChoreographer();
sp<IGraphicBufferProducer> getIGraphicBufferProducer();
@@ -134,7 +134,7 @@
PixelFormat mFormat = PIXEL_FORMAT_NONE;
uint32_t mCreateFlags = 0;
uint64_t mFallbackFrameNumber = 100;
- sp<Choreographer> mChoreographer;
+ std::shared_ptr<Choreographer> mChoreographer;
};
}; // namespace android