Skip to content

Commit 9045666

Browse files
author
Anton Ivanov
committed
Ensure Choreographer is held as sp<> in SurfaceControl.
Test: ChoreographerTests pass Flag: EXEMPT refactor Bug: 393217449 Change-Id: I60d42f383d4b73b60de1a7a1bbeec5170b805ebb
1 parent a4e35c6 commit 9045666

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

libs/gui/include/gui/SurfaceControl.h

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

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

29+
#include <gui/Choreographer.h>
2930
#include <ui/FrameStats.h>
3031
#include <ui/PixelFormat.h>
3132
#include <ui/Region.h>
@@ -36,7 +37,6 @@ namespace android {
3637

3738
// ---------------------------------------------------------------------------
3839

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-
std::shared_ptr<Choreographer> getChoreographer();
85+
sp<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-
std::shared_ptr<Choreographer> mChoreographer;
137+
sp<Choreographer> mChoreographer;
138138
};
139139

140140
}; // namespace android

0 commit comments

Comments
 (0)