diff options
author | Ben Clayton <bclayton@google.com> | 2015-07-13 13:28:41 +0100 |
---|---|---|
committer | Ben Clayton <bclayton@google.com> | 2015-07-13 13:52:08 +0100 |
commit | 083ae1a0c264325e9be79336e110ea818e3a90d9 (patch) | |
tree | 0304b1162851585f59ee86bb9b46f1061b1f9f3f /_experimental/client/commands_panel.go | |
parent | 8a1e414392a79cba19d2683df66b713509954241 (diff) | |
download | gpu-083ae1a0c264325e9be79336e110ea818e3a90d9.tar.gz |
Refactoring of the go client.
Instead of keeping all the requested in a big-fat application
context, keep the necessary information in each of the panels.
This:
• Reduces chances of data-races with updates between panels.
• Means we can have side-by-side views on different parts of
the capture, or even different captures.
• Let's each panel listen for paths they're interested in, or
could let us support drag-drop paths from one panel to
another.
We now also use the new task package for cancelable,
asynchronious jobs, like RPC calls.
RPCs and events have also been moved to separate structures to
make the application-context less monolithic.
The client behaves as it did before, except for pointers are
currently non-clickable. I'll be reimplementing this with paths
soon.
Change-Id: I2f1d89ca73534c68dc159882f2d7ce91ae870c49
Diffstat (limited to '_experimental/client/commands_panel.go')
-rw-r--r-- | _experimental/client/commands_panel.go | 83 |
1 files changed, 65 insertions, 18 deletions
diff --git a/_experimental/client/commands_panel.go b/_experimental/client/commands_panel.go index a4f791d02..4da3fea55 100644 --- a/_experimental/client/commands_panel.go +++ b/_experimental/client/commands_panel.go @@ -17,24 +17,22 @@ package client import ( "time" + "android.googlesource.com/platform/tools/gpu/service" + "android.googlesource.com/platform/tools/gpu/service/path" + "android.googlesource.com/platform/tools/gpu/task" "github.com/google/gxui" ) func CreateCommandsPanel(appCtx *ApplicationContext) gxui.Control { - theme := appCtx.Theme() - adapter := CreateCommandAdapter(appCtx) - tree := theme.CreateTree() + tree := appCtx.theme.CreateTree() tree.SetAdapter(adapter) timer := (*time.Timer)(nil) selectSelection := func() { appCtx.Run(func() { - r := adapter.AtomRange(tree.Selected()) - if !r.Contains(appCtx.SelectedAtomID()) { - appCtx.SelectAtom(r.Last()) - } + appCtx.events.Select(adapter.Path(tree.Selected())) }) } @@ -47,24 +45,73 @@ func CreateCommandsPanel(appCtx *ApplicationContext) gxui.Control { } }) - appCtx.OnHierarchyUpdated(func() { - adapter.SetRoot(appCtx.Hierarchy()) - }) - appCtx.OnTimingInfoUpdated(func() { - adapter.SetRoot(appCtx.Hierarchy()) - }) - appCtx.OnAtomSelected(func() { - r := adapter.AtomRange(tree.Selected()) - if appCtx.SelectedAtomID() != r.Last() { - tree.Select(adapter.Item(appCtx.SelectedAtomID())) + var device *path.Device + var capture *path.Capture + t := task.New() + update := func() { + if device != nil && capture != nil { + t.Run(updateCommandAdapter{appCtx, device, capture, adapter}) + } + } + + appCtx.events.OnSelect(func(p path.Path) { + if d := path.FindDevice(p); d != nil && !path.Equal(d, device) { + device = d + update() + } + if c := path.FindCapture(p); c != nil && !path.Equal(c, capture) { + capture = c + update() + } + if a := path.FindAtom(p); a != nil { + if item := adapter.Item(a); item != nil { + tree.Select(item) + } } }) tree.OnKeyPress(func(ev gxui.KeyboardEvent) { if ev.Key == gxui.KeyG && ev.Modifier&gxui.ModControl != 0 { - CreateGotoCommandDialog(appCtx) + CreateGotoCommandDialog(appCtx, capture.Atoms()) } }) return tree } + +type updateCommandAdapter struct { + context *ApplicationContext + device *path.Device + capture *path.Capture + adapter *CommandAdapter +} + +func (t updateCommandAdapter) Run(c task.CancelSignal) { + atoms, err := t.context.rpc.LoadAtoms(t.capture.Atoms()) + if err != nil { + return + } + c.Check() + hierarchy, err := t.context.rpc.LoadHierarchy(t.capture.Hierarchy()) + if err != nil { + return + } + c.Check() + t.context.RunSync(func() { + t.adapter.UpdateDevice(t.device) + t.adapter.UpdateTimings(service.TimingInfo{}) + t.adapter.UpdateAtoms(t.capture, atoms, hierarchy) + }) + flags := service.TimingFlagsTimingCPU | + service.TimingFlagsTimingPerCommand | + service.TimingFlagsTimingPerDrawCall | + service.TimingFlagsTimingPerFrame + timings, err := t.context.rpc.LoadTiming(t.device, t.capture, flags) + if err != nil { + return + } + c.Check() + t.context.Run(func() { + t.adapter.UpdateTimings(timings) + }) +} |