diff options
author | 2017-01-27 14:21:34 -0500 | |
---|---|---|
committer | 2017-01-31 16:29:42 -0500 | |
commit | 479c60c85c40fd3536b0c88036e838dc1a4c56a0 (patch) | |
tree | 9f6034273a86390db5b39f7a2e221dc23a51b9ad | |
parent | 27c5ac029619efe630a258aae92e2c496733c677 (diff) |
Refactor how layer metadata for use by VR is propagated
from WindowManager based on feedback in frameworks/base.
Since windowType and ownerUid are immutable, they are sent
on creation instead of separate IPC.
Bug: 30984984
Test: built locally
Change-Id: I380b3cdcf6aec471fc23f1e27846ab80492e8add
-rw-r--r-- | include/gui/ISurfaceComposerClient.h | 2 | ||||
-rw-r--r-- | include/gui/SurfaceComposerClient.h | 7 | ||||
-rw-r--r-- | include/gui/SurfaceControl.h | 1 | ||||
-rw-r--r-- | include/private/gui/LayerState.h | 7 | ||||
-rw-r--r-- | libs/gui/ISurfaceComposerClient.cpp | 10 | ||||
-rw-r--r-- | libs/gui/LayerState.cpp | 4 | ||||
-rw-r--r-- | libs/gui/SurfaceComposerClient.cpp | 24 | ||||
-rw-r--r-- | libs/gui/SurfaceControl.cpp | 5 | ||||
-rw-r--r-- | services/surfaceflinger/Client.cpp | 13 | ||||
-rw-r--r-- | services/surfaceflinger/Client.h | 2 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 9 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 4 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger_hwc1.cpp | 6 |
13 files changed, 37 insertions, 57 deletions
diff --git a/include/gui/ISurfaceComposerClient.h b/include/gui/ISurfaceComposerClient.h index 0a4d35dca5..1f4387d7c2 100644 --- a/include/gui/ISurfaceComposerClient.h +++ b/include/gui/ISurfaceComposerClient.h @@ -60,7 +60,7 @@ public: virtual status_t createSurface( const String8& name, uint32_t w, uint32_t h, PixelFormat format, uint32_t flags, - const sp<IBinder>& parent, + const sp<IBinder>& parent, uint32_t windowType, uint32_t ownerUid, sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp) = 0; diff --git a/include/gui/SurfaceComposerClient.h b/include/gui/SurfaceComposerClient.h index f537020b26..830216079f 100644 --- a/include/gui/SurfaceComposerClient.h +++ b/include/gui/SurfaceComposerClient.h @@ -106,8 +106,10 @@ public: uint32_t w, // width in pixel uint32_t h, // height in pixel PixelFormat format, // pixel-format desired - uint32_t flags = 0, // usage flags - SurfaceControl* parent = nullptr // parent + uint32_t flags = 0, // usage flags + SurfaceControl* parent = nullptr, // parent + uint32_t windowType = 0, // from WindowManager.java (STATUS_BAR, INPUT_METHOD, etc.) + uint32_t ownerUid = 0 // UID of the task ); //! Create a virtual display @@ -145,7 +147,6 @@ public: status_t setFlags(const sp<IBinder>& id, uint32_t flags, uint32_t mask); status_t setTransparentRegionHint(const sp<IBinder>& id, const Region& transparent); status_t setLayer(const sp<IBinder>& id, int32_t layer); - status_t setLayerInfo(const sp<IBinder>& id, uint32_t type, uint32_t appid); status_t setAlpha(const sp<IBinder>& id, float alpha=1.0f); status_t setMatrix(const sp<IBinder>& id, float dsdx, float dtdx, float dsdy, float dtdy); status_t setPosition(const sp<IBinder>& id, float x, float y); diff --git a/include/gui/SurfaceControl.h b/include/gui/SurfaceControl.h index 2dcbfa79f9..54c8fa9dd2 100644 --- a/include/gui/SurfaceControl.h +++ b/include/gui/SurfaceControl.h @@ -62,7 +62,6 @@ public: status_t setLayerStack(uint32_t layerStack); status_t setLayer(int32_t layer); - status_t setLayerInfo(uint32_t type, uint32_t appid); status_t setPosition(float x, float y); status_t setSize(uint32_t w, uint32_t h); status_t hide(); diff --git a/include/private/gui/LayerState.h b/include/private/gui/LayerState.h index aac76d23dc..2a1801b4dd 100644 --- a/include/private/gui/LayerState.h +++ b/include/private/gui/LayerState.h @@ -56,8 +56,7 @@ struct layer_state_t { eFinalCropChanged = 0x00000400, eOverrideScalingModeChanged = 0x00000800, eGeometryAppliesWithResize = 0x00001000, - eLayerInfoChanged = 0x00002000, - eReparentChildren = 0x00004000, + eReparentChildren = 0x00002000, }; layer_state_t() @@ -66,7 +65,7 @@ struct layer_state_t { alpha(0), flags(0), mask(0), reserved(0), crop(Rect::INVALID_RECT), finalCrop(Rect::INVALID_RECT), frameNumber(0), - overrideScalingMode(-1), type(0), appid(0) + overrideScalingMode(-1) { matrix.dsdx = matrix.dtdy = 1.0f; matrix.dsdy = matrix.dtdx = 0.0f; @@ -100,8 +99,6 @@ struct layer_state_t { sp<IBinder> reparentHandle; uint64_t frameNumber; int32_t overrideScalingMode; - uint32_t type; - uint32_t appid; // non POD must be last. see write/read Region transparentRegion; }; diff --git a/libs/gui/ISurfaceComposerClient.cpp b/libs/gui/ISurfaceComposerClient.cpp index b2036dcadb..5a3fa04379 100644 --- a/libs/gui/ISurfaceComposerClient.cpp +++ b/libs/gui/ISurfaceComposerClient.cpp @@ -56,8 +56,8 @@ public: virtual status_t createSurface(const String8& name, uint32_t width, uint32_t height, PixelFormat format, uint32_t flags, - const sp<IBinder>& parent, sp<IBinder>* handle, - sp<IGraphicBufferProducer>* gbp) { + const sp<IBinder>& parent, uint32_t windowType, uint32_t ownerUid, + sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp) { Parcel data, reply; data.writeInterfaceToken(ISurfaceComposerClient::getInterfaceDescriptor()); data.writeString8(name); @@ -65,6 +65,8 @@ public: data.writeUint32(height); data.writeInt32(static_cast<int32_t>(format)); data.writeUint32(flags); + data.writeUint32(windowType); + data.writeUint32(ownerUid); if (parent != nullptr) { data.writeStrongBinder(parent); } @@ -148,6 +150,8 @@ status_t BnSurfaceComposerClient::onTransact( uint32_t height = data.readUint32(); PixelFormat format = static_cast<PixelFormat>(data.readInt32()); uint32_t createFlags = data.readUint32(); + uint32_t windowType = data.readUint32(); + uint32_t ownerUid = data.readUint32(); sp<IBinder> parent = nullptr; if (data.dataAvail() > 0) { parent = data.readStrongBinder(); @@ -155,7 +159,7 @@ status_t BnSurfaceComposerClient::onTransact( sp<IBinder> handle; sp<IGraphicBufferProducer> gbp; status_t result = createSurface(name, width, height, format, - createFlags, parent, &handle, &gbp); + createFlags, parent, windowType, ownerUid, &handle, &gbp); reply->writeStrongBinder(handle); reply->writeStrongBinder(IInterface::asBinder(gbp)); reply->writeInt32(result); diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp index fbf76a1f50..bb552aa67c 100644 --- a/libs/gui/LayerState.cpp +++ b/libs/gui/LayerState.cpp @@ -43,8 +43,6 @@ status_t layer_state_t::write(Parcel& output) const output.writeStrongBinder(reparentHandle); output.writeUint64(frameNumber); output.writeInt32(overrideScalingMode); - output.writeUint32(type); - output.writeUint32(appid); output.write(transparentRegion); return NO_ERROR; } @@ -74,8 +72,6 @@ status_t layer_state_t::read(const Parcel& input) reparentHandle = input.readStrongBinder(); frameNumber = input.readUint64(); overrideScalingMode = input.readInt32(); - type = input.readUint32(); - appid = input.readUint32(); input.read(transparentRegion); return NO_ERROR; } diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index ece07a33fb..ae81c8fbd1 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -149,8 +149,6 @@ public: uint32_t w, uint32_t h); status_t setLayer(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id, int32_t z); - status_t setLayerInfo(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id, - uint32_t type, uint32_t appid); status_t setFlags(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id, uint32_t flags, uint32_t mask); status_t setTransparentRegionHint( @@ -340,18 +338,6 @@ status_t Composer::setLayer(const sp<SurfaceComposerClient>& client, return NO_ERROR; } -status_t Composer::setLayerInfo(const sp<SurfaceComposerClient>& client, - const sp<IBinder>& id, uint32_t type, uint32_t appid) { - Mutex::Autolock _l(mLock); - layer_state_t* s = getLayerStateLocked(client, id); - if (!s) - return BAD_INDEX; - s->what |= layer_state_t::eLayerInfoChanged; - s->type = type; - s->appid = appid; - return NO_ERROR; -} - status_t Composer::setFlags(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id, uint32_t flags, uint32_t mask) { @@ -636,7 +622,9 @@ sp<SurfaceControl> SurfaceComposerClient::createSurface( uint32_t h, PixelFormat format, uint32_t flags, - SurfaceControl* parent) + SurfaceControl* parent, + uint32_t windowType, + uint32_t ownerUid) { sp<SurfaceControl> sur; if (mStatus == NO_ERROR) { @@ -648,7 +636,7 @@ sp<SurfaceControl> SurfaceComposerClient::createSurface( parentHandle = parent->getHandle(); } status_t err = mClient->createSurface(name, w, h, format, flags, parentHandle, - &handle, &gbp); + windowType, ownerUid, &handle, &gbp); ALOGE_IF(err, "SurfaceComposerClient::createSurface error %s", strerror(-err)); if (err == NO_ERROR) { sur = new SurfaceControl(this, handle, gbp); @@ -749,10 +737,6 @@ status_t SurfaceComposerClient::setLayer(const sp<IBinder>& id, int32_t z) { return getComposer().setLayer(this, id, z); } -status_t SurfaceComposerClient::setLayerInfo(const sp<IBinder>& id, uint32_t type, uint32_t appid) { - return getComposer().setLayerInfo(this, id, type, appid); -} - status_t SurfaceComposerClient::hide(const sp<IBinder>& id) { return getComposer().setFlags(this, id, layer_state_t::eLayerHidden, diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp index 2d05b78483..0362216258 100644 --- a/libs/gui/SurfaceControl.cpp +++ b/libs/gui/SurfaceControl.cpp @@ -107,11 +107,6 @@ status_t SurfaceControl::setLayer(int32_t layer) { if (err < 0) return err; return mClient->setLayer(mHandle, layer); } -status_t SurfaceControl::setLayerInfo(uint32_t type, uint32_t appid) { - status_t err = validate(); - if (err < 0) return err; - return mClient->setLayerInfo(mHandle, type, appid); -} status_t SurfaceControl::setPosition(float x, float y) { status_t err = validate(); if (err < 0) return err; diff --git a/services/surfaceflinger/Client.cpp b/services/surfaceflinger/Client.cpp index f63784e18b..2b4f4cb6fd 100644 --- a/services/surfaceflinger/Client.cpp +++ b/services/surfaceflinger/Client.cpp @@ -121,7 +121,7 @@ status_t Client::onTransact( status_t Client::createSurface( const String8& name, uint32_t w, uint32_t h, PixelFormat format, uint32_t flags, - const sp<IBinder>& parentHandle, + const sp<IBinder>& parentHandle, uint32_t windowType, uint32_t ownerUid, sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp) { @@ -156,28 +156,31 @@ status_t Client::createSurface( PixelFormat format; uint32_t flags; sp<Layer>* parent; + uint32_t windowType; + uint32_t ownerUid; public: MessageCreateLayer(SurfaceFlinger* flinger, const String8& name, Client* client, uint32_t w, uint32_t h, PixelFormat format, uint32_t flags, - sp<IBinder>* handle, + sp<IBinder>* handle, uint32_t windowType, uint32_t ownerUid, sp<IGraphicBufferProducer>* gbp, sp<Layer>* parent) : flinger(flinger), client(client), handle(handle), gbp(gbp), result(NO_ERROR), name(name), w(w), h(h), format(format), flags(flags), - parent(parent) { + parent(parent), windowType(windowType), ownerUid(ownerUid) { } status_t getResult() const { return result; } virtual bool handler() { result = flinger->createLayer(name, client, w, h, format, flags, - handle, gbp, parent); + windowType, ownerUid, handle, gbp, parent); return true; } }; sp<MessageBase> msg = new MessageCreateLayer(mFlinger.get(), - name, this, w, h, format, flags, handle, gbp, &parent); + name, this, w, h, format, flags, handle, + windowType, ownerUid, gbp, &parent); mFlinger->postMessageSync(msg); return static_cast<MessageCreateLayer*>( msg.get() )->getResult(); } diff --git a/services/surfaceflinger/Client.h b/services/surfaceflinger/Client.h index 7328c224e9..141f6c767e 100644 --- a/services/surfaceflinger/Client.h +++ b/services/surfaceflinger/Client.h @@ -58,7 +58,7 @@ private: virtual status_t createSurface( const String8& name, uint32_t w, uint32_t h,PixelFormat format, uint32_t flags, - const sp<IBinder>& parent, + const sp<IBinder>& parent, uint32_t windowType, uint32_t ownerUid, sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp); diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 8cc8e318a6..a29c584c4e 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2600,9 +2600,6 @@ uint32_t SurfaceFlinger::setClientStateLocked( // We don't trigger a traversal here because if no other state is // changed, we don't want this to cause any more work } - if (what & layer_state_t::eLayerInfoChanged) { - layer->setInfo(s.type, s.appid); - } } return flags; } @@ -2611,8 +2608,8 @@ status_t SurfaceFlinger::createLayer( const String8& name, const sp<Client>& client, uint32_t w, uint32_t h, PixelFormat format, uint32_t flags, - sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp, - sp<Layer>* parent) + uint32_t windowType, uint32_t ownerUid, sp<IBinder>* handle, + sp<IGraphicBufferProducer>* gbp, sp<Layer>* parent) { if (int32_t(w|h) < 0) { ALOGE("createLayer() failed, w or h is negative (w=%d, h=%d)", @@ -2644,6 +2641,8 @@ status_t SurfaceFlinger::createLayer( return result; } + layer->setInfo(windowType, ownerUid); + result = addClientLayer(client, *handle, *gbp, layer, *parent); if (result != NO_ERROR) { return result; diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 45a52689d6..75c1920d52 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -294,8 +294,8 @@ private: */ status_t createLayer(const String8& name, const sp<Client>& client, uint32_t w, uint32_t h, PixelFormat format, uint32_t flags, - sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp, - sp<Layer>* parent); + uint32_t windowType, uint32_t ownerUid, sp<IBinder>* handle, + sp<IGraphicBufferProducer>* gbp, sp<Layer>* parent); status_t createNormalLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, PixelFormat& format, diff --git a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp index 2cd02a0919..f8a1f34060 100644 --- a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp +++ b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp @@ -2515,8 +2515,8 @@ status_t SurfaceFlinger::createLayer( const String8& name, const sp<Client>& client, uint32_t w, uint32_t h, PixelFormat format, uint32_t flags, - sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp, - sp<Layer>* parent) + uint32_t windowType, uint32_t ownerUid, sp<IBinder>* handle, + sp<IGraphicBufferProducer>* gbp, sp<Layer>* parent) { if (int32_t(w|h) < 0) { ALOGE("createLayer() failed, w or h is negative (w=%d, h=%d)", @@ -2548,6 +2548,8 @@ status_t SurfaceFlinger::createLayer( return result; } + layer->setInfo(windowType, ownerUid); + result = addClientLayer(client, *handle, *gbp, layer, *parent); if (result != NO_ERROR) { return result; |