summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-09-13 04:58:19 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-09-13 04:58:19 +0000
commit4d48a486be8a3d3e856b33d9a92567c3e9492980 (patch)
tree1bca85935788654055cf665af42a53634cef23bf
parent47b3ffac2014319c42eded655faa23e4c0714f94 (diff)
parent4fa12d2f33d71c0c7aaefd628cd52be3f6373c73 (diff)
downloadnative-android12-d1-s2-release.tar.gz
Merge cherrypicks of [15818447, 15818448, 15817598, 15818379, 15818380, 15818381, 15818382, 15818383, 15818384, 15818385, 15818469, 15818035, 15818470, 15818471, 15818472, 15818397, 15818161, 15818386, 15818487, 15818488, 15818162, 15818163, 15818398, 15818399, 15818400, 15818401, 15818402, 15818403, 15818404, 15818405, 15818406, 15818527, 15818256, 15818257, 15818258, 15817906, 15817599, 15817600, 15818547] into sparse-7706357-L05800000951102060android-12.0.0_r5android12-d1-s2-release
Change-Id: I5ac92f10f39e2d57e9453fee116168ac32178f54
-rw-r--r--libs/gui/BLASTBufferQueue.cpp19
-rw-r--r--libs/gui/Surface.cpp10
-rw-r--r--libs/gui/include/gui/Surface.h3
3 files changed, 31 insertions, 1 deletions
diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp
index 56a9683773..f7ec8ef40e 100644
--- a/libs/gui/BLASTBufferQueue.cpp
+++ b/libs/gui/BLASTBufferQueue.cpp
@@ -630,7 +630,10 @@ bool BLASTBufferQueue::maxBuffersAcquired(bool includeExtraAcquire) const {
class BBQSurface : public Surface {
private:
+ std::mutex mMutex;
sp<BLASTBufferQueue> mBbq;
+ bool mDestroyed = false;
+
public:
BBQSurface(const sp<IGraphicBufferProducer>& igbp, bool controlledByApp,
const sp<IBinder>& scHandle, const sp<BLASTBufferQueue>& bbq)
@@ -650,6 +653,10 @@ public:
status_t setFrameRate(float frameRate, int8_t compatibility,
int8_t changeFrameRateStrategy) override {
+ std::unique_lock _lock{mMutex};
+ if (mDestroyed) {
+ return DEAD_OBJECT;
+ }
if (!ValidateFrameRate(frameRate, compatibility, changeFrameRateStrategy,
"BBQSurface::setFrameRate")) {
return BAD_VALUE;
@@ -658,8 +665,20 @@ public:
}
status_t setFrameTimelineInfo(const FrameTimelineInfo& frameTimelineInfo) override {
+ std::unique_lock _lock{mMutex};
+ if (mDestroyed) {
+ return DEAD_OBJECT;
+ }
return mBbq->setFrameTimelineInfo(frameTimelineInfo);
}
+
+ void destroy() override {
+ Surface::destroy();
+
+ std::unique_lock _lock{mMutex};
+ mDestroyed = true;
+ mBbq = nullptr;
+ }
};
// TODO: Can we coalesce this with frame updates? Need to confirm
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index 2edb4e4ba4..353a91d062 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -2622,4 +2622,14 @@ status_t Surface::setFrameTimelineInfo(const FrameTimelineInfo& frameTimelineInf
return composerService()->setFrameTimelineInfo(mGraphicBufferProducer, frameTimelineInfo);
}
+sp<IBinder> Surface::getSurfaceControlHandle() const {
+ Mutex::Autolock lock(mMutex);
+ return mSurfaceControlHandle;
+}
+
+void Surface::destroy() {
+ Mutex::Autolock lock(mMutex);
+ mSurfaceControlHandle = nullptr;
+}
+
}; // namespace android
diff --git a/libs/gui/include/gui/Surface.h b/libs/gui/include/gui/Surface.h
index 7e4143b1f3..e5403512a9 100644
--- a/libs/gui/include/gui/Surface.h
+++ b/libs/gui/include/gui/Surface.h
@@ -99,7 +99,7 @@ public:
*/
sp<IGraphicBufferProducer> getIGraphicBufferProducer() const;
- sp<IBinder> getSurfaceControlHandle() const { return mSurfaceControlHandle; }
+ sp<IBinder> getSurfaceControlHandle() const;
/* convenience function to check that the given surface is non NULL as
* well as its IGraphicBufferProducer */
@@ -333,6 +333,7 @@ public:
virtual int connect(
int api, bool reportBufferRemoval,
const sp<SurfaceListener>& sListener);
+ virtual void destroy();
// When client connects to Surface with reportBufferRemoval set to true, any buffers removed
// from this Surface will be collected and returned here. Once this method returns, these