Skip to content

Commit 68f65ad

Browse files
Treehugger RobotAndroid (Google) Code Review
authored andcommitted
Merge "Revert "Ensure Choreographer is held as sp<> in SurfaceControl."" into main
2 parents 9dc2eef + ade9b0c commit 68f65ad

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

libs/gui/SurfaceControl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ const std::string& SurfaceControl::getName() const {
194194
return mName;
195195
}
196196

197-
sp<Choreographer> SurfaceControl::getChoreographer() {
197+
std::shared_ptr<Choreographer> SurfaceControl::getChoreographer() {
198198
if (mChoreographer) {
199199
return mChoreographer;
200200
}
@@ -203,7 +203,7 @@ sp<Choreographer> SurfaceControl::getChoreographer() {
203203
ALOGE("%s: No looper prepared for thread", __func__);
204204
return nullptr;
205205
}
206-
mChoreographer = sp<Choreographer>::make(looper, getHandle());
206+
mChoreographer = std::make_shared<Choreographer>(looper, getHandle());
207207
status_t result = mChoreographer->initialize();
208208
if (result != OK) {
209209
ALOGE("Failed to initialize choreographer");

libs/gui/include/gui/Choreographer.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ class Choreographer : public DisplayEventDispatcher, public MessageHandler {
7979
};
8080
static Context gChoreographers;
8181

82+
explicit Choreographer(const sp<Looper>& looper, const sp<IBinder>& layerHandle = nullptr)
83+
EXCLUDES(gChoreographers.lock);
84+
8285
void postFrameCallbackDelayed(AChoreographer_frameCallback cb,
8386
AChoreographer_frameCallback64 cb64,
8487
AChoreographer_vsyncCallback vsyncCallback, void* data,
@@ -111,10 +114,6 @@ class Choreographer : public DisplayEventDispatcher, public MessageHandler {
111114

112115
private:
113116
Choreographer(const Choreographer&) = delete;
114-
explicit Choreographer(const sp<Looper>& looper, const sp<IBinder>& layerHandle = nullptr)
115-
EXCLUDES(gChoreographers.lock);
116-
friend class sp<Choreographer>;
117-
friend AChoreographer* AChoreographer_create();
118117

119118
void dispatchVsync(nsecs_t timestamp, PhysicalDisplayId displayId, uint32_t count,
120119
VsyncEventData vsyncEventData) override;

libs/gui/include/gui/SurfaceControl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
#include <android/gui/ISurfaceComposerClient.h>
2828

29-
#include <gui/Choreographer.h>
3029
#include <ui/FrameStats.h>
3130
#include <ui/PixelFormat.h>
3231
#include <ui/Region.h>
@@ -37,6 +36,7 @@ namespace android {
3736

3837
// ---------------------------------------------------------------------------
3938

39+
class Choreographer;
4040
class IGraphicBufferProducer;
4141
class Surface;
4242
class SurfaceComposerClient;
@@ -82,7 +82,7 @@ class SurfaceControl : public RefBase
8282
const std::string& getName() const;
8383

8484
// TODO(b/267195698): Consider renaming.
85-
sp<Choreographer> getChoreographer();
85+
std::shared_ptr<Choreographer> getChoreographer();
8686

8787
sp<IGraphicBufferProducer> getIGraphicBufferProducer();
8888

@@ -134,7 +134,7 @@ class SurfaceControl : public RefBase
134134
PixelFormat mFormat = PIXEL_FORMAT_NONE;
135135
uint32_t mCreateFlags = 0;
136136
uint64_t mFallbackFrameNumber = 100;
137-
sp<Choreographer> mChoreographer;
137+
std::shared_ptr<Choreographer> mChoreographer;
138138
};
139139

140140
}; // namespace android

0 commit comments

Comments
 (0)