From c0b6cac1c33fab1db1a9d3938201bea8ad581b45 Mon Sep 17 00:00:00 2001 From: Pascal Muetschard Date: Tue, 11 Jun 2019 15:34:24 -0700 Subject: [PATCH] Don't be as eager to merge small slices and override state. - Only merge slices less than a pixel wide or with a gap of less than 2px. - If a slices is 3 times larger than what it's merged with, it's state dominates the merge priority, thus a tiny running slices doesn't turn it's large runnable neighbor into running. --- .../gapid/perfetto/views/ThreadPanel.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/gapic/src/main/com/google/gapid/perfetto/views/ThreadPanel.java b/gapic/src/main/com/google/gapid/perfetto/views/ThreadPanel.java index 6f8ed2a5b2..1dfb897d60 100644 --- a/gapic/src/main/com/google/gapid/perfetto/views/ThreadPanel.java +++ b/gapic/src/main/com/google/gapid/perfetto/views/ThreadPanel.java @@ -42,8 +42,9 @@ public class ThreadPanel extends TrackPanel implements Selectable { private static final double SLICE_HEIGHT = 25 - 2 * TRACK_MARGIN; private static final double HOVER_MARGIN = 10; private static final double HOVER_PADDING = 4; - private static final double MERGE_SLICE_THRESHOLD = 3; - private static final double MERGE_GAP_THRESHOLD = 4; + private static final double MERGE_SLICE_THRESHOLD = 1; + private static final double MERGE_GAP_THRESHOLD = 2; + private static final double MERGE_STATE_RATIO = 3; protected final ThreadTrack track; private boolean expanded; @@ -112,8 +113,13 @@ public void renderTrack(RenderContext ctx, Repainter repainter, double w, double } if (rectWidth < MERGE_SLICE_THRESHOLD) { if (merging) { + double ratio = (mergeEndX - mergeStartX) / rectWidth; + if (ratio < 1 / MERGE_STATE_RATIO) { + mergeState = data.schedStates[i]; + } else if (ratio < MERGE_STATE_RATIO) { + mergeState = mergeState.merge(data.schedStates[i]); + } mergeEndX = rectEnd; - mergeState = mergeState.merge(data.schedStates[i]); } else { merging = true; mergeStartX = rectStart; @@ -123,9 +129,14 @@ public void renderTrack(RenderContext ctx, Repainter repainter, double w, double } else { ThreadState ts = data.schedStates[i]; if (merging) { + double ratio = (mergeEndX - mergeStartX) / rectWidth; + if (ratio > MERGE_STATE_RATIO) { + ts = mergeState; + } else if (ratio > 1 / MERGE_STATE_RATIO) { + ts = mergeState.merge(ts); + } rectStart = mergeStartX; rectWidth = rectEnd - rectStart; - ts = ts.merge(mergeState); merging = false; }