diff options
author | 2020-10-22 17:27:21 -0700 | |
---|---|---|
committer | 2020-10-22 17:48:06 -0700 | |
commit | 992496bd2e1af9c93bce33216034dd5419acb444 (patch) | |
tree | 862be564b4ac33217000cd7c5b1f3f8e38c83943 /libs/gui/BLASTBufferQueue.cpp | |
parent | e0a064b66428c8da8a6fd6bd3693c3577d66772d (diff) |
Allow creating child surfaces from BlastBufferQueue
App such as Chrome create child surfaces and parent them to
surfaces provided by SurfaceView. When we enable the blast
adapter for SurfaceView, the IGBP returned to the app is
created in the client and SurfaceFlinger does not know about it.
When the app creates a child surface and provides the IGBP as the
parent surface identifier, SF fails to validate the IGBP and the
surface is not created. This can be avoid if the client creates the
child surface from the SV SurfaceControl but we still need to
support existing APIs.
To fix this, when we create a Surface from the adapter, pass in
the handle of the Blast SurfaceControl. When calling
ASurfaceControl_createFromWindow, use this handle to identify
the parent.
Bug: 168917217
Test: adb shell settings put global use_blast_adapter_sv 1 & launch chrome
Change-Id: I404bbd29b63044260f5403aae60f039a36eeea8b
Diffstat (limited to 'libs/gui/BLASTBufferQueue.cpp')
-rw-r--r-- | libs/gui/BLASTBufferQueue.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp index c8e1f3d1a0..0e47676dd6 100644 --- a/libs/gui/BLASTBufferQueue.cpp +++ b/libs/gui/BLASTBufferQueue.cpp @@ -357,11 +357,9 @@ class BBQSurface : public Surface { private: sp<BLASTBufferQueue> mBbq; public: - BBQSurface(const sp<IGraphicBufferProducer>& igbp, bool controlledByApp, - const sp<BLASTBufferQueue>& bbq) : - Surface(igbp, controlledByApp), - mBbq(bbq) { - } + BBQSurface(const sp<IGraphicBufferProducer>& igbp, bool controlledByApp, + const sp<IBinder>& scHandle, const sp<BLASTBufferQueue>& bbq) + : Surface(igbp, controlledByApp, scHandle), mBbq(bbq) {} void allocateBuffers() override { uint32_t reqWidth = mReqWidth ? mReqWidth : mUserWidth; @@ -405,8 +403,13 @@ status_t BLASTBufferQueue::setFrameTimelineVsync(int64_t frameTimelineVsyncId) { .apply(); } -sp<Surface> BLASTBufferQueue::getSurface() { - return new BBQSurface(mProducer, true, this); +sp<Surface> BLASTBufferQueue::getSurface(bool includeSurfaceControlHandle) { + std::unique_lock _lock{mMutex}; + sp<IBinder> scHandle = nullptr; + if (includeSurfaceControlHandle && mSurfaceControl) { + scHandle = mSurfaceControl->getHandle(); + } + return new BBQSurface(mProducer, true, scHandle, this); } } // namespace android |