Add a SampleApp flag to automate keystrokes on startup

This is a quick-and-dirty solution to select color mode, backend, etc.
from the command line.

e.g. 'out/Debug/SampleApp --keys CCd' for opengl and srgb

Bug: skia:
Change-Id: I61f9e0fd4209a5fadb585c02c71984398f2f0860
Reviewed-on: https://skia-review.googlesource.com/61482
Reviewed-by: Yuqian Li <liyuqian@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
This commit is contained in:
Chris Dalton 2017-10-18 10:57:02 -06:00 committed by Skia Commit-Bot
parent c9080c8846
commit 1d014105ac
2 changed files with 10 additions and 10 deletions

View File

@ -764,6 +764,7 @@ DEFINE_int32(measureMS, 0, "Number of miliseconds to measure the FPS before clos
"If it's 0, we won't measure the FPS or close SampleApp automatically.");
DEFINE_int32(width, 1024, "Width of the window");
DEFINE_int32(height, 768, "Height of the window");
DEFINE_string(keys, "", "List of chars to automate keystrokes for on startup.");
#include "SkTaskGroup.h"
@ -2534,7 +2535,14 @@ SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) {
if (false) { // avoid bit rot, suppress warning
test();
}
return new SampleWindow(hwnd, argc, argv, nullptr);
SkOSWindow* window = new SampleWindow(hwnd, argc, argv, nullptr);
for (int i = 0; i < FLAGS_keys.count(); ++i) {
const char* keys = FLAGS_keys[i];
while (char keystroke = *keys++) {
window->handleChar(keystroke);
}
}
return window;
}
#ifdef SK_BUILD_FOR_IOS

View File

@ -16,8 +16,6 @@
#include "SkStream.h"
#include <stack>
DEFINE_string(pathfinderTrail, "", "List of keystrokes to execute upon loading a pathfinder.");
/**
* This is a simple utility designed to extract the paths from an SKP file and then isolate a single
* one of them. Use the 'x' and 'X' keys to guide a binary search:
@ -58,12 +56,6 @@ public:
}
pic->playback(this);
}
for (int i = 0; i < FLAGS_pathfinderTrail.count(); ++i) {
const char* key = FLAGS_pathfinderTrail[i];
while (*key) {
this->handleKeystroke(*key++);
}
}
}
~PathFinderView() override {}
@ -132,7 +124,7 @@ private:
case 'D':
SkDebugf("SampleApp --pathfinder %s", fFilename.c_str());
if (!fTrail.empty()) {
SkDebugf(" --pathfinderTrail ", fFilename.c_str());
SkDebugf(" --keys ");
for (char ch : fTrail) {
SkDebugf("%c", ch);
}