Loading services/surfaceflinger/FrontEnd/LayerHierarchy.cpp +16 −4 Original line number Diff line number Diff line Loading @@ -153,7 +153,7 @@ void LayerHierarchy::dump(std::ostream& out, const std::string& prefix, out << prefix + (isLastChild ? "└─ " : "├─ "); if (variant == LayerHierarchy::Variant::Relative) { out << "(Relative) "; } else if (variant == LayerHierarchy::Variant::Mirror) { } else if (LayerHierarchy::isMirror(variant)) { if (!includeMirroredHierarchy) { out << "(Mirroring) " << *mLayer << "\n" + prefix + " └─ ..."; return; Loading Loading @@ -289,6 +289,12 @@ void LayerHierarchyBuilder::onLayerAdded(RequestedLayerState* layer) { LayerHierarchy* mirror = getHierarchyFromId(mirrorId); hierarchy->addChild(mirror, LayerHierarchy::Variant::Mirror); } if (FlagManager::getInstance().detached_mirror()) { if (layer->layerIdToMirror != UNASSIGNED_LAYER_ID) { LayerHierarchy* mirror = getHierarchyFromId(layer->layerIdToMirror); hierarchy->addChild(mirror, LayerHierarchy::Variant::Detached_Mirror); } } } void LayerHierarchyBuilder::onLayerDestroyed(RequestedLayerState* layer) { Loading Loading @@ -325,7 +331,7 @@ void LayerHierarchyBuilder::updateMirrorLayer(RequestedLayerState* layer) { LayerHierarchy* hierarchy = getHierarchyFromId(layer->id); auto it = hierarchy->mChildren.begin(); while (it != hierarchy->mChildren.end()) { if (it->second == LayerHierarchy::Variant::Mirror) { if (LayerHierarchy::isMirror(it->second)) { it = hierarchy->mChildren.erase(it); } else { it++; Loading @@ -335,6 +341,12 @@ void LayerHierarchyBuilder::updateMirrorLayer(RequestedLayerState* layer) { for (uint32_t mirrorId : layer->mirrorIds) { hierarchy->addChild(getHierarchyFromId(mirrorId), LayerHierarchy::Variant::Mirror); } if (FlagManager::getInstance().detached_mirror()) { if (layer->layerIdToMirror != UNASSIGNED_LAYER_ID) { hierarchy->addChild(getHierarchyFromId(layer->layerIdToMirror), LayerHierarchy::Variant::Detached_Mirror); } } } void LayerHierarchyBuilder::doUpdate( Loading Loading @@ -501,7 +513,7 @@ LayerHierarchy::ScopedAddToTraversalPath::ScopedAddToTraversalPath(TraversalPath // stored to reset the id upon destruction. traversalPath.id = layerId; traversalPath.variant = variant; if (variant == LayerHierarchy::Variant::Mirror) { if (LayerHierarchy::isMirror(variant)) { traversalPath.mirrorRootIds.emplace_back(mParentPath.id); } else if (variant == LayerHierarchy::Variant::Relative) { if (std::find(traversalPath.relativeRootIds.begin(), traversalPath.relativeRootIds.end(), Loading @@ -516,7 +528,7 @@ LayerHierarchy::ScopedAddToTraversalPath::ScopedAddToTraversalPath(TraversalPath LayerHierarchy::ScopedAddToTraversalPath::~ScopedAddToTraversalPath() { // Reset the traversal id to its original parent state using the state that was saved in // the constructor. if (mTraversalPath.variant == LayerHierarchy::Variant::Mirror) { if (LayerHierarchy::isMirror(mTraversalPath.variant)) { mTraversalPath.mirrorRootIds.pop_back(); } else if (mTraversalPath.variant == LayerHierarchy::Variant::Relative) { mTraversalPath.relativeRootIds.pop_back(); Loading services/surfaceflinger/FrontEnd/LayerHierarchy.h +11 −5 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ class LayerHierarchyBuilder; // Detached - child of the parent but currently relative parented to another layer // Relative - relative child of the parent // Mirror - mirrored from another layer // Detached_Mirror - mirrored from another layer, ignoring local transform // // By representing the hierarchy as a graph, we can represent mirrored layer hierarchies without // cloning the layer requested state. The mirrored hierarchy and its corresponding Loading @@ -47,9 +48,14 @@ public: Detached, // child of the parent but currently relative parented to another layer Relative, // relative child of the parent Mirror, // mirrored from another layer Detached_Mirror, // mirrored from another layer, ignoring local transform ftl_first = Attached, ftl_last = Mirror, ftl_last = Detached_Mirror, }; static inline bool isMirror(Variant variant) { return ((variant == Mirror) || (variant == Detached_Mirror)); } // Represents a unique path to a node. // The layer hierarchy is represented as a graph. Each node can be visited by multiple parents. // This allows us to represent mirroring in an efficient way. See the example below: Loading services/surfaceflinger/FrontEnd/LayerLifecycleManager.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -72,10 +72,12 @@ void LayerLifecycleManager::addLayers(std::vector<std::unique_ptr<RequestedLayer // Check if we are mirroring a single layer, and if so add it to the list of children // to be mirrored. layer.layerIdToMirror = linkLayer(layer.layerIdToMirror, layer.id); if (!FlagManager::getInstance().detached_mirror()) { if (layer.layerIdToMirror != UNASSIGNED_LAYER_ID) { layer.mirrorIds.emplace_back(layer.layerIdToMirror); } } } layer.touchCropId = linkLayer(layer.touchCropId, layer.id); if (layer.isRoot()) { updateDisplayMirrorLayers(layer); Loading services/surfaceflinger/FrontEnd/LayerSnapshot.cpp +10 −10 Original line number Diff line number Diff line Loading @@ -127,9 +127,8 @@ LayerSnapshot::LayerSnapshot(const RequestedLayerState& state, pid = state.ownerPid; changes = RequestedLayerState::Changes::Created; clientChanges = 0; mirrorRootPath = path.variant == LayerHierarchy::Variant::Mirror ? path : LayerHierarchy::TraversalPath::ROOT; mirrorRootPath = LayerHierarchy::isMirror(path.variant) ? path : LayerHierarchy::TraversalPath::ROOT; reachablilty = LayerSnapshot::Reachablilty::Unreachable; frameRateSelectionPriority = state.frameRateSelectionPriority; layerMetadata = state.metadata; Loading Loading @@ -472,13 +471,14 @@ void LayerSnapshot::merge(const RequestedLayerState& requested, bool forceUpdate geomContentCrop = requested.getBufferCrop(); } if (forceUpdate || if ((forceUpdate || requested.what & (layer_state_t::eFlagsChanged | layer_state_t::eDestinationFrameChanged | layer_state_t::ePositionChanged | layer_state_t::eMatrixChanged | layer_state_t::eBufferTransformChanged | layer_state_t::eTransformToDisplayInverseChanged) || requested.changes.test(RequestedLayerState::Changes::BufferSize) || displayChanges) { requested.changes.test(RequestedLayerState::Changes::BufferSize) || displayChanges) && !ignoreLocalTransform) { localTransform = requested.getTransform(displayRotationFlags); localTransformInverse = localTransform.inverse(); } Loading services/surfaceflinger/FrontEnd/LayerSnapshot.h +3 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,9 @@ struct LayerSnapshot : public compositionengine::LayerFECompositionState { ui::Transform localTransformInverse; gui::WindowInfo inputInfo; ui::Transform localTransform; // set to true if this snapshot will ignore local transforms. Used when the snapshot // is a mirror root bool ignoreLocalTransform; gui::DropInputMode dropInputMode; bool isTrustedOverlay; gui::GameMode gameMode; Loading Loading
services/surfaceflinger/FrontEnd/LayerHierarchy.cpp +16 −4 Original line number Diff line number Diff line Loading @@ -153,7 +153,7 @@ void LayerHierarchy::dump(std::ostream& out, const std::string& prefix, out << prefix + (isLastChild ? "└─ " : "├─ "); if (variant == LayerHierarchy::Variant::Relative) { out << "(Relative) "; } else if (variant == LayerHierarchy::Variant::Mirror) { } else if (LayerHierarchy::isMirror(variant)) { if (!includeMirroredHierarchy) { out << "(Mirroring) " << *mLayer << "\n" + prefix + " └─ ..."; return; Loading Loading @@ -289,6 +289,12 @@ void LayerHierarchyBuilder::onLayerAdded(RequestedLayerState* layer) { LayerHierarchy* mirror = getHierarchyFromId(mirrorId); hierarchy->addChild(mirror, LayerHierarchy::Variant::Mirror); } if (FlagManager::getInstance().detached_mirror()) { if (layer->layerIdToMirror != UNASSIGNED_LAYER_ID) { LayerHierarchy* mirror = getHierarchyFromId(layer->layerIdToMirror); hierarchy->addChild(mirror, LayerHierarchy::Variant::Detached_Mirror); } } } void LayerHierarchyBuilder::onLayerDestroyed(RequestedLayerState* layer) { Loading Loading @@ -325,7 +331,7 @@ void LayerHierarchyBuilder::updateMirrorLayer(RequestedLayerState* layer) { LayerHierarchy* hierarchy = getHierarchyFromId(layer->id); auto it = hierarchy->mChildren.begin(); while (it != hierarchy->mChildren.end()) { if (it->second == LayerHierarchy::Variant::Mirror) { if (LayerHierarchy::isMirror(it->second)) { it = hierarchy->mChildren.erase(it); } else { it++; Loading @@ -335,6 +341,12 @@ void LayerHierarchyBuilder::updateMirrorLayer(RequestedLayerState* layer) { for (uint32_t mirrorId : layer->mirrorIds) { hierarchy->addChild(getHierarchyFromId(mirrorId), LayerHierarchy::Variant::Mirror); } if (FlagManager::getInstance().detached_mirror()) { if (layer->layerIdToMirror != UNASSIGNED_LAYER_ID) { hierarchy->addChild(getHierarchyFromId(layer->layerIdToMirror), LayerHierarchy::Variant::Detached_Mirror); } } } void LayerHierarchyBuilder::doUpdate( Loading Loading @@ -501,7 +513,7 @@ LayerHierarchy::ScopedAddToTraversalPath::ScopedAddToTraversalPath(TraversalPath // stored to reset the id upon destruction. traversalPath.id = layerId; traversalPath.variant = variant; if (variant == LayerHierarchy::Variant::Mirror) { if (LayerHierarchy::isMirror(variant)) { traversalPath.mirrorRootIds.emplace_back(mParentPath.id); } else if (variant == LayerHierarchy::Variant::Relative) { if (std::find(traversalPath.relativeRootIds.begin(), traversalPath.relativeRootIds.end(), Loading @@ -516,7 +528,7 @@ LayerHierarchy::ScopedAddToTraversalPath::ScopedAddToTraversalPath(TraversalPath LayerHierarchy::ScopedAddToTraversalPath::~ScopedAddToTraversalPath() { // Reset the traversal id to its original parent state using the state that was saved in // the constructor. if (mTraversalPath.variant == LayerHierarchy::Variant::Mirror) { if (LayerHierarchy::isMirror(mTraversalPath.variant)) { mTraversalPath.mirrorRootIds.pop_back(); } else if (mTraversalPath.variant == LayerHierarchy::Variant::Relative) { mTraversalPath.relativeRootIds.pop_back(); Loading
services/surfaceflinger/FrontEnd/LayerHierarchy.h +11 −5 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ class LayerHierarchyBuilder; // Detached - child of the parent but currently relative parented to another layer // Relative - relative child of the parent // Mirror - mirrored from another layer // Detached_Mirror - mirrored from another layer, ignoring local transform // // By representing the hierarchy as a graph, we can represent mirrored layer hierarchies without // cloning the layer requested state. The mirrored hierarchy and its corresponding Loading @@ -47,9 +48,14 @@ public: Detached, // child of the parent but currently relative parented to another layer Relative, // relative child of the parent Mirror, // mirrored from another layer Detached_Mirror, // mirrored from another layer, ignoring local transform ftl_first = Attached, ftl_last = Mirror, ftl_last = Detached_Mirror, }; static inline bool isMirror(Variant variant) { return ((variant == Mirror) || (variant == Detached_Mirror)); } // Represents a unique path to a node. // The layer hierarchy is represented as a graph. Each node can be visited by multiple parents. // This allows us to represent mirroring in an efficient way. See the example below: Loading
services/surfaceflinger/FrontEnd/LayerLifecycleManager.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -72,10 +72,12 @@ void LayerLifecycleManager::addLayers(std::vector<std::unique_ptr<RequestedLayer // Check if we are mirroring a single layer, and if so add it to the list of children // to be mirrored. layer.layerIdToMirror = linkLayer(layer.layerIdToMirror, layer.id); if (!FlagManager::getInstance().detached_mirror()) { if (layer.layerIdToMirror != UNASSIGNED_LAYER_ID) { layer.mirrorIds.emplace_back(layer.layerIdToMirror); } } } layer.touchCropId = linkLayer(layer.touchCropId, layer.id); if (layer.isRoot()) { updateDisplayMirrorLayers(layer); Loading
services/surfaceflinger/FrontEnd/LayerSnapshot.cpp +10 −10 Original line number Diff line number Diff line Loading @@ -127,9 +127,8 @@ LayerSnapshot::LayerSnapshot(const RequestedLayerState& state, pid = state.ownerPid; changes = RequestedLayerState::Changes::Created; clientChanges = 0; mirrorRootPath = path.variant == LayerHierarchy::Variant::Mirror ? path : LayerHierarchy::TraversalPath::ROOT; mirrorRootPath = LayerHierarchy::isMirror(path.variant) ? path : LayerHierarchy::TraversalPath::ROOT; reachablilty = LayerSnapshot::Reachablilty::Unreachable; frameRateSelectionPriority = state.frameRateSelectionPriority; layerMetadata = state.metadata; Loading Loading @@ -472,13 +471,14 @@ void LayerSnapshot::merge(const RequestedLayerState& requested, bool forceUpdate geomContentCrop = requested.getBufferCrop(); } if (forceUpdate || if ((forceUpdate || requested.what & (layer_state_t::eFlagsChanged | layer_state_t::eDestinationFrameChanged | layer_state_t::ePositionChanged | layer_state_t::eMatrixChanged | layer_state_t::eBufferTransformChanged | layer_state_t::eTransformToDisplayInverseChanged) || requested.changes.test(RequestedLayerState::Changes::BufferSize) || displayChanges) { requested.changes.test(RequestedLayerState::Changes::BufferSize) || displayChanges) && !ignoreLocalTransform) { localTransform = requested.getTransform(displayRotationFlags); localTransformInverse = localTransform.inverse(); } Loading
services/surfaceflinger/FrontEnd/LayerSnapshot.h +3 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,9 @@ struct LayerSnapshot : public compositionengine::LayerFECompositionState { ui::Transform localTransformInverse; gui::WindowInfo inputInfo; ui::Transform localTransform; // set to true if this snapshot will ignore local transforms. Used when the snapshot // is a mirror root bool ignoreLocalTransform; gui::DropInputMode dropInputMode; bool isTrustedOverlay; gui::GameMode gameMode; Loading