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

Commit 93b8b794 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

[sf] provide a unique id for snapshots

Input and layer tracing relies on the fact that all layers
have a unique id. Because mirror layers are no longer
implemented by duplicating layers, we can have multiple
snapshots with the same id. To fix this, provide a unique
id that can be used by consumers who require them.

Test: atest FlickerTest
Bug: 238781169
Change-Id: Ibe54154b6e14f72bfe73a15faa0e7e0d19293e36
parent ea6ff819
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -27,12 +27,16 @@ using namespace ftl::flag_operators;
LayerSnapshot::LayerSnapshot(const RequestedLayerState& state,
                             const LayerHierarchy::TraversalPath& path)
      : path(path) {
    static uint32_t sUniqueSequenceId = 0;
    // Provide a unique id for clones otherwise keeping using the sequence id.
    // The seq id can still be useful for debugging if its available.
    uniqueSequence = (path.isClone()) ? sUniqueSequenceId++ : state.id;
    sequence = static_cast<int32_t>(state.id);
    name = state.name;
    textureName = state.textureName;
    premultipliedAlpha = state.premultipliedAlpha;
    inputInfo.name = state.name;
    inputInfo.id = static_cast<int32_t>(state.id);
    inputInfo.id = static_cast<int32_t>(uniqueSequence);
    inputInfo.ownerUid = static_cast<int32_t>(state.ownerUid);
    inputInfo.ownerPid = state.ownerPid;
    changes = RequestedLayerState::Changes::Created;
+6 −0
Original line number Diff line number Diff line
@@ -57,6 +57,12 @@ struct LayerSnapshot : public compositionengine::LayerFECompositionState {
    bool isHiddenByPolicyFromParent = false;
    bool isHiddenByPolicyFromRelativeParent = false;
    ftl::Flags<RequestedLayerState::Changes> changes;
    // Some consumers of this snapshot (input, layer traces) rely on each snapshot to be unique.
    // For mirrored layers, snapshots will have the same sequence so this unique id provides
    // an alternative identifier when needed.
    uint32_t uniqueSequence;
    // Layer id used to create this snapshot. Multiple snapshots will have the same sequence if they
    // generated from the same layer, for example when mirroring.
    int32_t sequence;
    std::string name;
    uint32_t textureName;
+1 −1
Original line number Diff line number Diff line
@@ -957,7 +957,7 @@ void LayerSnapshotBuilder::updateInput(LayerSnapshot& snapshot,
    }

    snapshot.inputInfo.name = requested.name;
    snapshot.inputInfo.id = static_cast<int32_t>(requested.id);
    snapshot.inputInfo.id = static_cast<int32_t>(snapshot.uniqueSequence);
    snapshot.inputInfo.ownerUid = static_cast<int32_t>(requested.ownerUid);
    snapshot.inputInfo.ownerPid = requested.ownerPid;
    snapshot.inputInfo.displayId = static_cast<int32_t>(snapshot.outputFilter.layerStack.id);
+2 −1
Original line number Diff line number Diff line
@@ -260,6 +260,7 @@ void LayerProtoHelper::writeHierarchyToProto(
    frontend::LayerSnapshot* snapshot = snapshotBuilder.getSnapshot(layer.id);

    if (!snapshot) {
        defaultSnapshot.uniqueSequence = layer.id;
        snapshot = &defaultSnapshot;
    }
    writeSnapshotToProto(layerProto, layer, *snapshot, traceFlags);
@@ -343,7 +344,7 @@ void LayerProtoHelper::writeSnapshotToProto(LayerProto* layerInfo,
                                   [&]() { return layerInfo->mutable_corner_radius_crop(); });
    layerInfo->set_shadow_radius(snapshot.shadowRadius);

    layerInfo->set_id(requestedState.id);
    layerInfo->set_id(snapshot.uniqueSequence);
    layerInfo->set_name(requestedState.name);
    layerInfo->set_type("Layer");