summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Prabir Pradhan <prabirmsp@google.com> 2025-01-08 18:48:05 +0000
committer Prabir Pradhan <prabirmsp@google.com> 2025-01-09 08:28:46 -0800
commitc32e52b74160f22f371c477ac421e76b3fe1b13a (patch)
tree3ef6d50b2abfa077f2ec292710710c8990de881e
parent0d41d4e0b6f310ab9138d9186631e39da75988e6 (diff)
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
-rw-r--r--services/inputflinger/dispatcher/trace/AndroidInputEventProtoConverter.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/services/inputflinger/dispatcher/trace/AndroidInputEventProtoConverter.cpp b/services/inputflinger/dispatcher/trace/AndroidInputEventProtoConverter.cpp
index 0b17507c2c..cc0468464e 100644
--- a/services/inputflinger/dispatcher/trace/AndroidInputEventProtoConverter.cpp
+++ b/services/inputflinger/dispatcher/trace/AndroidInputEventProtoConverter.cpp
@@ -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());
- pointerProto->set_x_in_display(rawXY.x);
- pointerProto->set_y_in_display(rawXY.y);
+ 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);