Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy state view #1086

Merged
merged 20 commits into from
Sep 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a9b3c9a
gapis/api: Rename State to GlobalState.
ben-clayton Sep 6, 2017
2ef2b54
gapis/api: Add a string function for api.ID.
ben-clayton Sep 6, 2017
45b7044
gapis/api: Change GlobalState.APIs key from API to ID.
ben-clayton Sep 8, 2017
00d3208
gapis/service/path: Add SetParent(Node) method to Node.
ben-clayton Sep 8, 2017
84f99d3
gapis/service/path: Add HasRoot and ShallowEqual helper functions.
ben-clayton Sep 8, 2017
25c2959
gapis/service/path: Add GlobalState path node.
ben-clayton Sep 8, 2017
6d5ecab
gapis/service/path: Check for boxed nils in validation.
ben-clayton Sep 8, 2017
a6e41fa
gapis/service/path: Add path.Transform() helper.
ben-clayton Sep 8, 2017
63c33ff
gapis/service/path: Fix bad path format strings.
ben-clayton Sep 8, 2017
f71ccdc
gapis/service/path: Change StateTree.After to StateTree.State.
ben-clayton Sep 8, 2017
d1d7b12
gapis/resolve: merge convertMapKey() into convertKey().
ben-clayton Sep 8, 2017
86b69b3
gapis/resolve: Simplify the InternalContext.ID.
ben-clayton Sep 8, 2017
41f8df6
gapis/resolve: Use a better path matching algorithm.
ben-clayton Sep 8, 2017
17d5a0b
gapis/resolve: Implement resolving of GlobalState paths.
ben-clayton Sep 8, 2017
81a501c
gapis/api/gles: Generate a stable context ID.
ben-clayton Sep 8, 2017
a22b054
gapic: Standardize and cleanup Paths.
ben-clayton Sep 8, 2017
b031899
gapis: Split @hidden into @hidden and @nobox.
ben-clayton Sep 8, 2017
427c4d3
gles: Fix panic when calling ID() with nil context
ben-clayton Sep 11, 2017
4ac56bc
Display the state of currently selected API & context.
ben-clayton Sep 8, 2017
a96d586
gapic: Restructure Paths.java.
ben-clayton Sep 14, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/gapit/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (verb *stateVerb) Run(ctx context.Context, flags flag.FlagSet) error {
verb.At = []uint64{uint64(boxedCapture.(*service.Capture).NumCommands) - 1}
}

