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

Most gapit verbs can now take a capture ID instead of a gfxtrace file. #2337

Merged
merged 3 commits into from
Nov 1, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
1 change: 1 addition & 0 deletions cmd/gapit/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ go_library(
"//core/app/flags:go_default_library",
"//core/app/status:go_default_library",
"//core/data/endian:go_default_library",
"//core/data/id:go_default_library",
"//core/data/pack:go_default_library",
"//core/data/protoutil:go_default_library",
"//core/event/task:go_default_library",
Expand Down
26 changes: 21 additions & 5 deletions cmd/gapit/screenshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

"github.com/google/gapid/core/app"
"github.com/google/gapid/core/app/flags"
"github.com/google/gapid/core/data/id"
"github.com/google/gapid/core/log"
"github.com/google/gapid/gapis/api"
"github.com/google/gapid/gapis/service"
Expand Down Expand Up @@ -60,9 +61,17 @@ func (verb *screenshotVerb) Run(ctx context.Context, flags flag.FlagSet) error {
return nil
}

filepath, err := filepath.Abs(flags.Arg(0))
captureFilepath := flags.Arg(0)

// Try parsing captureFilepath as a hex string.
captureId, err := id.Parse(captureFilepath)
paulthomson marked this conversation as resolved.
Show resolved Hide resolved

if err != nil {
return log.Errf(ctx, err, "Finding file: %v", flags.Arg(0))
// captureFilepath really *is* a file path.
captureFilepath, err = filepath.Abs(captureFilepath)
if err != nil {
return log.Errf(ctx, err, "Finding file: %v", flags.Arg(0))
}
}

client, err := getGapis(ctx, verb.Gapis, verb.Gapir)
Expand All @@ -71,10 +80,17 @@ func (verb *screenshotVerb) Run(ctx context.Context, flags flag.FlagSet) error {
}
defer client.Close()

capture, err := client.LoadCapture(ctx, filepath)
if err != nil {
return log.Errf(ctx, err, "LoadCapture(%v)", filepath)
var capture *path.Capture

if captureId.IsValid() {
capture = &path.Capture{ID: path.NewID(captureId)}
} else {
capture, err = client.LoadCapture(ctx, captureFilepath)
if err != nil {
return log.Errf(ctx, err, "LoadCapture(%v)", captureFilepath)
}
}
log.I(ctx, "Getting screenshot from capture id: %s", capture.ID)

device, err := getDevice(ctx, client, capture, verb.Gapir)
if err != nil {
Expand Down