summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryce Lee <brycelee@google.com>2017-06-16 07:06:17 -0700
committerBryce Lee <brycelee@google.com>2017-06-16 12:33:02 -0700
commit4e623e259c3e8677d57f761a3708423fb2e77e2a (patch)
treef26ea88c3e0304ccf81703c1f10b86b4427adf52
parentc175253b6d0738aec6235ef1c2e723ad36fcd346 (diff)
downloadnative-4e623e259c3e8677d57f761a3708423fb2e77e2a.tar.gz
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
-rw-r--r--include/gui/SurfaceControl.h2
-rw-r--r--libs/gui/SurfaceControl.cpp19
2 files changed, 18 insertions, 3 deletions
diff --git a/include/gui/SurfaceControl.h b/include/gui/SurfaceControl.h
index 712a323337..8bb705cf77 100644
--- a/include/gui/SurfaceControl.h
+++ b/include/gui/SurfaceControl.h
@@ -135,6 +135,7 @@ public:
const sp<SurfaceControl>& control, Parcel* parcel);
sp<Surface> getSurface() const;
+ sp<Surface> createSurface() const;
sp<IBinder> getHandle() const;
status_t clearLayerFrameStats() const;
@@ -155,6 +156,7 @@ private:
~SurfaceControl();
+ sp<Surface> generateSurfaceLocked() const;
status_t validate() const;
void destroy();
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<Surface> 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<Surface> 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<Surface> SurfaceControl::createSurface() const
+{
+ Mutex::Autolock _l(mLock);
+ return generateSurfaceLocked();
+}
+
sp<IBinder> SurfaceControl::getHandle() const
{
Mutex::Autolock lock(mLock);