| Index: tools/viewer/Viewer.cpp
|
| diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
|
| index e5432b0ffa4c05f2b67f9689097642d7613e61b1..eb8097282891c4237c5fd92e1bd22f2a4b30e6fe 100644
|
| --- a/tools/viewer/Viewer.cpp
|
| +++ b/tools/viewer/Viewer.cpp
|
| @@ -58,16 +58,23 @@ DEFINE_string2(match, m, nullptr,
|
| "^ and $ requires an exact match\n"
|
| "If a bench does not match any list entry,\n"
|
| "it is skipped unless some list entry starts with ~");
|
| +
|
| +#ifdef SK_VULKAN
|
| +# define BACKENDS_STR "\"sw\", \"gl\", and \"vulkan\""
|
| +#else
|
| +# define BACKENDS_STR "\"sw\" and \"gl\""
|
| +#endif
|
| +
|
| #ifdef SK_BUILD_FOR_ANDROID
|
| DEFINE_string(skps, "/data/local/tmp/skia", "Directory to read skps from.");
|
| DEFINE_string(jpgs, "/data/local/tmp/skia", "Directory to read jpgs from.");
|
| -DEFINE_bool(vulkan, false, "Run with Vulkan.");
|
| #else
|
| DEFINE_string(skps, "skps", "Directory to read skps from.");
|
| DEFINE_string(jpgs, "jpgs", "Directory to read jpgs from.");
|
| -DEFINE_bool(vulkan, true, "Run with Vulkan.");
|
| #endif
|
|
|
| +DEFINE_string2(backend, b, "sw", "Backend to use. Allowed values are " BACKENDS_STR ".");
|
| +
|
| const char *kBackendTypeStrings[sk_app::Window::kBackendTypeCount] = {
|
| " [OpenGL]",
|
| #ifdef SK_VULKAN
|
| @@ -76,6 +83,22 @@ const char *kBackendTypeStrings[sk_app::Window::kBackendTypeCount] = {
|
| " [Raster]"
|
| };
|
|
|
| +static sk_app::Window::BackendType get_backend_type(const char* str) {
|
| +#ifdef SK_VULKAN
|
| + if (0 == strcmp(str, "vk")) {
|
| + return sk_app::Window::kVulkan_BackendType;
|
| + } else
|
| +#endif
|
| + if (0 == strcmp(str, "gl")) {
|
| + return sk_app::Window::kNativeGL_BackendType;
|
| + } else if (0 == strcmp(str, "sw")) {
|
| + return sk_app::Window::kRaster_BackendType;
|
| + } else {
|
| + SkDebugf("Unknown backend type, %s, defaulting to sw.", str);
|
| + return sk_app::Window::kRaster_BackendType;
|
| + }
|
| +}
|
| +
|
| const char* kName = "name";
|
| const char* kValue = "value";
|
| const char* kOptions = "options";
|
| @@ -110,10 +133,7 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
|
|
|
| SkCommandLineFlags::Parse(argc, argv);
|
|
|
| -#ifdef SK_VULKAN
|
| - fBackendType = FLAGS_vulkan ? sk_app::Window::kVulkan_BackendType
|
| - : sk_app::Window::kNativeGL_BackendType;
|
| -#endif
|
| + fBackendType = get_backend_type(FLAGS_backend[0]);
|
| fWindow = Window::CreateNativeWindow(platformData);
|
| fWindow->attach(fBackendType, DisplayParams());
|
|
|
|
|