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

Commit 7b0f18b0 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

SF: Fix transaction trace merging

As entries get purged from the ring buffer, they need to be
merged in order to update the starting state. The tracing logic
tried to update the state directly from proto to be more
efficient. But this introduced slight changes in behavior.

Fix by reusing layerstate merge logic.

Test: atest TransactionProtoParserTest
Bug: 200284593
Change-Id: I8bfcf23c43fa89f3e5c4e899c5c8942d098bbe7f
parent d37343ba
Loading
Loading
Loading
Loading
+13 −10
Original line number Diff line number Diff line
@@ -305,6 +305,7 @@ TransactionState TransactionProtoParser::fromProto(const proto::TransactionState
    t.states.reserve(static_cast<size_t>(layerCount));
    for (int i = 0; i < layerCount; i++) {
        ComposerState s;
        s.state.what = 0;
        fromProto(proto.layer_changes(i), getLayerHandle, s.state);
        t.states.add(s);
    }
@@ -326,21 +327,23 @@ void TransactionProtoParser::fromProto(const proto::LayerCreationArgs& proto,
    outArgs.mirrorFromId = proto.mirror_from_id();
}

void TransactionProtoParser::fromProto(const proto::LayerState& proto,
void TransactionProtoParser::mergeFromProto(const proto::LayerState& proto,
                                            LayerIdToHandleFn getLayerHandle,
                                            TracingLayerState& outState) {
    fromProto(proto, getLayerHandle, static_cast<layer_state_t&>(outState));
    if (proto.what() & layer_state_t::eReparent) {
    layer_state_t state;
    fromProto(proto, getLayerHandle, state);
    outState.merge(state);

    if (state.what & layer_state_t::eReparent) {
        outState.parentId = proto.parent_id();
        outState.args.parentId = outState.parentId;
    }
    if (proto.what() & layer_state_t::eRelativeLayerChanged) {
    if (state.what & layer_state_t::eRelativeLayerChanged) {
        outState.relativeParentId = proto.relative_parent_id();
    }
    if (proto.what() & layer_state_t::eInputInfoChanged) {
    if (state.what & layer_state_t::eInputInfoChanged) {
        outState.inputCropId = proto.window_info_handle().crop_layer_id();
    }
    if (proto.what() & layer_state_t::eBufferChanged) {
    if (state.what & layer_state_t::eBufferChanged) {
        const proto::LayerState_BufferData& bufferProto = proto.buffer_data();
        outState.bufferId = bufferProto.buffer_id();
        outState.bufferWidth = bufferProto.width();
@@ -348,7 +351,7 @@ void TransactionProtoParser::fromProto(const proto::LayerState& proto,
        outState.pixelFormat = bufferProto.pixel_format();
        outState.bufferUsage = bufferProto.usage();
    }
    if (proto.what() & layer_state_t::eSidebandStreamChanged) {
    if (state.what & layer_state_t::eSidebandStreamChanged) {
        outState.hasSidebandStream = proto.has_sideband_stream();
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ public:
    static TransactionState fromProto(const proto::TransactionState&,
                                      LayerIdToHandleFn getLayerHandleFn,
                                      DisplayIdToHandleFn getDisplayHandleFn);
    static void fromProto(const proto::LayerState&, LayerIdToHandleFn getLayerHandleFn,
    static void mergeFromProto(const proto::LayerState&, LayerIdToHandleFn getLayerHandleFn,
                               TracingLayerState& outState);
    static void fromProto(const proto::LayerCreationArgs&, TracingLayerCreationArgs& outArgs);

+1 −1
Original line number Diff line number Diff line
@@ -332,7 +332,7 @@ void TransactionTracing::updateStartingStateLocked(
                ALOGW("Could not find layer id %d", layerState.layer_id());
                continue;
            }
            TransactionProtoParser::fromProto(layerState, nullptr, it->second);
            TransactionProtoParser::mergeFromProto(layerState, nullptr, it->second);
        }
    }