boxedTree, err := client.Get(ctx, c.Command(uint64(verb.At[0]), verb.At[1:]...).StateTreeAfter().Path())
boxedTree, err := client.Get(ctx, c.Command(uint64(verb.At[0]), verb.At[1:]...).StateAfter().Tree().Path())
if err != nil {
return log.Err(ctx, err, "Failed to load the command tree")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/gapit/stresstest.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (verb *stresstestVerb) Run(ctx context.Context, flags flag.FlagSet) error {
go func() {
defer wg.Done()
ctx, _ := task.WithTimeout(ctx, duration)
boxedTree, err := client.Get(ctx, c.Command(at).StateTreeAfter().Path())
boxedTree, err := client.Get(ctx, c.Command(at).StateAfter().Tree().Path())
if err != nil {
return
}
Expand Down
14 changes: 14 additions & 0 deletions gapic/src/main/com/google/gapid/models/ApiContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,20 @@ public int getPriority() {
return context != null ? context.getPriority() : 0;
}

public Path.State.Builder state(Path.State.Builder path) {
if (id != null) {
path.getContextBuilder().setData(id.getData());
}
return path;
}

public Path.StateTree.Builder stateTree(Path.StateTree.Builder path) {
if (id != null) {
path.getStateBuilder().getContextBuilder().setData(id.getData());
}
return path;
}

public Path.Events.Builder events(Path.Events.Builder path) {
path.getFilterBuilder().setContext(id);
return path;
Expand Down
8 changes: 4 additions & 4 deletions gapic/src/main/com/google/gapid/models/ApiState.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ public class ApiState
private final ObjectStore<Path.Any> selection = ObjectStore.create();

public ApiState(
Shell shell, Client client, Follower follower, AtomStream atoms, ConstantSets constants) {
Shell shell, Client client, Follower follower, AtomStream atoms, ApiContext contexts, ConstantSets constants) {
super(LOG, shell, client, Listener.class);
this.constants = constants;

atoms.addListener(new AtomStream.Listener() {
@Override
public void onAtomsSelected(AtomIndex index) {
load(stateTree(index), false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undo - this is specifically written to handle null selection, which mean deselection.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

load(stateTree(index, contexts.getSelectedContext()), false);
}
});
follower.addListener(new Follower.Listener() {
Expand All @@ -76,7 +76,7 @@ public void onStateFollowed(Path.Any path) {
@Override
protected ListenableFuture<Node> doLoad(Path.Any path) {
return Futures.transformAsync(client.get(path),
tree -> Futures.transform(client.get(Paths.any(tree.getStateTree().getRoot())),
tree -> Futures.transform(client.get(Paths.toAny(tree.getStateTree().getRoot())),
val -> new RootNode(
tree.getStateTree().getRoot().getTree(), val.getStateTreeNode())));
}
Expand Down Expand Up @@ -115,7 +115,7 @@ protected void fireLoadedEvent() {

public ListenableFuture<Node> load(Node node) {
return node.load(shell, () -> Futures.transformAsync(
client.get(Paths.any(node.getPath(Path.StateTreeNode.newBuilder()))),
client.get(Paths.toAny(node.getPath(Path.StateTreeNode.newBuilder()))),
value -> Futures.transform(constants.loadConstants(value.getStateTreeNode()),
ignore -> new NodeData(value.getStateTreeNode()))));
}
Expand Down
7 changes: 3 additions & 4 deletions gapic/src/main/com/google/gapid/models/AtomStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package com.google.gapid.models;

import static com.google.gapid.proto.service.memory.Memory.PoolNames.Application_VALUE;
import static com.google.gapid.util.Paths.any;
import static com.google.gapid.util.Paths.commandTree;
import static com.google.gapid.util.Paths.lastCommand;
import static com.google.gapid.util.Paths.observationsAfter;
Expand Down Expand Up @@ -104,14 +103,14 @@ public void onContextSelected(FilteringContext ctx) {
@Override
protected ListenableFuture<Node> doLoad(Path.Any path) {
return Futures.transformAsync(client.get(path),
tree -> Futures.transform(client.get(Paths.any(tree.getCommandTree().getRoot())),
tree -> Futures.transform(client.get(Paths.toAny(tree.getCommandTree().getRoot())),
val -> new RootNode(
tree.getCommandTree().getRoot().getTree(), val.getCommandTreeNode())));
}

public ListenableFuture<Node> load(Node node) {
return node.load(shell, () -> Futures.transformAsync(
client.get(any(node.getPath(Path.CommandTreeNode.newBuilder()))), v1 -> {
client.get(Paths.toAny(node.getPath(Path.CommandTreeNode.newBuilder()))), v1 -> {
Service.CommandTreeNode data = v1.getCommandTreeNode();
if (data.getGroup().isEmpty() && data.hasCommands()) {
return Futures.transform(
Expand All @@ -122,7 +121,7 @@ public ListenableFuture<Node> load(Node node) {
}

public ListenableFuture<API.Command> loadCommand(Path.Command path) {
return Futures.transformAsync(client.get(any(path)), value ->
return Futures.transformAsync(client.get(Paths.toAny(path)), value ->
Futures.transform(constants.loadConstants(value.getCommand()), ignore ->
value.getCommand()));
}
Expand Down
2 changes: 1 addition & 1 deletion gapic/src/main/com/google/gapid/models/ConstantSets.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class ConstantSets {

public ConstantSets(Client client) {
this.cache = FutureCache.hardCache(
path -> Futures.transform(client.get(Paths.any(path)), Service.Value::getConstantSet),
path -> Futures.transform(client.get(Paths.toAny(path)), Service.Value::getConstantSet),
result -> result.getConstantsCount() != 0);
}

Expand Down
2 changes: 1 addition & 1 deletion gapic/src/main/com/google/gapid/models/Devices.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void loadDevices() {
rpcController.start().listen(Futures.transformAsync(client.getDevices(), paths -> {
List<ListenableFuture<Service.Value>> results = Lists.newArrayList();
for (Path.Device path : paths) {
results.add(client.get(Paths.device(path)));
results.add(client.get(Paths.toAny(path)));
}
return Futures.allAsList(results);
}), new UiErrorCallback<List<Service.Value>, List<Device.Instance>, Void>(shell, LOG) {
Expand Down
7 changes: 2 additions & 5 deletions gapic/src/main/com/google/gapid/models/Follower.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.google.gapid.models;

import static com.google.gapid.util.Paths.findState;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.WARNING;

Expand All @@ -37,15 +36,13 @@
import com.google.gapid.util.Flags.Flag;
import com.google.gapid.util.ObjectStore;
import com.google.gapid.util.Paths;

import org.eclipse.swt.widgets.Shell;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.eclipse.swt.widgets.Shell;

/**
* Model handling link following throughout the UI.
Expand Down Expand Up @@ -209,7 +206,7 @@ public void onFollow(Path.Any path) {
case FIELD:
case ARRAY_INDEX:
case MAP_INDEX:
if (findState(path) != null) {
if (Paths.contains(path, n -> n instanceof Path.State || n instanceof Path.GlobalState)) {
listeners.fire().onStateFollowed(path);
} else {
LOG.log(WARNING, "Unknown follow path result: " + path);
Expand Down
2 changes: 1 addition & 1 deletion gapic/src/main/com/google/gapid/models/Models.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static Models create(Shell shell, Settings settings, Client client) {
Timeline timeline = new Timeline(shell, client, capture, contexts);
AtomStream atoms = new AtomStream(shell, client, capture, contexts, constants);
Resources resources = new Resources(shell, client, capture);
ApiState state = new ApiState(shell, client, follower, atoms, constants);
ApiState state = new ApiState(shell, client, follower, atoms, contexts, constants);
Reports reports = new Reports(shell, client, capture, devices, contexts);
Thumbnails thumbs = new Thumbnails(client, devices, capture);
return new Models(settings, follower, capture, devices, atoms, contexts, timeline, resources,
Expand Down
Loading