Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 92990e29 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

[sf] fix snapshot updates for mirror layers

Ensure we update the mirrored snapshots when they are
created.

Test: atest CtsSurfaceControlTests
Bug: 238781169

Change-Id: I245702f8b521745ba59f0f993bcaef90d0cdbe9a
parent c765c6c3
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -449,7 +449,7 @@ LayerHierarchy::ScopedAddToTraversalPath::ScopedAddToTraversalPath(TraversalPath
    traversalPath.id = layerId;
    traversalPath.id = layerId;
    traversalPath.variant = variant;
    traversalPath.variant = variant;
    if (variant == LayerHierarchy::Variant::Mirror) {
    if (variant == LayerHierarchy::Variant::Mirror) {
        traversalPath.mirrorRootId = layerId;
        traversalPath.mirrorRootId = mParentPath.id;
    } else if (variant == LayerHierarchy::Variant::Relative) {
    } else if (variant == LayerHierarchy::Variant::Relative) {
        if (std::find(traversalPath.relativeRootIds.begin(), traversalPath.relativeRootIds.end(),
        if (std::find(traversalPath.relativeRootIds.begin(), traversalPath.relativeRootIds.end(),
                      layerId) != traversalPath.relativeRootIds.end()) {
                      layerId) != traversalPath.relativeRootIds.end()) {
+3 −2
Original line number Original line Diff line number Diff line
@@ -37,7 +37,6 @@ void LayerLifecycleManager::addLayers(std::vector<std::unique_ptr<RequestedLayer
    mGlobalChanges |= RequestedLayerState::Changes::Hierarchy;
    mGlobalChanges |= RequestedLayerState::Changes::Hierarchy;
    for (auto& newLayer : newLayers) {
    for (auto& newLayer : newLayers) {
        RequestedLayerState& layer = *newLayer.get();
        RequestedLayerState& layer = *newLayer.get();
        LLOGV(layer.id, "%s layer %s", __func__, layer.getDebugStringShort().c_str());
        auto [it, inserted] = mIdToLayer.try_emplace(layer.id, References{.owner = layer});
        auto [it, inserted] = mIdToLayer.try_emplace(layer.id, References{.owner = layer});
        if (!inserted) {
        if (!inserted) {
            LOG_ALWAYS_FATAL("Duplicate layer id %d found. Existing layer: %s", layer.id,
            LOG_ALWAYS_FATAL("Duplicate layer id %d found. Existing layer: %s", layer.id,
@@ -68,6 +67,7 @@ void LayerLifecycleManager::addLayers(std::vector<std::unique_ptr<RequestedLayer
        if (layer.isRoot()) {
        if (layer.isRoot()) {
            updateDisplayMirrorLayers(layer);
            updateDisplayMirrorLayers(layer);
        }
        }
        LLOGV(layer.id, "%s", layer.getDebugString().c_str());
        mLayers.emplace_back(std::move(newLayer));
        mLayers.emplace_back(std::move(newLayer));
    }
    }
}
}
@@ -81,6 +81,7 @@ void LayerLifecycleManager::onHandlesDestroyed(const std::vector<uint32_t>& dest
            continue;
            continue;
        }
        }
        RequestedLayerState& layer = it->second.owner;
        RequestedLayerState& layer = it->second.owner;
        LLOGV(layer.id, "%s", layer.getDebugString().c_str());
        layer.handleAlive = false;
        layer.handleAlive = false;
        if (!layer.canBeDestroyed()) {
        if (!layer.canBeDestroyed()) {
            continue;
            continue;
@@ -148,7 +149,7 @@ void LayerLifecycleManager::onHandlesDestroyed(const std::vector<uint32_t>& dest
    while (it != mLayers.end()) {
    while (it != mLayers.end()) {
        RequestedLayerState* layer = it->get();
        RequestedLayerState* layer = it->get();
        if (layer->changes.test(RequestedLayerState::Changes::Destroyed)) {
        if (layer->changes.test(RequestedLayerState::Changes::Destroyed)) {
            LLOGV(layer->id, "destroyed layer %s", layer->getDebugStringShort().c_str());
            LLOGV(layer->id, "destroyed %s", layer->getDebugStringShort().c_str());
            std::iter_swap(it, mLayers.end() - 1);
            std::iter_swap(it, mLayers.end() - 1);
            mDestroyedLayers.emplace_back(std::move(mLayers.back()));
            mDestroyedLayers.emplace_back(std::move(mLayers.back()));
            if (it == mLayers.end() - 1) {
            if (it == mLayers.end() - 1) {
+2 −0
Original line number Original line Diff line number Diff line
@@ -25,3 +25,5 @@
#else
#else
#define LLOGV(LAYER_ID, x, ...) ALOGV("[%d] %s " x, (LAYER_ID), __func__, ##__VA_ARGS__);
#define LLOGV(LAYER_ID, x, ...) ALOGV("[%d] %s " x, (LAYER_ID), __func__, ##__VA_ARGS__);
#endif
#endif

#define LLOGD(LAYER_ID, x, ...) ALOGD("[%d] %s " x, (LAYER_ID), __func__, ##__VA_ARGS__);
+6 −1
Original line number Original line Diff line number Diff line
@@ -35,6 +35,10 @@ LayerSnapshot::LayerSnapshot(const RequestedLayerState& state,
    inputInfo.id = static_cast<int32_t>(state.id);
    inputInfo.id = static_cast<int32_t>(state.id);
    inputInfo.ownerUid = static_cast<int32_t>(state.ownerUid);
    inputInfo.ownerUid = static_cast<int32_t>(state.ownerUid);
    inputInfo.ownerPid = state.ownerPid;
    inputInfo.ownerPid = state.ownerPid;
    changes = RequestedLayerState::Changes::Created;
    mirrorRootPath = path.variant == LayerHierarchy::Variant::Mirror
            ? path
            : LayerHierarchy::TraversalPath::ROOT;
}
}


// As documented in libhardware header, formats in the range
// As documented in libhardware header, formats in the range
@@ -165,7 +169,8 @@ bool LayerSnapshot::hasInputInfo() const {
std::string LayerSnapshot::getDebugString() const {
std::string LayerSnapshot::getDebugString() const {
    std::stringstream debug;
    std::stringstream debug;
    debug << "Snapshot{" << path.toString() << name << " isVisible=" << isVisible << " {"
    debug << "Snapshot{" << path.toString() << name << " isVisible=" << isVisible << " {"
          << getIsVisibleReason() << "} changes=" << changes.string() << "}";
          << getIsVisibleReason() << "} changes=" << changes.string()
          << " layerStack=" << outputFilter.layerStack.id << "}";
    return debug.str();
    return debug.str();
}
}


+1 −0
Original line number Original line Diff line number Diff line
@@ -84,6 +84,7 @@ struct LayerSnapshot : public compositionengine::LayerFECompositionState {
    scheduler::LayerInfo::FrameRate frameRate;
    scheduler::LayerInfo::FrameRate frameRate;
    ui::Transform::RotationFlags fixedTransformHint;
    ui::Transform::RotationFlags fixedTransformHint;
    bool handleSkipScreenshotFlag = false;
    bool handleSkipScreenshotFlag = false;
    LayerHierarchy::TraversalPath mirrorRootPath;
    ChildState childState;
    ChildState childState;


    static bool isOpaqueFormat(PixelFormat format);
    static bool isOpaqueFormat(PixelFormat format);
Loading