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

Commit c32e52b7 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

InputTracer: Skip tracing raw coords if they are the same

Save some space in the trace by skipping tracing the raw x/y coords in
in window dispatch events if they are the same as the coords already
traced in the event.

Bug: 388336752
Test: Presubmit
Flag: EXEMPT tracing only
Change-Id: If504a03a4d66a1119fe9209794b18a767ceea81e
parent 0d41d4e0
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -115,13 +115,17 @@ void AndroidInputEventProtoConverter::toProtoWindowDispatchEvent(
        for (size_t i = 0; i < motion->pointerProperties.size(); i++) {
            auto* pointerProto = outProto.add_dispatched_pointer();
            pointerProto->set_pointer_id(motion->pointerProperties[i].id);
            const auto& coords = motion->pointerCoords[i];
            const auto rawXY =
                    MotionEvent::calculateTransformedXY(motion->source, args.rawTransform,
                                                        motion->pointerCoords[i].getXYValue());
                                                        coords.getXYValue());
            if (coords.getXYValue() != rawXY) {
                // These values are only traced if they were modified by the raw transform
                // to save space. Trace consumers should be aware of this optimization.
                pointerProto->set_x_in_display(rawXY.x);
                pointerProto->set_y_in_display(rawXY.y);
            }

            const auto& coords = motion->pointerCoords[i];
            const auto coordsInWindow =
                    MotionEvent::calculateTransformedCoords(motion->source, motion->flags,
                                                            args.transform, coords);
@@ -129,6 +133,7 @@ void AndroidInputEventProtoConverter::toProtoWindowDispatchEvent(
            for (int32_t axisIndex = 0; !bits.isEmpty(); axisIndex++) {
                const uint32_t axis = bits.clearFirstMarkedBit();
                const float axisValueInWindow = coordsInWindow.values[axisIndex];
                // Only values that are modified by the window transform are traced.
                if (coords.values[axisIndex] != axisValueInWindow) {
                    auto* axisEntry = pointerProto->add_axis_value_in_window();
                    axisEntry->set_axis(axis);