Loading libs/gui/LayerState.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ namespace android { status_t layer_state_t::write(Parcel& output) const { SAFE_PARCEL(output.writeStrongBinder, surface); SAFE_PARCEL(output.writeInt32, layerId); SAFE_PARCEL(output.writeUint64, what); SAFE_PARCEL(output.writeFloat, x); SAFE_PARCEL(output.writeFloat, y); Loading Loading @@ -115,6 +116,7 @@ status_t layer_state_t::write(Parcel& output) const status_t layer_state_t::read(const Parcel& input) { SAFE_PARCEL(input.readNullableStrongBinder, &surface); SAFE_PARCEL(input.readInt32, &layerId); SAFE_PARCEL(input.readUint64, &what); SAFE_PARCEL(input.readFloat, &x); SAFE_PARCEL(input.readFloat, &y); Loading libs/gui/SurfaceComposerClient.cpp +19 −12 Original line number Diff line number Diff line Loading @@ -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; } Loading Loading @@ -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); } Loading @@ -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); } } Loading Loading @@ -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) { Loading Loading @@ -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; } Loading Loading @@ -1678,7 +1685,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; Loading Loading @@ -1711,7 +1718,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; Loading @@ -1727,7 +1734,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; } Loading libs/gui/SurfaceControl.cpp +11 −2 Original line number Diff line number Diff line Loading @@ -46,11 +46,12 @@ namespace android { // ============================================================================ SurfaceControl::SurfaceControl(const sp<SurfaceComposerClient>& client, const sp<IBinder>& handle, const sp<IGraphicBufferProducer>& gbp, const sp<IGraphicBufferProducer>& gbp, int32_t layerId, uint32_t transform) : mClient(client), mHandle(handle), mGraphicBufferProducer(gbp), mLayerId(layerId), mTransformHint(transform) {} SurfaceControl::SurfaceControl(const sp<SurfaceControl>& other) { Loading @@ -58,6 +59,7 @@ SurfaceControl::SurfaceControl(const sp<SurfaceControl>& other) { mHandle = other->mHandle; mGraphicBufferProducer = other->mGraphicBufferProducer; mTransformHint = other->mTransformHint; mLayerId = other->mLayerId; } SurfaceControl::~SurfaceControl() Loading Loading @@ -148,6 +150,10 @@ sp<IBinder> SurfaceControl::getHandle() const return mHandle; } int32_t SurfaceControl::getLayerId() const { return mLayerId; } sp<IGraphicBufferProducer> SurfaceControl::getIGraphicBufferProducer() const { Mutex::Autolock _l(mLock); Loading @@ -173,6 +179,7 @@ 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); return NO_ERROR; Loading @@ -183,18 +190,20 @@ status_t SurfaceControl::readFromParcel(const Parcel& parcel, sp<IBinder> client; sp<IBinder> handle; sp<IBinder> gbp; int32_t layerId; uint32_t transformHint; 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); // We aren't the original owner of the surface. *outSurfaceControl = new SurfaceControl(new SurfaceComposerClient( interface_cast<ISurfaceComposerClient>(client)), handle.get(), interface_cast<IGraphicBufferProducer>(gbp), handle.get(), interface_cast<IGraphicBufferProducer>(gbp), layerId, transformHint); return NO_ERROR; Loading libs/gui/include/gui/LayerState.h +1 −0 Original line number Diff line number Diff line Loading @@ -180,6 +180,7 @@ struct layer_state_t { status_t read(const Parcel& input); }; sp<IBinder> surface; int32_t layerId; uint64_t what; float x; float y; Loading libs/gui/include/gui/SurfaceComposerClient.h +2 −5 Original line number Diff line number Diff line Loading @@ -376,10 +376,7 @@ public: InputWindowCommands mInputWindowCommands; int mStatus = NO_ERROR; layer_state_t* getLayerState(const sp<IBinder>& surfaceHandle); layer_state_t* getLayerState(const sp<SurfaceControl>& sc) { return getLayerState(sc->getHandle()); } layer_state_t* getLayerState(const sp<SurfaceControl>& sc); DisplayState& getDisplayState(const sp<IBinder>& token); void cacheBuffers(); Loading Loading
libs/gui/LayerState.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ namespace android { status_t layer_state_t::write(Parcel& output) const { SAFE_PARCEL(output.writeStrongBinder, surface); SAFE_PARCEL(output.writeInt32, layerId); SAFE_PARCEL(output.writeUint64, what); SAFE_PARCEL(output.writeFloat, x); SAFE_PARCEL(output.writeFloat, y); Loading Loading @@ -115,6 +116,7 @@ status_t layer_state_t::write(Parcel& output) const status_t layer_state_t::read(const Parcel& input) { SAFE_PARCEL(input.readNullableStrongBinder, &surface); SAFE_PARCEL(input.readInt32, &layerId); SAFE_PARCEL(input.readUint64, &what); SAFE_PARCEL(input.readFloat, &x); SAFE_PARCEL(input.readFloat, &y); Loading
libs/gui/SurfaceComposerClient.cpp +19 −12 Original line number Diff line number Diff line Loading @@ -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; } Loading Loading @@ -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); } Loading @@ -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); } } Loading Loading @@ -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) { Loading Loading @@ -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; } Loading Loading @@ -1678,7 +1685,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; Loading Loading @@ -1711,7 +1718,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; Loading @@ -1727,7 +1734,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; } Loading
libs/gui/SurfaceControl.cpp +11 −2 Original line number Diff line number Diff line Loading @@ -46,11 +46,12 @@ namespace android { // ============================================================================ SurfaceControl::SurfaceControl(const sp<SurfaceComposerClient>& client, const sp<IBinder>& handle, const sp<IGraphicBufferProducer>& gbp, const sp<IGraphicBufferProducer>& gbp, int32_t layerId, uint32_t transform) : mClient(client), mHandle(handle), mGraphicBufferProducer(gbp), mLayerId(layerId), mTransformHint(transform) {} SurfaceControl::SurfaceControl(const sp<SurfaceControl>& other) { Loading @@ -58,6 +59,7 @@ SurfaceControl::SurfaceControl(const sp<SurfaceControl>& other) { mHandle = other->mHandle; mGraphicBufferProducer = other->mGraphicBufferProducer; mTransformHint = other->mTransformHint; mLayerId = other->mLayerId; } SurfaceControl::~SurfaceControl() Loading Loading @@ -148,6 +150,10 @@ sp<IBinder> SurfaceControl::getHandle() const return mHandle; } int32_t SurfaceControl::getLayerId() const { return mLayerId; } sp<IGraphicBufferProducer> SurfaceControl::getIGraphicBufferProducer() const { Mutex::Autolock _l(mLock); Loading @@ -173,6 +179,7 @@ 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); return NO_ERROR; Loading @@ -183,18 +190,20 @@ status_t SurfaceControl::readFromParcel(const Parcel& parcel, sp<IBinder> client; sp<IBinder> handle; sp<IBinder> gbp; int32_t layerId; uint32_t transformHint; 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); // We aren't the original owner of the surface. *outSurfaceControl = new SurfaceControl(new SurfaceComposerClient( interface_cast<ISurfaceComposerClient>(client)), handle.get(), interface_cast<IGraphicBufferProducer>(gbp), handle.get(), interface_cast<IGraphicBufferProducer>(gbp), layerId, transformHint); return NO_ERROR; Loading
libs/gui/include/gui/LayerState.h +1 −0 Original line number Diff line number Diff line Loading @@ -180,6 +180,7 @@ struct layer_state_t { status_t read(const Parcel& input); }; sp<IBinder> surface; int32_t layerId; uint64_t what; float x; float y; Loading
libs/gui/include/gui/SurfaceComposerClient.h +2 −5 Original line number Diff line number Diff line Loading @@ -376,10 +376,7 @@ public: InputWindowCommands mInputWindowCommands; int mStatus = NO_ERROR; layer_state_t* getLayerState(const sp<IBinder>& surfaceHandle); layer_state_t* getLayerState(const sp<SurfaceControl>& sc) { return getLayerState(sc->getHandle()); } layer_state_t* getLayerState(const sp<SurfaceControl>& sc); DisplayState& getDisplayState(const sp<IBinder>& token); void cacheBuffers(); Loading