summaryrefslogtreecommitdiff
path: root/libs/gui/SurfaceControl.cpp
diff options
context:
space:
mode:
authorScott Lobdell <slobdell@google.com>2021-04-25 19:53:06 +0000
committerRob Seymour <rseymour@google.com>2021-05-06 22:32:25 +0000
commitafbe732519a96ff0a42a1c98bd59fd04080b4a96 (patch)
tree9ca836d438ca47756e4761ee4b844b85bd7e8857 /libs/gui/SurfaceControl.cpp
parent7a303d6e8135bbd0a32075986c9f7083e0fbef23 (diff)
parent7132116dfd8bdb9c5b505db8d8a27526a4e889d8 (diff)
Merge SP1A.210425.001
Change-Id: I219cc0af128876534b77a72c36979fa1fe08ba13
Diffstat (limited to 'libs/gui/SurfaceControl.cpp')
-rw-r--r--libs/gui/SurfaceControl.cpp81
1 files changed, 64 insertions, 17 deletions
diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp
index 4be6d2b539..9871447552 100644
--- a/libs/gui/SurfaceControl.cpp
+++ b/libs/gui/SurfaceControl.cpp
@@ -35,6 +35,7 @@
#include <ui/StaticDisplayInfo.h>
#include <gui/BufferQueueCore.h>
+#include <gui/BLASTBufferQueue.h>
#include <gui/ISurfaceComposer.h>
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>
@@ -51,12 +52,17 @@ namespace android {
SurfaceControl::SurfaceControl(const sp<SurfaceComposerClient>& client, const sp<IBinder>& handle,
const sp<IGraphicBufferProducer>& gbp, int32_t layerId,
- uint32_t transform)
+ uint32_t w, uint32_t h, PixelFormat format, uint32_t transform,
+ uint32_t flags)
: mClient(client),
mHandle(handle),
mGraphicBufferProducer(gbp),
mLayerId(layerId),
mTransformHint(transform),
+ mWidth(w),
+ mHeight(h),
+ mFormat(format),
+ mCreateFlags(flags),
mExtension(mHandle, &mGraphicBufferProducer) {}
SurfaceControl::SurfaceControl(const sp<SurfaceControl>& other) {
@@ -65,6 +71,9 @@ SurfaceControl::SurfaceControl(const sp<SurfaceControl>& other) {
mGraphicBufferProducer = other->mGraphicBufferProducer;
mTransformHint = other->mTransformHint;
mLayerId = other->mLayerId;
+ mWidth = other->mWidth;
+ mHeight = other->mHeight;
+ mCreateFlags = other->mCreateFlags;
}
SurfaceControl::~SurfaceControl()
@@ -73,13 +82,13 @@ SurfaceControl::~SurfaceControl()
// happen without delay, since these resources are quite heavy.
mClient.clear();
mHandle.clear();
- mGraphicBufferProducer.clear();
+ mBbq.clear();
IPCThreadState::self()->flushCommands();
}
void SurfaceControl::disconnect() {
- if (mGraphicBufferProducer != nullptr) {
- mGraphicBufferProducer->disconnect(
+ if (getIGraphicBufferProducer() != nullptr) {
+ getIGraphicBufferProducer()->disconnect(
BufferQueueCore::CURRENTLY_CONNECTED_API);
}
}
@@ -121,22 +130,29 @@ status_t SurfaceControl::writeSurfaceToParcel(
{
sp<IGraphicBufferProducer> bp;
if (control != nullptr) {
- bp = control->mGraphicBufferProducer;
+ bp = control->getIGraphicBufferProducer();
}
return parcel->writeStrongBinder(IInterface::asBinder(bp));
}
-sp<Surface> SurfaceControl::generateSurfaceLocked() const
+sp<Surface> SurfaceControl::generateSurfaceLocked()
{
+ uint32_t ignore;
+ auto flags = mCreateFlags & (ISurfaceComposerClient::eCursorWindow |
+ ISurfaceComposerClient::eOpaque);
+ mBbqChild = mClient->createSurface(String8("bbq-wrapper"), 0, 0, mFormat,
+ flags, mHandle, {}, &ignore);
+ mBbq = new BLASTBufferQueue("bbq-adapter", mBbqChild, mWidth, mHeight, mFormat);
+
// This surface is always consumed by SurfaceFlinger, so the
// producerControlledByApp value doesn't matter; using false.
mExtension.init();
- mSurfaceData = new Surface(mGraphicBufferProducer, false);
+ mSurfaceData = mBbq->getSurface(true);
return mSurfaceData;
}
-sp<Surface> SurfaceControl::getSurface() const
+sp<Surface> SurfaceControl::getSurface()
{
Mutex::Autolock _l(mLock);
if (mSurfaceData == nullptr) {
@@ -145,25 +161,42 @@ sp<Surface> SurfaceControl::getSurface() const
return mSurfaceData;
}
-sp<Surface> SurfaceControl::createSurface() const
+sp<Surface> SurfaceControl::createSurface()
{
+ return getSurface();
+}
+
+void SurfaceControl::updateDefaultBufferSize(uint32_t width, uint32_t height) {
Mutex::Autolock _l(mLock);
- return generateSurfaceLocked();
+ mWidth = width; mHeight = height;
+ if (mBbq) {
+ mBbq->update(this, width, height, mFormat);
+ }
+
}
-sp<IBinder> SurfaceControl::getHandle() const
+sp<IBinder> SurfaceControl::getLayerStateHandle() const
{
return mHandle;
}
+sp<IBinder> SurfaceControl::getHandle() const {
+ if (mBbqChild != nullptr) {
+ return mBbqChild->getHandle();
+ }
+ return getLayerStateHandle();
+}
+
int32_t SurfaceControl::getLayerId() const {
return mLayerId;
}
-sp<IGraphicBufferProducer> SurfaceControl::getIGraphicBufferProducer() const
+sp<IGraphicBufferProducer> SurfaceControl::getIGraphicBufferProducer()
{
+ getSurface();
Mutex::Autolock _l(mLock);
- return mGraphicBufferProducer;
+
+ return mBbq->getIGraphicBufferProducer();
}
sp<SurfaceComposerClient> SurfaceControl::getClient() const
@@ -184,9 +217,11 @@ void SurfaceControl::setTransformHint(uint32_t hint) {
status_t SurfaceControl::writeToParcel(Parcel& parcel) {
SAFE_PARCEL(parcel.writeStrongBinder, ISurfaceComposerClient::asBinder(mClient->getClient()));
SAFE_PARCEL(parcel.writeStrongBinder, mHandle);
- SAFE_PARCEL(parcel.writeStrongBinder, IGraphicBufferProducer::asBinder(mGraphicBufferProducer));
SAFE_PARCEL(parcel.writeInt32, mLayerId);
SAFE_PARCEL(parcel.writeUint32, mTransformHint);
+ SAFE_PARCEL(parcel.writeUint32, mWidth);
+ SAFE_PARCEL(parcel.writeUint32, mHeight);
+ SAFE_PARCEL(parcel.writeUint32, mFormat);
return NO_ERROR;
}
@@ -195,21 +230,26 @@ status_t SurfaceControl::readFromParcel(const Parcel& parcel,
sp<SurfaceControl>* outSurfaceControl) {
sp<IBinder> client;
sp<IBinder> handle;
- sp<IBinder> gbp;
int32_t layerId;
uint32_t transformHint;
+ uint32_t width;
+ uint32_t height;
+ uint32_t format;
SAFE_PARCEL(parcel.readStrongBinder, &client);
SAFE_PARCEL(parcel.readStrongBinder, &handle);
- SAFE_PARCEL(parcel.readNullableStrongBinder, &gbp);
SAFE_PARCEL(parcel.readInt32, &layerId);
SAFE_PARCEL(parcel.readUint32, &transformHint);
+ SAFE_PARCEL(parcel.readUint32, &width);
+ SAFE_PARCEL(parcel.readUint32, &height);
+ SAFE_PARCEL(parcel.readUint32, &format);
// We aren't the original owner of the surface.
*outSurfaceControl =
new SurfaceControl(new SurfaceComposerClient(
interface_cast<ISurfaceComposerClient>(client)),
- handle.get(), interface_cast<IGraphicBufferProducer>(gbp), layerId,
+ handle.get(), nullptr, layerId,
+ width, height, format,
transformHint);
return NO_ERROR;
@@ -237,6 +277,13 @@ status_t SurfaceControl::writeNullableToParcel(Parcel& parcel,
return NO_ERROR;
}
+sp<SurfaceControl> SurfaceControl::getParentingLayer() {
+ if (mBbqChild != nullptr) {
+ return mBbqChild;
+ }
+ return this;
+}
+
typedef bool (*InitFunc_t)(sp<IGraphicBufferProducer>*, const sp<IBinder>&);
typedef void (*DeinitFunc_t)(const sp<IBinder>&);
SurfaceControl::VpsExtension::VpsExtension()