Merge "[ui] Remove superfluous args from getSliceRect()" into main
diff --git a/ui/src/common/track_adapter.ts b/ui/src/common/track_adapter.ts
index acc142d..9afa02b 100644
--- a/ui/src/common/track_adapter.ts
+++ b/ui/src/common/track_adapter.ts
@@ -16,8 +16,7 @@
import {v4 as uuidv4} from 'uuid';
import {assertExists} from '../base/logging';
-import {duration, Span, time} from '../base/time';
-import {PxSpan, TimeScale} from '../frontend/time_scale';
+import {duration, time} from '../base/time';
import {NewTrackArgs} from '../frontend/track';
import {SliceRect} from '../public';
import {EngineProxy} from '../trace_processor/engine';
@@ -64,12 +63,8 @@
super.onDestroy();
}
- getSliceRect(
- visibleTimeScale: TimeScale, visibleWindow: Span<time, bigint>,
- windowSpan: PxSpan, tStart: time, tEnd: time, depth: number): SliceRect
- |undefined {
- return this.track.getSliceRect(
- visibleTimeScale, visibleWindow, windowSpan, tStart, tEnd, depth);
+ getSliceRect(tStart: time, tEnd: time, depth: number): SliceRect|undefined {
+ return this.track.getSliceRect(tStart, tEnd, depth);
}
getHeight(): number {
@@ -140,10 +135,8 @@
abstract renderCanvas(ctx: CanvasRenderingContext2D): void;
- getSliceRect(
- _visibleTimeScale: TimeScale, _visibleWindow: Span<time, bigint>,
- _windowSpan: PxSpan, _tStart: time, _tEnd: time,
- _depth: number): SliceRect|undefined {
+ getSliceRect(_tStart: time, _tEnd: time, _depth: number): SliceRect
+ |undefined {
return undefined;
}
diff --git a/ui/src/common/track_helper.ts b/ui/src/common/track_helper.ts
index 114e2c9..f634627 100644
--- a/ui/src/common/track_helper.ts
+++ b/ui/src/common/track_helper.ts
@@ -14,10 +14,9 @@
import m from 'mithril';
-import {duration, Span, Time, time} from '../base/time';
+import {duration, Time, time} from '../base/time';
import {raf} from '../core/raf_scheduler';
import {globals} from '../frontend/globals';
-import {PxSpan, TimeScale} from '../frontend/time_scale';
import {SliceRect, Track, TrackContext} from '../public';
import {TrackData} from './track_data';
@@ -66,10 +65,8 @@
// only for track types that support slices e.g. chrome_slice, async_slices
// tStart - slice start time in seconds, tEnd - slice end time in seconds,
// depth - slice depth
- getSliceRect(
- _visibleTimeScale: TimeScale, _visibleWindow: Span<time, duration>,
- _windowSpan: PxSpan, _tStart: time, _tEnd: time,
- _depth: number): SliceRect|undefined {
+ getSliceRect(_tStart: time, _tEnd: time, _depth: number): SliceRect
+ |undefined {
return undefined;
}
diff --git a/ui/src/frontend/base_slice_track.ts b/ui/src/frontend/base_slice_track.ts
index 2dbe0f2..2c873da 100644
--- a/ui/src/frontend/base_slice_track.ts
+++ b/ui/src/frontend/base_slice_track.ts
@@ -17,7 +17,6 @@
import {clamp, floatEqual} from '../base/math_utils';
import {
duration,
- Span,
Time,
time,
} from '../base/time';
@@ -30,6 +29,7 @@
import {colorCompare} from '../common/color';
import {UNEXPECTED_PINK} from '../common/colorizer';
import {Selection, SelectionKind} from '../common/state';
+import {featureFlags} from '../core/feature_flags';
import {raf} from '../core/raf_scheduler';
import {Slice, SliceRect} from '../public';
import {LONG, NUM} from '../trace_processor/query_result';
@@ -38,10 +38,8 @@
import {globals} from './globals';
import {DEFAULT_SLICE_LAYOUT, SliceLayout} from './slice_layout';
import {constraintsToQuerySuffix} from './sql_utils';
-import {PxSpan, TimeScale} from './time_scale';
import {NewTrackArgs, TrackBase} from './track';
import {BUCKETS_PER_PIXEL, CacheKey, TrackCache} from './track_cache';
-import {featureFlags} from '../core/feature_flags';
// The common class that underpins all tracks drawing slices.
@@ -967,17 +965,20 @@
return this.computedTrackHeight;
}
- getSliceRect(
- visibleTimeScale: TimeScale, visibleWindow: Span<time, duration>,
- windowSpan: PxSpan, tStart: time, tEnd: time, depth: number): SliceRect
- |undefined {
+ getSliceRect(tStart: time, tEnd: time, depth: number): SliceRect|undefined {
this.updateSliceAndTrackHeight();
+ const {
+ windowSpan,
+ visibleTimeScale,
+ visibleTimeSpan,
+ } = globals.frontendLocalState;
+
const pxEnd = windowSpan.end;
const left = Math.max(visibleTimeScale.timeToPx(tStart), 0);
const right = Math.min(visibleTimeScale.timeToPx(tEnd), pxEnd);
- const visible = visibleWindow.intersects(tStart, tEnd);
+ const visible = visibleTimeSpan.intersects(tStart, tEnd);
const totalSliceHeight = this.computedRowSpacing + this.computedSliceHeight;
diff --git a/ui/src/frontend/flow_events_renderer.ts b/ui/src/frontend/flow_events_renderer.ts
index fd73ca4..12ce93c 100644
--- a/ui/src/frontend/flow_events_renderer.ts
+++ b/ui/src/frontend/flow_events_renderer.ts
@@ -140,19 +140,12 @@
private getSliceRect(args: FlowEventsRendererArgs, point: FlowPoint):
SliceRect|undefined {
- const {visibleTimeScale, visibleTimeSpan, windowSpan} =
- globals.frontendLocalState;
const trackPanel = args.trackIdToTrackPanel.get(point.trackId) ?.panel;
if (!trackPanel) {
return undefined;
}
return trackPanel.getSliceRect(
- visibleTimeScale,
- visibleTimeSpan,
- windowSpan,
- point.sliceStartTs,
- point.sliceEndTs,
- point.depth);
+ point.sliceStartTs, point.sliceEndTs, point.depth);
}
render(ctx: CanvasRenderingContext2D, args: FlowEventsRendererArgs) {
diff --git a/ui/src/frontend/slice_track.ts b/ui/src/frontend/slice_track.ts
index dd8756d..0264d07 100644
--- a/ui/src/frontend/slice_track.ts
+++ b/ui/src/frontend/slice_track.ts
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-import {duration, Span, Time, time} from '../base/time';
+import {Time, time} from '../base/time';
import {Actions} from '../common/actions';
import {cropText, drawIncompleteSlice} from '../common/canvas_utils';
import {getColorForSlice} from '../common/colorizer';
@@ -24,7 +24,6 @@
import {CROP_INCOMPLETE_SLICE_FLAG} from './base_slice_track';
import {checkerboardExcept} from './checkerboard';
import {globals} from './globals';
-import {PxSpan, TimeScale} from './time_scale';
export const SLICE_TRACK_KIND = 'ChromeSliceTrack';
const SLICE_HEIGHT = 18;
@@ -126,11 +125,16 @@
continue;
}
- const rect = this.getSliceRect(
- visibleTimeScale, visibleTimeSpan, windowSpan, tStart, tEnd, depth);
- if (!rect || !rect.visible) {
- continue;
- }
+ const pxEnd = windowSpan.end;
+ const left = Math.max(visibleTimeScale.timeToPx(tStart), 0);
+ const right = Math.min(visibleTimeScale.timeToPx(tEnd), pxEnd);
+
+ const rect = {
+ left,
+ width: Math.max(right - left, 1),
+ top: TRACK_PADDING + depth * SLICE_HEIGHT,
+ height: SLICE_HEIGHT,
+ };
const currentSelection = globals.state.currentSelection;
const isSelected = currentSelection &&
@@ -340,15 +344,18 @@
return SLICE_HEIGHT * (this.maxDepth + 1) + 2 * TRACK_PADDING;
}
- getSliceRect(
- visibleTimeScale: TimeScale, visibleWindow: Span<time, duration>,
- windowSpan: PxSpan, tStart: time, tEnd: time, depth: number): SliceRect
- |undefined {
+ getSliceRect(tStart: time, tEnd: time, depth: number): SliceRect|undefined {
+ const {
+ windowSpan,
+ visibleTimeScale,
+ visibleTimeSpan,
+ } = globals.frontendLocalState;
+
const pxEnd = windowSpan.end;
const left = Math.max(visibleTimeScale.timeToPx(tStart), 0);
const right = Math.min(visibleTimeScale.timeToPx(tEnd), pxEnd);
- const visible = visibleWindow.intersects(tStart, tEnd);
+ const visible = visibleTimeSpan.intersects(tStart, tEnd);
return {
left,
diff --git a/ui/src/frontend/track.ts b/ui/src/frontend/track.ts
index 88565f2..7fcce0b 100644
--- a/ui/src/frontend/track.ts
+++ b/ui/src/frontend/track.ts
@@ -14,12 +14,10 @@
import m from 'mithril';
-import {duration, Span, time} from '../base/time';
+import {time} from '../base/time';
import {SliceRect, Track, TrackContext} from '../public';
import {EngineProxy} from '../trace_processor/engine';
-import {PxSpan, TimeScale} from './time_scale';
-
// Args passed to the track constructors when creating a new track.
export interface NewTrackArgs {
trackKey: string;
@@ -72,10 +70,8 @@
// only for track types that support slices e.g. chrome_slice, async_slices
// tStart - slice start time in seconds, tEnd - slice end time in seconds,
// depth - slice depth
- getSliceRect(
- _visibleTimeScale: TimeScale, _visibleWindow: Span<time, duration>,
- _windowSpan: PxSpan, _tStart: time, _tEnd: time,
- _depth: number): SliceRect|undefined {
+ getSliceRect(_tStart: time, _tEnd: time, _depth: number): SliceRect
+ |undefined {
return undefined;
}
}
diff --git a/ui/src/frontend/track_panel.ts b/ui/src/frontend/track_panel.ts
index 0116ae7..dec3a65 100644
--- a/ui/src/frontend/track_panel.ts
+++ b/ui/src/frontend/track_panel.ts
@@ -17,7 +17,7 @@
import {currentTargetOffset} from '../base/dom_utils';
import {Icons} from '../base/semantic_icons';
-import {duration, Span, time} from '../base/time';
+import {time} from '../base/time';
import {Actions} from '../common/actions';
import {pluginManager} from '../common/plugins';
import {TrackState} from '../common/state';
@@ -30,7 +30,6 @@
import {drawGridLines} from './gridline_helper';
import {Panel, PanelSize} from './panel';
import {verticalScrollToTrack} from './scroll_helper';
-import {PxSpan, TimeScale} from './time_scale';
import {
drawVerticalLineAtTime,
} from './vertical_line_helper';
@@ -510,14 +509,10 @@
}
}
- getSliceRect(
- visibleTimeScale: TimeScale, visibleWindow: Span<time, duration>,
- windowSpan: PxSpan, tStart: time, tDur: time, depth: number): SliceRect
- |undefined {
+ getSliceRect(tStart: time, tDur: time, depth: number): SliceRect|undefined {
if (this.track === undefined) {
return undefined;
}
- return this.track.getSliceRect(
- visibleTimeScale, visibleWindow, windowSpan, tStart, tDur, depth);
+ return this.track.getSliceRect(tStart, tDur, depth);
}
}
diff --git a/ui/src/public/index.ts b/ui/src/public/index.ts
index 480676c..81f9225 100644
--- a/ui/src/public/index.ts
+++ b/ui/src/public/index.ts
@@ -15,10 +15,9 @@
import m from 'mithril';
import {Hotkey} from '../base/hotkeys';
-import {duration, Span, time} from '../base/time';
+import {duration, time} from '../base/time';
import {ColorScheme} from '../common/colorizer';
import {Store} from '../frontend/store';
-import {PxSpan, TimeScale} from '../frontend/time_scale';
import {EngineProxy} from '../trace_processor/engine';
export {createStore, Store} from '../frontend/store';
@@ -175,10 +174,7 @@
onCreate(ctx: TrackContext): void;
render(ctx: CanvasRenderingContext2D): void;
onFullRedraw(): void;
- getSliceRect(
- visibleTimeScale: TimeScale, visibleWindow: Span<time, duration>,
- windowSpan: PxSpan, tStart: time, tEnd: time, depth: number): SliceRect
- |undefined;
+ getSliceRect(tStart: time, tEnd: time, depth: number): SliceRect|undefined;
getHeight(): number;
getTrackShellButtons(): m.Children;
onMouseMove(position: {x: number, y: number}): void;