diff options
author | 2020-09-01 18:28:58 +0000 | |
---|---|---|
committer | 2020-09-25 12:33:30 +0000 | |
commit | dbc31672ea7e7b8e8847db8ef70447de918d5b27 (patch) | |
tree | 3384e13cede47e1920cd31dbb7c548319b638472 /libs/gui/SurfaceComposerClient.cpp | |
parent | 91512a00615042c9e80ec3f907339389a53a9810 (diff) |
Add LayerId to SurfaceControl and LayerState when created
Allows us to then dump the LayerState on transaction merges and have an id to associate the LayerState with a layer
Test: Check if layer id is available in the LayerState when we dump the LayerState on merges
Change-Id: I5046835d6a82574110125c7dbdf2098bd10ac296
Diffstat (limited to 'libs/gui/SurfaceComposerClient.cpp')
-rw-r--r-- | libs/gui/SurfaceComposerClient.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 0264e17b97..dd24c2c9c8 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -443,12 +443,14 @@ status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel std::unordered_map<sp<IBinder>, ComposerState, IBinderHash> composerStates; composerStates.reserve(count); for (size_t i = 0; i < count; i++) { - sp<IBinder> surfaceControlHandle = parcel->readStrongBinder(); + sp<IBinder> surfaceControlHandle; + SAFE_PARCEL(parcel->readStrongBinder, &surfaceControlHandle); ComposerState composerState; if (composerState.read(*parcel) == BAD_VALUE) { return BAD_VALUE; } + composerStates[surfaceControlHandle] = composerState; } @@ -512,8 +514,8 @@ status_t SurfaceComposerClient::Transaction::writeToParcel(Parcel* parcel) const } parcel->writeUint32(static_cast<uint32_t>(mComposerStates.size())); - for (auto const& [surfaceHandle, composerState] : mComposerStates) { - parcel->writeStrongBinder(surfaceHandle); + for (auto const& [handle, composerState] : mComposerStates) { + SAFE_PARCEL(parcel->writeStrongBinder, handle); composerState.write(*parcel); } @@ -522,11 +524,11 @@ status_t SurfaceComposerClient::Transaction::writeToParcel(Parcel* parcel) const } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Transaction&& other) { - for (auto const& [surfaceHandle, composerState] : other.mComposerStates) { - if (mComposerStates.count(surfaceHandle) == 0) { - mComposerStates[surfaceHandle] = composerState; + for (auto const& [handle, composerState] : other.mComposerStates) { + if (mComposerStates.count(handle) == 0) { + mComposerStates[handle] = composerState; } else { - mComposerStates[surfaceHandle].state.merge(composerState.state); + mComposerStates[handle].state.merge(composerState.state); } } @@ -606,7 +608,7 @@ void SurfaceComposerClient::Transaction::cacheBuffers() { size_t count = 0; for (auto& [handle, cs] : mComposerStates) { - layer_state_t* s = getLayerState(handle); + layer_state_t* s = &(mComposerStates[handle].state); if (!(s->what & layer_state_t::eBufferChanged)) { continue; } else if (s->what & layer_state_t::eCachedBufferChanged) { @@ -779,11 +781,16 @@ void SurfaceComposerClient::Transaction::setExplicitEarlyWakeupEnd() { mExplicitEarlyWakeupEnd = true; } -layer_state_t* SurfaceComposerClient::Transaction::getLayerState(const sp<IBinder>& handle) { +layer_state_t* SurfaceComposerClient::Transaction::getLayerState(const sp<SurfaceControl>& sc) { + auto handle = sc->getHandle(); + if (mComposerStates.count(handle) == 0) { // we don't have it, add an initialized layer_state to our list ComposerState s; + s.state.surface = handle; + s.state.layerId = sc->getLayerId(); + mComposerStates[handle] = s; } @@ -1664,7 +1671,7 @@ sp<SurfaceControl> SurfaceComposerClient::createWithSurfaceParent(const String8& } ALOGE_IF(err, "SurfaceComposerClient::createWithSurfaceParent error %s", strerror(-err)); if (err == NO_ERROR) { - return new SurfaceControl(this, handle, gbp, transformHint); + return new SurfaceControl(this, handle, gbp, id, transformHint); } } return nullptr; @@ -1697,7 +1704,7 @@ status_t SurfaceComposerClient::createSurfaceChecked(const String8& name, uint32 } ALOGE_IF(err, "SurfaceComposerClient::createSurface error %s", strerror(-err)); if (err == NO_ERROR) { - *outSurface = new SurfaceControl(this, handle, gbp, transformHint); + *outSurface = new SurfaceControl(this, handle, gbp, id, transformHint); } } return err; @@ -1713,7 +1720,7 @@ sp<SurfaceControl> SurfaceComposerClient::mirrorSurface(SurfaceControl* mirrorFr int32_t layer_id = -1; status_t err = mClient->mirrorSurface(mirrorFromHandle, &handle, &layer_id); if (err == NO_ERROR) { - return new SurfaceControl(this, handle, nullptr, true /* owned */); + return new SurfaceControl(this, handle, nullptr, layer_id, true /* owned */); } return nullptr; } |