Merge "libui: set USAGE_HW_2D in getValid10UsageBits"
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 939a209..c40cad3 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -615,7 +615,7 @@
windowType, ownerUid, &handle, &gbp);
ALOGE_IF(err, "SurfaceComposerClient::createSurface error %s", strerror(-err));
if (err == NO_ERROR) {
- sur = new SurfaceControl(this, handle, gbp);
+ sur = new SurfaceControl(this, handle, gbp, true /* owned */);
}
}
return sur;
diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp
index f5fb8ac..5eafbb3 100644
--- a/libs/gui/SurfaceControl.cpp
+++ b/libs/gui/SurfaceControl.cpp
@@ -48,8 +48,9 @@
SurfaceControl::SurfaceControl(
const sp<SurfaceComposerClient>& client,
const sp<IBinder>& handle,
- const sp<IGraphicBufferProducer>& gbp)
- : mClient(client), mHandle(handle), mGraphicBufferProducer(gbp)
+ const sp<IGraphicBufferProducer>& gbp,
+ bool owned)
+ : mClient(client), mHandle(handle), mGraphicBufferProducer(gbp), mOwned(owned)
{
}
@@ -60,7 +61,9 @@
void SurfaceControl::destroy()
{
- if (isValid()) {
+ // Avoid destroying the server-side surface if we are not the owner of it, meaning that we
+ // retrieved it from another process.
+ if (isValid() && mOwned) {
mClient->destroySurface(mHandle);
}
// clear all references and trigger an IPC now, to make sure things
@@ -184,9 +187,11 @@
}
sp<IBinder> gbp;
parcel->readNullableStrongBinder(&gbp);
+
+ // We aren't the original owner of the surface.
return new SurfaceControl(new SurfaceComposerClient(
interface_cast<ISurfaceComposerClient>(client)),
- handle.get(), interface_cast<IGraphicBufferProducer>(gbp));
+ handle.get(), interface_cast<IGraphicBufferProducer>(gbp), false /* owned */);
}
// ----------------------------------------------------------------------------
diff --git a/libs/gui/include/gui/SurfaceControl.h b/libs/gui/include/gui/SurfaceControl.h
index 1416d87..bd987dd 100644
--- a/libs/gui/include/gui/SurfaceControl.h
+++ b/libs/gui/include/gui/SurfaceControl.h
@@ -87,7 +87,8 @@
SurfaceControl(
const sp<SurfaceComposerClient>& client,
const sp<IBinder>& handle,
- const sp<IGraphicBufferProducer>& gbp);
+ const sp<IGraphicBufferProducer>& gbp,
+ bool owned);
~SurfaceControl();
@@ -100,6 +101,7 @@
sp<IGraphicBufferProducer> mGraphicBufferProducer;
mutable Mutex mLock;
mutable sp<Surface> mSurfaceData;
+ bool mOwned;
};
}; // namespace android