ui: Add infrastructure for frontend only slice tracks
Adds common code for frontend only slice tracks:
- ui/src/frontend/base_slice_track.ts
- ui/src/frontend/named_slice_track.ts
- ui/src/frontend/slice.ts
- ui/src/frontend/slice_layout.ts
as well a small number of necessary other adjustments across
the code base.
it also adds an example of a V2 slice track:
- ui/src/tracks/generic_slice_track/index.ts
and puts that new tack behind a feature flag ("Tracks V2"):
- ui/src/controller/track_decider.ts
There are a number of TODOs most of which are resolved immediately
in follow up changes. This sequence of patches is based on the code
in aosp/1772573.
These new tracks work quite differently than the existing tracks.
- The concept of a 'TrackController' seprate from 'Track' is gone
- The common superclass in base_slice_track handles:
- making the queries
- the quantization & over fetching logic
- caching (in a follow up CL)
- rendering the slices to the canvas
- selection
this avoids a large amount of duplicated code in each subclass.
Finally a note on rendering. Changing the 'state' of canvas contexts
(e.g. fillStyle, lineWidth, fontStyle, etc) is expensive to the extent
it is worth doing significant up front work and multiple passes to
avoid changes. The new rendering code follows this logic.
Bug: 207474444
Change-Id: I683ead4aed0b72fc2e954d8d8d52a8c42f358c8f
diff --git a/ui/src/frontend/track_panel.ts b/ui/src/frontend/track_panel.ts
index 2828b45..a916e93 100644
--- a/ui/src/frontend/track_panel.ts
+++ b/ui/src/frontend/track_panel.ts
@@ -314,6 +314,18 @@
return m(TrackComponent, {trackState: this.trackState, track: this.track});
}
+ oncreate() {
+ if (this.track !== undefined) {
+ this.track.onFullRedraw();
+ }
+ }
+
+ onupdate() {
+ if (this.track !== undefined) {
+ this.track.onFullRedraw();
+ }
+ }
+
highlightIfTrackSelected(ctx: CanvasRenderingContext2D, size: PanelSize) {
const localState = globals.frontendLocalState;
const selection = globals.state.currentSelection;