Loading libs/gui/LayerState.cpp +0 −2 Original line number Original line Diff line number Diff line Loading @@ -169,12 +169,10 @@ status_t layer_state_t::read(const Parcel& input) } } status_t ComposerState::write(Parcel& output) const { status_t ComposerState::write(Parcel& output) const { output.writeStrongBinder(IInterface::asBinder(client)); return state.write(output); return state.write(output); } } status_t ComposerState::read(const Parcel& input) { status_t ComposerState::read(const Parcel& input) { client = interface_cast<ISurfaceComposerClient>(input.readStrongBinder()); return state.read(input); return state.read(input); } } Loading libs/gui/SurfaceComposerClient.cpp +19 −21 Original line number Original line Diff line number Diff line Loading @@ -202,7 +202,8 @@ void TransactionCompletedListener::onTransactionCompleted(ListenerStats listener * callbackIds to generate one super map that contains all the sp<IBinder> to sp<SurfaceControl> * callbackIds to generate one super map that contains all the sp<IBinder> to sp<SurfaceControl> * that could possibly exist for the callbacks. * that could possibly exist for the callbacks. */ */ std::unordered_map<sp<IBinder>, sp<SurfaceControl>, IBinderHash> surfaceControls; std::unordered_map<sp<IBinder>, sp<SurfaceControl>, SurfaceComposerClient::IBinderHash> surfaceControls; for (const auto& transactionStats : listenerStats.transactionStats) { for (const auto& transactionStats : listenerStats.transactionStats) { for (auto callbackId : transactionStats.callbackIds) { for (auto callbackId : transactionStats.callbackIds) { auto& [callbackFunction, callbackSurfaceControls] = mCallbacks[callbackId]; auto& [callbackFunction, callbackSurfaceControls] = mCallbacks[callbackId]; Loading Loading @@ -365,16 +366,16 @@ status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel if (count > parcel->dataSize()) { if (count > parcel->dataSize()) { return BAD_VALUE; return BAD_VALUE; } } std::unordered_map<sp<SurfaceControl>, ComposerState, SCHash> composerStates; std::unordered_map<sp<IBinder>, ComposerState, IBinderHash> composerStates; composerStates.reserve(count); composerStates.reserve(count); for (size_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) { sp<SurfaceControl> surfaceControl = SurfaceControl::readFromParcel(parcel); sp<IBinder> surfaceControlHandle = parcel->readStrongBinder(); ComposerState composerState; ComposerState composerState; if (composerState.read(*parcel) == BAD_VALUE) { if (composerState.read(*parcel) == BAD_VALUE) { return BAD_VALUE; return BAD_VALUE; } } composerStates[surfaceControl] = composerState; composerStates[surfaceControlHandle] = composerState; } } InputWindowCommands inputWindowCommands; InputWindowCommands inputWindowCommands; Loading Loading @@ -408,8 +409,8 @@ status_t SurfaceComposerClient::Transaction::writeToParcel(Parcel* parcel) const } } parcel->writeUint32(static_cast<uint32_t>(mComposerStates.size())); parcel->writeUint32(static_cast<uint32_t>(mComposerStates.size())); for (auto const& [surfaceControl, composerState] : mComposerStates) { for (auto const& [surfaceHandle, composerState] : mComposerStates) { surfaceControl->writeToParcel(parcel); parcel->writeStrongBinder(surfaceHandle); composerState.write(*parcel); composerState.write(*parcel); } } Loading @@ -418,11 +419,11 @@ status_t SurfaceComposerClient::Transaction::writeToParcel(Parcel* parcel) const } } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Transaction&& other) { SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Transaction&& other) { for (auto const& kv : other.mComposerStates) { for (auto const& [surfaceHandle, composerState] : other.mComposerStates) { if (mComposerStates.count(kv.first) == 0) { if (mComposerStates.count(surfaceHandle) == 0) { mComposerStates[kv.first] = kv.second; mComposerStates[surfaceHandle] = composerState; } else { } else { mComposerStates[kv.first].state.merge(kv.second.state); mComposerStates[surfaceHandle].state.merge(composerState.state); } } } } Loading Loading @@ -466,14 +467,12 @@ void SurfaceComposerClient::Transaction::clear() { mDesiredPresentTime = -1; mDesiredPresentTime = -1; } } void SurfaceComposerClient::doDropReferenceTransaction(const sp<IBinder>& handle, void SurfaceComposerClient::doDropReferenceTransaction(const sp<IBinder>& handle) { const sp<ISurfaceComposerClient>& client) { sp<ISurfaceComposer> sf(ComposerService::getComposerService()); sp<ISurfaceComposer> sf(ComposerService::getComposerService()); Vector<ComposerState> composerStates; Vector<ComposerState> composerStates; Vector<DisplayState> displayStates; Vector<DisplayState> displayStates; ComposerState s; ComposerState s; s.client = client; s.state.surface = handle; s.state.surface = handle; s.state.what |= layer_state_t::eReparent; s.state.what |= layer_state_t::eReparent; s.state.parentHandleForChild = nullptr; s.state.parentHandleForChild = nullptr; Loading @@ -500,8 +499,8 @@ void SurfaceComposerClient::Transaction::cacheBuffers() { } } size_t count = 0; size_t count = 0; for (auto& [sc, cs] : mComposerStates) { for (auto& [handle, cs] : mComposerStates) { layer_state_t* s = getLayerState(sc); layer_state_t* s = getLayerState(handle); if (!(s->what & layer_state_t::eBufferChanged)) { if (!(s->what & layer_state_t::eBufferChanged)) { continue; continue; } } Loading Loading @@ -640,16 +639,15 @@ void SurfaceComposerClient::Transaction::setEarlyWakeup() { mEarlyWakeup = true; mEarlyWakeup = true; } } layer_state_t* SurfaceComposerClient::Transaction::getLayerState(const sp<SurfaceControl>& sc) { layer_state_t* SurfaceComposerClient::Transaction::getLayerState(const sp<IBinder>& handle) { if (mComposerStates.count(sc) == 0) { if (mComposerStates.count(handle) == 0) { // we don't have it, add an initialized layer_state to our list // we don't have it, add an initialized layer_state to our list ComposerState s; ComposerState s; s.client = sc->getClient()->mClient; s.state.surface = handle; s.state.surface = sc->getHandle(); mComposerStates[handle] = s; mComposerStates[sc] = s; } } return &(mComposerStates[sc].state); return &(mComposerStates[handle].state); } } void SurfaceComposerClient::Transaction::registerSurfaceControlForCallback( void SurfaceComposerClient::Transaction::registerSurfaceControlForCallback( Loading libs/gui/SurfaceControl.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -65,8 +65,8 @@ SurfaceControl::~SurfaceControl() { { // Avoid reparenting the server-side surface to null if we are not the owner of it, // Avoid reparenting the server-side surface to null if we are not the owner of it, // meaning that we retrieved it from another process. // meaning that we retrieved it from another process. if (mClient != nullptr && mHandle != nullptr && mOwned) { if (mHandle != nullptr && mOwned) { SurfaceComposerClient::doDropReferenceTransaction(mHandle, mClient->getClient()); SurfaceComposerClient::doDropReferenceTransaction(mHandle); } } release(); release(); } } Loading libs/gui/include/gui/LayerState.h +0 −3 Original line number Original line Diff line number Diff line Loading @@ -206,7 +206,6 @@ struct layer_state_t { }; }; struct ComposerState { struct ComposerState { sp<ISurfaceComposerClient> client; layer_state_t state; layer_state_t state; status_t write(Parcel& output) const; status_t write(Parcel& output) const; status_t read(const Parcel& input); status_t read(const Parcel& input); Loading Loading @@ -274,8 +273,6 @@ struct InputWindowCommands { }; }; static inline int compare_type(const ComposerState& lhs, const ComposerState& rhs) { static inline int compare_type(const ComposerState& lhs, const ComposerState& rhs) { if (lhs.client < rhs.client) return -1; if (lhs.client > rhs.client) return 1; if (lhs.state.surface < rhs.state.surface) return -1; if (lhs.state.surface < rhs.state.surface) return -1; if (lhs.state.surface > rhs.state.surface) return 1; if (lhs.state.surface > rhs.state.surface) return 1; return 0; return 0; Loading libs/gui/include/gui/SurfaceComposerClient.h +14 −11 Original line number Original line Diff line number Diff line Loading @@ -163,8 +163,7 @@ public: * Called from SurfaceControl d'tor to 'destroy' the surface (or rather, reparent it * Called from SurfaceControl d'tor to 'destroy' the surface (or rather, reparent it * to null), but without needing an sp<SurfaceControl> to avoid infinite ressurection. * to null), but without needing an sp<SurfaceControl> to avoid infinite ressurection. */ */ static void doDropReferenceTransaction(const sp<IBinder>& handle, static void doDropReferenceTransaction(const sp<IBinder>& handle); const sp<ISurfaceComposerClient>& client); /** /** * Uncaches a buffer in ISurfaceComposer. It must be uncached via a transaction so that it is * Uncaches a buffer in ISurfaceComposer. It must be uncached via a transaction so that it is Loading Loading @@ -270,6 +269,12 @@ public: } } }; }; struct IBinderHash { std::size_t operator()(const sp<IBinder>& iBinder) const { return std::hash<IBinder*>{}(iBinder.get()); } }; struct TCLHash { struct TCLHash { std::size_t operator()(const sp<ITransactionCompletedListener>& tcl) const { std::size_t operator()(const sp<ITransactionCompletedListener>& tcl) const { return std::hash<IBinder*>{}((tcl) ? IInterface::asBinder(tcl).get() : nullptr); return std::hash<IBinder*>{}((tcl) ? IInterface::asBinder(tcl).get() : nullptr); Loading @@ -286,7 +291,7 @@ public: }; }; class Transaction : Parcelable { class Transaction : Parcelable { std::unordered_map<sp<SurfaceControl>, ComposerState, SCHash> mComposerStates; std::unordered_map<sp<IBinder>, ComposerState, IBinderHash> mComposerStates; SortedVector<DisplayState > mDisplayStates; SortedVector<DisplayState > mDisplayStates; std::unordered_map<sp<ITransactionCompletedListener>, CallbackInfo, TCLHash> std::unordered_map<sp<ITransactionCompletedListener>, CallbackInfo, TCLHash> mListenerCallbacks; mListenerCallbacks; Loading Loading @@ -314,7 +319,10 @@ public: InputWindowCommands mInputWindowCommands; InputWindowCommands mInputWindowCommands; int mStatus = NO_ERROR; int mStatus = NO_ERROR; layer_state_t* getLayerState(const sp<SurfaceControl>& sc); layer_state_t* getLayerState(const sp<IBinder>& surfaceHandle); layer_state_t* getLayerState(const sp<SurfaceControl>& sc) { return getLayerState(sc->getHandle()); } DisplayState& getDisplayState(const sp<IBinder>& token); DisplayState& getDisplayState(const sp<IBinder>& token); void cacheBuffers(); void cacheBuffers(); Loading Loading @@ -560,15 +568,10 @@ class TransactionCompletedListener : public BnTransactionCompletedListener { CallbackId mCallbackIdCounter GUARDED_BY(mMutex) = 1; CallbackId mCallbackIdCounter GUARDED_BY(mMutex) = 1; struct IBinderHash { std::size_t operator()(const sp<IBinder>& iBinder) const { return std::hash<IBinder*>{}(iBinder.get()); } }; struct CallbackTranslation { struct CallbackTranslation { TransactionCompletedCallback callbackFunction; TransactionCompletedCallback callbackFunction; std::unordered_map<sp<IBinder>, sp<SurfaceControl>, IBinderHash> surfaceControls; std::unordered_map<sp<IBinder>, sp<SurfaceControl>, SurfaceComposerClient::IBinderHash> surfaceControls; }; }; std::unordered_map<CallbackId, CallbackTranslation> mCallbacks GUARDED_BY(mMutex); std::unordered_map<CallbackId, CallbackTranslation> mCallbacks GUARDED_BY(mMutex); Loading Loading
libs/gui/LayerState.cpp +0 −2 Original line number Original line Diff line number Diff line Loading @@ -169,12 +169,10 @@ status_t layer_state_t::read(const Parcel& input) } } status_t ComposerState::write(Parcel& output) const { status_t ComposerState::write(Parcel& output) const { output.writeStrongBinder(IInterface::asBinder(client)); return state.write(output); return state.write(output); } } status_t ComposerState::read(const Parcel& input) { status_t ComposerState::read(const Parcel& input) { client = interface_cast<ISurfaceComposerClient>(input.readStrongBinder()); return state.read(input); return state.read(input); } } Loading
libs/gui/SurfaceComposerClient.cpp +19 −21 Original line number Original line Diff line number Diff line Loading @@ -202,7 +202,8 @@ void TransactionCompletedListener::onTransactionCompleted(ListenerStats listener * callbackIds to generate one super map that contains all the sp<IBinder> to sp<SurfaceControl> * callbackIds to generate one super map that contains all the sp<IBinder> to sp<SurfaceControl> * that could possibly exist for the callbacks. * that could possibly exist for the callbacks. */ */ std::unordered_map<sp<IBinder>, sp<SurfaceControl>, IBinderHash> surfaceControls; std::unordered_map<sp<IBinder>, sp<SurfaceControl>, SurfaceComposerClient::IBinderHash> surfaceControls; for (const auto& transactionStats : listenerStats.transactionStats) { for (const auto& transactionStats : listenerStats.transactionStats) { for (auto callbackId : transactionStats.callbackIds) { for (auto callbackId : transactionStats.callbackIds) { auto& [callbackFunction, callbackSurfaceControls] = mCallbacks[callbackId]; auto& [callbackFunction, callbackSurfaceControls] = mCallbacks[callbackId]; Loading Loading @@ -365,16 +366,16 @@ status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel if (count > parcel->dataSize()) { if (count > parcel->dataSize()) { return BAD_VALUE; return BAD_VALUE; } } std::unordered_map<sp<SurfaceControl>, ComposerState, SCHash> composerStates; std::unordered_map<sp<IBinder>, ComposerState, IBinderHash> composerStates; composerStates.reserve(count); composerStates.reserve(count); for (size_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) { sp<SurfaceControl> surfaceControl = SurfaceControl::readFromParcel(parcel); sp<IBinder> surfaceControlHandle = parcel->readStrongBinder(); ComposerState composerState; ComposerState composerState; if (composerState.read(*parcel) == BAD_VALUE) { if (composerState.read(*parcel) == BAD_VALUE) { return BAD_VALUE; return BAD_VALUE; } } composerStates[surfaceControl] = composerState; composerStates[surfaceControlHandle] = composerState; } } InputWindowCommands inputWindowCommands; InputWindowCommands inputWindowCommands; Loading Loading @@ -408,8 +409,8 @@ status_t SurfaceComposerClient::Transaction::writeToParcel(Parcel* parcel) const } } parcel->writeUint32(static_cast<uint32_t>(mComposerStates.size())); parcel->writeUint32(static_cast<uint32_t>(mComposerStates.size())); for (auto const& [surfaceControl, composerState] : mComposerStates) { for (auto const& [surfaceHandle, composerState] : mComposerStates) { surfaceControl->writeToParcel(parcel); parcel->writeStrongBinder(surfaceHandle); composerState.write(*parcel); composerState.write(*parcel); } } Loading @@ -418,11 +419,11 @@ status_t SurfaceComposerClient::Transaction::writeToParcel(Parcel* parcel) const } } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Transaction&& other) { SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Transaction&& other) { for (auto const& kv : other.mComposerStates) { for (auto const& [surfaceHandle, composerState] : other.mComposerStates) { if (mComposerStates.count(kv.first) == 0) { if (mComposerStates.count(surfaceHandle) == 0) { mComposerStates[kv.first] = kv.second; mComposerStates[surfaceHandle] = composerState; } else { } else { mComposerStates[kv.first].state.merge(kv.second.state); mComposerStates[surfaceHandle].state.merge(composerState.state); } } } } Loading Loading @@ -466,14 +467,12 @@ void SurfaceComposerClient::Transaction::clear() { mDesiredPresentTime = -1; mDesiredPresentTime = -1; } } void SurfaceComposerClient::doDropReferenceTransaction(const sp<IBinder>& handle, void SurfaceComposerClient::doDropReferenceTransaction(const sp<IBinder>& handle) { const sp<ISurfaceComposerClient>& client) { sp<ISurfaceComposer> sf(ComposerService::getComposerService()); sp<ISurfaceComposer> sf(ComposerService::getComposerService()); Vector<ComposerState> composerStates; Vector<ComposerState> composerStates; Vector<DisplayState> displayStates; Vector<DisplayState> displayStates; ComposerState s; ComposerState s; s.client = client; s.state.surface = handle; s.state.surface = handle; s.state.what |= layer_state_t::eReparent; s.state.what |= layer_state_t::eReparent; s.state.parentHandleForChild = nullptr; s.state.parentHandleForChild = nullptr; Loading @@ -500,8 +499,8 @@ void SurfaceComposerClient::Transaction::cacheBuffers() { } } size_t count = 0; size_t count = 0; for (auto& [sc, cs] : mComposerStates) { for (auto& [handle, cs] : mComposerStates) { layer_state_t* s = getLayerState(sc); layer_state_t* s = getLayerState(handle); if (!(s->what & layer_state_t::eBufferChanged)) { if (!(s->what & layer_state_t::eBufferChanged)) { continue; continue; } } Loading Loading @@ -640,16 +639,15 @@ void SurfaceComposerClient::Transaction::setEarlyWakeup() { mEarlyWakeup = true; mEarlyWakeup = true; } } layer_state_t* SurfaceComposerClient::Transaction::getLayerState(const sp<SurfaceControl>& sc) { layer_state_t* SurfaceComposerClient::Transaction::getLayerState(const sp<IBinder>& handle) { if (mComposerStates.count(sc) == 0) { if (mComposerStates.count(handle) == 0) { // we don't have it, add an initialized layer_state to our list // we don't have it, add an initialized layer_state to our list ComposerState s; ComposerState s; s.client = sc->getClient()->mClient; s.state.surface = handle; s.state.surface = sc->getHandle(); mComposerStates[handle] = s; mComposerStates[sc] = s; } } return &(mComposerStates[sc].state); return &(mComposerStates[handle].state); } } void SurfaceComposerClient::Transaction::registerSurfaceControlForCallback( void SurfaceComposerClient::Transaction::registerSurfaceControlForCallback( Loading
libs/gui/SurfaceControl.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -65,8 +65,8 @@ SurfaceControl::~SurfaceControl() { { // Avoid reparenting the server-side surface to null if we are not the owner of it, // Avoid reparenting the server-side surface to null if we are not the owner of it, // meaning that we retrieved it from another process. // meaning that we retrieved it from another process. if (mClient != nullptr && mHandle != nullptr && mOwned) { if (mHandle != nullptr && mOwned) { SurfaceComposerClient::doDropReferenceTransaction(mHandle, mClient->getClient()); SurfaceComposerClient::doDropReferenceTransaction(mHandle); } } release(); release(); } } Loading
libs/gui/include/gui/LayerState.h +0 −3 Original line number Original line Diff line number Diff line Loading @@ -206,7 +206,6 @@ struct layer_state_t { }; }; struct ComposerState { struct ComposerState { sp<ISurfaceComposerClient> client; layer_state_t state; layer_state_t state; status_t write(Parcel& output) const; status_t write(Parcel& output) const; status_t read(const Parcel& input); status_t read(const Parcel& input); Loading Loading @@ -274,8 +273,6 @@ struct InputWindowCommands { }; }; static inline int compare_type(const ComposerState& lhs, const ComposerState& rhs) { static inline int compare_type(const ComposerState& lhs, const ComposerState& rhs) { if (lhs.client < rhs.client) return -1; if (lhs.client > rhs.client) return 1; if (lhs.state.surface < rhs.state.surface) return -1; if (lhs.state.surface < rhs.state.surface) return -1; if (lhs.state.surface > rhs.state.surface) return 1; if (lhs.state.surface > rhs.state.surface) return 1; return 0; return 0; Loading
libs/gui/include/gui/SurfaceComposerClient.h +14 −11 Original line number Original line Diff line number Diff line Loading @@ -163,8 +163,7 @@ public: * Called from SurfaceControl d'tor to 'destroy' the surface (or rather, reparent it * Called from SurfaceControl d'tor to 'destroy' the surface (or rather, reparent it * to null), but without needing an sp<SurfaceControl> to avoid infinite ressurection. * to null), but without needing an sp<SurfaceControl> to avoid infinite ressurection. */ */ static void doDropReferenceTransaction(const sp<IBinder>& handle, static void doDropReferenceTransaction(const sp<IBinder>& handle); const sp<ISurfaceComposerClient>& client); /** /** * Uncaches a buffer in ISurfaceComposer. It must be uncached via a transaction so that it is * Uncaches a buffer in ISurfaceComposer. It must be uncached via a transaction so that it is Loading Loading @@ -270,6 +269,12 @@ public: } } }; }; struct IBinderHash { std::size_t operator()(const sp<IBinder>& iBinder) const { return std::hash<IBinder*>{}(iBinder.get()); } }; struct TCLHash { struct TCLHash { std::size_t operator()(const sp<ITransactionCompletedListener>& tcl) const { std::size_t operator()(const sp<ITransactionCompletedListener>& tcl) const { return std::hash<IBinder*>{}((tcl) ? IInterface::asBinder(tcl).get() : nullptr); return std::hash<IBinder*>{}((tcl) ? IInterface::asBinder(tcl).get() : nullptr); Loading @@ -286,7 +291,7 @@ public: }; }; class Transaction : Parcelable { class Transaction : Parcelable { std::unordered_map<sp<SurfaceControl>, ComposerState, SCHash> mComposerStates; std::unordered_map<sp<IBinder>, ComposerState, IBinderHash> mComposerStates; SortedVector<DisplayState > mDisplayStates; SortedVector<DisplayState > mDisplayStates; std::unordered_map<sp<ITransactionCompletedListener>, CallbackInfo, TCLHash> std::unordered_map<sp<ITransactionCompletedListener>, CallbackInfo, TCLHash> mListenerCallbacks; mListenerCallbacks; Loading Loading @@ -314,7 +319,10 @@ public: InputWindowCommands mInputWindowCommands; InputWindowCommands mInputWindowCommands; int mStatus = NO_ERROR; int mStatus = NO_ERROR; layer_state_t* getLayerState(const sp<SurfaceControl>& sc); layer_state_t* getLayerState(const sp<IBinder>& surfaceHandle); layer_state_t* getLayerState(const sp<SurfaceControl>& sc) { return getLayerState(sc->getHandle()); } DisplayState& getDisplayState(const sp<IBinder>& token); DisplayState& getDisplayState(const sp<IBinder>& token); void cacheBuffers(); void cacheBuffers(); Loading Loading @@ -560,15 +568,10 @@ class TransactionCompletedListener : public BnTransactionCompletedListener { CallbackId mCallbackIdCounter GUARDED_BY(mMutex) = 1; CallbackId mCallbackIdCounter GUARDED_BY(mMutex) = 1; struct IBinderHash { std::size_t operator()(const sp<IBinder>& iBinder) const { return std::hash<IBinder*>{}(iBinder.get()); } }; struct CallbackTranslation { struct CallbackTranslation { TransactionCompletedCallback callbackFunction; TransactionCompletedCallback callbackFunction; std::unordered_map<sp<IBinder>, sp<SurfaceControl>, IBinderHash> surfaceControls; std::unordered_map<sp<IBinder>, sp<SurfaceControl>, SurfaceComposerClient::IBinderHash> surfaceControls; }; }; std::unordered_map<CallbackId, CallbackTranslation> mCallbacks GUARDED_BY(mMutex); std::unordered_map<CallbackId, CallbackTranslation> mCallbacks GUARDED_BY(mMutex); Loading