Loading services/surfaceflinger/FrontEnd/LayerCreationArgs.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,10 @@ LayerCreationArgs::LayerCreationArgs(SurfaceFlinger* flinger, sp<Client> client, } } LayerCreationArgs::LayerCreationArgs(std::optional<uint32_t> id, bool internalLayer) : LayerCreationArgs(nullptr, nullptr, /*name=*/"", /*flags=*/0, /*metadata=*/{}, id, internalLayer) {} LayerCreationArgs::LayerCreationArgs(const LayerCreationArgs& args) : LayerCreationArgs(args.flinger, args.client, args.name, args.flags, args.metadata) {} Loading services/surfaceflinger/FrontEnd/LayerCreationArgs.h +4 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,8 @@ struct LayerCreationArgs { LayerCreationArgs(android::SurfaceFlinger*, sp<android::Client>, std::string name, uint32_t flags, gui::LayerMetadata, std::optional<uint32_t> id = std::nullopt, bool internalLayer = false); LayerCreationArgs(std::optional<uint32_t> id, bool internalLayer = false); LayerCreationArgs(const LayerCreationArgs&); android::SurfaceFlinger* flinger; Loading @@ -56,6 +58,8 @@ struct LayerCreationArgs { wp<IBinder> parentHandle = nullptr; wp<IBinder> mirrorLayerHandle = nullptr; ui::LayerStack layerStackToMirror = ui::INVALID_LAYER_STACK; uint32_t parentId = UNASSIGNED_LAYER_ID; uint32_t layerIdToMirror = UNASSIGNED_LAYER_ID; }; } // namespace android::surfaceflinger services/surfaceflinger/FrontEnd/LayerLifecycleManager.cpp +10 −14 Original line number Diff line number Diff line Loading @@ -20,8 +20,7 @@ #define LOG_TAG "LayerLifecycleManager" #include "LayerLifecycleManager.h" #include "Layer.h" // temporarily needed for LayerHandle #include "LayerHandle.h" #include "Client.h" // temporarily needed for LayerCreationArgs #include "LayerLog.h" #include "SwapErase.h" Loading Loading @@ -167,7 +166,7 @@ void LayerLifecycleManager::applyTransactions(const std::vector<TransactionState for (const auto& transaction : transactions) { for (const auto& resolvedComposerState : transaction.states) { const auto& clientState = resolvedComposerState.state; uint32_t layerId = LayerHandle::getLayerId(clientState.surface); uint32_t layerId = resolvedComposerState.layerId; if (layerId == UNASSIGNED_LAYER_ID) { ALOGW("%s Handle %p is not valid", __func__, clientState.surface.get()); continue; Loading @@ -175,15 +174,14 @@ void LayerLifecycleManager::applyTransactions(const std::vector<TransactionState RequestedLayerState* layer = getLayerFromId(layerId); if (layer == nullptr) { LOG_ALWAYS_FATAL("%s Layer with handle %p (layerid=%d) not found", __func__, clientState.surface.get(), layerId); LOG_ALWAYS_FATAL("%s Layer with layerid=%d not found", __func__, layerId); continue; } if (!layer->handleAlive) { LOG_ALWAYS_FATAL("%s Layer's handle %p (layerid=%d) is not alive. Possible out of " LOG_ALWAYS_FATAL("%s Layer's with layerid=%d) is not alive. Possible out of " "order LayerLifecycleManager updates", __func__, clientState.surface.get(), layerId); __func__, layerId); continue; } Loading @@ -198,13 +196,11 @@ void LayerLifecycleManager::applyTransactions(const std::vector<TransactionState if (layer->what & layer_state_t::eBackgroundColorChanged) { if (layer->bgColorLayerId == UNASSIGNED_LAYER_ID && layer->bgColor.a != 0) { LayerCreationArgs backgroundLayerArgs{nullptr, nullptr, layer->name + "BackgroundColorLayer", ISurfaceComposerClient::eFXSurfaceEffect, {}, layer->id, /*internalLayer=*/true}; LayerCreationArgs backgroundLayerArgs(layer->id, /*internalLayer=*/true); backgroundLayerArgs.parentId = layer->id; backgroundLayerArgs.name = layer->name + "BackgroundColorLayer"; backgroundLayerArgs.flags = ISurfaceComposerClient::eFXSurfaceEffect; std::vector<std::unique_ptr<RequestedLayerState>> newLayers; newLayers.emplace_back( std::make_unique<RequestedLayerState>(backgroundLayerArgs)); Loading services/surfaceflinger/FrontEnd/RequestedLayerState.cpp +8 −19 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ #include "Layer.h" #include "LayerCreationArgs.h" #include "LayerHandle.h" #include "LayerLog.h" #include "RequestedLayerState.h" Loading @@ -33,14 +32,6 @@ using ftl::Flags; using namespace ftl::flag_operators; namespace { uint32_t getLayerIdFromSurfaceControl(sp<SurfaceControl> surfaceControl) { if (!surfaceControl) { return UNASSIGNED_LAYER_ID; } return LayerHandle::getLayerId(surfaceControl->getHandle()); } std::string layerIdToString(uint32_t layerId) { return layerId == UNASSIGNED_LAYER_ID ? "none" : std::to_string(layerId); } Loading @@ -64,17 +55,17 @@ RequestedLayerState::RequestedLayerState(const LayerCreationArgs& args) layerCreationFlags(args.flags), textureName(args.textureName), ownerUid(args.ownerUid), ownerPid(args.ownerPid) { ownerPid(args.ownerPid), parentId(args.parentId), layerIdToMirror(args.layerIdToMirror) { layerId = static_cast<int32_t>(args.sequence); changes |= RequestedLayerState::Changes::Created; metadata.merge(args.metadata); changes |= RequestedLayerState::Changes::Metadata; handleAlive = true; parentId = LayerHandle::getLayerId(args.parentHandle.promote()); if (args.parentHandle != nullptr) { if (parentId != UNASSIGNED_LAYER_ID) { canBeRoot = false; } layerIdToMirror = LayerHandle::getLayerId(args.mirrorLayerHandle.promote()); if (layerIdToMirror != UNASSIGNED_LAYER_ID) { changes |= RequestedLayerState::Changes::Mirror; } else if (args.layerStackToMirror != ui::INVALID_LAYER_STACK) { Loading Loading @@ -209,7 +200,7 @@ void RequestedLayerState::merge(const ResolvedComposerState& resolvedComposerSta } if (clientState.what & layer_state_t::eReparent) { changes |= RequestedLayerState::Changes::Parent; parentId = getLayerIdFromSurfaceControl(clientState.parentSurfaceControlForChild); parentId = resolvedComposerState.parentId; parentSurfaceControlForChild = nullptr; // Once a layer has be reparented, it cannot be placed at the root. It sounds odd // but thats the existing logic and until we make this behavior more explicit, we need Loading @@ -218,7 +209,7 @@ void RequestedLayerState::merge(const ResolvedComposerState& resolvedComposerSta } if (clientState.what & layer_state_t::eRelativeLayerChanged) { changes |= RequestedLayerState::Changes::RelativeParent; relativeParentId = getLayerIdFromSurfaceControl(clientState.relativeLayerSurfaceControl); relativeParentId = resolvedComposerState.relativeParentId; isRelativeOf = true; relativeLayerSurfaceControl = nullptr; } Loading @@ -235,10 +226,8 @@ void RequestedLayerState::merge(const ResolvedComposerState& resolvedComposerSta changes |= RequestedLayerState::Changes::RelativeParent; } if (clientState.what & layer_state_t::eInputInfoChanged) { wp<IBinder>& touchableRegionCropHandle = windowInfoHandle->editInfo()->touchableRegionCropHandle; touchCropId = LayerHandle::getLayerId(touchableRegionCropHandle.promote()); touchableRegionCropHandle.clear(); touchCropId = resolvedComposerState.touchCropId; windowInfoHandle->editInfo()->touchableRegionCropHandle.clear(); } if (clientState.what & layer_state_t::eStretchChanged) { stretchEffect.sanitize(); Loading services/surfaceflinger/FrontEnd/RequestedLayerState.h +5 −5 Original line number Diff line number Diff line Loading @@ -105,17 +105,17 @@ struct RequestedLayerState : layer_state_t { std::shared_ptr<renderengine::ExternalTexture> externalTexture; gui::GameMode gameMode; scheduler::LayerInfo::FrameRate requestedFrameRate; ui::LayerStack layerStackToMirror = ui::INVALID_LAYER_STACK; uint32_t parentId = UNASSIGNED_LAYER_ID; uint32_t relativeParentId = UNASSIGNED_LAYER_ID; uint32_t layerIdToMirror = UNASSIGNED_LAYER_ID; ui::LayerStack layerStackToMirror = ui::INVALID_LAYER_STACK; uint32_t touchCropId = UNASSIGNED_LAYER_ID; uint32_t bgColorLayerId = UNASSIGNED_LAYER_ID; // book keeping states bool handleAlive = true; bool isRelativeOf = false; uint32_t parentId = UNASSIGNED_LAYER_ID; uint32_t relativeParentId = UNASSIGNED_LAYER_ID; std::vector<uint32_t> mirrorIds{}; uint32_t touchCropId = UNASSIGNED_LAYER_ID; uint32_t bgColorLayerId = UNASSIGNED_LAYER_ID; ftl::Flags<RequestedLayerState::Changes> changes; bool bgColorLayer = false; }; Loading Loading
services/surfaceflinger/FrontEnd/LayerCreationArgs.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,10 @@ LayerCreationArgs::LayerCreationArgs(SurfaceFlinger* flinger, sp<Client> client, } } LayerCreationArgs::LayerCreationArgs(std::optional<uint32_t> id, bool internalLayer) : LayerCreationArgs(nullptr, nullptr, /*name=*/"", /*flags=*/0, /*metadata=*/{}, id, internalLayer) {} LayerCreationArgs::LayerCreationArgs(const LayerCreationArgs& args) : LayerCreationArgs(args.flinger, args.client, args.name, args.flags, args.metadata) {} Loading
services/surfaceflinger/FrontEnd/LayerCreationArgs.h +4 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,8 @@ struct LayerCreationArgs { LayerCreationArgs(android::SurfaceFlinger*, sp<android::Client>, std::string name, uint32_t flags, gui::LayerMetadata, std::optional<uint32_t> id = std::nullopt, bool internalLayer = false); LayerCreationArgs(std::optional<uint32_t> id, bool internalLayer = false); LayerCreationArgs(const LayerCreationArgs&); android::SurfaceFlinger* flinger; Loading @@ -56,6 +58,8 @@ struct LayerCreationArgs { wp<IBinder> parentHandle = nullptr; wp<IBinder> mirrorLayerHandle = nullptr; ui::LayerStack layerStackToMirror = ui::INVALID_LAYER_STACK; uint32_t parentId = UNASSIGNED_LAYER_ID; uint32_t layerIdToMirror = UNASSIGNED_LAYER_ID; }; } // namespace android::surfaceflinger
services/surfaceflinger/FrontEnd/LayerLifecycleManager.cpp +10 −14 Original line number Diff line number Diff line Loading @@ -20,8 +20,7 @@ #define LOG_TAG "LayerLifecycleManager" #include "LayerLifecycleManager.h" #include "Layer.h" // temporarily needed for LayerHandle #include "LayerHandle.h" #include "Client.h" // temporarily needed for LayerCreationArgs #include "LayerLog.h" #include "SwapErase.h" Loading Loading @@ -167,7 +166,7 @@ void LayerLifecycleManager::applyTransactions(const std::vector<TransactionState for (const auto& transaction : transactions) { for (const auto& resolvedComposerState : transaction.states) { const auto& clientState = resolvedComposerState.state; uint32_t layerId = LayerHandle::getLayerId(clientState.surface); uint32_t layerId = resolvedComposerState.layerId; if (layerId == UNASSIGNED_LAYER_ID) { ALOGW("%s Handle %p is not valid", __func__, clientState.surface.get()); continue; Loading @@ -175,15 +174,14 @@ void LayerLifecycleManager::applyTransactions(const std::vector<TransactionState RequestedLayerState* layer = getLayerFromId(layerId); if (layer == nullptr) { LOG_ALWAYS_FATAL("%s Layer with handle %p (layerid=%d) not found", __func__, clientState.surface.get(), layerId); LOG_ALWAYS_FATAL("%s Layer with layerid=%d not found", __func__, layerId); continue; } if (!layer->handleAlive) { LOG_ALWAYS_FATAL("%s Layer's handle %p (layerid=%d) is not alive. Possible out of " LOG_ALWAYS_FATAL("%s Layer's with layerid=%d) is not alive. Possible out of " "order LayerLifecycleManager updates", __func__, clientState.surface.get(), layerId); __func__, layerId); continue; } Loading @@ -198,13 +196,11 @@ void LayerLifecycleManager::applyTransactions(const std::vector<TransactionState if (layer->what & layer_state_t::eBackgroundColorChanged) { if (layer->bgColorLayerId == UNASSIGNED_LAYER_ID && layer->bgColor.a != 0) { LayerCreationArgs backgroundLayerArgs{nullptr, nullptr, layer->name + "BackgroundColorLayer", ISurfaceComposerClient::eFXSurfaceEffect, {}, layer->id, /*internalLayer=*/true}; LayerCreationArgs backgroundLayerArgs(layer->id, /*internalLayer=*/true); backgroundLayerArgs.parentId = layer->id; backgroundLayerArgs.name = layer->name + "BackgroundColorLayer"; backgroundLayerArgs.flags = ISurfaceComposerClient::eFXSurfaceEffect; std::vector<std::unique_ptr<RequestedLayerState>> newLayers; newLayers.emplace_back( std::make_unique<RequestedLayerState>(backgroundLayerArgs)); Loading
services/surfaceflinger/FrontEnd/RequestedLayerState.cpp +8 −19 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ #include "Layer.h" #include "LayerCreationArgs.h" #include "LayerHandle.h" #include "LayerLog.h" #include "RequestedLayerState.h" Loading @@ -33,14 +32,6 @@ using ftl::Flags; using namespace ftl::flag_operators; namespace { uint32_t getLayerIdFromSurfaceControl(sp<SurfaceControl> surfaceControl) { if (!surfaceControl) { return UNASSIGNED_LAYER_ID; } return LayerHandle::getLayerId(surfaceControl->getHandle()); } std::string layerIdToString(uint32_t layerId) { return layerId == UNASSIGNED_LAYER_ID ? "none" : std::to_string(layerId); } Loading @@ -64,17 +55,17 @@ RequestedLayerState::RequestedLayerState(const LayerCreationArgs& args) layerCreationFlags(args.flags), textureName(args.textureName), ownerUid(args.ownerUid), ownerPid(args.ownerPid) { ownerPid(args.ownerPid), parentId(args.parentId), layerIdToMirror(args.layerIdToMirror) { layerId = static_cast<int32_t>(args.sequence); changes |= RequestedLayerState::Changes::Created; metadata.merge(args.metadata); changes |= RequestedLayerState::Changes::Metadata; handleAlive = true; parentId = LayerHandle::getLayerId(args.parentHandle.promote()); if (args.parentHandle != nullptr) { if (parentId != UNASSIGNED_LAYER_ID) { canBeRoot = false; } layerIdToMirror = LayerHandle::getLayerId(args.mirrorLayerHandle.promote()); if (layerIdToMirror != UNASSIGNED_LAYER_ID) { changes |= RequestedLayerState::Changes::Mirror; } else if (args.layerStackToMirror != ui::INVALID_LAYER_STACK) { Loading Loading @@ -209,7 +200,7 @@ void RequestedLayerState::merge(const ResolvedComposerState& resolvedComposerSta } if (clientState.what & layer_state_t::eReparent) { changes |= RequestedLayerState::Changes::Parent; parentId = getLayerIdFromSurfaceControl(clientState.parentSurfaceControlForChild); parentId = resolvedComposerState.parentId; parentSurfaceControlForChild = nullptr; // Once a layer has be reparented, it cannot be placed at the root. It sounds odd // but thats the existing logic and until we make this behavior more explicit, we need Loading @@ -218,7 +209,7 @@ void RequestedLayerState::merge(const ResolvedComposerState& resolvedComposerSta } if (clientState.what & layer_state_t::eRelativeLayerChanged) { changes |= RequestedLayerState::Changes::RelativeParent; relativeParentId = getLayerIdFromSurfaceControl(clientState.relativeLayerSurfaceControl); relativeParentId = resolvedComposerState.relativeParentId; isRelativeOf = true; relativeLayerSurfaceControl = nullptr; } Loading @@ -235,10 +226,8 @@ void RequestedLayerState::merge(const ResolvedComposerState& resolvedComposerSta changes |= RequestedLayerState::Changes::RelativeParent; } if (clientState.what & layer_state_t::eInputInfoChanged) { wp<IBinder>& touchableRegionCropHandle = windowInfoHandle->editInfo()->touchableRegionCropHandle; touchCropId = LayerHandle::getLayerId(touchableRegionCropHandle.promote()); touchableRegionCropHandle.clear(); touchCropId = resolvedComposerState.touchCropId; windowInfoHandle->editInfo()->touchableRegionCropHandle.clear(); } if (clientState.what & layer_state_t::eStretchChanged) { stretchEffect.sanitize(); Loading
services/surfaceflinger/FrontEnd/RequestedLayerState.h +5 −5 Original line number Diff line number Diff line Loading @@ -105,17 +105,17 @@ struct RequestedLayerState : layer_state_t { std::shared_ptr<renderengine::ExternalTexture> externalTexture; gui::GameMode gameMode; scheduler::LayerInfo::FrameRate requestedFrameRate; ui::LayerStack layerStackToMirror = ui::INVALID_LAYER_STACK; uint32_t parentId = UNASSIGNED_LAYER_ID; uint32_t relativeParentId = UNASSIGNED_LAYER_ID; uint32_t layerIdToMirror = UNASSIGNED_LAYER_ID; ui::LayerStack layerStackToMirror = ui::INVALID_LAYER_STACK; uint32_t touchCropId = UNASSIGNED_LAYER_ID; uint32_t bgColorLayerId = UNASSIGNED_LAYER_ID; // book keeping states bool handleAlive = true; bool isRelativeOf = false; uint32_t parentId = UNASSIGNED_LAYER_ID; uint32_t relativeParentId = UNASSIGNED_LAYER_ID; std::vector<uint32_t> mirrorIds{}; uint32_t touchCropId = UNASSIGNED_LAYER_ID; uint32_t bgColorLayerId = UNASSIGNED_LAYER_ID; ftl::Flags<RequestedLayerState::Changes> changes; bool bgColorLayer = false; }; Loading