From 4e623e259c3e8677d57f761a3708423fb2e77e2a Mon Sep 17 00:00:00 2001 From: Bryce Lee Date: Fri, 16 Jun 2017 07:06:17 -0700 Subject: Add method to explicitly create Surface. It is sometimes necessary for a SurfaceControl client to request the associated Surface object be created rather than reuse the cached value. This changelist adds an additional method that performs the same creation operations as if the Surface object was created for the first time. Bug: 62108743 Test: go/wm-smoke Change-Id: I2f460f20b2d16ed9ff81cb36842bcd2f8641e03c --- libs/gui/SurfaceControl.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'libs/gui/SurfaceControl.cpp') diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp index bf8a815fe6..58bd273de6 100644 --- a/libs/gui/SurfaceControl.cpp +++ b/libs/gui/SurfaceControl.cpp @@ -237,17 +237,30 @@ status_t SurfaceControl::writeSurfaceToParcel( return parcel->writeStrongBinder(IInterface::asBinder(bp)); } +sp SurfaceControl::generateSurfaceLocked() const +{ + // This surface is always consumed by SurfaceFlinger, so the + // producerControlledByApp value doesn't matter; using false. + mSurfaceData = new Surface(mGraphicBufferProducer, false); + + return mSurfaceData; +} + sp SurfaceControl::getSurface() const { Mutex::Autolock _l(mLock); if (mSurfaceData == 0) { - // This surface is always consumed by SurfaceFlinger, so the - // producerControlledByApp value doesn't matter; using false. - mSurfaceData = new Surface(mGraphicBufferProducer, false); + return generateSurfaceLocked(); } return mSurfaceData; } +sp SurfaceControl::createSurface() const +{ + Mutex::Autolock _l(mLock); + return generateSurfaceLocked(); +} + sp SurfaceControl::getHandle() const { Mutex::Autolock lock(mLock); -- cgit v1.2.3-59-g8ed1b